#DOCUMENTATION by cg
class: SelectionInTree
comment/format in: #doMakeVisible:
changed:
#each:do:
#selectNode:
--- a/SelectionInTree.st Tue Oct 17 03:40:20 2017 +0000
+++ b/SelectionInTree.st Thu Oct 19 12:15:57 2017 +0200
@@ -122,12 +122,12 @@
!SelectionInTree methodsFor:'accessing hierarchy new'!
-doMakeVisible:something
- "make an item or list of items to become visible"
+doMakeVisible:itemOrCollectionOfItems
+ "make an item or collection of items visible"
|anchor parent|
- self each:something do:[:anItem|
+ self each:itemOrCollectionOfItems do:[:anItem|
parent := anItem.
anchor := nil.
@@ -144,7 +144,7 @@
].
]
- "Modified (comment): / 04-02-2017 / 19:37:02 / cg"
+ "Modified (comment): / 18-10-2017 / 11:55:53 / cg"
! !
!SelectionInTree methodsFor:'accessing-behavior'!
@@ -630,16 +630,19 @@
!SelectionInTree methodsFor:'enumerating'!
-each:something do:aBlock
+each:itemOrCollectionOfItems do:aOneArgBlock
"evaluate a block for something or in case of a collection for each
element in the collection"
- something notNil ifTrue:[
- something isCollection ifTrue:[something do:[:el|aBlock value:el]]
- ifFalse:[aBlock value:something]
+ itemOrCollectionOfItems notNil ifTrue:[
+ itemOrCollectionOfItems isCollection ifTrue:[
+ itemOrCollectionOfItems do:aOneArgBlock
+ ] ifFalse:[
+ aOneArgBlock value:itemOrCollectionOfItems
+ ]
]
- "Modified (comment): / 04-02-2017 / 19:37:07 / cg"
+ "Modified (format): / 18-10-2017 / 11:55:36 / cg"
! !
!SelectionInTree methodsFor:'initialization'!
@@ -799,15 +802,19 @@
!SelectionInTree methodsFor:'selection'!
selectNode:aNode
- "select a given node (by identity - not by index)"
+ "select a given node (by identity - not by index).
+ Notice, that the node must be visible - i.e. its parent chain must be
+ currently expanded."
|index|
(index := self indexOf:aNode) ~~ 0 ifTrue:[
self selectionIndex:index
+ ] ifFalse:[
+ "/ self halt.
]
- "Modified (comment): / 04-02-2017 / 19:40:42 / cg"
+ "Modified: / 18-10-2017 / 11:56:20 / cg"
!
selectNodes:aCollectionOfNodes