MethodSelectionBrowser.st
author tz
Sat, 18 Apr 1998 16:53:48 +0200
changeset 782 62f2cd2978d5
parent 773 de5c99bd3078
child 789 ee325d04f292
permissions -rw-r--r--
#directory: must not delete line
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
646
d2fc253819c1 initial checkin
tz
parents:
diff changeset
     1
"
771
905c3b4ba565 revised
tz
parents: 680
diff changeset
     2
 COPYRIGHT (c) 1997-1998 by eXept Software AG
646
d2fc253819c1 initial checkin
tz
parents:
diff changeset
     3
              All Rights Reserved
d2fc253819c1 initial checkin
tz
parents:
diff changeset
     4
d2fc253819c1 initial checkin
tz
parents:
diff changeset
     5
 This software is furnished under a license and may be used
d2fc253819c1 initial checkin
tz
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
d2fc253819c1 initial checkin
tz
parents:
diff changeset
     7
 inclusion of the above copyright notice. This software may not
d2fc253819c1 initial checkin
tz
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
d2fc253819c1 initial checkin
tz
parents:
diff changeset
     9
 other person. No title to or ownership of the software is
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    10
 hereby transferred.
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    11
"
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    12
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    13
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    14
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    15
ResourceSelectionBrowser subclass:#MethodSelectionBrowser
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    16
	instanceVariableNames:''
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    17
	classVariableNames:''
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    18
	poolDictionaries:''
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    19
	category:'Interface-Dialogs'
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    20
!
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    21
771
905c3b4ba565 revised
tz
parents: 680
diff changeset
    22
Object subclass:#Method
665
be9ead6a517b row label changed
tz
parents: 650
diff changeset
    23
	instanceVariableNames:'selector protocol'
646
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    24
	classVariableNames:''
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    25
	poolDictionaries:''
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    26
	privateIn:MethodSelectionBrowser
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    27
!
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    28
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    29
!MethodSelectionBrowser class methodsFor:'documentation'!
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    30
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    31
copyright
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    32
"
771
905c3b4ba565 revised
tz
parents: 680
diff changeset
    33
 COPYRIGHT (c) 1997-1998 by eXept Software AG
646
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    34
              All Rights Reserved
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    35
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    36
 This software is furnished under a license and may be used
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    37
 only in accordance with the terms of that license and with the
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    38
 inclusion of the above copyright notice. This software may not
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    39
 be provided or otherwise made available to, or used by, any
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    40
 other person. No title to or ownership of the software is
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    41
 hereby transferred.
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    42
"
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    43
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    44
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    45
!
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    46
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    47
documentation
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    48
"
771
905c3b4ba565 revised
tz
parents: 680
diff changeset
    49
    The MethodSelectionBrowser allows you to browse in class hierarchies
905c3b4ba565 revised
tz
parents: 680
diff changeset
    50
    for selecting methods for you purposes.
905c3b4ba565 revised
tz
parents: 680
diff changeset
    51
646
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    52
    [start with:]
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    53
        MethodSelectionBrowser open
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    54
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    55
    [author:]
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    56
        Thomas Zwick
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    57
"
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    58
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    59
! !
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    60
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    61
!MethodSelectionBrowser class methodsFor:'instance creation'!
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    62
771
905c3b4ba565 revised
tz
parents: 680
diff changeset
    63
request: aTitle onSuperclass: aSuperclass andClass: aClass andSelector: aSelector withTypes: protocolTypes
905c3b4ba565 revised
tz
parents: 680
diff changeset
    64
    "opens a MethodSelectionBrowser on 
905c3b4ba565 revised
tz
parents: 680
diff changeset
    65
	aSuperclassOrSymbol, 
905c3b4ba565 revised
tz
parents: 680
diff changeset
    66
	and aClassOrSymbol, 
905c3b4ba565 revised
tz
parents: 680
diff changeset
    67
	and aSelector,
905c3b4ba565 revised
tz
parents: 680
diff changeset
    68
	with allowed protocolTypes"
646
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    69
650
495b35593c09 the returning message should contain some info about the method protocol type
tz
parents: 646
diff changeset
    70
    "
495b35593c09 the returning message should contain some info about the method protocol type
tz
parents: 646
diff changeset
    71
    MethodSelectionBrowser
771
905c3b4ba565 revised
tz
parents: 680
diff changeset
    72
	request: 'Select a Method'
905c3b4ba565 revised
tz
parents: 680
diff changeset
    73
	onSuperclass: #ApplicationModel 
905c3b4ba565 revised
tz
parents: 680
diff changeset
    74
	andClass: #ToolApplicationModel 
905c3b4ba565 revised
tz
parents: 680
diff changeset
    75
	andSelector: #saveIcon 
905c3b4ba565 revised
tz
parents: 680
diff changeset
    76
	withTypes: #(class)      
646
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    77
    "
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    78
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    79
    ^self new
771
905c3b4ba565 revised
tz
parents: 680
diff changeset
    80
	title: aTitle;
905c3b4ba565 revised
tz
parents: 680
diff changeset
    81
	openOnSuperclass: aSuperclass
905c3b4ba565 revised
tz
parents: 680
diff changeset
    82
	andClass: aClass
905c3b4ba565 revised
tz
parents: 680
diff changeset
    83
	andSelector: aSelector
905c3b4ba565 revised
tz
parents: 680
diff changeset
    84
	withTypes: protocolTypes
646
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    85
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    86
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    87
! !
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    88
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    89
!MethodSelectionBrowser class methodsFor:'list specs'!
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    90
771
905c3b4ba565 revised
tz
parents: 680
diff changeset
    91
resourceMethodColumns
905c3b4ba565 revised
tz
parents: 680
diff changeset
    92
    "returns the columns for the table of the resource methods"
646
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    93
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    94
  ^ #(
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    95
   #(#DataSetColumnSpec
650
495b35593c09 the returning message should contain some info about the method protocol type
tz
parents: 646
diff changeset
    96
      #label: ' Selector'
495b35593c09 the returning message should contain some info about the method protocol type
tz
parents: 646
diff changeset
    97
      #'labelAlignment:' #left
646
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    98
      #model: #selector
d2fc253819c1 initial checkin
tz
parents:
diff changeset
    99
      #canSelect: false
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   100
  )
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   101
   (#DataSetColumnSpec
665
be9ead6a517b row label changed
tz
parents: 650
diff changeset
   102
      #label: ' Protocol'
650
495b35593c09 the returning message should contain some info about the method protocol type
tz
parents: 646
diff changeset
   103
      #'labelAlignment:' #left
665
be9ead6a517b row label changed
tz
parents: 650
diff changeset
   104
      #model: #protocol
646
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   105
      #canSelect: false
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   106
  ))
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   107
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   108
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   109
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   110
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   111
! !
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   112
773
tz
parents: 771
diff changeset
   113
!MethodSelectionBrowser methodsFor:'aspects'!
tz
parents: 771
diff changeset
   114
tz
parents: 771
diff changeset
   115
helpEnabled
tz
parents: 771
diff changeset
   116
    "returns whether there is a documentation file"
tz
parents: 771
diff changeset
   117
tz
parents: 771
diff changeset
   118
    ^false
tz
parents: 771
diff changeset
   119
tz
parents: 771
diff changeset
   120
! !
tz
parents: 771
diff changeset
   121
646
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   122
!MethodSelectionBrowser methodsFor:'callbacks - user'!
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   123
771
905c3b4ba565 revised
tz
parents: 680
diff changeset
   124
classSelected
905c3b4ba565 revised
tz
parents: 680
diff changeset
   125
    "after a class selection, read the class or/and instance methods of the selected class"
646
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   126
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   127
    self selectionOfClass value isNil ifTrue: [^nil].
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   128
    self withWaitCursorDo:
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   129
    [
771
905c3b4ba565 revised
tz
parents: 680
diff changeset
   130
        |clsName contentsBlock|
646
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   131
        resourceTypes isNil ifTrue: [resourceTypes := #(instance class)].
771
905c3b4ba565 revised
tz
parents: 680
diff changeset
   132
        clsName := self selectionOfClass value name.
646
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   133
        self valueOfClassName value: clsName.
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   134
        self class lastSelection: clsName.
771
905c3b4ba565 revised
tz
parents: 680
diff changeset
   135
        self listOfResourceMethods removeAll.
905c3b4ba565 revised
tz
parents: 680
diff changeset
   136
        contentsBlock := 
905c3b4ba565 revised
tz
parents: 680
diff changeset
   137
        [:protocol|
905c3b4ba565 revised
tz
parents: 680
diff changeset
   138
            |cls|
905c3b4ba565 revised
tz
parents: 680
diff changeset
   139
            (resourceTypes includes: protocol) 
905c3b4ba565 revised
tz
parents: 680
diff changeset
   140
            ifTrue: 
905c3b4ba565 revised
tz
parents: 680
diff changeset
   141
            [
905c3b4ba565 revised
tz
parents: 680
diff changeset
   142
                cls := Smalltalk at: clsName.
905c3b4ba565 revised
tz
parents: 680
diff changeset
   143
                cls := (protocol = #instance) ifTrue: [cls] ifFalse: [cls class].
905c3b4ba565 revised
tz
parents: 680
diff changeset
   144
                self listOfResourceMethods addAll:
905c3b4ba565 revised
tz
parents: 680
diff changeset
   145
                    (cls selectors asOrderedCollection
905c3b4ba565 revised
tz
parents: 680
diff changeset
   146
                     collect: [:sel| Method new selector: sel; protocol: protocol asString])
905c3b4ba565 revised
tz
parents: 680
diff changeset
   147
            ]
905c3b4ba565 revised
tz
parents: 680
diff changeset
   148
        ].
905c3b4ba565 revised
tz
parents: 680
diff changeset
   149
        contentsBlock value: #instance.
905c3b4ba565 revised
tz
parents: 680
diff changeset
   150
        contentsBlock value: #class.
646
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   151
    ]
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   152
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   153
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   154
! !
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   155
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   156
!MethodSelectionBrowser methodsFor:'instance creation'!
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   157
771
905c3b4ba565 revised
tz
parents: 680
diff changeset
   158
openOnSuperclass: aSuperclassOrSymbol andClass: aClassOrSymbol andSelector: aSelector withTypes: protocolTypes
905c3b4ba565 revised
tz
parents: 680
diff changeset
   159
    "opens a MethodSelectionBrowser on 
905c3b4ba565 revised
tz
parents: 680
diff changeset
   160
	aSuperclassOrSymbol, 
905c3b4ba565 revised
tz
parents: 680
diff changeset
   161
	and aClassOrSymbol, 
905c3b4ba565 revised
tz
parents: 680
diff changeset
   162
	and aSelector,
905c3b4ba565 revised
tz
parents: 680
diff changeset
   163
	with allowed protocolTypes"
646
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   164
650
495b35593c09 the returning message should contain some info about the method protocol type
tz
parents: 646
diff changeset
   165
    |message type row|
771
905c3b4ba565 revised
tz
parents: 680
diff changeset
   166
650
495b35593c09 the returning message should contain some info about the method protocol type
tz
parents: 646
diff changeset
   167
    message := super openOnSuperclass: aSuperclassOrSymbol 
771
905c3b4ba565 revised
tz
parents: 680
diff changeset
   168
	andClass: aClassOrSymbol 
905c3b4ba565 revised
tz
parents: 680
diff changeset
   169
	andSelector: aSelector 
905c3b4ba565 revised
tz
parents: 680
diff changeset
   170
	withResourceTypes: protocolTypes.
650
495b35593c09 the returning message should contain some info about the method protocol type
tz
parents: 646
diff changeset
   171
495b35593c09 the returning message should contain some info about the method protocol type
tz
parents: 646
diff changeset
   172
    (message notNil and:
771
905c3b4ba565 revised
tz
parents: 680
diff changeset
   173
    [((row := self selectionOfResourceMethod value) notNil and:
905c3b4ba565 revised
tz
parents: 680
diff changeset
   174
    [(type := row protocol) = 'class'])])
650
495b35593c09 the returning message should contain some info about the method protocol type
tz
parents: 646
diff changeset
   175
    ifTrue:
495b35593c09 the returning message should contain some info about the method protocol type
tz
parents: 646
diff changeset
   176
    [   
771
905c3b4ba565 revised
tz
parents: 680
diff changeset
   177
	message := message replChar:$  withString: ' class '
650
495b35593c09 the returning message should contain some info about the method protocol type
tz
parents: 646
diff changeset
   178
    ].
495b35593c09 the returning message should contain some info about the method protocol type
tz
parents: 646
diff changeset
   179
    ^message
646
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   180
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   181
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   182
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   183
! !
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   184
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   185
!MethodSelectionBrowser methodsFor:'startup / release'!
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   186
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   187
postBuildWith:aBuilder
771
905c3b4ba565 revised
tz
parents: 680
diff changeset
   188
    "sets the correct title"
646
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   189
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   190
    title := 'Method Selection Browser'.
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   191
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   192
    ^super postBuildWith:aBuilder
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   193
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   194
! !
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   195
771
905c3b4ba565 revised
tz
parents: 680
diff changeset
   196
!MethodSelectionBrowser::Method methodsFor:'accessing'!
646
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   197
665
be9ead6a517b row label changed
tz
parents: 650
diff changeset
   198
protocol
773
tz
parents: 771
diff changeset
   199
    "returns the protocol of the method (#instance or #class)"
665
be9ead6a517b row label changed
tz
parents: 650
diff changeset
   200
be9ead6a517b row label changed
tz
parents: 650
diff changeset
   201
    ^protocol
be9ead6a517b row label changed
tz
parents: 650
diff changeset
   202
be9ead6a517b row label changed
tz
parents: 650
diff changeset
   203
be9ead6a517b row label changed
tz
parents: 650
diff changeset
   204
!
be9ead6a517b row label changed
tz
parents: 650
diff changeset
   205
773
tz
parents: 771
diff changeset
   206
protocol: aSymbol
tz
parents: 771
diff changeset
   207
    "sets the protocol of the method (#instance or #class)"
665
be9ead6a517b row label changed
tz
parents: 650
diff changeset
   208
773
tz
parents: 771
diff changeset
   209
    protocol := aSymbol
665
be9ead6a517b row label changed
tz
parents: 650
diff changeset
   210
be9ead6a517b row label changed
tz
parents: 650
diff changeset
   211
be9ead6a517b row label changed
tz
parents: 650
diff changeset
   212
!
be9ead6a517b row label changed
tz
parents: 650
diff changeset
   213
646
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   214
selector
773
tz
parents: 771
diff changeset
   215
    "returns the selector of the method"
646
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   216
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   217
    ^selector
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   218
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   219
!
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   220
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   221
selector: aSymbol
773
tz
parents: 771
diff changeset
   222
    "sets the selector of the method"
646
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   223
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   224
    selector := aSymbol
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   225
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   226
! !
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   227
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   228
!MethodSelectionBrowser class methodsFor:'documentation'!
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   229
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   230
version
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   231
    ^ '$Header$'
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   232
! !