ResourceSpecEditor.st
changeset 889 85b7aa0e79e4
parent 877 a5461433de58
child 896 6e23150974d0
equal deleted inserted replaced
888:69628f75a4b8 889:85b7aa0e79e4
    12 
    12 
    13 
    13 
    14 
    14 
    15 
    15 
    16 
    16 
    17 'From Smalltalk/X, Version:3.4.3 on 23-mar-1998 at 9:12:52 pm'                  !
       
    18 
       
    19 ToolApplicationModel subclass:#ResourceSpecEditor
    17 ToolApplicationModel subclass:#ResourceSpecEditor
    20 	instanceVariableNames:'modified aspects specClass specSelector tabSelection hasSaved'
    18 	instanceVariableNames:'modified aspects specClass specSelector tabSelection hasSaved'
    21 	classVariableNames:''
    19 	classVariableNames:''
    22 	poolDictionaries:''
    20 	poolDictionaries:''
    23 	category:'Interface-Framework'
    21 	category:'Interface-Framework'
   124 ! !
   122 ! !
   125 
   123 
   126 !ResourceSpecEditor methodsFor:'accessing'!
   124 !ResourceSpecEditor methodsFor:'accessing'!
   127 
   125 
   128 modified       
   126 modified       
   129     "return true, if the resource spec was modified"
   127     "returns whether the resource spec was modified"
   130 
   128 
   131     ^modified
   129     ^modified
   132 !
   130 !
   133 
   131 
   134 modified: aBoolean         
   132 modified: aBoolean         
   136 
   134 
   137     modified := aBoolean
   135     modified := aBoolean
   138 !
   136 !
   139 
   137 
   140 specClass
   138 specClass
   141     "get the class where the resource spec is implemented"
   139     "returns the class where the resource spec is implemented"
   142 
   140 
   143     ^specClass
   141     ^specClass
   144 !
   142 !
   145 
   143 
   146 specClass:aClass
   144 specClass:aClass
   147     "set the class (or name) where the resource spec is (or should be) implemented"
   145     "sets the class (or name) where the resource spec is (or should be) implemented"
   148 
   146 
   149     aClass isBehavior ifTrue:[specClass := aClass name]
   147     aClass isBehavior ifTrue:[specClass := aClass name]
   150                      ifFalse:[specClass := aClass]
   148                      ifFalse:[specClass := aClass]
   151 !
   149 !
   152 
   150 
   153 specSelector
   151 specSelector
   154     "get the method selector of the resource spec"
   152     "returns the method selector of the resource spec"
   155 
   153 
   156     ^specSelector
   154     ^specSelector
   157 
   155 
   158 !
   156 !
   159 
   157 
   160 specSelector:aSelector
   158 specSelector:aSelector
   161     "set the method selector of the resource spec"
   159     "sets the method selector of the resource spec"
   162 
   160 
   163     specSelector := aSelector
   161     specSelector := aSelector
   164 ! !
   162 ! !
   165 
   163 
   166 !ResourceSpecEditor methodsFor:'aspects'!
   164 !ResourceSpecEditor methodsFor:'aspects'!
   167 
   165 
   168 aspectFor:aKey
   166 aspectFor:aKey
   169     "get the aspect for a aKey or nil"
   167     "returns the aspect for a aKey or nil"
   170 
   168 
   171     ^aspects at: aKey ifAbsent: [super aspectFor:aKey]
   169     ^aspects at: aKey ifAbsent: [super aspectFor:aKey]
   172 
   170 
   173 !
   171 !
   174 
   172 
   175 tabModel
   173 tabModel
   176     "get the value holder for the tab selection"
   174     "returns the value holder for the tab selection"
   177 
   175 
   178     |holder|
   176     |holder|
   179     (holder := builder bindingAt:#tabModel) isNil ifTrue:[
   177     (holder := builder bindingAt:#tabModel) isNil ifTrue:[
   180         holder := AspectAdaptor new subject:self; forAspect:#tabSelection.
   178         holder := AspectAdaptor new subject:self; forAspect:#tabSelection.
   181         builder aspectAt:#tabModel put:holder.
   179         builder aspectAt:#tabModel put:holder.
   250 ! !
   248 ! !
   251 
   249 
   252 !ResourceSpecEditor methodsFor:'help'!
   250 !ResourceSpecEditor methodsFor:'help'!
   253 
   251 
   254 defaultInfoLabel
   252 defaultInfoLabel
   255     "get default label for the info bar"
   253     "returns the default label for the info bar"
   256 
   254 
   257     |cls|
   255     |cls|
   258     (specClass isSymbol and: [(cls := Smalltalk at: specClass) isClass])
   256     (specClass isSymbol and: [(cls := Smalltalk at: specClass) isClass])
   259     ifTrue:
   257     ifTrue:
   260     [
   258     [
   291 ! !
   289 ! !
   292 
   290 
   293 !ResourceSpecEditor methodsFor:'private'!
   291 !ResourceSpecEditor methodsFor:'private'!
   294 
   292 
   295 askForItemModification
   293 askForItemModification
   296     "ask for resource item modification"
   294     "asks for resource item modification"
   297 
   295 
   298     self valueOfEnablingCommitButtons value
   296     self valueOfEnablingCommitButtons value
   299     ifTrue:
   297     ifTrue:
   300     [          
   298     [          
   301         ((YesNoBox title:'Resource item was modified!!\Save it?\' withCRs)        
   299         ((YesNoBox title:'Resource item was modified!!\Save it?\' withCRs)        
   314     ^true
   312     ^true
   315 
   313 
   316 !
   314 !
   317 
   315 
   318 askForListModification
   316 askForListModification
   319     "ask for resource modification"
   317     "asks for resource modification"
   320 
   318 
   321     modified
   319     modified
   322     ifTrue:
   320     ifTrue:
   323     [
   321     [
   324         ((YesNoBox title: 'List was modified!!')        
   322         ((YesNoBox title: self class resourceType asUppercaseFirst, ' spec was modified!!')        
   325             noText:'Cancel';
   323             noText:'Cancel';
   326             yesText:'Waste it and proceed';
   324             yesText:'Waste it and proceed';
   327             showAtPointer;
   325             showAtPointer;
   328             accepted) ifFalse: [^false].
   326             accepted) ifFalse: [^false].
   329         modified := false
   327         modified := false
   330     ].
   328     ].
   331     ^true
   329     ^true
   332 !
   330 !
   333 
   331 
   334 askForModification
   332 askForModification
   335     "ask first for item and then for resource modification"
   333     "asks first for item and then for resource modification"
   336 
   334 
   337     ^self askForItemModification and: [self askForListModification]
   335     ^self askForItemModification and: [self askForListModification]
   338 
   336 
   339 !
   337 !
   340 
   338 
   341 resolveClassNamed
   339 resolveClassNamed
   342     "get current class or nil"
   340     "returns current class or nil"
   343 
   341 
   344     ^Smalltalk resolveName:specClass inClass:self class
   342     ^Smalltalk resolveName:specClass inClass:self class
   345 !
   343 !
   346 
   344 
   347 resourceMessage: aString
   345 resourceMessage: aString
   348     "extract from aString the specClass and the specSelector"
   346     "extracts from aString the specClass and the specSelector"
   349 
   347 
   350     (aString notNil and: [self askForModification]) 
   348     (aString notNil and: [self askForModification]) 
   351     ifTrue:
   349     ifTrue:
   352     [            
   350     [            
   353         |msg cls sel|
   351         |msg cls sel|
   363     ].
   361     ].
   364     ^false
   362     ^false
   365 !
   363 !
   366 
   364 
   367 updateHistory
   365 updateHistory
   368     "if there was loaded a resource spec, update the history"
   366     "if there was loaded a resource spec, it updates the history"
   369 
   367 
   370     |cls|             
   368     |cls|             
   371     ((cls := self resolveClassNamed) notNil and: [cls class implements: specSelector])
   369     ((cls := self resolveClassNamed) notNil and: [cls class implements: specSelector])
   372     ifTrue:
   370     ifTrue:
   373     [
   371     [
   495     self valueOfEnablingCommitButtons value: false.
   493     self valueOfEnablingCommitButtons value: false.
   496     modified := true
   494     modified := true
   497 !
   495 !
   498 
   496 
   499 doBrowseClass
   497 doBrowseClass
   500     "open a System Browser on the specClass and specSelector"
   498     "opens a System Browser on the specClass and specSelector"
   501 
   499 
   502     |cls|
   500     |cls|
   503 
   501 
   504     (cls := self resolveClassNamed) notNil 
   502     (cls := self resolveClassNamed) notNil 
   505         ifTrue: [SystemBrowser openInClass:cls class selector: specSelector] 
   503         ifTrue: [SystemBrowser openInClass:cls class selector: specSelector] 
   506         ifFalse:[self information:'No class defined!!']
   504         ifFalse:[self information:'No class defined!!']
   507 !
   505 !
   508 
   506 
   509 doEditImage
   507 doEditImage
   510     "open the Image Editor on a resource retriever and icon selector"
   508     "opens a Image Editor on a resource retriever and icon selector"
   511 
   509 
   512     |cls resourceClass resourceSelector imageResourceMessage readStream|
   510     |cls resourceClass resourceSelector imageResourceMessage readStream|
   513 
   511 
   514     cls := self resolveName: specClass.
   512     cls := self resolveName: specClass.
   515     cls isNil ifTrue:[
   513     cls isNil ifTrue:[
   534 
   532 
   535 
   533 
   536 !
   534 !
   537 
   535 
   538 doLoad
   536 doLoad
   539     "open a Resource Selection Browser in order to get a resource message"
   537     "opens a Resource Selection Browser in order to get a resource message"
   540 
   538 
   541     self loadFromMessage: 
   539     self loadFromMessage: 
   542         (ResourceSelectionBrowser
   540         (ResourceSelectionBrowser
   543             request: 'Load ', self class resourceType asUppercaseFirst, ' Spec From Class'
   541             request: 'Load ', self class resourceType asUppercaseFirst, ' Spec From Class'
   544             onSuperclass: nil
   542             onSuperclass: nil
   607 ! !
   605 ! !
   608 
   606 
   609 !ResourceSpecEditor class methodsFor:'documentation'!
   607 !ResourceSpecEditor class methodsFor:'documentation'!
   610 
   608 
   611 version
   609 version
   612     ^ '$Header: /cvs/stx/stx/libview2/ResourceSpecEditor.st,v 1.4 1998-03-30 14:00:39 tz Exp $'
   610     ^ '$Header: /cvs/stx/stx/libview2/ResourceSpecEditor.st,v 1.5 1998-04-01 15:21:53 tz Exp $'
   613 ! !
   611 ! !