ResourceSelectionBrowser.st
changeset 730 238d796c5da0
parent 727 bbe063ccf4a3
child 733 6454aaabda51
equal deleted inserted replaced
729:12f157d5e017 730:238d796c5da0
   120         label
   120         label
   121      ]
   121      ]
   122 
   122 
   123 
   123 
   124 ! !
   124 ! !
       
   125 
       
   126 !ResourceSelectionBrowser class methodsFor:'image specs'!
       
   127 
       
   128 iconClass
       
   129     "Generated by the Image Editor"
       
   130     "
       
   131     ImageEditor openOnClass:self andSelector:#iconClass
       
   132     "
       
   133 
       
   134     <resource: #image>
       
   135 
       
   136     ^Icon
       
   137         constantNamed:#'ResourceSelectionBrowser iconClass'
       
   138         ifAbsentPut:[(Depth2Image new) width: 18; height: 16; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@UUUUUAQ****(@F**** @Z****@A****(@F**** @Z****@A****(LF**** TZ****@A****(@F**** @Z****@@@@@@@@@@@@@@@b') ; colorMapFromArray:#[0 0 0 255 255 255 170 170 170 255 0 0]; mask:((Depth1Image new) width: 18; height: 16; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'_?>@???@???@???@???@???@???@???@???@???@???@???@???@???@???@_?>@') ; yourself); yourself]!
       
   139 
       
   140 iconPrivateClass
       
   141     "Generated by the Image Editor"
       
   142     "
       
   143     ImageEditor openOnClass:self andSelector:#iconPrivateClass
       
   144     "
       
   145 
       
   146     <resource: #image>
       
   147 
       
   148     ^Icon
       
   149         constantNamed:#'ResourceSelectionBrowser iconPrivateClass'
       
   150         ifAbsentPut:[(Depth2Image new) width: 18; height: 16; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@PUUUUU@A****(@F*??* @Z+??*@A*/*>(OF*>+: @Z+??*@A*/?:(DF*>** @Z+:**@A*/**(@F*>** @Z****C0@@@@@@@@@@@@@b') ; colorMapFromArray:#[0 0 0 255 255 255 170 170 170 255 0 0]; mask:((Depth1Image new) width: 18; height: 16; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'_?>@???@???@???@???@???@???@???@???@???@???@???@???@???@???@_?>@') ; yourself); yourself]! !
   125 
   151 
   126 !ResourceSelectionBrowser class methodsFor:'interface specs'!
   152 !ResourceSelectionBrowser class methodsFor:'interface specs'!
   127 
   153 
   128 windowSpec
   154 windowSpec
   129     "this window spec was automatically generated by the ST/X UIPainter"
   155     "this window spec was automatically generated by the ST/X UIPainter"
   309       #model: #resourceType
   335       #model: #resourceType
   310       #canSelect: false
   336       #canSelect: false
   311   ))
   337   ))
   312 ! !
   338 ! !
   313 
   339 
   314 !ResourceSelectionBrowser class methodsFor:'resources'!
       
   315 
       
   316 iconClass
       
   317     "Generated by the Image Editor"
       
   318     "
       
   319     ImageEditor openOnClass:self andSelector:#iconClass
       
   320     "
       
   321 
       
   322     <resource: #image>
       
   323 
       
   324     ^Icon
       
   325         constantNamed:#'ResourceSelectionBrowser iconClass'
       
   326         ifAbsentPut:[(Depth2Image new) width: 18; height: 16; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@@UUUUUAQ****(@F**** @Z****@A****(@F**** @Z****@A****(LF**** TZ****@A****(@F**** @Z****@@@@@@@@@@@@@@@b') ; colorMapFromArray:#[0 0 0 255 255 255 170 170 170 255 0 0]; mask:((Depth1Image new) width: 18; height: 16; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'_?>@???@???@???@???@???@???@???@???@???@???@???@???@???@???@_?>@') ; yourself); yourself]
       
   327 !
       
   328 
       
   329 iconPrivateClass
       
   330     "Generated by the Image Editor"
       
   331     "
       
   332     ImageEditor openOnClass:self andSelector:#iconPrivateClass
       
   333     "
       
   334 
       
   335     <resource: #image>
       
   336 
       
   337     ^Icon
       
   338         constantNamed:#'ResourceSelectionBrowser iconPrivateClass'
       
   339         ifAbsentPut:[(Depth2Image new) width: 18; height: 16; photometric:(#palette); bitsPerSample:(#(2 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'@@@@@@PUUUUU@A****(@F*??* @Z+??*@A*/*>(OF*>+: @Z+??*@A*/?:(DF*>** @Z+:**@A*/**(@F*>** @Z****C0@@@@@@@@@@@@@b') ; colorMapFromArray:#[0 0 0 255 255 255 170 170 170 255 0 0]; mask:((Depth1Image new) width: 18; height: 16; photometric:(#blackIs0); bitsPerSample:(#(1 )); samplesPerPixel:(1); bits:(ByteArray fromPackedString:'_?>@???@???@???@???@???@???@???@???@???@???@???@???@???@???@_?>@') ; yourself); yourself]! !
       
   340 
       
   341 !ResourceSelectionBrowser methodsFor:'accessing - views'!
   340 !ResourceSelectionBrowser methodsFor:'accessing - views'!
   342 
   341 
   343 classNameInputField
   342 classNameInputField
   344 
   343 
   345     ^builder componentAt: #classNameInputField
   344     ^builder componentAt: #classNameInputField
   430 ! !
   429 ! !
   431 
   430 
   432 !ResourceSelectionBrowser methodsFor:'callbacks - user'!
   431 !ResourceSelectionBrowser methodsFor:'callbacks - user'!
   433 
   432 
   434 classSelected: anIndex
   433 classSelected: anIndex
   435     
   434 
   436     self selectionOfClass value isNil ifTrue: [^nil].
   435     self selectionOfClass value isNil ifTrue: [^nil].
   437     self withWaitCursorDo:
   436     self withWaitCursorDo:
   438     [
   437     [
   439         |clsName|
   438         |clsName|
   440         resourceTypes isNil ifTrue: [resourceTypes := Method resourceTypes].
   439         resourceTypes isNil ifTrue: [resourceTypes := Method resourceTypes].
   477     [
   476     [
   478         |superClsCandidate|
   477         |superClsCandidate|
   479         superClsCandidate := (Dialog 
   478         superClsCandidate := (Dialog 
   480                 request: 'Enter name of superclass of private class.'
   479                 request: 'Enter name of superclass of private class.'
   481                 initialAnswer: 'Object') asSymbol.
   480                 initialAnswer: 'Object') asSymbol.
   482         (superClsCandidate := Smalltalk at: superClsCandidate) isNil ifTrue: [^nil].
   481         (Smalltalk at: superClsCandidate) isNil ifTrue: [^self warn: 'Class ', superClsCandidate asBoldText, ' does not exist!!'].
   483 
   482 
   484         (superClsCandidate isClass and: [superClsCandidate isPrivate not])
   483         ((superClsCandidate := Smalltalk at: superClsCandidate) isClass and: [superClsCandidate isPrivate not])
   485             ifFalse: [^self warn: 'May not create private class with superclass ', superClsCandidate asBoldText, '!!'].
   484             ifFalse: [^self warn: 'May not create private class with superclass ', superClsCandidate asBoldText, '!!'].
   486         superClsCandidate subclass: clsCandidat
   485         superClsCandidate subclass: clsCandidat
   487             instanceVariableNames:''
   486             instanceVariableNames:''
   488             classVariableNames:''
   487             classVariableNames:''
   489             poolDictionaries:''
   488             poolDictionaries:''
   609 ! !
   608 ! !
   610 
   609 
   611 !ResourceSelectionBrowser::Row methodsFor:'accessing'!
   610 !ResourceSelectionBrowser::Row methodsFor:'accessing'!
   612 
   611 
   613 iconOn:aGC
   612 iconOn:aGC
   614 
   613     "register and answer an icon indicating the resource type."
   615     icon isNil ifTrue: [icon := method iconOn: aGC].
   614 
       
   615     self resourceType isNil ifTrue: [^nil].
       
   616     icon isNil 
       
   617     ifTrue: 
       
   618     [
       
   619         |cls sel image imageKey|
       
   620         ((self resourceType = #image) or: [resourceType = #fileImage])
       
   621         ifTrue: 
       
   622         [  
       
   623             cls := method who methodClass soleInstance.
       
   624             sel := method who methodSelector.
       
   625         ]
       
   626         ifFalse:
       
   627         [
       
   628             cls := BrowserView.
       
   629             sel := (resourceType, 'Icon') asSymbol.
       
   630         ].
       
   631         imageKey := (cls name, sel) asSymbol.
       
   632         (icon := aGC registeredImageAt: imageKey) isNil
       
   633         ifTrue:
       
   634         [       
       
   635             image := cls perform: sel.
       
   636             image extent y > 18
       
   637             ifTrue:
       
   638             [         
       
   639                 image := image magnifiedBy: 18/image extent y
       
   640             ].
       
   641             aGC registerImage: image key: imageKey.
       
   642             icon := aGC registeredImageAt: imageKey.
       
   643         ].
       
   644     ].
   616     ^icon
   645     ^icon
   617 
       
   618 !
   646 !
   619 
   647 
   620 method: aMethod
   648 method: aMethod
   621 
   649 
   622     method := aMethod
   650     method := aMethod