SelectionInTreeView.st
changeset 2688 2d853020325f
parent 2659 3af857eb52fb
child 2689 c382886ddb08
equal deleted inserted replaced
2687:7c7bedb930c6 2688:2d853020325f
  1750     "
  1750     "
  1751     |coll value size idx|
  1751     |coll value size idx|
  1752 
  1752 
  1753     (value := selectionHolder value) isNil ifFalse:[
  1753     (value := selectionHolder value) isNil ifFalse:[
  1754         (multipleSelectOk and:[value isCollection]) ifFalse:[
  1754         (multipleSelectOk and:[value isCollection]) ifFalse:[
  1755             ^ self selectNode:value
  1755             ^ self selectNode:value withNotify:false.
  1756         ].
  1756         ].
  1757 
  1757 
  1758         (size := value size) ~~ 0 ifTrue:[
  1758         (size := value size) ~~ 0 ifTrue:[
  1759             size == 1 ifTrue:[
  1759             size == 1 ifTrue:[
  1760                 ^ self selectNode:(value at:1)
  1760                 ^ self selectNode:(value at:1) withNotify:false
  1761             ].
  1761             ].
  1762 
  1762 
  1763             model doMakeVisible:value.
  1763             model doMakeVisible:value.
  1764 
  1764 
  1765             coll := OrderedCollection new:size.
  1765             coll := OrderedCollection new:size.
  1775             coll isEmpty ifTrue:[
  1775             coll isEmpty ifTrue:[
  1776                 coll := nil
  1776                 coll := nil
  1777             ].
  1777             ].
  1778         ].
  1778         ].
  1779     ].
  1779     ].
  1780     self selection:coll
  1780     self setSelection:coll
  1781 !
  1781 !
  1782 
  1782 
  1783 selectionToModel
  1783 selectionToModel
  1784     "write selection to selection holder
  1784     "write selection to selection holder
  1785     "
  1785     "
  2197 !SelectionInTreeView methodsFor:'selection'!
  2197 !SelectionInTreeView methodsFor:'selection'!
  2198 
  2198 
  2199 selectNode:aNode
  2199 selectNode:aNode
  2200     "change selection to a node
  2200     "change selection to a node
  2201     "
  2201     "
       
  2202     ^ self selectNode:aNode withNotify:true.
       
  2203 !
       
  2204 
       
  2205 selectNode:aNode withNotify:withNotify
       
  2206     "change selection to a node
       
  2207     "
  2202     |index|
  2208     |index|
  2203 
  2209 
  2204     (index := aNode) notNil ifTrue:[
  2210     (index := aNode) notNil ifTrue:[
  2205         index isNumber ifFalse:[
  2211         index isNumber ifFalse:[
  2206             (index := self indexOfNode:aNode) == 0 ifTrue:[
  2212             (index := self indexOfNode:aNode) == 0 ifTrue:[
  2210         ].
  2216         ].
  2211         index == 0 ifTrue:[
  2217         index == 0 ifTrue:[
  2212             index := nil
  2218             index := nil
  2213         ]
  2219         ]
  2214     ].
  2220     ].
  2215     self selection:index 
  2221     withNotify ifFalse:[
  2216 
  2222         self setSelection:index
  2217 
  2223     ] ifTrue:[
       
  2224         self selection:index 
       
  2225     ].
  2218 !
  2226 !
  2219 
  2227 
  2220 selectNodes:aCollectionOfNodes
  2228 selectNodes:aCollectionOfNodes
       
  2229     ^ self selectNode:aCollectionOfNodes withNotify:true.
       
  2230 !
       
  2231 
       
  2232 selectNodes:aCollectionOfNodes withNotify:withNotify
  2221     |selIndexCollection|
  2233     |selIndexCollection|
  2222 
  2234 
  2223     selIndexCollection := aCollectionOfNodes collect:[:eachNode | listOfNodes identityIndexOf:eachNode].
  2235     selIndexCollection := aCollectionOfNodes collect:[:eachNode | listOfNodes identityIndexOf:eachNode].
  2224     selIndexCollection := selIndexCollection reject:[:eachIndex | eachIndex == 0].
  2236     selIndexCollection := selIndexCollection reject:[:eachIndex | eachIndex == 0].
  2225     self selection:selIndexCollection.
  2237 
       
  2238     withNotify ifTrue:[
       
  2239         self selection:selIndexCollection.
       
  2240     ] ifFalse:[
       
  2241         self setSelection:selIndexCollection.
       
  2242     ].
  2226 
  2243 
  2227 "/    first := true.
  2244 "/    first := true.
  2228 "/    aCollectionOfNodes do:[:eachNode |
  2245 "/    aCollectionOfNodes do:[:eachNode |
  2229 "/        first ifTrue:[
  2246 "/        first ifTrue:[
  2230 "/            self selectNode:eachNode.
  2247 "/            self selectNode:eachNode.
  2469 ! !
  2486 ! !
  2470 
  2487 
  2471 !SelectionInTreeView class methodsFor:'documentation'!
  2488 !SelectionInTreeView class methodsFor:'documentation'!
  2472 
  2489 
  2473 version
  2490 version
  2474     ^ '$Header: /cvs/stx/stx/libwidg2/SelectionInTreeView.st,v 1.104 2004-02-26 12:18:38 cg Exp $'
  2491     ^ '$Header: /cvs/stx/stx/libwidg2/SelectionInTreeView.st,v 1.105 2004-03-26 11:35:42 ca Exp $'
  2475 ! !
  2492 ! !