UIPainterView.st
changeset 2396 042e31fded4f
parent 2395 9f9cf71a311c
child 2421 2504941c00c2
equal deleted inserted replaced
2395:9f9cf71a311c 2396:042e31fded4f
   270     "delete the selection buffered"
   270     "delete the selection buffered"
   271 
   271 
   272     self deleteSelectionBuffered: true
   272     self deleteSelectionBuffered: true
   273 !
   273 !
   274 
   274 
   275 deleteSelectionBuffered: buffered
   275 deleteSelectionBuffered:buffered
   276     "cut the selection. If buffered is true, place it into the cut&paste-buffer"
   276     "cut the selection. If buffered is true, place it into the cut&paste-buffer"
   277 
   277 
   278     |specs specsToRemove index oldSelection newSelection treeModel children size node|
   278     |specs viewsToRemove newSelection firstView|
   279 
   279 
   280     treeView askForSelectionChangeAllowed ifFalse:[^ self].
   280     treeView askForSelectionChangeAllowed ifFalse:[^ self].
   281 
   281 
   282     specsToRemove := self minClosedViewSetFor:(self selection).
   282     viewsToRemove := self minClosedViewSetFor:(self selection).
   283     specsToRemove notEmptyOrNil ifTrue:[
   283     viewsToRemove isEmptyOrNil ifTrue:[ ^ self].
       
   284 
       
   285     buffered ifTrue:[
       
   286         specs := viewsToRemove collect:[:aView| self fullSpecWithAbsolutePositionFor:aView ].
       
   287         self setClipboardObject:specs
       
   288     ].
       
   289     firstView    := viewsToRemove first.
       
   290     newSelection := self findContainerOfView:firstView.
       
   291 
       
   292     newSelection isNil ifTrue:[
       
   293         newSelection := self.
       
   294     ] ifFalse:[
       
   295         viewsToRemove size == 1 ifTrue:[
       
   296             |subviews index|
       
   297 
       
   298             subviews := newSelection subViews.
       
   299 
       
   300             subviews size > 1 ifTrue:[
       
   301                 index := subviews findFirst:[:eachView| eachView isSameOrComponentOf:firstView ].
       
   302                 index > 0 ifTrue:[
       
   303                     newSelection := subviews
       
   304                             at:(index + 1)
       
   305                             ifAbsent:[subviews at:index -1].
       
   306                 ].
       
   307             ].
       
   308         ].
       
   309     ].
       
   310 
       
   311     self withSelectionHiddenDo:[
       
   312         self select:newSelection.
       
   313 
   284         treeView canvasEventsDisabledDo:[
   314         treeView canvasEventsDisabledDo:[
   285             treeModel    := treeView model.
   315             self withinTransaction:#cut objects:viewsToRemove do:[
   286             oldSelection := treeModel selectedNodes at:1 ifAbsent: nil.
   316                 viewsToRemove reverseDo:[:aView|
   287 
       
   288             oldSelection notNil ifTrue:[
       
   289                 children := oldSelection parent children.
       
   290                 (size := children size) > 1 ifTrue:[
       
   291                     index := children identityIndexOf:oldSelection.
       
   292                     size == index ifTrue:[
       
   293                         index := index - 1
       
   294                     ].
       
   295                     newSelection := children at:index ifAbsent:1.
       
   296                 ] ifFalse:[
       
   297                     newSelection := oldSelection parent
       
   298                 ].
       
   299                 newSelection := treeModel indexOf:newSelection.
       
   300             ] ifFalse:[
       
   301                 newSelection := 1
       
   302             ].
       
   303 
       
   304             self hideSelection.
       
   305             selection := nil.
       
   306             specs := specsToRemove collect:[:aView| self fullSpecWithAbsolutePositionFor:aView ].
       
   307 
       
   308             self withinTransaction:#cut objects:specsToRemove do:[
       
   309                 specsToRemove reverseDo:[:aView|
       
   310                     self createUndoRemove:aView.
   317                     self createUndoRemove:aView.
   311                     self remove:aView.
   318                     self remove:aView.
   312                 ]
   319                 ]
   313             ].
   320             ].
   314             buffered ifTrue: [self setClipboardObject:specs].
   321         ].
   315             treeView selection:nil.
   322         self windowGroup processRealExposeEvents.
   316             treeView selection:(Array with: newSelection).
   323     ].
   317             (node := treeView selectedNode) notNil ifTrue:[
       
   318                 self setSelection:node contents view withRedraw:true.
       
   319             ]
       
   320         ]
       
   321     ]
       
   322 !
   324 !
   323 
   325 
   324 deleteTotalSelection
   326 deleteTotalSelection
   325     "delete the selection"
   327     "delete the selection"
   326 
   328