SelectionInTree.st
changeset 1209 2f7f9bf064bb
parent 1204 3940e6cbde19
child 1213 5b22dd452a58
equal deleted inserted replaced
1208:2f9d74cead2f 1209:2f7f9bf064bb
   482     |sel|
   482     |sel|
   483 
   483 
   484     sel := self selectionIndex.
   484     sel := self selectionIndex.
   485     self selectionIndex:nil.
   485     self selectionIndex:nil.
   486     self remove:sel.
   486     self remove:sel.
       
   487 !
       
   488 
       
   489 replaceNode:aNode with:aNewNode
       
   490     "replace a node by a new node; if the new node is nil, the node and its
       
   491      children are removed. Otherwise the children are taken over to the new
       
   492      node.
       
   493     "
       
   494     |parent index children|
       
   495 
       
   496     (aNode isNil or:[aNode == aNewNode]) ifTrue:[
       
   497         ^ self
       
   498     ].
       
   499 
       
   500     aNewNode isNil ifTrue:[
       
   501         ^ self remove:aNode
       
   502     ].
       
   503     self stopIndicatorValidationFor:aNode.
       
   504 
       
   505     aNewNode children:(aNode children).    
       
   506     aNode    children:nil.
       
   507 
       
   508     aNode == root ifTrue:[
       
   509         aNewNode tree:(aNode tree).
       
   510         aNewNode parent:nil.
       
   511         root := aNewNode.
       
   512     ] ifFalse:[
       
   513         parent := aNode parent.
       
   514         aNewNode tree:nil.
       
   515         aNewNode parent:parent.
       
   516         children := parent children.
       
   517         index := children identityIndexOf:aNode.
       
   518         children at:index put:aNewNode.
       
   519     ].
       
   520 
       
   521     aNode tree:nil.        
       
   522     aNode parent:nil.        
       
   523 
       
   524     (index := self indexOf:aNode) ~~ 0 ifTrue:[
       
   525         list at:index put:aNewNode.
       
   526         self changed:#at: with:index
       
   527     ].
   487 ! !
   528 ! !
   488 
   529 
   489 !SelectionInTree methodsFor:'change & update'!
   530 !SelectionInTree methodsFor:'change & update'!
   490 
   531 
   491 invalidate
   532 invalidate
   831 ! !
   872 ! !
   832 
   873 
   833 !SelectionInTree class methodsFor:'documentation'!
   874 !SelectionInTree class methodsFor:'documentation'!
   834 
   875 
   835 version
   876 version
   836     ^ '$Header: /cvs/stx/stx/libwidg2/SelectionInTree.st,v 1.22 1999-02-18 19:38:48 cg Exp $'
   877     ^ '$Header: /cvs/stx/stx/libwidg2/SelectionInTree.st,v 1.23 1999-02-19 15:32:26 cg Exp $'
   837 ! !
   878 ! !