MethodSelectionBrowser.st
author Patrik Svestka <patrik.svestka@gmail.com>
Wed, 14 Nov 2018 12:07:51 +0100
branchjv
changeset 3630 5e718e0a754e
parent 3305 6cfecdd561c1
permissions -rw-r--r--
Issue #239: Fix all Smalltak/X source files to be in unicode (UTF8 without BOM) and prefixed by "{ Encoding: utf8 }" when any unicode character is present

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