MethodSelectionBrowser.st
author Claus Gittinger <cg@exept.de>
Wed, 29 Jul 2009 20:02:02 +0200
changeset 2570 4e663bc64364
parent 1979 7b14d02e8ed1
child 3305 6cfecdd561c1
permissions -rw-r--r--
changed #requestPackage
     1 "
     2  COPYRIGHT (c) 1997-1998 by eXept Software AG
     3               All Rights Reserved
     4 
     5  This software is furnished under a license and may be used
     6  only in accordance with the terms of that license and with the
     7  inclusion of the above copyright notice. This software may not
     8  be provided or otherwise made available to, or used by, any
     9  other person. No title to or ownership of the software is
    10  hereby transferred.
    11 "
    12 
    13 
    14 
    15 "{ Package: 'stx:libtool2' }"
    16 
    17 ResourceSelectionBrowser subclass:#MethodSelectionBrowser
    18 	instanceVariableNames:''
    19 	classVariableNames:''
    20 	poolDictionaries:''
    21 	category:'Interface-Dialogs'
    22 !
    23 
    24 Object subclass:#Method
    25 	instanceVariableNames:'selector protocol'
    26 	classVariableNames:''
    27 	poolDictionaries:''
    28 	privateIn:MethodSelectionBrowser
    29 !
    30 
    31 !MethodSelectionBrowser class methodsFor:'documentation'!
    32 
    33 copyright
    34 "
    35  COPYRIGHT (c) 1997-1998 by eXept Software AG
    36               All Rights Reserved
    37 
    38  This software is furnished under a license and may be used
    39  only in accordance with the terms of that license and with the
    40  inclusion of the above copyright notice. This software may not
    41  be provided or otherwise made available to, or used by, any
    42  other person. No title to or ownership of the software is
    43  hereby transferred.
    44 "
    45 
    46 
    47 !
    48 
    49 documentation
    50 "
    51     The MethodSelectionBrowser allows you to browse in class hierarchies
    52     for selecting methods for you purposes.
    53 
    54     [start with:]
    55         MethodSelectionBrowser open
    56 
    57     [author:]
    58         Thomas Zwick
    59 "
    60 
    61 ! !
    62 
    63 !MethodSelectionBrowser class methodsFor:'instance creation'!
    64 
    65 request: aTitle onSuperclass: aSuperclass andClass: aClass andSelector: aSelector withTypes: protocolTypes
    66     "opens a MethodSelectionBrowser on 
    67         aSuperclassOrSymbol, 
    68         and aClassOrSymbol, 
    69         and aSelector,
    70         with allowed protocolTypes"
    71 
    72     ^ self new
    73         title: aTitle;
    74         openOnSuperclass: aSuperclass
    75         andClass: aClass
    76         andSelector: aSelector
    77         withTypes: protocolTypes
    78 
    79     "
    80      MethodSelectionBrowser
    81         request: 'Select a Method'
    82         onSuperclass: #ApplicationModel 
    83         andClass: #MenuEditor 
    84         andSelector: #menuItemImage
    85         withTypes: #(class)      
    86     "
    87 ! !
    88 
    89 !MethodSelectionBrowser class methodsFor:'list specs'!
    90 
    91 tableColumnsForResourceMethodAttributes
    92     "This resource specification was automatically generated
    93      by the DataSetBuilder of ST/X."
    94 
    95     "Do not manually edit this!! If it is corrupted,
    96      the DataSetBuilder may not be able to read the specification."
    97 
    98     "
    99      DataSetBuilder new openOnClass:MethodSelectionBrowser andSelector:#tableColumnsForResourceMethodAttributes
   100     "
   101 
   102     <resource: #tableColumns>
   103 
   104 
   105     ^ #(
   106         #(#DataSetColumnSpec
   107            #label: ' Selector'
   108            #labelAlignment: #left
   109            #model: #selector
   110            #canSelect: false
   111        )
   112         #(#DataSetColumnSpec
   113            #label: ' Protocol'
   114            #labelAlignment: #left
   115            #model: #protocol
   116            #canSelect: false
   117        )
   118      )
   119 ! !
   120 
   121 !MethodSelectionBrowser methodsFor:'aspects'!
   122 
   123 helpEnabled
   124     "returns whether there is a documentation file"
   125 
   126     ^false
   127 
   128 ! !
   129 
   130 !MethodSelectionBrowser methodsFor:'callbacks - user'!
   131 
   132 classSelected
   133     "after a class selection, read the class or/and instance methods of the selected class"
   134 
   135     ClassPresentation = #'Class Hierarchy'
   136         ifTrue:  [self selectionOfClassHierarchy  value isNil ifTrue: [^nil]]
   137         ifFalse: [self selectionOfClassCategories value isNil ifTrue: [^nil]].
   138 
   139     self withWaitCursorDo:
   140     [
   141         |clsName contentsBlock|
   142         resourceTypes isNil ifTrue: [resourceTypes := #(instance class)].
   143         ClassPresentation = #'Class Hierarchy'
   144             ifTrue:  [clsName := (self selectionOfClassHierarchy  value name upTo: $ ) asSymbol]
   145             ifFalse: [clsName := (self selectionOfClassCategories value name upTo: $ ) asSymbol].
   146         self valueOfClassName value: clsName.
   147         self class lastSelection: clsName.
   148         self listOfResourceMethods removeAll.
   149         contentsBlock := 
   150         [:protocol|
   151             |cls|
   152             (resourceTypes includes: protocol) 
   153             ifTrue: 
   154             [
   155                 cls := Smalltalk at: clsName.
   156                 cls := (protocol = #instance) ifTrue: [cls] ifFalse: [cls class].
   157                 self listOfResourceMethods addAll:
   158                     (cls selectors asOrderedCollection
   159                      collect: [:sel| Method new selector: sel; protocol: protocol asString])
   160             ]
   161         ].
   162         contentsBlock value: #instance.
   163         contentsBlock value: #class.
   164     ]
   165 
   166 
   167 ! !
   168 
   169 !MethodSelectionBrowser methodsFor:'instance creation'!
   170 
   171 openOnSuperclass: aSuperclassOrSymbol andClass: aClassOrSymbol andSelector: aSelector withTypes: protocolTypes
   172     "opens a MethodSelectionBrowser on 
   173         aSuperclassOrSymbol, 
   174         and aClassOrSymbol, 
   175         and aSelector,
   176         with allowed protocolTypes"
   177 
   178     |message type row|
   179 
   180     message := self 
   181         openOnSuperclass: aSuperclassOrSymbol 
   182         andClass: aClassOrSymbol 
   183         andSelector: aSelector 
   184         withResourceTypes: protocolTypes.
   185 
   186     (message notNil and:
   187     [((row := self selectionOfResourceMethod value) notNil and:
   188     [(type := row protocol) = 'class'])])
   189     ifTrue:
   190     [   
   191         message := message replChar:$  withString: ' class '
   192     ].
   193     ^message
   194 ! !
   195 
   196 !MethodSelectionBrowser methodsFor:'startup / release'!
   197 
   198 postBuildWith:aBuilder
   199     "sets the correct title"
   200 
   201     title := 'Method Selection Browser'.
   202 
   203     ^super postBuildWith:aBuilder
   204 
   205 ! !
   206 
   207 !MethodSelectionBrowser::Method methodsFor:'accessing'!
   208 
   209 protocol
   210     "returns the protocol of the method (#instance or #class)"
   211 
   212     ^protocol
   213 
   214 
   215 !
   216 
   217 protocol: aSymbol
   218     "sets the protocol of the method (#instance or #class)"
   219 
   220     protocol := aSymbol
   221 
   222 
   223 !
   224 
   225 selector
   226     "returns the selector of the method"
   227 
   228     ^selector
   229 
   230 !
   231 
   232 selector: aSymbol
   233     "sets the selector of the method"
   234 
   235     selector := aSymbol
   236 
   237 ! !
   238 
   239 !MethodSelectionBrowser class methodsFor:'documentation'!
   240 
   241 version
   242     ^ '$Header$'
   243 ! !