MethodSelectionBrowser.st
author tz
Thu, 09 Apr 1998 21:12:59 +0200
changeset 771 905c3b4ba565
parent 680 49c81e9cc6f7
child 773 de5c99bd3078
permissions -rw-r--r--
revised
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
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   113
!MethodSelectionBrowser methodsFor:'callbacks - user'!
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   114
771
905c3b4ba565 revised
tz
parents: 680
diff changeset
   115
classSelected
905c3b4ba565 revised
tz
parents: 680
diff changeset
   116
    "after a class selection, read the class or/and instance methods of the selected class"
646
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   117
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   118
    self selectionOfClass value isNil ifTrue: [^nil].
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   119
    self withWaitCursorDo:
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   120
    [
771
905c3b4ba565 revised
tz
parents: 680
diff changeset
   121
        |clsName contentsBlock|
646
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   122
        resourceTypes isNil ifTrue: [resourceTypes := #(instance class)].
771
905c3b4ba565 revised
tz
parents: 680
diff changeset
   123
        clsName := self selectionOfClass value name.
646
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   124
        self valueOfClassName value: clsName.
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   125
        self class lastSelection: clsName.
771
905c3b4ba565 revised
tz
parents: 680
diff changeset
   126
        self listOfResourceMethods removeAll.
905c3b4ba565 revised
tz
parents: 680
diff changeset
   127
        contentsBlock := 
905c3b4ba565 revised
tz
parents: 680
diff changeset
   128
        [:protocol|
905c3b4ba565 revised
tz
parents: 680
diff changeset
   129
            |cls|
905c3b4ba565 revised
tz
parents: 680
diff changeset
   130
            (resourceTypes includes: protocol) 
905c3b4ba565 revised
tz
parents: 680
diff changeset
   131
            ifTrue: 
905c3b4ba565 revised
tz
parents: 680
diff changeset
   132
            [
905c3b4ba565 revised
tz
parents: 680
diff changeset
   133
                cls := Smalltalk at: clsName.
905c3b4ba565 revised
tz
parents: 680
diff changeset
   134
                cls := (protocol = #instance) ifTrue: [cls] ifFalse: [cls class].
905c3b4ba565 revised
tz
parents: 680
diff changeset
   135
                self listOfResourceMethods addAll:
905c3b4ba565 revised
tz
parents: 680
diff changeset
   136
                    (cls selectors asOrderedCollection
905c3b4ba565 revised
tz
parents: 680
diff changeset
   137
                     collect: [:sel| Method new selector: sel; protocol: protocol asString])
905c3b4ba565 revised
tz
parents: 680
diff changeset
   138
            ]
905c3b4ba565 revised
tz
parents: 680
diff changeset
   139
        ].
905c3b4ba565 revised
tz
parents: 680
diff changeset
   140
        contentsBlock value: #instance.
905c3b4ba565 revised
tz
parents: 680
diff changeset
   141
        contentsBlock value: #class.
646
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   142
    ]
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   143
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   144
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   145
! !
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   146
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   147
!MethodSelectionBrowser methodsFor:'instance creation'!
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   148
771
905c3b4ba565 revised
tz
parents: 680
diff changeset
   149
openOnSuperclass: aSuperclassOrSymbol andClass: aClassOrSymbol andSelector: aSelector withTypes: protocolTypes
905c3b4ba565 revised
tz
parents: 680
diff changeset
   150
    "opens a MethodSelectionBrowser on 
905c3b4ba565 revised
tz
parents: 680
diff changeset
   151
	aSuperclassOrSymbol, 
905c3b4ba565 revised
tz
parents: 680
diff changeset
   152
	and aClassOrSymbol, 
905c3b4ba565 revised
tz
parents: 680
diff changeset
   153
	and aSelector,
905c3b4ba565 revised
tz
parents: 680
diff changeset
   154
	with allowed protocolTypes"
646
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   155
650
495b35593c09 the returning message should contain some info about the method protocol type
tz
parents: 646
diff changeset
   156
    |message type row|
771
905c3b4ba565 revised
tz
parents: 680
diff changeset
   157
650
495b35593c09 the returning message should contain some info about the method protocol type
tz
parents: 646
diff changeset
   158
    message := super openOnSuperclass: aSuperclassOrSymbol 
771
905c3b4ba565 revised
tz
parents: 680
diff changeset
   159
	andClass: aClassOrSymbol 
905c3b4ba565 revised
tz
parents: 680
diff changeset
   160
	andSelector: aSelector 
905c3b4ba565 revised
tz
parents: 680
diff changeset
   161
	withResourceTypes: protocolTypes.
650
495b35593c09 the returning message should contain some info about the method protocol type
tz
parents: 646
diff changeset
   162
495b35593c09 the returning message should contain some info about the method protocol type
tz
parents: 646
diff changeset
   163
    (message notNil and:
771
905c3b4ba565 revised
tz
parents: 680
diff changeset
   164
    [((row := self selectionOfResourceMethod value) notNil and:
905c3b4ba565 revised
tz
parents: 680
diff changeset
   165
    [(type := row protocol) = 'class'])])
650
495b35593c09 the returning message should contain some info about the method protocol type
tz
parents: 646
diff changeset
   166
    ifTrue:
495b35593c09 the returning message should contain some info about the method protocol type
tz
parents: 646
diff changeset
   167
    [   
771
905c3b4ba565 revised
tz
parents: 680
diff changeset
   168
	message := message replChar:$  withString: ' class '
650
495b35593c09 the returning message should contain some info about the method protocol type
tz
parents: 646
diff changeset
   169
    ].
495b35593c09 the returning message should contain some info about the method protocol type
tz
parents: 646
diff changeset
   170
    ^message
646
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   171
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   172
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   173
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   174
! !
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   175
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   176
!MethodSelectionBrowser methodsFor:'startup / release'!
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   177
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   178
postBuildWith:aBuilder
771
905c3b4ba565 revised
tz
parents: 680
diff changeset
   179
    "sets the correct title"
646
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   180
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   181
    title := 'Method Selection Browser'.
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   182
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   183
    ^super postBuildWith:aBuilder
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   184
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   185
! !
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   186
771
905c3b4ba565 revised
tz
parents: 680
diff changeset
   187
!MethodSelectionBrowser::Method methodsFor:'accessing'!
646
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   188
665
be9ead6a517b row label changed
tz
parents: 650
diff changeset
   189
protocol
be9ead6a517b row label changed
tz
parents: 650
diff changeset
   190
be9ead6a517b row label changed
tz
parents: 650
diff changeset
   191
    ^protocol
be9ead6a517b row label changed
tz
parents: 650
diff changeset
   192
be9ead6a517b row label changed
tz
parents: 650
diff changeset
   193
be9ead6a517b row label changed
tz
parents: 650
diff changeset
   194
!
be9ead6a517b row label changed
tz
parents: 650
diff changeset
   195
be9ead6a517b row label changed
tz
parents: 650
diff changeset
   196
protocol: aString
be9ead6a517b row label changed
tz
parents: 650
diff changeset
   197
be9ead6a517b row label changed
tz
parents: 650
diff changeset
   198
    protocol := aString
be9ead6a517b row label changed
tz
parents: 650
diff changeset
   199
be9ead6a517b row label changed
tz
parents: 650
diff changeset
   200
be9ead6a517b row label changed
tz
parents: 650
diff changeset
   201
!
be9ead6a517b row label changed
tz
parents: 650
diff changeset
   202
646
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   203
selector
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   204
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   205
    ^selector
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   206
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   207
!
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   208
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   209
selector: aSymbol
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   210
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   211
    selector := aSymbol
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   212
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   213
! !
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   214
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   215
!MethodSelectionBrowser class methodsFor:'documentation'!
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   216
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   217
version
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   218
    ^ '$Header$'
d2fc253819c1 initial checkin
tz
parents:
diff changeset
   219
! !