UIPainterView.st
changeset 316 053e2d3089b7
parent 315 056c9fe74cc6
child 327 0040d47658c6
equal deleted inserted replaced
315:056c9fe74cc6 316:053e2d3089b7
   452       '    ^ holder\' ,
   452       '    ^ holder\' ,
   453       '!! !!\\') withCRs
   453       '!! !!\\') withCRs
   454 !
   454 !
   455 
   455 
   456 generateAspectMethods
   456 generateAspectMethods
   457     |cls code skip|
   457     |cls code skip modelSelector menuSelector menuPerformer protoSpec thisCode|
   458 
   458 
   459     code := ''.
   459     code := ''.
   460 
   460 
   461     className isNil ifTrue:[
   461     className isNil ifTrue:[
   462         self warn:'set the class first'.
   462         self warn:'set the class first'.
   463         ^ code
   463         ^ code
   464     ].
   464     ].
   465     cls := Smalltalk classNamed:className.
   465     cls := Smalltalk classNamed:className.
   466 
   466 
   467     treeView propertiesDo:[:aProp |
   467     treeView propertiesDo:[:aProp|
   468         |modelSelector menuSelector protoSpec thisCode|
       
   469 
       
   470         protoSpec := aProp spec.
   468         protoSpec := aProp spec.
   471 
   469 
   472         (modelSelector := aProp model) notNil ifTrue:[
   470         (modelSelector := aProp model) notNil ifTrue:[
   473             (cls implements:modelSelector asSymbol) ifFalse:[
   471             (cls implements:modelSelector asSymbol) ifFalse:[
   474                 skip := false.
   472                 skip := false.
   486                 ].
   484                 ].
   487             ].
   485             ].
   488         ].
   486         ].
   489 
   487 
   490         (menuSelector := aProp menu) notNil ifTrue:[
   488         (menuSelector := aProp menu) notNil ifTrue:[
   491             (cls implements:menuSelector asSymbol) ifFalse:[
   489             thisCode := self generateMenuMethodFor:menuSelector spec:protoSpec inClass:cls.
   492                 thisCode := (self generateAspectMethodFor:menuSelector spec:protoSpec inClass:cls).
   490             thisCode size ~~ 0 ifTrue:[
   493                 code := code , thisCode
   491                 code := code , thisCode
   494             ]
   492             ]
   495         ].
   493         ].
   496 
   494 
   497         aProp spec aspectSelectors do:[:aSel|
   495         aProp spec aspectSelectors do:[:aSel|
   509         aProp spec valueSelectors do:[:aSel|
   507         aProp spec valueSelectors do:[:aSel|
   510             (cls implements:aSel asSymbol) ifFalse:[
   508             (cls implements:aSel asSymbol) ifFalse:[
   511                 thisCode := (self generateValueMethodFor:aSel spec:protoSpec inClass:cls).
   509                 thisCode := (self generateValueMethodFor:aSel spec:protoSpec inClass:cls).
   512                 code := code , thisCode
   510                 code := code , thisCode
   513             ]
   511             ]
   514         ].
   512         ]
   515 
   513     ].
   516     ].
   514 
       
   515     protoSpec := treeView canvasSpec.
       
   516 
       
   517     (menuSelector := protoSpec menu) notNil ifTrue:[
       
   518         thisCode := self generateMenuMethodFor:menuSelector spec:protoSpec inClass:cls.
       
   519         thisCode size ~~ 0 ifTrue:[
       
   520             code := code , thisCode
       
   521         ]
       
   522     ].
       
   523 
       
   524 
   517     ^ code
   525     ^ code
       
   526 !
       
   527 
       
   528 generateMenuMethodFor:aspect spec:protoSpec inClass:aClass
       
   529     |code cperf performer category|
       
   530 
       
   531     (aClass implements:aspect asSymbol) ifFalse:[
       
   532         code := MenuEditor generateCodeFor:aClass menuSelector:(aspect asSymbol).
       
   533     ] ifTrue:[
       
   534         code := ''
       
   535     ].
       
   536 
       
   537     (protoSpec respondsTo:#menuPerformer) ifTrue:[
       
   538         performer := protoSpec menuPerformer.
       
   539     ].
       
   540     performer notNil ifTrue:[
       
   541         performer := performer asSymbol.
       
   542 
       
   543         (aClass implements:performer) ifFalse:[
       
   544             category := MenuEditor sourceCategory.
       
   545 
       
   546             cperf  := Character excla asString 
       
   547                     , aClass name , ' methodsFor:' , category storeString
       
   548                     , Character excla asString , '\\'
       
   549                     , performer , '\'
       
   550                     , '    "this window spec was automatically generated by the UI Builder"\\'
       
   551                     , '    ^ self\\'
       
   552                     , '\'
       
   553                     , Character excla asString
       
   554                     , ' '
       
   555                     , Character excla asString
       
   556                     , '\\'.
       
   557 
       
   558             code := code, cperf.
       
   559         ]
       
   560     ].
       
   561 
       
   562     code size == 0 ifTrue:[
       
   563         ^ nil
       
   564     ].
       
   565   ^ code withCRs
   518 !
   566 !
   519 
   567 
   520 generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
   568 generateValueMethodFor:aspect spec:protoSpec inClass:targetClass
   521     ^ ('!!' , targetClass name , ' methodsFor:''values''!!\\' ,
   569     ^ ('!!' , targetClass name , ' methodsFor:''values''!!\\' ,
   522       aspect , '\' ,
   570       aspect , '\' ,