BrowserView.st
changeset 1360 4943d5582937
parent 1355 34c98fc48b14
child 1362 df021eafd510
equal deleted inserted replaced
1359:17bc3051f5d7 1360:4943d5582937
   189     ].
   189     ].
   190     ^ i
   190     ^ i
   191 
   191 
   192     "Modified: 19.3.1997 / 20:48:34 / ca"
   192     "Modified: 19.3.1997 / 20:48:34 / ca"
   193     "Modified: 15.8.1997 / 15:29:16 / cg"
   193     "Modified: 15.8.1997 / 15:29:16 / cg"
       
   194 !
       
   195 
       
   196 fileImageIcon
       
   197     "answer an icon to mark file-loading image  methods"
       
   198 
       
   199     ^ self imageIcon
       
   200 
       
   201     "Created: / 29.10.1997 / 03:32:43 / cg"
   194 !
   202 !
   195 
   203 
   196 imageIcon
   204 imageIcon
   197     "answer an icon to mark image (menuSpec) methods"
   205     "answer an icon to mark image (menuSpec) methods"
   198 
   206 
  4214 
  4222 
  4215     "Created: 23.12.1996 / 12:45:43 / cg"
  4223     "Created: 23.12.1996 / 12:45:43 / cg"
  4216     "Modified: 16.1.1997 / 01:46:39 / cg"
  4224     "Modified: 16.1.1997 / 01:46:39 / cg"
  4217 !
  4225 !
  4218 
  4226 
       
  4227 classDoubleClick:lineNr
       
  4228     currentClass notNil ifTrue:[
       
  4229         currentClass isVisualStartable ifTrue:[
       
  4230             currentClass open
       
  4231         ]
       
  4232     ]
       
  4233 
       
  4234     "Modified: / 28.10.1997 / 12:45:05 / cg"
       
  4235     "Created: / 29.10.1997 / 15:50:26 / cg"
       
  4236 !
       
  4237 
  4219 classListUpdate
  4238 classListUpdate
  4220     RememberAspect ifTrue:[
  4239     RememberAspect ifTrue:[
  4221 	aspect == #hierarchy ifTrue:[
  4240 	aspect == #hierarchy ifTrue:[
  4222 	    ^ self classHierarchy
  4241 	    ^ self classHierarchy
  4223 	].
  4242 	].
  5530     ].
  5549     ].
  5531 
  5550 
  5532     v := classListView.
  5551     v := classListView.
  5533     v notNil ifTrue:[
  5552     v notNil ifTrue:[
  5534         v action:[:lineNr | self classSelection:lineNr].
  5553         v action:[:lineNr | self classSelection:lineNr].
       
  5554         v doubleClickAction:[:lineNr | self classDoubleClick:lineNr].
  5535         v selectConditionBlock:checkBlock.
  5555         v selectConditionBlock:checkBlock.
  5536         v ignoreReselect:false.
  5556         v ignoreReselect:false.
  5537         "
  5557         "
  5538          tell classListView to ask for the menu
  5558          tell classListView to ask for the menu
  5539         "
  5559         "
  5589     fullProtocol ifTrue:[
  5609     fullProtocol ifTrue:[
  5590         classListView scrollToBottom.
  5610         classListView scrollToBottom.
  5591     ]
  5611     ]
  5592 
  5612 
  5593     "Created: / 24.7.1997 / 18:14:59 / cg"
  5613     "Created: / 24.7.1997 / 18:14:59 / cg"
  5594     "Modified: / 27.10.1997 / 00:29:30 / cg"
  5614     "Modified: / 29.10.1997 / 15:50:26 / cg"
  5595 !
  5615 !
  5596 
  5616 
  5597 terminate
  5617 terminate
  5598     (self checkSelectionChangeAllowed) ifTrue:[
  5618     (self checkSelectionChangeAllowed) ifTrue:[
  5599 	super terminate
  5619 	super terminate
  7199 
  7219 
  7200     self checkMethodSelected ifFalse:[^ self].
  7220     self checkMethodSelected ifFalse:[^ self].
  7201 
  7221 
  7202     w := currentMethod who.
  7222     w := currentMethod who.
  7203     w notNil ifTrue:[
  7223     w notNil ifTrue:[
  7204 	cls := w methodClass.
  7224         cls := w methodClass.
  7205 	cls notNil ifTrue:[
  7225         cls notNil ifTrue:[
  7206 	    cls ~~ actualClass ifTrue:[
  7226             cls ~~ actualClass ifTrue:[
  7207 		^ self warn:'oops - obsolete class; please reselect class ...'
  7227                 ^ self warn:'oops - obsolete class; please reselect class ...'
  7208 	    ].
  7228             ].
  7209 	    cls isMeta ifTrue:[
  7229             cls isMeta ifTrue:[
  7210 		cls := cls soleInstance
  7230                 cls := cls soleInstance
  7211 	    ] ifFalse:[
  7231             ] ifFalse:[
  7212 		cls := nil
  7232                 cls := nil
  7213 	    ].
  7233             ].
  7214 	    cls notNil ifTrue:[
  7234             cls notNil ifTrue:[
  7215 		sel := w methodSelector.
  7235                 sel := w methodSelector.
  7216 		sel notNil ifTrue:[
  7236                 sel notNil ifTrue:[
  7217 		    actualClass perform:sel.
  7237                     currentClass perform:sel.
  7218 		    ^ self
  7238                     ^ self
  7219 		]
  7239                 ]
  7220 	    ]
  7240             ]
  7221 	].
  7241         ].
  7222     ]. 
  7242     ]. 
  7223     self warn:'cannot invoke method (no class)'
  7243     self warn:'cannot invoke method (no class)'
  7224 
  7244 
  7225     "Modified: 29.4.1997 / 11:24:30 / dq"
  7245     "Modified: / 29.4.1997 / 11:24:30 / dq"
       
  7246     "Modified: / 29.10.1997 / 15:50:28 / cg"
  7226 !
  7247 !
  7227 
  7248 
  7228 methodLocalSuperSends
  7249 methodLocalSuperSends
  7229     "launch a browser showing super sends in current class & subclasses"
  7250     "launch a browser showing super sends in current class & subclasses"
  7230 
  7251 
  8128                         icn := self menuIcon
  8149                         icn := self menuIcon
  8129                     ] ifFalse:[
  8150                     ] ifFalse:[
  8130                         (resources includesKey:#image) ifTrue:[
  8151                         (resources includesKey:#image) ifTrue:[
  8131                             icn := self imageIcon
  8152                             icn := self imageIcon
  8132                         ] ifFalse:[
  8153                         ] ifFalse:[
  8133                             (resources includesKey:#programMenu) ifTrue:[
  8154                             (resources includesKey:#fileImage) ifTrue:[
  8134                                 icn := self programMenuIcon
  8155                                 icn := self fileImageIcon
       
  8156                             ] ifFalse:[
       
  8157                                 (resources includesKey:#programMenu) ifTrue:[
       
  8158                                     icn := self programMenuIcon
       
  8159                                 ]
  8135                             ]
  8160                             ]
  8136                         ]
  8161                         ]
  8137                     ]
  8162                     ]
  8138                 ]
  8163                 ]
  8139             ].
  8164             ].
  8144         ^ LabelAndIcon icon:icn string:s
  8169         ^ LabelAndIcon icon:icn string:s
  8145     ].
  8170     ].
  8146     ^ s
  8171     ^ s
  8147 
  8172 
  8148     "Created: / 22.10.1996 / 19:51:00 / cg"
  8173     "Created: / 22.10.1996 / 19:51:00 / cg"
  8149     "Modified: / 28.10.1997 / 13:39:38 / cg"
  8174     "Modified: / 29.10.1997 / 03:31:41 / cg"
  8150 !
  8175 !
  8151 
  8176 
  8152 listOfAllMethodsInCategory:aCategory inFullProtocolHierarchyOfClass:aClass
  8177 listOfAllMethodsInCategory:aCategory inFullProtocolHierarchyOfClass:aClass
  8153     "answer a list of all methods in a given method category 
  8178     "answer a list of all methods in a given method category 
  8154      of the argument, aClass and its superclasses.
  8179      of the argument, aClass and its superclasses.
  8865 ! !
  8890 ! !
  8866 
  8891 
  8867 !BrowserView methodsFor:'namespace menu'!
  8892 !BrowserView methodsFor:'namespace menu'!
  8868 
  8893 
  8869 nameSpaceMenu
  8894 nameSpaceMenu
       
  8895     <resource: #programMenu >
       
  8896 
  8870     |labels selectors|
  8897     |labels selectors|
  8871 
  8898 
  8872     labels := #('new namespace').
  8899     labels := #('new namespace').
  8873     selectors := #(nameSpaceNewNameSpace).
  8900     selectors := #(nameSpaceNewNameSpace).
  8874 
  8901 
  8882 
  8909 
  8883 
  8910 
  8884     (currentNamespace notNil
  8911     (currentNamespace notNil
  8885     and:[currentNamespace ~~ Smalltalk
  8912     and:[currentNamespace ~~ Smalltalk
  8886     and:[currentNamespace ~= '* all *']]) ifTrue:[
  8913     and:[currentNamespace ~= '* all *']]) ifTrue:[
  8887 	"/ is it all empty ?
  8914         "/ is it all empty ?
  8888 	currentNamespace allClasses isEmpty ifTrue:[
  8915         currentNamespace allClasses isEmpty ifTrue:[
  8889 	    labels := labels , #('-' 'remove').
  8916             labels := labels , #('-' 'remove').
  8890 	    selectors := selectors , #(nil nameSpaceRemove).
  8917             selectors := selectors , #(nil nameSpaceRemove).
  8891 	]
  8918         ]
  8892     ].
  8919     ].
  8893 
  8920 
  8894     ^ PopUpMenu
  8921     ^ PopUpMenu
  8895 	labels:(resources array:labels)
  8922         labels:(resources array:labels)
  8896 	selectors:selectors
  8923         selectors:selectors
  8897 	receiver:self.
  8924         receiver:self.
  8898 
  8925 
  8899     "Created: 4.1.1997 / 23:51:38 / cg"
  8926     "Created: / 4.1.1997 / 23:51:38 / cg"
  8900     "Modified: 31.7.1997 / 22:40:33 / cg"
  8927     "Modified: / 29.10.1997 / 03:39:12 / cg"
  8901 !
  8928 !
  8902 
  8929 
  8903 nameSpaceNewNameSpace
  8930 nameSpaceNewNameSpace
  8904     "create a namespace-definition prototype in codeview"
  8931     "create a namespace-definition prototype in codeview"
  8905 
  8932 
  9997 
 10024 
  9998 setAcceptAndExplainActionsForMethod
 10025 setAcceptAndExplainActionsForMethod
  9999     "tell the codeView what to do on accept and explain"
 10026     "tell the codeView what to do on accept and explain"
 10000 
 10027 
 10001     codeView acceptAction:[:theCode |
 10028     codeView acceptAction:[:theCode |
 10002 	|cat cls rslt|
 10029         |cat cls rslt|
 10003 
 10030 
 10004 	fullProtocol ifTrue:[
 10031         fullProtocol ifTrue:[
 10005 	    cls := acceptClass 
 10032             cls := acceptClass 
 10006 	].
 10033         ].
 10007 	cls isNil ifTrue:[
 10034         cls isNil ifTrue:[
 10008 	    cls := actualClass
 10035             cls := actualClass.
 10009 	].
 10036             cls isNil ifTrue:[
 10010 	cls isNil ifTrue:[
 10037                 self warning:'oops class is gone; reselect and try again'.
 10011 	    self warning:'oops class is gone; reselect and try again'.
 10038                 ^ self
 10012 	    ^ self
 10039             ].
 10013 	].
 10040         ].
 10014 
 10041 
 10015 	codeView cursor:Cursor execute.
 10042         codeView cursor:Cursor execute.
 10016 
 10043 
 10017 	(cat := currentMethodCategory) = '* all *' ifTrue:[
 10044         (cat := currentMethodCategory) = '* all *' ifTrue:[
 10018 	    "must check from which category this code came from ...
 10045             "must check from which category this code came from ...
 10019 	     ... thanks to Arno for pointing this out"
 10046              ... thanks to Arno for pointing this out"
 10020 
 10047 
 10021 	    cat := self askForMethodCategory.
 10048             cat := self askForMethodCategory.
 10022 	].
 10049         ].
 10023 	(cat notNil and:[cat notEmpty]) ifTrue:[
 10050         (cat notNil and:[cat notEmpty]) ifTrue:[
 10024 	    Object abortSignal catch:[
 10051             Object abortSignal catch:[
 10025 		lockUpdates := true.
 10052                 lockUpdates := true.
 10026 
 10053 
 10027 		rslt := actualClass compilerClass 
 10054                 Class methodRedefinitionSignal handle:[:ex |
 10028 		    compile:theCode asString
 10055                     |answer oldVsNew oldPkg newPkg|
 10029 		    forClass:cls
 10056 
 10030 		    inCategory:cat 
 10057                     oldVsNew := ex parameter.
 10031 		    notifying:codeView.
 10058                     oldPkg := oldVsNew key package.
 10032 
 10059                     newPkg := oldVsNew value package.
 10033 		codeView modified:false.
 10060                     answer := OptionBox 
 10034 		currentMethod := actualClass compiledMethodAt:currentSelector.
 10061                                   request: 
 10035 		self updateMethodListWithScroll:false keepSelection:(rslt == currentMethod).
 10062 ('You are about to change code from another (system-) package.
 10036 		self normalLabel.
 10063 The methods original packageID was ''%1''. 
 10037 	    ].
 10064 If you proceed, the new code will be marked as belonging
 10038 	    lockUpdates := false.
 10065 to the ''%2'' package (and this warning will not be shown again).
 10039 	].
 10066 If you proceed with ''keep'', the old packageID will be preserved.
 10040 	codeView cursor:Cursor normal.
 10067 Otherwise, hit ''cancel'' to leave the code unchanged.
       
 10068 
       
 10069 PS: you can disable these checks in the launchers settings-compilation dialog.' bindWith:oldPkg with:newPkg)
       
 10070 
       
 10071                                   label:'Method redefinition'
       
 10072                                   form:(WarningBox iconBitmap)
       
 10073                                   buttonLabels:#('cancel' 'keep' 'continue')
       
 10074                                   values:#(#cancel #keep #continue)
       
 10075                                   default:#continue.
       
 10076 
       
 10077                     (answer ~~ #cancel) ifTrue:[
       
 10078                         ex proceedWith:answer
       
 10079                     ]
       
 10080                 ] do:[
       
 10081 
       
 10082                     rslt := actualClass compilerClass 
       
 10083                         compile:theCode asString
       
 10084                         forClass:cls
       
 10085                         inCategory:cat 
       
 10086                         notifying:codeView.
       
 10087 
       
 10088                     codeView modified:false.
       
 10089                     currentMethod := actualClass compiledMethodAt:currentSelector.
       
 10090                     self updateMethodListWithScroll:false keepSelection:(rslt == currentMethod).
       
 10091                     self normalLabel.
       
 10092                 ]
       
 10093             ].
       
 10094             lockUpdates := false.
       
 10095         ].
       
 10096         codeView cursor:Cursor normal.
 10041     ].
 10097     ].
 10042 
 10098 
 10043     codeView explainAction:[:theCode :theSelection |
 10099     codeView explainAction:[:theCode :theSelection |
 10044 	self showExplanation:(Explainer 
 10100         self showExplanation:(Explainer 
 10045 				explain:theSelection 
 10101                                 explain:theSelection 
 10046 				in:theCode
 10102                                 in:theCode
 10047 				forClass:actualClass)
 10103                                 forClass:actualClass)
 10048     ].
 10104     ].
 10049 
 10105 
 10050     "Modified: 19.6.1997 / 18:57:35 / cg"
 10106     "Modified: / 29.10.1997 / 15:48:35 / cg"
 10051 !
 10107 !
 10052 
 10108 
 10053 setDoitActionForClass
 10109 setDoitActionForClass
 10054     "tell the codeView what to do on doIt"
 10110     "tell the codeView what to do on doIt"
 10055 
 10111 
 10174 
 10230 
 10175 commentEmphasis
 10231 commentEmphasis
 10176     ^ (#color -> (Color red:0 green:0 blue:25))
 10232     ^ (#color -> (Color red:0 green:0 blue:25))
 10177 
 10233 
 10178     "Created: 1.8.1997 / 12:36:14 / cg"
 10234     "Created: 1.8.1997 / 12:36:14 / cg"
       
 10235 !
       
 10236 
       
 10237 fileImageIcon
       
 10238     "answer an icon to mark fileImage methods"
       
 10239 
       
 10240     ^ self class fileImageIcon
       
 10241 
       
 10242     "Modified: / 7.4.1997 / 17:31:40 / cg"
       
 10243     "Created: / 29.10.1997 / 03:32:05 / cg"
 10179 !
 10244 !
 10180 
 10245 
 10181 imageIcon
 10246 imageIcon
 10182     "answer an icon to mark image methods"
 10247     "answer an icon to mark image methods"
 10183 
 10248 
 11071 ! !
 11136 ! !
 11072 
 11137 
 11073 !BrowserView class methodsFor:'documentation'!
 11138 !BrowserView class methodsFor:'documentation'!
 11074 
 11139 
 11075 version
 11140 version
 11076     ^ '$Header: /cvs/stx/stx/libtool/BrowserView.st,v 1.345 1997-10-28 18:26:12 cg Exp $'
 11141     ^ '$Header: /cvs/stx/stx/libtool/BrowserView.st,v 1.346 1997-10-29 16:02:53 cg Exp $'
 11077 ! !
 11142 ! !
 11078 BrowserView initialize!
 11143 BrowserView initialize!