SelectionInTree.st
author ca
Wed, 24 Oct 2001 10:52:35 +0200
changeset 2038 81b3b590c9d8
parent 1818 fe99c5c721e9
child 2494 87ae868b836a
permissions -rw-r--r--
*** empty log message ***
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
     1
"
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
     2
 COPYRIGHT (c) 1997 by eXept Software AG / Claus Gittinger
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
     3
              All Rights Reserved
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
     4
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
     5
 This software is furnished under a license and may be used
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    10
 hereby transferred.
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    11
"
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    12
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    13
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    14
1818
fe99c5c721e9 category changes
Claus Gittinger <cg@exept.de>
parents: 1553
diff changeset
    15
"{ Package: 'stx:libwidg2' }"
fe99c5c721e9 category changes
Claus Gittinger <cg@exept.de>
parents: 1553
diff changeset
    16
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    17
Model subclass:#SelectionInTree
762
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
    18
	instanceVariableNames:'root list selection showRoot contentsAction labelAction
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
    19
		childrenAction iconAction indicatorList indicatorTask accessLock'
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    20
	classVariableNames:''
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    21
	poolDictionaries:''
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    22
	category:'Interface-Support-Models'
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    23
!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    24
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    25
!SelectionInTree class methodsFor:'documentation'!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    26
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    27
copyright
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    28
"
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    29
 COPYRIGHT (c) 1997 by eXept Software AG / Claus Gittinger
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    30
              All Rights Reserved
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    31
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    32
 This software is furnished under a license and may be used
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    33
 only in accordance with the terms of that license and with the
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    34
 inclusion of the above copyright notice.   This software may not
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    35
 be provided or otherwise made available to, or used by, any
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    36
 other person.  No title to or ownership of the software is
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    37
 hereby transferred.
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    38
"
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    39
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    40
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    41
!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    42
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    43
documentation
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    44
"
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    45
    list and selection holder for hierarchical list structures. Used
1189
0c2cf8ee62e3 comment
Claus Gittinger <cg@exept.de>
parents: 1176
diff changeset
    46
    to buildup file-trees, class trees etc.
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    47
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    48
    Especially suited for use with SelectionInTreeView.
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    49
1189
0c2cf8ee62e3 comment
Claus Gittinger <cg@exept.de>
parents: 1176
diff changeset
    50
    Notice: this class replaces SelectionInHierarchy, which provides
0c2cf8ee62e3 comment
Claus Gittinger <cg@exept.de>
parents: 1176
diff changeset
    51
            similar (but less sphisticated) functionality.
0c2cf8ee62e3 comment
Claus Gittinger <cg@exept.de>
parents: 1176
diff changeset
    52
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    53
    [See also:]
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    54
        TreeItem
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    55
        SelectionInTreeView
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    56
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    57
    [Author:]
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    58
        W. Olberding
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    59
        Claus Atzkern
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    60
"
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    61
! !
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    62
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
    63
!SelectionInTree class methodsFor:'instance creation'!
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
    64
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
    65
new
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
    66
    ^ super new initialize
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
    67
! !
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
    68
1174
8d0c73401ea8 ask model for default itemClass
ca
parents: 1166
diff changeset
    69
!SelectionInTree class methodsFor:'defaults'!
8d0c73401ea8 ask model for default itemClass
ca
parents: 1166
diff changeset
    70
8d0c73401ea8 ask model for default itemClass
ca
parents: 1166
diff changeset
    71
defaultItemClass
8d0c73401ea8 ask model for default itemClass
ca
parents: 1166
diff changeset
    72
    "returns the default item class or nil (the default)
8d0c73401ea8 ask model for default itemClass
ca
parents: 1166
diff changeset
    73
    "
8d0c73401ea8 ask model for default itemClass
ca
parents: 1166
diff changeset
    74
    ^ nil
8d0c73401ea8 ask model for default itemClass
ca
parents: 1166
diff changeset
    75
8d0c73401ea8 ask model for default itemClass
ca
parents: 1166
diff changeset
    76
8d0c73401ea8 ask model for default itemClass
ca
parents: 1166
diff changeset
    77
8d0c73401ea8 ask model for default itemClass
ca
parents: 1166
diff changeset
    78
! !
8d0c73401ea8 ask model for default itemClass
ca
parents: 1166
diff changeset
    79
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    80
!SelectionInTree methodsFor:'accessing'!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    81
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    82
list
1189
0c2cf8ee62e3 comment
Claus Gittinger <cg@exept.de>
parents: 1176
diff changeset
    83
    "get the list of currently shown objects
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    84
    "
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    85
    ^ list
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    86
!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    87
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    88
root
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    89
    "get the root node
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    90
    "
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    91
    ^ root
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    92
!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    93
509
c6c9f5ecb977 add method expand
ca
parents: 496
diff changeset
    94
root:aRoot
c6c9f5ecb977 add method expand
ca
parents: 496
diff changeset
    95
    "set a new root
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    96
    "
1176
cd9fc4bfb273 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1174
diff changeset
    97
    |tree|
cd9fc4bfb273 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1174
diff changeset
    98
762
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
    99
    root notNil ifTrue: [
1176
cd9fc4bfb273 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1174
diff changeset
   100
        tree := root tree.
cd9fc4bfb273 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1174
diff changeset
   101
        root tree:nil.
cd9fc4bfb273 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1174
diff changeset
   102
    ] ifFalse:[
cd9fc4bfb273 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1174
diff changeset
   103
        tree := self
762
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   104
    ].
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   105
    self stopRunningTasks.
762
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   106
515
2c09c8688bb8 set parent of root allways to nil
ca
parents: 509
diff changeset
   107
    (root := aRoot) notNil ifTrue:[
1176
cd9fc4bfb273 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1174
diff changeset
   108
        root tree:tree.
762
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   109
        root parent:nil.
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   110
    ].
1189
0c2cf8ee62e3 comment
Claus Gittinger <cg@exept.de>
parents: 1176
diff changeset
   111
    self recomputeList
860
64d52b8e3dbd bug fix in remove:
ca
parents: 857
diff changeset
   112
!
64d52b8e3dbd bug fix in remove:
ca
parents: 857
diff changeset
   113
64d52b8e3dbd bug fix in remove:
ca
parents: 857
diff changeset
   114
value
64d52b8e3dbd bug fix in remove:
ca
parents: 857
diff changeset
   115
    ^ list
496
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   116
! !
491
c7d57a5e7a21 change root, do not remove children
ca
parents: 482
diff changeset
   117
1818
fe99c5c721e9 category changes
Claus Gittinger <cg@exept.de>
parents: 1553
diff changeset
   118
!SelectionInTree methodsFor:'accessing-behavior'!
496
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   119
762
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   120
childrenAction
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   121
    "get children action block
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   122
    "
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   123
    ^childrenAction
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   124
!
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   125
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   126
childrenAction:aBlock
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   127
    "set children action block
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   128
    "
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   129
    childrenAction := aBlock.
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   130
!
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   131
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   132
contentsAction
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   133
    "get contents action block
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   134
    "
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   135
    ^contentsAction
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   136
!
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   137
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   138
contentsAction:aBlock
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   139
    "set contents action block
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   140
    "
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   141
    contentsAction := aBlock.
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   142
!
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   143
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   144
iconAction
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   145
    "get icon action block
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   146
    "
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   147
    ^iconAction
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   148
!
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   149
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   150
iconAction:aBlock
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   151
    "set icon action block
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   152
    "
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   153
    iconAction := aBlock.
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   154
!
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   155
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   156
labelAction
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   157
    "get label action block
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   158
    "
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   159
    ^labelAction
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   160
!
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   161
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   162
labelAction:aBlock
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   163
    "set label action block
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   164
    "
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   165
    labelAction := aBlock.
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   166
!
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   167
496
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   168
showRoot
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   169
    "list with or without root
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   170
    "
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   171
    ^ showRoot
491
c7d57a5e7a21 change root, do not remove children
ca
parents: 482
diff changeset
   172
!
c7d57a5e7a21 change root, do not remove children
ca
parents: 482
diff changeset
   173
496
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   174
showRoot:aState
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   175
    "list with or without root
491
c7d57a5e7a21 change root, do not remove children
ca
parents: 482
diff changeset
   176
    "
496
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   177
    aState ~~ showRoot ifTrue:[
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   178
        showRoot := aState.
491
c7d57a5e7a21 change root, do not remove children
ca
parents: 482
diff changeset
   179
496
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   180
        root notNil ifTrue:[
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   181
            aState ifTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   182
                list addFirst:root.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   183
                self changed:#insertCollection: with:(Array with:1 with:1 with:nil).
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   184
            ] ifFalse:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   185
                list removeFirst.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   186
                self changed:#removeFrom: with:(Array with:1 with:1 with:nil).
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   187
            ].
491
c7d57a5e7a21 change root, do not remove children
ca
parents: 482
diff changeset
   188
        ].
c7d57a5e7a21 change root, do not remove children
ca
parents: 482
diff changeset
   189
    ].
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   190
! !
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   191
1818
fe99c5c721e9 category changes
Claus Gittinger <cg@exept.de>
parents: 1553
diff changeset
   192
!SelectionInTree methodsFor:'accessing-hierarchy'!
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   193
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   194
collapse:something 
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   195
    "collapse a node or collection of nodes
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   196
    "
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   197
    |listChanged|
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   198
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   199
    listChanged := false.
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   200
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   201
    self each:something do:[:aNode|
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   202
        aNode isCollapsable ifTrue:[
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   203
            aNode collapse.
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   204
            listChanged := true
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   205
        ]
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   206
    ].
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   207
    listChanged ifTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   208
        self listFromRoot.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   209
        self changed:#list.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   210
    ]
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   211
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   212
!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   213
509
c6c9f5ecb977 add method expand
ca
parents: 496
diff changeset
   214
expand
c6c9f5ecb977 add method expand
ca
parents: 496
diff changeset
   215
    "expand the root
c6c9f5ecb977 add method expand
ca
parents: 496
diff changeset
   216
    "
c6c9f5ecb977 add method expand
ca
parents: 496
diff changeset
   217
    self expand:root
c6c9f5ecb977 add method expand
ca
parents: 496
diff changeset
   218
!
c6c9f5ecb977 add method expand
ca
parents: 496
diff changeset
   219
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   220
expand:something 
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   221
    "expand a node or collection of nodes
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   222
    "
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   223
    |listChanged|
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   224
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   225
    listChanged := false.
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   226
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   227
    self each:something do:[:aNode|
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   228
        aNode isExpandable ifTrue:[
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   229
            aNode expand.
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   230
            listChanged := true
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   231
        ]
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   232
    ].
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   233
    listChanged ifTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   234
        self listFromRoot.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   235
        self changed:#list.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   236
    ]
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   237
! !
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   238
1818
fe99c5c721e9 category changes
Claus Gittinger <cg@exept.de>
parents: 1553
diff changeset
   239
!SelectionInTree methodsFor:'accessing-hierarchy new'!
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   240
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   241
doCollapse:something
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   242
    "collapse all children under an item or a sequence of items;
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   243
     if the list changed, notifications are raised
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   244
    "
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   245
    self each:something do:[:anItem|
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   246
        self collapseItem:anItem do:[ anItem collapse ]
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   247
    ]
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   248
!
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   249
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   250
doCollapseAll:something
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   251
    "collapse all children and subChildren under an item or sequence of items;
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   252
     if the list changed, notifications are raised
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   253
    "
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   254
    self each:something do:[:anItem|
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   255
        self collapseItem:anItem do:[ anItem collapseAll ]
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   256
    ]
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   257
!
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   258
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   259
doExpand:something
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   260
    "expand all children under an item or collection of items;
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   261
     if the list changed, notifications are raised
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   262
    "
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   263
    self each:something do:[:anItem|
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   264
        self expandItem:anItem do:[anItem expand]
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   265
    ]
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   266
!
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   267
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   268
doExpandAll:something
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   269
    "expand all children and subChildren under an item or sequence of items;
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   270
     if the list changed, notifications are raised
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   271
    "
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   272
    self each:something do:[:anItem|
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   273
        self expandItem:anItem do:[anItem expandAll]
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   274
    ]
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   275
!
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   276
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   277
doMakeVisible:something
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   278
    "make an item or list of items to become visible
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   279
    "
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   280
    |anchor parent|
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   281
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   282
    self each:something do:[:anItem|
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   283
        parent := anItem.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   284
        anchor := nil.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   285
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   286
        [(parent := parent parent) notNil] whileTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   287
            parent hidden ifTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   288
                anchor notNil ifTrue:[ anchor expand ].
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   289
                anchor := parent.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   290
            ]
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   291
        ].
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   292
        anchor notNil ifTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   293
            self expandItem:anchor do:[anchor expand]
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   294
        ]
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   295
    ]
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   296
! !
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   297
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   298
!SelectionInTree methodsFor:'adding & removing'!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   299
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   300
add:something after:aChild
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   301
    "add a node or collection of nodes to parent after a child
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   302
    "
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   303
    "add a node or collection of nodes to after a child
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   304
    "
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   305
    |p|
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   306
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   307
    (aChild notNil and:[(p := aChild parent) notNil]) ifTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   308
        self add:something afterIndex:(p indexOfChild:aChild) below:p
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   309
    ]
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   310
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   311
!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   312
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   313
add:something afterIndex:anIndex below:aParent
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   314
    "add a node or collection of nodes to parent after an index
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   315
    "
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   316
    self add:something beforeIndex:(anIndex + 1) below:aParent
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   317
!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   318
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   319
add:something before:aChild
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   320
    "add a node or collection of nodes to before a child
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   321
    "
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   322
    |p|
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   323
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   324
    (aChild notNil and:[(p := aChild parent) notNil]) ifTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   325
        self add:something beforeIndex:(p indexOfChild:aChild) below:p
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   326
    ]
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   327
!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   328
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   329
add:something beforeIndex:anIndex below:aParent
1204
3940e6cbde19 comment
Claus Gittinger <cg@exept.de>
parents: 1189
diff changeset
   330
    "add a node or collection of nodes to aParents children
3940e6cbde19 comment
Claus Gittinger <cg@exept.de>
parents: 1189
diff changeset
   331
     before anIndex (which is a child-index)
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   332
    "
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   333
    |children start index size pList|
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   334
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   335
    (    aParent isNil
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   336
     or:[something isNil
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   337
     or:[(something isCollection and:[something isEmpty])]]
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   338
    ) ifTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   339
        ^ self
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   340
    ].
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   341
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   342
    (start := self indexOf:aParent) == 0 ifTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   343
        "/
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   344
        "/ parent not visible; list not changed
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   345
        "/
1304
e6693ac51d54 add item at root
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   346
        aParent == root ifFalse:[
e6693ac51d54 add item at root
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   347
            aParent add:something beforeIndex:anIndex.
e6693ac51d54 add item at root
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   348
          ^ self
e6693ac51d54 add item at root
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   349
        ]
e6693ac51d54 add item at root
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   350
    ] ifFalse:[
e6693ac51d54 add item at root
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   351
        aParent shown ifFalse:[
e6693ac51d54 add item at root
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   352
            aParent add:something beforeIndex:anIndex.
e6693ac51d54 add item at root
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   353
            self changed:#at: with:start.
e6693ac51d54 add item at root
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   354
            ^ self
e6693ac51d54 add item at root
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   355
        ]
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   356
    ].
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   357
    children := aParent children.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   358
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   359
    (children isEmpty or:[anIndex <= 1]) ifTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   360
        index := 1.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   361
    ] ifFalse:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   362
        size  := children size.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   363
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   364
        anIndex > size ifTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   365
            index := size + 1.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   366
            start := aParent numberOfAllVisibleChildren + start.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   367
        ] ifFalse:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   368
            index := anIndex.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   369
            start := (self indexOf:(children at:index)) - 1.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   370
        ]
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   371
    ].
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   372
    aParent add:something beforeIndex:index.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   373
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   374
    (start := start + 1) == 0 ifTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   375
        "/
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   376
        "/ not visible
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   377
        "/
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   378
        ^ self
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   379
    ].
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   380
    pList := OrderedCollection new:2048.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   381
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   382
    self each:something do:[:aNode|
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   383
        pList add:aNode.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   384
        aNode addVisibleChildrenTo:pList
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   385
    ].
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   386
    pList isEmpty ifTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   387
        ^ self
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   388
    ].
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   389
    list addAll:pList beforeIndex:start.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   390
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   391
    self changed:#insertCollection:
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   392
            with:(Array with:start with:pList size with:aParent).
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   393
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   394
!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   395
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   396
add:something below:aParent
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   397
    "add a node or collection of nodes to parent
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   398
    "
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   399
    aParent notNil ifTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   400
        self add:something beforeIndex:(aParent numberOfChildren + 1) below:aParent
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   401
    ]
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   402
!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   403
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   404
remove:something
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   405
    "remove a node or collection of nodes
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   406
    "
1268
37066c039eb3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1234
diff changeset
   407
    |node index loNums loItem start size parent stop|
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   408
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   409
    something isNil ifTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   410
        ^ something
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   411
    ].
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   412
    loNums := SortedCollection new.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   413
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   414
    self each:something do:[:el|
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   415
        node := el isNumber ifTrue:[list at:el ifAbsent:nil]
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   416
                           ifFalse:[el].
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   417
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   418
        node notNil ifTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   419
            self stopIndicatorValidationFor:node.
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   420
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   421
            node parent isNil ifTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   422
                "/ remove all including root
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   423
                node == root ifTrue:[ self root:nil ].
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   424
              ^ something
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   425
            ].
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   426
            index := self indexOf:node.
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   427
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   428
            index == 0 ifTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   429
                "/ not visible
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   430
                node parent removeChild:node
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   431
            ] ifFalse:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   432
                loNums add:index
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   433
            ].
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   434
        ]
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   435
    ].
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   436
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   437
    loNums isEmpty ifTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   438
        "/ nothing visible changed
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   439
        ^ something
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   440
    ].
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   441
    loItem := OrderedCollection new.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   442
    loNums do:[:i| loItem add:(list at:i)].
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   443
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   444
    loItem do:[:aNode|
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   445
        start := self indexOf:aNode.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   446
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   447
        start ~~ 0 ifTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   448
            parent := aNode parent.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   449
            size   := 1 + aNode numberOfAllVisibleChildren.
860
64d52b8e3dbd bug fix in remove:
ca
parents: 857
diff changeset
   450
            stop   := start + size - 1.
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   451
            parent remove:aNode.
860
64d52b8e3dbd bug fix in remove:
ca
parents: 857
diff changeset
   452
            list removeFromIndex:start toIndex:stop.
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   453
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   454
            self changed:#removeFrom:
860
64d52b8e3dbd bug fix in remove:
ca
parents: 857
diff changeset
   455
                    with:(Array with:start with:stop with:parent).
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   456
        ]
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   457
    ].
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   458
    ^ something
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   459
!
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   460
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   461
removeAllOtherThanRoot
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   462
    "remove all other than the root
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   463
    "
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   464
    |listChanged|
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   465
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   466
    root notNil ifTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   467
        listChanged := root isCollapsable.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   468
        root children:(OrderedCollection new).
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   469
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   470
        listChanged ifTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   471
            self listFromRoot.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   472
            self changed:#list
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   473
        ]
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   474
    ]
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   475
!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   476
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   477
removeIndex:something
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   478
    "remove a node at index or collection of indexed nodes
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   479
    "
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   480
    self remove:something
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   481
!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   482
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   483
removeSelection
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   484
    "remove selected nodes
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   485
    "
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   486
    |sel|
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   487
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   488
    sel := self selectionIndex.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   489
    self selectionIndex:nil.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   490
    self remove:sel.
1209
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   491
!
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   492
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   493
replaceNode:aNode with:aNewNode
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   494
    "replace a node by a new node; if the new node is nil, the node and its
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   495
     children are removed. Otherwise the children are taken over to the new
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   496
     node.
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   497
    "
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   498
    |parent index children|
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   499
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   500
    (aNode isNil or:[aNode == aNewNode]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   501
        ^ self
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   502
    ].
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   503
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   504
    aNewNode isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   505
        ^ self remove:aNode
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   506
    ].
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   507
    self stopIndicatorValidationFor:aNode.
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   508
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   509
    aNewNode children:(aNode children).    
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   510
    aNode    children:nil.
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   511
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   512
    aNode == root ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   513
        aNewNode tree:(aNode tree).
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   514
        aNewNode parent:nil.
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   515
        root := aNewNode.
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   516
    ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   517
        parent := aNode parent.
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   518
        aNewNode tree:nil.
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   519
        aNewNode parent:parent.
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   520
        children := parent children.
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   521
        index := children identityIndexOf:aNode.
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   522
        children at:index put:aNewNode.
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   523
    ].
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   524
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   525
    aNode tree:nil.        
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   526
    aNode parent:nil.        
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   527
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   528
    (index := self indexOf:aNode) ~~ 0 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   529
        list at:index put:aNewNode.
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   530
        self changed:#at: with:index
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   531
    ].
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   532
! !
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   533
758
0f0b16a16fa7 add method: #invalidate
ca
parents: 585
diff changeset
   534
!SelectionInTree methodsFor:'change & update'!
0f0b16a16fa7 add method: #invalidate
ca
parents: 585
diff changeset
   535
0f0b16a16fa7 add method: #invalidate
ca
parents: 585
diff changeset
   536
invalidate
0f0b16a16fa7 add method: #invalidate
ca
parents: 585
diff changeset
   537
    "called; something changed what requires a redraw but no recomputation.
0f0b16a16fa7 add method: #invalidate
ca
parents: 585
diff changeset
   538
     for example a name
0f0b16a16fa7 add method: #invalidate
ca
parents: 585
diff changeset
   539
    "
0f0b16a16fa7 add method: #invalidate
ca
parents: 585
diff changeset
   540
    self dependents do:[:aDependent|
0f0b16a16fa7 add method: #invalidate
ca
parents: 585
diff changeset
   541
        aDependent isView ifTrue:[ aDependent invalidate ]
0f0b16a16fa7 add method: #invalidate
ca
parents: 585
diff changeset
   542
    ].
0f0b16a16fa7 add method: #invalidate
ca
parents: 585
diff changeset
   543
0f0b16a16fa7 add method: #invalidate
ca
parents: 585
diff changeset
   544
762
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   545
!
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   546
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   547
update:something with:aParameter from:aModel
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   548
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   549
    self dependents do:[:aDependent|
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   550
        aDependent update:something with:aParameter from:aModel
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   551
    ]
758
0f0b16a16fa7 add method: #invalidate
ca
parents: 585
diff changeset
   552
! !
0f0b16a16fa7 add method: #invalidate
ca
parents: 585
diff changeset
   553
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   554
!SelectionInTree methodsFor:'enumerating'!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   555
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   556
each:something do:aBlock
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   557
    "evaluate a block for something or in case of a collection for each
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   558
     element in the collection
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   559
    "
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   560
    something notNil ifTrue:[
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   561
        something isCollection ifTrue:[something do:[:el|aBlock value:el]]
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   562
                              ifFalse:[aBlock value:something]
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   563
    ]
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   564
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   565
! !
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   566
496
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   567
!SelectionInTree methodsFor:'initialization'!
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   568
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   569
initialize
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   570
1166
d062a52bc7cc list attribute changed from OrderedCollection to List
Claus Gittinger <cg@exept.de>
parents: 1155
diff changeset
   571
    showRoot      := true.
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   572
    indicatorList := OrderedCollection new.
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   573
    accessLock    := Semaphore forMutualExclusion.
1166
d062a52bc7cc list attribute changed from OrderedCollection to List
Claus Gittinger <cg@exept.de>
parents: 1155
diff changeset
   574
    list          := List new.
d062a52bc7cc list attribute changed from OrderedCollection to List
Claus Gittinger <cg@exept.de>
parents: 1155
diff changeset
   575
496
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   576
    super initialize.
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   577
496
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   578
! !
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   579
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   580
!SelectionInTree methodsFor:'private'!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   581
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   582
recomputeList
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   583
    "Travers the tree and build a new list."
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   584
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   585
    self listFromRoot.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   586
    self changed:#list.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   587
! !
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   588
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   589
!SelectionInTree methodsFor:'private hierarchy'!
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   590
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   591
collapseItem:anItem do:collapseBlock
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   592
    "collapse all children under an item; raise a notification if
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   593
     the list changed
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   594
    "
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   595
    |start stop size|
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   596
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   597
    anItem isCollapsable ifFalse:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   598
        ^ self
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   599
    ].
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   600
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   601
    (start := self indexOf:anItem) == 0 ifTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   602
        "/
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   603
        "/ item not visible
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   604
        "/
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   605
        collapseBlock value.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   606
    ] ifFalse:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   607
        size := anItem numberOfAllVisibleChildren.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   608
        collapseBlock value.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   609
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   610
        size == 0 ifTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   611
            "/
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   612
            "/ no children before; list not changed 
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   613
            "/
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   614
            self changed:#at: with:start
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   615
        ] ifFalse:[        
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   616
            stop  := start + size.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   617
            start := start + 1.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   618
            list removeFromIndex:start toIndex:stop.
860
64d52b8e3dbd bug fix in remove:
ca
parents: 857
diff changeset
   619
            self changed:#removeFrom: with:(Array with:start with:stop with:anItem).
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   620
        ]
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   621
    ]
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   622
!
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   623
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   624
expandItem:anItem do:expandBlock
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   625
    "expand all children under an item; raise a notification if
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   626
     the list changed
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   627
    "
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   628
    |start size pList|
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   629
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   630
    anItem isExpandable ifFalse:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   631
        ^ self
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   632
    ].
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   633
    expandBlock value.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   634
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   635
    (start := self indexOf:anItem) ~~ 0 ifTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   636
        anItem addVisibleChildrenTo:(pList := OrderedCollection new:2048).
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   637
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   638
        (size := pList size) ~~ 0 ifTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   639
            start := 1 + start.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   640
            list addAll:pList beforeIndex:start.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   641
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   642
            self changed:#insertCollection:
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   643
                    with:(Array with:start with:size with:anItem).
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   644
        ] ifFalse:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   645
            self changed:#at: with:start
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   646
        ]
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   647
    ]
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   648
!
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   649
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   650
listFromRoot
1204
3940e6cbde19 comment
Claus Gittinger <cg@exept.de>
parents: 1189
diff changeset
   651
    "Traverse the tree and build a new list;
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   652
     no change notification is raised
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   653
    "
842
636d8a543c35 call clearContents to reinitialize the list
ca
parents: 811
diff changeset
   654
    list clearContents.
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   655
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   656
    root notNil ifTrue:[
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   657
        showRoot ifTrue:[ list add:root ].
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   658
        root addVisibleChildrenTo:list
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   659
    ]
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   660
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   661
! !
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   662
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   663
!SelectionInTree methodsFor:'queries'!
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   664
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   665
indexOf:anItem
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   666
    "returns the index of an item or 0
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   667
    "
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   668
    ^ anItem notNil ifTrue:[list identityIndexOf:anItem]
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   669
                   ifFalse:[0]
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   670
! !
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   671
849
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   672
!SelectionInTree methodsFor:'searching'!
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   673
1550
3f9efcb63b4e added detectFirstItem:
Claus Gittinger <cg@exept.de>
parents: 1304
diff changeset
   674
detectFirstItem:aOneArgBlock
3f9efcb63b4e added detectFirstItem:
Claus Gittinger <cg@exept.de>
parents: 1304
diff changeset
   675
    "detect an item the evaluation of the block returns true. 
3f9efcb63b4e added detectFirstItem:
Claus Gittinger <cg@exept.de>
parents: 1304
diff changeset
   676
     The argument to the block is the item.
3f9efcb63b4e added detectFirstItem:
Claus Gittinger <cg@exept.de>
parents: 1304
diff changeset
   677
     This recursively enumerates the tree for the first item for which
3f9efcb63b4e added detectFirstItem:
Claus Gittinger <cg@exept.de>
parents: 1304
diff changeset
   678
     the block returns true.
3f9efcb63b4e added detectFirstItem:
Claus Gittinger <cg@exept.de>
parents: 1304
diff changeset
   679
    "
3f9efcb63b4e added detectFirstItem:
Claus Gittinger <cg@exept.de>
parents: 1304
diff changeset
   680
    root notNil ifTrue:[
3f9efcb63b4e added detectFirstItem:
Claus Gittinger <cg@exept.de>
parents: 1304
diff changeset
   681
        ^ root detectFirstChild:aOneArgBlock
3f9efcb63b4e added detectFirstItem:
Claus Gittinger <cg@exept.de>
parents: 1304
diff changeset
   682
    ].
3f9efcb63b4e added detectFirstItem:
Claus Gittinger <cg@exept.de>
parents: 1304
diff changeset
   683
    ^ nil
3f9efcb63b4e added detectFirstItem:
Claus Gittinger <cg@exept.de>
parents: 1304
diff changeset
   684
3f9efcb63b4e added detectFirstItem:
Claus Gittinger <cg@exept.de>
parents: 1304
diff changeset
   685
3f9efcb63b4e added detectFirstItem:
Claus Gittinger <cg@exept.de>
parents: 1304
diff changeset
   686
!
3f9efcb63b4e added detectFirstItem:
Claus Gittinger <cg@exept.de>
parents: 1304
diff changeset
   687
849
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   688
detectItem:aOneArgBlock
1553
38d1274a3e2f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
   689
    "detect an item the evaluation of the block returns true. 
38d1274a3e2f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
   690
     The argument to the block is the item.
1550
3f9efcb63b4e added detectFirstItem:
Claus Gittinger <cg@exept.de>
parents: 1304
diff changeset
   691
     This searches top-level items only.
849
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   692
    "
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   693
    root notNil ifTrue:[
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   694
        ^ root detectChild:aOneArgBlock
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   695
    ].
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   696
    ^ nil
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   697
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   698
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   699
!
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   700
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   701
detectItem:aTwoArgBlock arguments:aListOfArgs
1553
38d1274a3e2f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
   702
    "detect an item the evaluation of the block returns true. 
38d1274a3e2f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
   703
     The first argument to the block is the item, the second argument
38d1274a3e2f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
   704
     the value derived from the argument list at level.
38d1274a3e2f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
   705
     This recursively walks down the tree up to aListOfArgs size levels;
38d1274a3e2f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
   706
     i.e. if you pass (1 to:10) as aListOfArgs, the block will get the sub-level
38d1274a3e2f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
   707
     as second argument and stop the search after 10 levels.
849
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   708
    "
1550
3f9efcb63b4e added detectFirstItem:
Claus Gittinger <cg@exept.de>
parents: 1304
diff changeset
   709
849
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   710
    root notNil ifTrue:[
1553
38d1274a3e2f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
   711
        ^ root detectChild:aTwoArgBlock arguments:aListOfArgs
849
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   712
    ].
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   713
    ^ nil
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   714
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   715
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   716
! !
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   717
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   718
!SelectionInTree methodsFor:'selection'!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   719
1213
5b22dd452a58 added #selectNode:.
Claus Gittinger <cg@exept.de>
parents: 1209
diff changeset
   720
selectNode:aNode
5b22dd452a58 added #selectNode:.
Claus Gittinger <cg@exept.de>
parents: 1209
diff changeset
   721
    |index|
5b22dd452a58 added #selectNode:.
Claus Gittinger <cg@exept.de>
parents: 1209
diff changeset
   722
5b22dd452a58 added #selectNode:.
Claus Gittinger <cg@exept.de>
parents: 1209
diff changeset
   723
    (index := self indexOf:aNode) ~~ 0 ifTrue:[
5b22dd452a58 added #selectNode:.
Claus Gittinger <cg@exept.de>
parents: 1209
diff changeset
   724
        self selectionIndex:index
5b22dd452a58 added #selectNode:.
Claus Gittinger <cg@exept.de>
parents: 1209
diff changeset
   725
    ]
5b22dd452a58 added #selectNode:.
Claus Gittinger <cg@exept.de>
parents: 1209
diff changeset
   726
!
5b22dd452a58 added #selectNode:.
Claus Gittinger <cg@exept.de>
parents: 1209
diff changeset
   727
1234
1dee4432fd38 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1213
diff changeset
   728
selectNodes:aCollectionOfNodes
1dee4432fd38 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1213
diff changeset
   729
    | indices|
1dee4432fd38 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1213
diff changeset
   730
1dee4432fd38 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1213
diff changeset
   731
    indices := aCollectionOfNodes collect:[:aNode | self indexOf:aNode].
1dee4432fd38 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1213
diff changeset
   732
    indices := indices select:[:idx | idx ~~ 0].
1dee4432fd38 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1213
diff changeset
   733
    indices sort.
1dee4432fd38 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1213
diff changeset
   734
    self selectionIndex:indices
1dee4432fd38 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1213
diff changeset
   735
1dee4432fd38 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1213
diff changeset
   736
    "Created: / 6.3.1999 / 22:37:59 / cg"
1dee4432fd38 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1213
diff changeset
   737
!
1dee4432fd38 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1213
diff changeset
   738
906
6173137343de need method #selectedNode
tz
parents: 860
diff changeset
   739
selectedNode
6173137343de need method #selectedNode
tz
parents: 860
diff changeset
   740
    "returns selected node or nil
6173137343de need method #selectedNode
tz
parents: 860
diff changeset
   741
    "
6173137343de need method #selectedNode
tz
parents: 860
diff changeset
   742
    |nodes|
6173137343de need method #selectedNode
tz
parents: 860
diff changeset
   743
    (nodes := self selectedNodes) notNil ifTrue: [
6173137343de need method #selectedNode
tz
parents: 860
diff changeset
   744
        ^nodes first
6173137343de need method #selectedNode
tz
parents: 860
diff changeset
   745
    ].
6173137343de need method #selectedNode
tz
parents: 860
diff changeset
   746
    ^nil
6173137343de need method #selectedNode
tz
parents: 860
diff changeset
   747
6173137343de need method #selectedNode
tz
parents: 860
diff changeset
   748
6173137343de need method #selectedNode
tz
parents: 860
diff changeset
   749
!
6173137343de need method #selectedNode
tz
parents: 860
diff changeset
   750
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   751
selectedNodes
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   752
    "returns list of selected nodes or nil
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   753
    "
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   754
    |node coll|
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   755
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   756
    selection isNil ifTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   757
        ^ nil
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   758
    ].
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   759
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   760
    selection isCollection ifFalse:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   761
        node := list at:selection ifAbsent:nil.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   762
      ^ node notNil ifTrue:[Array with:node] ifFalse:[nil]
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   763
    ].
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   764
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   765
    selection isEmpty ifTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   766
        ^ nil
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   767
    ].
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   768
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   769
    coll := OrderedCollection new:(selection size).
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   770
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   771
    selection do:[:idx|
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   772
        (node := list at:idx ifAbsent:nil) notNil ifTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   773
            coll add:node
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   774
        ]
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   775
    ].
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   776
    ^ coll notEmpty ifTrue:[coll] ifFalse:[nil]
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   777
        
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   778
!
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   779
2038
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   780
selectedNodesDo:aOneArgBlock
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   781
    "evaluate the block on eack node selected
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   782
    "
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   783
    |node|
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   784
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   785
    selection isNil ifTrue:[
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   786
        ^ nil
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   787
    ].
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   788
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   789
    selection isCollection ifFalse:[
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   790
        node := list at:selection ifAbsent:nil.
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   791
        node notNil ifTrue:[
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   792
            aOneArgBlock value:node
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   793
        ].
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   794
        ^ self
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   795
    ].
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   796
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   797
    selection do:[:i|
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   798
        node := list at:i ifAbsent:nil.
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   799
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   800
        node notNil ifTrue:[
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   801
            aOneArgBlock value:node
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   802
        ].
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   803
    ].
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   804
!
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   805
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   806
selection
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   807
    "get the selection or nil
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   808
    "
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   809
    ^ self selectionIndex
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   810
!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   811
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   812
selection:indexesOrNil
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   813
    "set the selection
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   814
    "
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   815
    self selectionIndex:indexesOrNil
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   816
!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   817
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   818
selectionIndex
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   819
    "get the selection or nil
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   820
    "
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   821
    ^ selection
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   822
!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   823
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   824
selectionIndex:indexesOrNil
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   825
    "set the selection
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   826
    "
496
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   827
    |oldSel|
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   828
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   829
    oldSel := selection.
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   830
    self setSelectionIndex:indexesOrNil.
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   831
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   832
    oldSel = selection ifFalse:[
2038
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   833
        self changed:#selectionIndex.
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   834
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   835
        self selectedNodesDo:[:aNode|
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   836
            aNode changedSelected
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   837
        ]
496
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   838
    ]
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   839
!
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   840
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   841
setSelection:indexesOrNil
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   842
    "set the selection without raising a notification
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   843
    "
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   844
    self setSelectionIndex:indexesOrNil
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   845
!
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   846
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   847
setSelectionIndex:indexesOrNil
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   848
    "set the selection without raising a notification
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   849
    "
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   850
    |indexes|
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   851
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   852
    indexes := indexesOrNil.
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   853
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   854
    indexes size == 0 ifTrue:[
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   855
        (indexes isCollection or:[indexes == 0]) ifTrue:[
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   856
            indexes := nil
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   857
        ]
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   858
    ].
496
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   859
    selection := indexes
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   860
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   861
! !
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   862
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   863
!SelectionInTree methodsFor:'update indication task'!
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   864
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   865
startIndicatorValidationFor:aNode
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   866
    "add a node to list of updating indications
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   867
    "
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   868
    |index|
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   869
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   870
    accessLock critical:[
1155
ff5b146ca277 run the indicator update process with a prio-range,
Claus Gittinger <cg@exept.de>
parents: 1145
diff changeset
   871
        |prio|
ff5b146ca277 run the indicator update process with a prio-range,
Claus Gittinger <cg@exept.de>
parents: 1145
diff changeset
   872
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   873
        index := indicatorList identityIndexOf:aNode.
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   874
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   875
        index ~~ 0 ifTrue:[
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   876
            indicatorList removeIndex:index.    "/ reorganize list to be faster
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   877
        ].
1155
ff5b146ca277 run the indicator update process with a prio-range,
Claus Gittinger <cg@exept.de>
parents: 1145
diff changeset
   878
        indicatorList addLast: "addFirst:" aNode.
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   879
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   880
        indicatorTask isNil ifTrue:[
1155
ff5b146ca277 run the indicator update process with a prio-range,
Claus Gittinger <cg@exept.de>
parents: 1145
diff changeset
   881
            prio := Processor activePriority.
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   882
            indicatorTask := [
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   883
                [ self taskCycle ] whileTrue:[ Processor yield ]
1155
ff5b146ca277 run the indicator update process with a prio-range,
Claus Gittinger <cg@exept.de>
parents: 1145
diff changeset
   884
            ] forkAt:(prio - 1).
ff5b146ca277 run the indicator update process with a prio-range,
Claus Gittinger <cg@exept.de>
parents: 1145
diff changeset
   885
            indicatorTask priorityRange:(prio-1 to:prio).
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   886
        ]
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   887
    ].
1155
ff5b146ca277 run the indicator update process with a prio-range,
Claus Gittinger <cg@exept.de>
parents: 1145
diff changeset
   888
ff5b146ca277 run the indicator update process with a prio-range,
Claus Gittinger <cg@exept.de>
parents: 1145
diff changeset
   889
    "Modified: / 26.9.1998 / 15:20:44 / cg"
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   890
!
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   891
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   892
stopIndicatorValidationFor:aNodeOrList
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   893
    "remove a node or list of nodes from list of updating indications
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   894
    "
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   895
    accessLock critical:[
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   896
        aNodeOrList isCollection ifTrue:[
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   897
            aNodeOrList do:[:aNode|
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   898
                indicatorList removeIdentical:aNode ifAbsent:nil
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   899
            ]
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   900
        ] ifFalse:[
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   901
            indicatorList removeIdentical:aNodeOrList ifAbsent:nil
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   902
        ]
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   903
    ]
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   904
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   905
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   906
!
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   907
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   908
stopRunningTasks
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   909
    "stop task
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   910
    "
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   911
    accessLock critical:[ indicatorList removeAll ]
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   912
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   913
!
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   914
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   915
taskCycle
1155
ff5b146ca277 run the indicator update process with a prio-range,
Claus Gittinger <cg@exept.de>
parents: 1145
diff changeset
   916
    "run one cycle fetching indicator state.
ff5b146ca277 run the indicator update process with a prio-range,
Claus Gittinger <cg@exept.de>
parents: 1145
diff changeset
   917
     This is done in the background to avoid long startup
ff5b146ca277 run the indicator update process with a prio-range,
Claus Gittinger <cg@exept.de>
parents: 1145
diff changeset
   918
     delays, in case the indicator information takes long to
ff5b146ca277 run the indicator update process with a prio-range,
Claus Gittinger <cg@exept.de>
parents: 1145
diff changeset
   919
     gather (i.e. when reading directories)"
ff5b146ca277 run the indicator update process with a prio-range,
Claus Gittinger <cg@exept.de>
parents: 1145
diff changeset
   920
2038
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   921
    |node flag|
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   922
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   923
    accessLock critical:[
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   924
        indicatorList isEmpty ifTrue:[          "/ queue is empty; terminate task
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   925
            indicatorTask := nil.
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   926
            ^ false
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   927
        ].
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   928
        node := indicatorList removeFirst.      "/ run task on first node
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   929
        node hasValidIndicator ifTrue:[         "/ up to date
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   930
            ^ true
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   931
        ].
2038
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   932
        node setShowIndicator:(node defaultShowSeparator).      "/ disable registry
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   933
    ].
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   934
2038
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   935
    flag := DirectoryContents directoryNamed:(node fileName) detect:(node matchAction).
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   936
    node showIndicator:flag.
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   937
    ^ true
1145
3ee5513dff2a no change
Claus Gittinger <cg@exept.de>
parents: 906
diff changeset
   938
1155
ff5b146ca277 run the indicator update process with a prio-range,
Claus Gittinger <cg@exept.de>
parents: 1145
diff changeset
   939
    "Modified: / 26.9.1998 / 15:11:16 / cg"
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   940
! !
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   941
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   942
!SelectionInTree class methodsFor:'documentation'!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   943
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   944
version
2038
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   945
    ^ '$Header: /cvs/stx/stx/libwidg2/SelectionInTree.st,v 1.31 2001-10-24 08:52:35 ca Exp $'
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   946
! !