MenuEditor.st
changeset 2839 25c0162deb43
parent 2835 383fc6922db1
child 2843 066a69e88211
equal deleted inserted replaced
2838:66257924fbf6 2839:25c0162deb43
  5333     retrieverHolder value:(classAndSelector methodClass) name.
  5333     retrieverHolder value:(classAndSelector methodClass) name.
  5334     selectorHolder  value:(classAndSelector methodSelector).
  5334     selectorHolder  value:(classAndSelector methodSelector).
  5335 !
  5335 !
  5336 
  5336 
  5337 doBrowseImageClass
  5337 doBrowseImageClass
  5338     |cls sel|
  5338     |cls sel image|
  5339 
  5339 
  5340     (cls := retrieverHolder value) isNil ifTrue:[
  5340     (cls := retrieverHolder value) isNil ifTrue:[
  5341         Dialog warn:'No resource retriever is defined.'.
  5341         Dialog warn:'No resource retriever is defined.'.
  5342     ] ifFalse:[
  5342     ] ifFalse:[
  5343         sel := selectorHolder value.
  5343         sel := selectorHolder value.
  5344 
  5344 
  5345         cls := Smalltalk classNamed:cls.
  5345         cls := Smalltalk classNamed:cls.
  5346         cls isNil ifTrue:[
  5346         cls isNil ifTrue:[
  5347             Dialog warn:'No such resource retriever class.'.
  5347             Dialog warn:'No such resource retriever class.'.
  5348         ] ifFalse:[
  5348         ] ifFalse:[
       
  5349             (cls respondsTo:#visualFor:) ifTrue:[
       
  5350                 image := cls visualFor:sel.
       
  5351                 image ~~ (cls perform:sel) ifTrue:[
       
  5352                     self warn:'The image is resolved via #visualFor: from some unknown class'.
       
  5353                     sel := #visualFor:.
       
  5354                 ].
       
  5355             ].
  5349             UserPreferences current systemBrowserClass openInClass:cls class selector:sel
  5356             UserPreferences current systemBrowserClass openInClass:cls class selector:sel
  5350         ]
  5357         ]
  5351     ]
  5358     ]
  5352 
  5359 
  5353     "Created: / 20-09-2010 / 13:27:34 / cg"
  5360     "Created: / 20-09-2010 / 13:27:34 / cg"
  5354 !
  5361 !
  5355 
  5362 
  5356 doEditImage
  5363 doEditImage
  5357     |sel cls item|
  5364     |sel cls item image|
  5358 
  5365 
  5359     item := imageHolder value.
  5366     item := imageHolder value.
  5360     item notNil ifTrue:[
  5367     item notNil ifTrue:[
  5361 	item doEdit
  5368         item doEdit.
  5362     ] ifFalse:[
  5369         ^ self.
  5363 	(sel := selectorHolder value) isNil ifTrue:[
  5370     ].
  5364 	    Dialog warn:'No selector is defined.'.
  5371 
  5365 	] ifFalse:[
  5372     sel := selectorHolder value. 
  5366 	    (cls := retrieverHolder value) isNil ifTrue:[
  5373     sel isNil ifTrue:[
  5367 		Dialog warn:'No resource retriever is defined.'.
  5374         Dialog warn:'No selector is defined.'.
  5368 	    ] ifFalse:[
  5375         ^ self.
  5369 		cls := Smalltalk classNamed:cls.
  5376     ].
  5370 		cls isNil ifTrue:[
  5377     cls := retrieverHolder value.
  5371 		    Dialog warn:'No such resource retriever class.'.
  5378     cls isNil ifTrue:[
  5372 		] ifFalse:[
  5379         Dialog warn:'No resource retriever is defined.'.
  5373 		    ImageEditor openOnClass:cls andSelector:sel
  5380         ^ self.
  5374 		]
  5381     ].
  5375 	    ]
  5382     cls := Smalltalk classNamed:cls.
  5376 	]
  5383     cls isNil ifTrue:[
  5377     ].
  5384         Dialog warn:'No such resource retriever class.'.
       
  5385         ^ self.
       
  5386     ].
       
  5387     (cls respondsTo:#visualFor:) ifTrue:[
       
  5388         image := cls visualFor:sel.
       
  5389         image ~~ (cls perform:sel ifNotUnderstood:nil) ifTrue:[
       
  5390             self warn:'The image is resolved via #visualFor: from some unknown class'.
       
  5391             image notNil ifTrue:[
       
  5392                 ImageEditor openOnImage:image.
       
  5393             ].
       
  5394             ^ self.
       
  5395         ].
       
  5396     ].
       
  5397 
       
  5398     ImageEditor openOnClass:cls andSelector:sel
  5378 ! !
  5399 ! !
  5379 
  5400 
  5380 !MenuEditor::ResourceEditor methodsFor:'aspects'!
  5401 !MenuEditor::ResourceEditor methodsFor:'aspects'!
  5381 
  5402 
  5382 entryCompletionForRetriever
  5403 entryCompletionForRetriever
  5593     |w h magnify iconOrSymbol|
  5614     |w h magnify iconOrSymbol|
  5594 
  5615 
  5595     selector := aSelector asSymbol.
  5616     selector := aSelector asSymbol.
  5596     selector numArgs == 0 ifFalse:[^ self].
  5617     selector numArgs == 0 ifFalse:[^ self].
  5597 
  5618 
  5598     iconOrSymbol := aClass perform:selector.
  5619     "do waht the ResourceRetriever will do"
       
  5620     (aClass respondsTo:#visualFor:) ifTrue:[
       
  5621         iconOrSymbol := aClass visualFor:selector.
       
  5622     ].
       
  5623     iconOrSymbol isNil ifTrue:[
       
  5624         iconOrSymbol := aClass perform:selector.
       
  5625     ].
  5599     iconOrSymbol isSymbol ifTrue:[
  5626     iconOrSymbol isSymbol ifTrue:[
  5600         icon := ToolbarIconLibrary perform:iconOrSymbol.
  5627         icon := ToolbarIconLibrary perform:iconOrSymbol.
  5601     ] ifFalse:[
  5628     ] ifFalse:[
  5602         icon := iconOrSymbol.
  5629         icon := iconOrSymbol.
  5603     ].
  5630     ].
  5623 ! !
  5650 ! !
  5624 
  5651 
  5625 !MenuEditor::ResourceEditorItem methodsFor:'user operations'!
  5652 !MenuEditor::ResourceEditorItem methodsFor:'user operations'!
  5626 
  5653 
  5627 doEdit
  5654 doEdit
  5628     "open image browser on self
  5655     "open image browser on self"
  5629     "
  5656 
  5630     |parent|
  5657     |parent aClass image|
  5631 
  5658 
  5632     parent := self parent.
  5659     parent := self parent.
  5633 
  5660     parent notNil ifTrue:[
  5634     parent ifNotNil:[
  5661         aClass := parent selector.
  5635 	ImageEditor openOnClass:(parent selector) andSelector:selector
  5662         (aClass respondsTo:#visualFor:) ifTrue:[
       
  5663             image := aClass visualFor:selector.
       
  5664             image ~~ (aClass perform:selector) ifTrue:[
       
  5665                 self warn:'The image is resolved via #visualFor: from some unknown class'.
       
  5666                 ImageEditor openOnImage:image.
       
  5667                 ^ self.
       
  5668             ].
       
  5669         ].
       
  5670         ImageEditor openOnClass:aClass andSelector:selector.
  5636     ].
  5671     ].
  5637 ! !
  5672 ! !
  5638 
  5673 
  5639 !MenuEditor::RootItem class methodsFor:'defaults'!
  5674 !MenuEditor::RootItem class methodsFor:'defaults'!
  5640 
  5675