selection after paste expecco_1_3_4
authorClaus Gittinger <cg@exept.de>
Mon, 17 Dec 2007 12:05:23 +0100
changeset 22218ac60d4545ad
parent 2220 ff2b5cb004c2
child 2222 23205ddb56e1
selection after paste
UIPainterView.st
     1.1 --- a/UIPainterView.st	Mon Dec 17 12:04:57 2007 +0100
     1.2 +++ b/UIPainterView.st	Mon Dec 17 12:05:23 2007 +0100
     1.3 @@ -215,6 +215,12 @@
     1.4  
     1.5  !UIPainterView methodsFor:'copy & cut & paste'!
     1.6  
     1.7 +changeSelectionAfterPasteOf:sel
     1.8 +    sel notNil ifTrue:[
     1.9 +        self select:sel.
    1.10 +    ].
    1.11 +!
    1.12 +
    1.13  commonContainerOf:someComponents
    1.14      |container|
    1.15  
    1.16 @@ -329,10 +335,7 @@
    1.17      |sel|
    1.18  
    1.19      sel := self pasteSpecifications:(self getClipboardObject) keepLayout:false.
    1.20 -
    1.21 -    sel notNil ifTrue:[
    1.22 -        self select:sel.
    1.23 -    ].
    1.24 +    self changeSelectionAfterPasteOf:sel.
    1.25  !
    1.26  
    1.27  pasteKeepingPosition
    1.28 @@ -348,9 +351,7 @@
    1.29          keepPosition:true
    1.30          at:nil.
    1.31  
    1.32 -    sel notNil ifTrue:[
    1.33 -        self select:sel.
    1.34 -    ].
    1.35 +    self changeSelectionAfterPasteOf:sel.
    1.36  !
    1.37  
    1.38  pasteSpecifications:aSpecificationOrList keepLayout:keepLayout
    1.39 @@ -388,7 +389,7 @@
    1.40          ] ifFalse:[
    1.41              containerToPasteInto := self
    1.42          ].
    1.43 -        self selection:containerToPasteInto.
    1.44 +"/        self selection:containerToPasteInto.
    1.45      ].
    1.46  
    1.47      (self canPasteInto:containerToPasteInto) ifFalse:[
    1.48 @@ -401,14 +402,16 @@
    1.49                      containerToPasteInto := containerToPasteInto container.
    1.50                  ].
    1.51              ].
    1.52 -            self selection:containerToPasteInto.
    1.53 +"/            self selection:containerToPasteInto.
    1.54          ].
    1.55      ].
    1.56      containerToPasteInto isNil ifTrue:[
    1.57          containerToPasteInto := self
    1.58      ].
    1.59  
    1.60 -    (self canPaste:aSpecificationOrList) ifFalse:[
    1.61 +    (self canPaste:aSpecificationOrList into:containerToPasteInto)
    1.62 +    "(self canPaste:aSpecificationOrList)" 
    1.63 +    ifFalse:[
    1.64          Dialog warn:'Cannot paste into selected component (not a container ?)'.
    1.65          ^ nil
    1.66      ].
    1.67 @@ -418,7 +421,7 @@
    1.68      ] ifFalse:[
    1.69          paste := Array with:aSpecificationOrList
    1.70      ].
    1.71 -    self setClipboardObject:nil.
    1.72 +"/    self setClipboardObject:nil.
    1.73  
    1.74      newSel  := OrderedCollection new.
    1.75      builder := UIBuilder new isEditing:true.
    1.76 @@ -495,10 +498,7 @@
    1.77      |sel|
    1.78  
    1.79      sel := self pasteSpecifications:(self getClipboardObject) keepLayout:true.
    1.80 -
    1.81 -    sel notNil ifTrue:[
    1.82 -        self select:sel.
    1.83 -    ].
    1.84 +    self changeSelectionAfterPasteOf:sel.
    1.85  ! !
    1.86  
    1.87  !UIPainterView methodsFor:'drag & drop'!
    1.88 @@ -529,6 +529,12 @@
    1.89  canPaste:something
    1.90      "returns true if something could be pasted"
    1.91  
    1.92 +    ^ self canPaste:something into:(self singleSelection)
    1.93 +!
    1.94 +
    1.95 +canPaste:something into:containerToPasteInto
    1.96 +    "returns true if something could be pasted"
    1.97 +
    1.98      |el size|
    1.99  
   1.100      ((size := self numberOfSelections) <= 1 and:[self enabled]) ifFalse:[
   1.101 @@ -543,7 +549,7 @@
   1.102      ].
   1.103  
   1.104      size == 1 ifTrue:[
   1.105 -        ^ self canPasteInto:(self singleSelection)
   1.106 +        ^ self canPasteInto:containerToPasteInto
   1.107      ].
   1.108      ^ true
   1.109  !