PPContext.st
changeset 650 4c6ed0a28d18
parent 427 a7f5e6de19d2
equal deleted inserted replaced
643:65da3a4195b6 650:4c6ed0a28d18
    42 !
    42 !
    43 
    43 
    44 globalAt: aKey put: anObject
    44 globalAt: aKey put: anObject
    45 	"Set the global property at aKey to be anObject. If aKey is not found, create a new entry for aKey and set is value to anObject. Answer anObject."
    45 	"Set the global property at aKey to be anObject. If aKey is not found, create a new entry for aKey and set is value to anObject. Answer anObject."
    46 
    46 
    47 	^ (globals ifNil: [ globals := Dictionary new: 1 ])
    47 	^ (globals isNil ifTrue: [ globals := Dictionary new: 1 ])
    48 		at: aKey put: anObject
    48 		at: aKey put: anObject
    49 !
    49 !
    50 
    50 
    51 hasGlobal: aKey
    51 hasGlobal: aKey
    52 	"Test if the global property aKey is present."
    52 	"Test if the global property aKey is present."
    99 !
    99 !
   100 
   100 
   101 propertyAt: aKey put: anObject
   101 propertyAt: aKey put: anObject
   102 	"Set the property at aKey to be anObject. If aKey is not found, create a new entry for aKey and set is value to anObject. Answer anObject."
   102 	"Set the property at aKey to be anObject. If aKey is not found, create a new entry for aKey and set is value to anObject. Answer anObject."
   103 
   103 
   104 	^ (properties ifNil: [ properties := Dictionary new: 1 ])
   104 	^ (properties isNil ifTrue: [ properties := Dictionary new: 1 ])
   105 		at: aKey put: anObject
   105 		at: aKey put: anObject
   106 !
   106 !
   107 
   107 
   108 removeProperty: aKey
   108 removeProperty: aKey
   109 	"Remove the property with aKey. Answer the property or raise an error if aKey isn't found."
   109 	"Remove the property with aKey. Answer the property or raise an error if aKey isn't found."
   179 	self rememberProperties: memento.
   179 	self rememberProperties: memento.
   180 	^ memento
   180 	^ memento
   181 !
   181 !
   182 
   182 
   183 rememberProperties: aPPContextMemento
   183 rememberProperties: aPPContextMemento
   184 	properties ifNil: [ ^ self ].
   184 	properties isNil ifTrue: [ ^ self ].
   185 	
   185 	
   186 	properties keysAndValuesDo: [ :key :value |
   186 	properties keysAndValuesDo: [ :key :value |
   187 		aPPContextMemento propertyAt: key put: value
   187 		aPPContextMemento propertyAt: key put: value
   188 	].
   188 	].
   189 !
   189 !
   196 !
   196 !
   197 
   197 
   198 restoreProperties: aPPContextMemento
   198 restoreProperties: aPPContextMemento
   199 	aPPContextMemento stream == stream ifFalse: [ self error: 'Oops!!' ].
   199 	aPPContextMemento stream == stream ifFalse: [ self error: 'Oops!!' ].
   200 	
   200 	
   201 	properties ifNil: [ ^ self ].
   201 	properties isNil ifTrue: [ ^ self ].
   202 	
   202 	
   203 	properties keysDo: [ :key |
   203 	properties keysDo: [ :key |
   204 		(aPPContextMemento hasProperty: key)
   204 		(aPPContextMemento hasProperty: key)
   205 			ifTrue: [ properties at: key put: (aPPContextMemento propertyAt: key) ]
   205 			ifTrue: [ properties at: key put: (aPPContextMemento propertyAt: key) ]
   206 			ifFalse: [ properties removeKey: key  ]. 
   206 			ifFalse: [ properties removeKey: key  ].