UIPainterView.st
changeset 1954 1344ec1f99eb
parent 1953 3b5022bccca4
child 1959 fd6bf76e712a
equal deleted inserted replaced
1953:3b5022bccca4 1954:1344ec1f99eb
   463         newSel add:view.
   463         newSel add:view.
   464     ].
   464     ].
   465 
   465 
   466     self withinTransaction:#paste objects:newSel do:[
   466     self withinTransaction:#paste objects:newSel do:[
   467         undoHistory addUndoSelector:#undoCreate:
   467         undoHistory addUndoSelector:#undoCreate:
   468                            withArgs:(newSel collect:[:v|(self propertyOfView:v) identifier])
   468                            withArgs:(newSel collect:[:v|(self propertyOfView:v) identifier]).
       
   469         self undoHistoryChanged.
   469     ].
   470     ].
   470 
   471 
   471     self realizeAllSubViews.
   472     self realizeAllSubViews.
   472     newSel do:[:v| v raise].
   473     newSel do:[:v| v raise].
   473     self elementChangedSize:containerToPasteInto.
   474     self elementChangedSize:containerToPasteInto.
  2196     self withinTransaction:aType objects:something do:[
  2197     self withinTransaction:aType objects:something do:[
  2197 	self forEach:something do:aOneArgBlock
  2198 	self forEach:something do:aOneArgBlock
  2198     ]
  2199     ]
  2199 !
  2200 !
  2200 
  2201 
  2201 withinTransaction:aType objects:objects do:aNoneArgBlock
  2202 withinTransaction:aType objects:objects do:aNoArgBlock
  2202     "evaluate a block with no arguments within a transaction
  2203     "evaluate a block with no arguments within a transaction
  2203     "
  2204     "
  2204     |text size prop|
  2205     |text size prop|
  2205 
  2206 
  2206     objects isNil ifTrue:[ ^ self ].
  2207     objects isNil ifTrue:[ ^ self ].
  2207 
  2208 
  2208     size := objects size.
  2209     size := objects size.
  2209 
  2210 
  2210     objects isCollection ifTrue:[
  2211     objects isCollection ifTrue:[
  2211 	size == 0 ifTrue:[ ^ self ].
  2212         size == 0 ifTrue:[ ^ self ].
  2212 	size == 1 ifTrue:[ prop := self propertyOfView:(objects first) ]
  2213         size == 1 ifTrue:[ prop := self propertyOfView:(objects first) ]
  2213     ] ifFalse:[
  2214     ] ifFalse:[
  2214 	prop := self propertyOfView:objects
  2215         prop := self propertyOfView:objects
  2215     ].
  2216     ].
  2216 
  2217 
  2217     prop notNil ifTrue:[
  2218     prop notNil ifTrue:[
  2218 	text := prop name
  2219         text := prop name
  2219     ] ifFalse:[
  2220     ] ifFalse:[
  2220 	text := size printString, ' elements'
  2221         text := size printString, ' elements'
  2221     ].
  2222     ].
  2222 
  2223 
  2223     undoHistory withinTransaction:aType text:text do:[
  2224     undoHistory withinTransaction:aType text:text do:aNoArgBlock.
  2224 	aNoneArgBlock value
  2225     self undoHistoryChanged.
  2225     ]
       
  2226 ! !
  2226 ! !
  2227 
  2227 
  2228 !UIPainterView methodsFor:'undo actions'!
  2228 !UIPainterView methodsFor:'undo actions'!
  2229 
  2229 
  2230 createUndoLayout:aView
  2230 createUndoLayout:aView
  2231     "create undo action before changing a views layout
  2231     "create undo action before changing a views layout
  2232     "
  2232     "
  2233     |lyt args prop|
  2233     |lyt args prop|
  2234 
  2234 
  2235     undoHistory isTransactionOpen ifTrue:[
  2235     undoHistory isTransactionOpen ifTrue:[
  2236 	prop := self propertyOfView:aView.
  2236         prop := self propertyOfView:aView.
  2237 
  2237 
  2238 	prop notNil ifTrue:[
  2238         prop notNil ifTrue:[
  2239 	    args := Array new:3.
  2239             args := Array new:3.
  2240 	    args at:1 put:(prop identifier).
  2240             args at:1 put:(prop identifier).
  2241 
  2241 
  2242 	    (lyt := aView geometryLayout) notNil ifTrue:[
  2242             (lyt := aView geometryLayout) notNil ifTrue:[
  2243 		args at:2 put:#geometryLayout:
  2243                 args at:2 put:#geometryLayout:
  2244 	    ] ifFalse:[
  2244             ] ifFalse:[
  2245 		lyt := aView extent.
  2245                 lyt := aView extent.
  2246 		args at:2 put:#extent:
  2246                 args at:2 put:#extent:
  2247 	    ].
  2247             ].
  2248 	    args at:3 put:(lyt copy).
  2248             args at:3 put:(lyt copy).
  2249 	    undoHistory addUndoSelector:#undoLayout: withArgs:args.
  2249             undoHistory addUndoSelector:#undoLayout: withArgs:args.
  2250 	]
  2250             self undoHistoryChanged.
       
  2251         ]
  2251     ]
  2252     ]
  2252 !
  2253 !
  2253 
  2254 
  2254 createUndoRemove:aView
  2255 createUndoRemove:aView
  2255     "create undo method before deleting views
  2256     "create undo method before deleting views
  2256     "
  2257     "
  2257     |prop pid|
  2258     |prop pid|
  2258 
  2259 
  2259     (prop := self propertyOfView:aView) notNil ifTrue:[
  2260     (prop := self propertyOfView:aView) notNil ifTrue:[
  2260 	(pid := self propertyOfParentForView:aView) notNil ifTrue:[
  2261         (pid := self propertyOfParentForView:aView) notNil ifTrue:[
  2261 	    pid := pid identifier
  2262             pid := pid identifier
  2262 	].
  2263         ].
  2263 
  2264 
  2264 	undoHistory addUndoSelector:#undoRemove:
  2265         undoHistory addUndoSelector:#undoRemove:
  2265 			   withArgs:(Array with:(self fullSpecFor:aView)
  2266                            withArgs:(Array with:(self fullSpecFor:aView)
  2266 			       with:(prop identifier)
  2267                                with:(prop identifier)
  2267 			       with:pid)
  2268                                with:pid).
       
  2269         self undoHistoryChanged.
  2268     ]
  2270     ]
  2269 !
  2271 !
  2270 
  2272 
  2271 createUndoSpecModify:aProp
  2273 createUndoSpecModify:aProp
  2272     "undo method when changing the specification for an object
  2274     "undo method when changing the specification for an object
  2273     "
  2275     "
  2274     aProp notNil ifTrue:[
  2276     aProp notNil ifTrue:[
  2275 	undoHistory addUndoSelector:#undoSpecModify:
  2277         undoHistory addUndoSelector:#undoSpecModify:
  2276 			   withArgs:(Array with:(aProp spec) with:(aProp identifier))
  2278                            withArgs:(Array with:(aProp spec) with:(aProp identifier)).
       
  2279         self undoHistoryChanged.
  2277     ]
  2280     ]
  2278 !
  2281 !
  2279 
  2282 
  2280 undoCreate:something
  2283 undoCreate:something
  2281     "undo method for creating or pasting an object
  2284     "undo method for creating or pasting an object