UIPainter.st
changeset 2525 16c3872003d7
parent 2523 1f315c18f4da
child 2527 c953939a481e
equal deleted inserted replaced
2524:759b4b908fcb 2525:16c3872003d7
  4869 !
  4869 !
  4870 
  4870 
  4871 doBrowseAspectMethod:aspectSelector nameAs:aspectNameShown
  4871 doBrowseAspectMethod:aspectSelector nameAs:aspectNameShown
  4872     "browse or create the aspect method as entered in the field"
  4872     "browse or create the aspect method as entered in the field"
  4873 
  4873 
  4874     |cls spec aspect code implementingClass|
  4874     |cls spec aspect code implementingClass answer|
  4875 
  4875 
  4876     cls := self specClass.
  4876     cls := self specClass.
  4877     cls isNil ifTrue:[
  4877     cls isNil ifTrue:[
  4878         Dialog information:'No Application Class defined.'.
  4878         Dialog information:'No Application Class defined.'.
  4879         ^ self
  4879         ^ self
  4880     ].
  4880     ].
  4881 
  4881 
  4882     spec := painter specForSelection.
  4882     spec := painter specForSelection.
  4883     spec isNil ifTrue:[^ self].
  4883     spec isNil ifTrue:[^ self].
       
  4884 
  4884     aspect := spec perform:aspectSelector.
  4885     aspect := spec perform:aspectSelector.
  4885     aspect isString ifFalse:[
  4886     aspect isString ifFalse:[
  4886         "ignore non-strings (list may be an Array)"
  4887         "ignore non-strings (list may be an Array)"
  4887         aspect isNil ifTrue:[
  4888         aspect isNil ifTrue:[
  4888             Dialog information:(resources 
  4889             Dialog information:(resources 
  4895     implementingClass := (cls whichClassImplements:aspect asSymbol).
  4896     implementingClass := (cls whichClassImplements:aspect asSymbol).
  4896     implementingClass isNil ifTrue:[
  4897     implementingClass isNil ifTrue:[
  4897         implementingClass := (cls class whichClassImplements:aspect asSymbol).
  4898         implementingClass := (cls class whichClassImplements:aspect asSymbol).
  4898     ].
  4899     ].
  4899     implementingClass isNil ifTrue:[
  4900     implementingClass isNil ifTrue:[
  4900         (Dialog confirm:(resources 
  4901         answer := OptionBox
  4901                             stringWithCRs:'%1 does not implement %2.\\Create ?'
  4902                           request:(resources 
  4902                             with:(cls name allBold)
  4903                                     stringWithCRs:'%1 does not implement %2.\\Create ?'
  4903                             with:aspect allBold)) 
  4904                                     with:(cls name allBold)
  4904         ifFalse:[
  4905                                     with:aspect allBold)
  4905             (Dialog confirm:(resources 
  4906                           label:'Create/Browse Aspect Method'
  4906                                 stringWithCRs:'Browse implementors of %1 ?'
  4907                           image:(WarningBox iconBitmap)
  4907                                 with:aspect allBold)) 
  4908                           buttonLabels:#('Cancel' 'Browse Implementors' 'Create & Browse' 'Create' )
  4908             ifTrue:[
  4909                           values:#(abort browseImplementors createAndBrowse create )
  4909                 UserPreferences current systemBrowserClass browseImplementorsOf:aspect
  4910                           default:#create
  4910             ].
  4911                           onCancel:#abort.
       
  4912 
       
  4913         answer == #browseImplementors ifTrue:[
       
  4914             UserPreferences current systemBrowserClass browseImplementorsOf:aspect.
  4911             ^ self
  4915             ^ self
  4912         ].
  4916         ].
  4913         code := painter
  4917         answer == #abort ifTrue:[
  4914             generateAspectMethodFor:aspect 
  4918             ^ self
  4915             spec:spec 
  4919         ].
  4916             inClass:cls.
  4920 
  4917         code readStream fileIn.
  4921         self doGenerateAspectMethodsForAll:(Array with:aspect).
  4918     ].
  4922         implementingClass := self painter targetClass.
       
  4923 "/        code := painter
       
  4924 "/            generateAspectMethodFor:aspect 
       
  4925 "/            spec:spec 
       
  4926 "/            inClass:cls.
       
  4927 "/        code readStream fileIn.
       
  4928 
       
  4929         answer == #create ifTrue:[^ self].
       
  4930     ] ifFalse:[
       
  4931         (Dialog confirm:(resources string:'Browse the implementation of %1?')) ifFalse:[
       
  4932             ^ self.
       
  4933         ].
       
  4934     ].
       
  4935 
  4919     UserPreferences current systemBrowserClass 
  4936     UserPreferences current systemBrowserClass 
  4920         openInClass:implementingClass selector:aspect
  4937         openInClass:implementingClass selector:aspect
  4921 !
  4938 !
  4922 
  4939 
  4923 doBrowseAspectMethods
  4940 doBrowseAspectMethods
  5113         (specTool aspectFor:listSelector) subject value:editor list.
  5130         (specTool aspectFor:listSelector) subject value:editor list.
  5114     ].
  5131     ].
  5115 !
  5132 !
  5116 
  5133 
  5117 doGenerateAspectMethodFor
  5134 doGenerateAspectMethodFor
  5118     |cls code aspectList displayedList selectorsToGenerateCode 
  5135     |cls aspectList displayedList selectorsToGenerateCode 
  5119      doBrowse methods|
  5136      doBrowse methods|
  5120 
  5137 
  5121     self askForSectionModification.
  5138     self askForSectionModification.
  5122 
  5139 
  5123     cls := self painter targetClass.
  5140     cls := self painter targetClass.
  5166                             b := dialog addButton:b before:dialog okButton.
  5183                             b := dialog addButton:b before:dialog okButton.
  5167                        ].
  5184                        ].
  5168 
  5185 
  5169     selectorsToGenerateCode isEmptyOrNil ifTrue:[^ self].
  5186     selectorsToGenerateCode isEmptyOrNil ifTrue:[^ self].
  5170 
  5187 
  5171     code := self painter generateAspectMethodCodeFiltering:selectorsToGenerateCode.
  5188     self doGenerateAspectMethodsForAll:selectorsToGenerateCode.
  5172     code readStream fileIn.
       
  5173 
  5189 
  5174     "/ refetch - cls is now obsolete
  5190     "/ refetch - cls is now obsolete
  5175     cls := self painter targetClass.
  5191     cls := self painter targetClass.
  5176 
  5192 
  5177     doBrowse ifTrue:[
  5193     doBrowse ifTrue:[
  5193         |code|
  5209         |code|
  5194 
  5210 
  5195         code := self painter generateAspectMethodCode.
  5211         code := self painter generateAspectMethodCode.
  5196         code readStream fileIn.
  5212         code readStream fileIn.
  5197     ]
  5213     ]
       
  5214 !
       
  5215 
       
  5216 doGenerateAspectMethodsForAll:selectorsToGenerateCode
       
  5217     |code|
       
  5218 
       
  5219     code := self painter generateAspectMethodCodeFiltering:selectorsToGenerateCode.
       
  5220     code readStream fileIn.
  5198 !
  5221 !
  5199 
  5222 
  5200 doGenerateAspectSelectorsMethod
  5223 doGenerateAspectSelectorsMethod
  5201     "generates aspectSelectors method for the exported aspects"
  5224     "generates aspectSelectors method for the exported aspects"
  5202 
  5225