SelectionInTree.st
author Claus Gittinger <cg@exept.de>
Tue, 02 Aug 2005 15:14:45 +0200
changeset 2840 93e2b635838d
parent 2697 c04e7ba6c251
child 3872 a35d3ecdb0bb
permissions -rw-r--r--
proper #initialize
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
2840
93e2b635838d proper #initialize
Claus Gittinger <cg@exept.de>
parents: 2697
diff changeset
    66
    ^ self basicNew initialize
811
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
2697
c04e7ba6c251 care for nil parent
werner
parents: 2494
diff changeset
   118
!SelectionInTree methodsFor:'accessing hierarchy new'!
c04e7ba6c251 care for nil parent
werner
parents: 2494
diff changeset
   119
c04e7ba6c251 care for nil parent
werner
parents: 2494
diff changeset
   120
doMakeVisible:something
c04e7ba6c251 care for nil parent
werner
parents: 2494
diff changeset
   121
    "make an item or list of items to become visible
c04e7ba6c251 care for nil parent
werner
parents: 2494
diff changeset
   122
    "
c04e7ba6c251 care for nil parent
werner
parents: 2494
diff changeset
   123
    |anchor parent|
c04e7ba6c251 care for nil parent
werner
parents: 2494
diff changeset
   124
c04e7ba6c251 care for nil parent
werner
parents: 2494
diff changeset
   125
    self each:something do:[:anItem|
c04e7ba6c251 care for nil parent
werner
parents: 2494
diff changeset
   126
        parent := anItem.
c04e7ba6c251 care for nil parent
werner
parents: 2494
diff changeset
   127
        anchor := nil.
c04e7ba6c251 care for nil parent
werner
parents: 2494
diff changeset
   128
c04e7ba6c251 care for nil parent
werner
parents: 2494
diff changeset
   129
        parent notNil ifTrue:[
c04e7ba6c251 care for nil parent
werner
parents: 2494
diff changeset
   130
            [(parent := parent parent) notNil] whileTrue:[
c04e7ba6c251 care for nil parent
werner
parents: 2494
diff changeset
   131
                parent hidden ifTrue:[
c04e7ba6c251 care for nil parent
werner
parents: 2494
diff changeset
   132
                    anchor notNil ifTrue:[ anchor expand ].
c04e7ba6c251 care for nil parent
werner
parents: 2494
diff changeset
   133
                    anchor := parent.
c04e7ba6c251 care for nil parent
werner
parents: 2494
diff changeset
   134
                ]
c04e7ba6c251 care for nil parent
werner
parents: 2494
diff changeset
   135
            ].
c04e7ba6c251 care for nil parent
werner
parents: 2494
diff changeset
   136
            anchor notNil ifTrue:[
c04e7ba6c251 care for nil parent
werner
parents: 2494
diff changeset
   137
                self expandItem:anchor do:[anchor expand]
c04e7ba6c251 care for nil parent
werner
parents: 2494
diff changeset
   138
            ]
c04e7ba6c251 care for nil parent
werner
parents: 2494
diff changeset
   139
        ].
c04e7ba6c251 care for nil parent
werner
parents: 2494
diff changeset
   140
    ]
c04e7ba6c251 care for nil parent
werner
parents: 2494
diff changeset
   141
! !
c04e7ba6c251 care for nil parent
werner
parents: 2494
diff changeset
   142
1818
fe99c5c721e9 category changes
Claus Gittinger <cg@exept.de>
parents: 1553
diff changeset
   143
!SelectionInTree methodsFor:'accessing-behavior'!
496
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   144
762
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   145
childrenAction
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   146
    "get children action block
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   147
    "
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   148
    ^childrenAction
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
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   151
childrenAction:aBlock
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   152
    "set children action block
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   153
    "
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   154
    childrenAction := aBlock.
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
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   157
contentsAction
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   158
    "get contents action block
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   159
    "
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   160
    ^contentsAction
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
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   163
contentsAction:aBlock
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   164
    "set contents action block
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   165
    "
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   166
    contentsAction := aBlock.
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   167
!
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   168
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   169
iconAction
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   170
    "get icon action block
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   171
    "
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   172
    ^iconAction
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   173
!
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   174
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   175
iconAction:aBlock
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   176
    "set icon action block
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   177
    "
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   178
    iconAction := aBlock.
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   179
!
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   180
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   181
labelAction
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   182
    "get label action block
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   183
    "
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   184
    ^labelAction
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   185
!
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   186
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   187
labelAction:aBlock
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   188
    "set label action block
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   189
    "
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   190
    labelAction := aBlock.
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   191
!
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   192
496
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   193
showRoot
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   194
    "list with or without root
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   195
    "
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   196
    ^ showRoot
491
c7d57a5e7a21 change root, do not remove children
ca
parents: 482
diff changeset
   197
!
c7d57a5e7a21 change root, do not remove children
ca
parents: 482
diff changeset
   198
496
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   199
showRoot:aState
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   200
    "list with or without root
491
c7d57a5e7a21 change root, do not remove children
ca
parents: 482
diff changeset
   201
    "
496
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   202
    aState ~~ showRoot ifTrue:[
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   203
        showRoot := aState.
491
c7d57a5e7a21 change root, do not remove children
ca
parents: 482
diff changeset
   204
496
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   205
        root notNil ifTrue:[
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   206
            aState ifTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   207
                list addFirst:root.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   208
                self changed:#insertCollection: with:(Array with:1 with:1 with:nil).
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   209
            ] ifFalse:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   210
                list removeFirst.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   211
                self changed:#removeFrom: with:(Array with:1 with:1 with:nil).
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   212
            ].
491
c7d57a5e7a21 change root, do not remove children
ca
parents: 482
diff changeset
   213
        ].
c7d57a5e7a21 change root, do not remove children
ca
parents: 482
diff changeset
   214
    ].
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   215
! !
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   216
1818
fe99c5c721e9 category changes
Claus Gittinger <cg@exept.de>
parents: 1553
diff changeset
   217
!SelectionInTree methodsFor:'accessing-hierarchy'!
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   218
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   219
collapse:something 
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   220
    "collapse a node or collection of nodes
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   221
    "
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   222
    |listChanged|
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   223
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   224
    listChanged := false.
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   225
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   226
    self each:something do:[:aNode|
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   227
        aNode isCollapsable ifTrue:[
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   228
            aNode collapse.
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   229
            listChanged := true
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   230
        ]
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   231
    ].
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   232
    listChanged ifTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   233
        self listFromRoot.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   234
        self changed:#list.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   235
    ]
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   236
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   237
!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   238
509
c6c9f5ecb977 add method expand
ca
parents: 496
diff changeset
   239
expand
c6c9f5ecb977 add method expand
ca
parents: 496
diff changeset
   240
    "expand the root
c6c9f5ecb977 add method expand
ca
parents: 496
diff changeset
   241
    "
c6c9f5ecb977 add method expand
ca
parents: 496
diff changeset
   242
    self expand:root
c6c9f5ecb977 add method expand
ca
parents: 496
diff changeset
   243
!
c6c9f5ecb977 add method expand
ca
parents: 496
diff changeset
   244
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   245
expand:something 
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   246
    "expand a node or collection of nodes
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   247
    "
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   248
    |listChanged|
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
    listChanged := false.
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   251
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   252
    self each:something do:[:aNode|
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   253
        aNode isExpandable ifTrue:[
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   254
            aNode expand.
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   255
            listChanged := true
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   256
        ]
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   257
    ].
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   258
    listChanged ifTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   259
        self listFromRoot.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   260
        self changed:#list.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   261
    ]
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
1818
fe99c5c721e9 category changes
Claus Gittinger <cg@exept.de>
parents: 1553
diff changeset
   264
!SelectionInTree methodsFor:'accessing-hierarchy new'!
857
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
doCollapse:something
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   267
    "collapse all children under an item or a sequence of items;
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   268
     if the list changed, notifications are raised
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   269
    "
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   270
    self each:something do:[:anItem|
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   271
        self collapseItem:anItem do:[ anItem collapse ]
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   272
    ]
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   273
!
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
doCollapseAll:something
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   276
    "collapse all children and subChildren under an item or sequence of items;
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   277
     if the list changed, notifications are raised
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   278
    "
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   279
    self each:something do:[:anItem|
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   280
        self collapseItem:anItem do:[ anItem collapseAll ]
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
!
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   283
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   284
doExpand:something
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   285
    "expand all children under an item or collection of items;
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   286
     if the list changed, notifications are raised
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   287
    "
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   288
    self each:something do:[:anItem|
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   289
        self expandItem:anItem do:[anItem expand]
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
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   293
doExpandAll:something
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   294
    "expand all children and subChildren under an item or sequence of items;
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   295
     if the list changed, notifications are raised
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   296
    "
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   297
    self each:something do:[:anItem|
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   298
        self expandItem:anItem do:[anItem expandAll]
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   299
    ]
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   300
! !
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   301
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   302
!SelectionInTree methodsFor:'adding & removing'!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   303
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   304
add:something after:aChild
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   305
    "add a node or collection of nodes to parent after a child
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   306
    "
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   307
    "add a node or collection of nodes to after a child
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   308
    "
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   309
    |p|
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   310
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   311
    (aChild notNil and:[(p := aChild parent) notNil]) ifTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   312
        self add:something afterIndex:(p indexOfChild:aChild) below:p
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   313
    ]
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   314
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   315
!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   316
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   317
add:something afterIndex:anIndex below:aParent
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   318
    "add a node or collection of nodes to parent after an index
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   319
    "
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   320
    self add:something beforeIndex:(anIndex + 1) below:aParent
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   321
!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   322
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   323
add:something before:aChild
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   324
    "add a node or collection of nodes to before a child
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   325
    "
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   326
    |p|
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   327
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   328
    (aChild notNil and:[(p := aChild parent) notNil]) ifTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   329
        self add:something beforeIndex:(p indexOfChild:aChild) below:p
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   330
    ]
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   331
!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   332
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   333
add:something beforeIndex:anIndex below:aParent
1204
3940e6cbde19 comment
Claus Gittinger <cg@exept.de>
parents: 1189
diff changeset
   334
    "add a node or collection of nodes to aParents children
3940e6cbde19 comment
Claus Gittinger <cg@exept.de>
parents: 1189
diff changeset
   335
     before anIndex (which is a child-index)
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   336
    "
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   337
    |children start index size pList|
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   338
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   339
    (    aParent isNil
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   340
     or:[something isNil
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   341
     or:[(something isCollection and:[something isEmpty])]]
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   342
    ) ifTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   343
        ^ self
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   344
    ].
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   345
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   346
    (start := self indexOf:aParent) == 0 ifTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   347
        "/
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   348
        "/ parent not visible; list not changed
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   349
        "/
1304
e6693ac51d54 add item at root
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   350
        aParent == root ifFalse:[
e6693ac51d54 add item at root
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   351
            aParent add:something beforeIndex:anIndex.
e6693ac51d54 add item at root
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   352
          ^ self
e6693ac51d54 add item at root
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   353
        ]
e6693ac51d54 add item at root
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   354
    ] ifFalse:[
e6693ac51d54 add item at root
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   355
        aParent shown ifFalse:[
e6693ac51d54 add item at root
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   356
            aParent add:something beforeIndex:anIndex.
e6693ac51d54 add item at root
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   357
            self changed:#at: with:start.
e6693ac51d54 add item at root
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   358
            ^ self
e6693ac51d54 add item at root
Claus Gittinger <cg@exept.de>
parents: 1268
diff changeset
   359
        ]
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   360
    ].
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   361
    children := aParent children.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   362
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   363
    (children isEmpty or:[anIndex <= 1]) ifTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   364
        index := 1.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   365
    ] ifFalse:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   366
        size  := children size.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   367
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   368
        anIndex > size ifTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   369
            index := size + 1.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   370
            start := aParent numberOfAllVisibleChildren + start.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   371
        ] ifFalse:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   372
            index := anIndex.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   373
            start := (self indexOf:(children at:index)) - 1.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   374
        ]
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
    aParent add:something beforeIndex:index.
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
    (start := start + 1) == 0 ifTrue:[
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
        "/ not visible
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
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   383
    ].
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   384
    pList := OrderedCollection new:2048.
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
    self each:something do:[:aNode|
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   387
        pList add:aNode.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   388
        aNode addVisibleChildrenTo:pList
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   389
    ].
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   390
    pList isEmpty ifTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   391
        ^ self
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   392
    ].
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   393
    list addAll:pList beforeIndex:start.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   394
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   395
    self changed:#insertCollection:
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   396
            with:(Array with:start with:pList size with:aParent).
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   397
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   398
!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   399
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   400
add:something below:aParent
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   401
    "add a node or collection of nodes to parent
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   402
    "
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   403
    aParent notNil ifTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   404
        self add:something beforeIndex:(aParent numberOfChildren + 1) below:aParent
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   405
    ]
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   406
!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   407
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   408
remove:something
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   409
    "remove a node or collection of nodes
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   410
    "
1268
37066c039eb3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1234
diff changeset
   411
    |node index loNums loItem start size parent stop|
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   412
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   413
    something isNil ifTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   414
        ^ something
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   415
    ].
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   416
    loNums := SortedCollection new.
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
    self each:something do:[:el|
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   419
        node := el isNumber ifTrue:[list at:el ifAbsent:nil]
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   420
                           ifFalse:[el].
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   421
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   422
        node notNil ifTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   423
            self stopIndicatorValidationFor:node.
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   424
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   425
            node parent isNil ifTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   426
                "/ remove all including root
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   427
                node == root ifTrue:[ self root:nil ].
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   428
              ^ something
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   429
            ].
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   430
            index := self indexOf:node.
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   431
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   432
            index == 0 ifTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   433
                "/ not visible
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   434
                node parent removeChild:node
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   435
            ] ifFalse:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   436
                loNums add:index
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   437
            ].
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   438
        ]
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   439
    ].
857
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
    loNums isEmpty ifTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   442
        "/ nothing visible changed
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   443
        ^ something
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   444
    ].
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   445
    loItem := OrderedCollection new.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   446
    loNums do:[:i| loItem add:(list at:i)].
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   447
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   448
    loItem do:[:aNode|
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   449
        start := self indexOf:aNode.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   450
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   451
        start ~~ 0 ifTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   452
            parent := aNode parent.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   453
            size   := 1 + aNode numberOfAllVisibleChildren.
860
64d52b8e3dbd bug fix in remove:
ca
parents: 857
diff changeset
   454
            stop   := start + size - 1.
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   455
            parent remove:aNode.
860
64d52b8e3dbd bug fix in remove:
ca
parents: 857
diff changeset
   456
            list removeFromIndex:start toIndex:stop.
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   457
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   458
            self changed:#removeFrom:
860
64d52b8e3dbd bug fix in remove:
ca
parents: 857
diff changeset
   459
                    with:(Array with:start with:stop with:parent).
857
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
    ].
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   462
    ^ something
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
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   465
removeAllOtherThanRoot
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   466
    "remove all other than the root
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   467
    "
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   468
    |listChanged|
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
    root notNil ifTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   471
        listChanged := root isCollapsable.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   472
        root children:(OrderedCollection new).
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
        listChanged ifTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   475
            self listFromRoot.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   476
            self changed:#list
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   477
        ]
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   478
    ]
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   479
!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   480
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   481
removeIndex:something
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   482
    "remove a node at index or collection of indexed nodes
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   483
    "
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   484
    self remove:something
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   485
!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   486
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   487
removeSelection
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   488
    "remove selected nodes
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   489
    "
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   490
    |sel|
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   491
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   492
    sel := self selectionIndex.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   493
    self selectionIndex:nil.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   494
    self remove:sel.
1209
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   495
!
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   496
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   497
replaceNode:aNode with:aNewNode
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   498
    "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
   499
     children are removed. Otherwise the children are taken over to the new
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   500
     node.
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   501
    "
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   502
    |parent index children|
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   503
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   504
    (aNode isNil or:[aNode == aNewNode]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   505
        ^ self
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   506
    ].
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   507
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   508
    aNewNode isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   509
        ^ self remove:aNode
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   510
    ].
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   511
    self stopIndicatorValidationFor:aNode.
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   512
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   513
    aNewNode children:(aNode children).    
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   514
    aNode    children:nil.
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   515
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   516
    aNode == root ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   517
        aNewNode tree:(aNode tree).
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   518
        aNewNode parent:nil.
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   519
        root := aNewNode.
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   520
    ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   521
        parent := aNode parent.
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   522
        aNewNode tree:nil.
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   523
        aNewNode parent:parent.
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   524
        children := parent children.
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   525
        index := children identityIndexOf:aNode.
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   526
        children at:index put:aNewNode.
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   527
    ].
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   528
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   529
    aNode tree:nil.        
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   530
    aNode parent:nil.        
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   531
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   532
    (index := self indexOf:aNode) ~~ 0 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   533
        list at:index put:aNewNode.
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   534
        self changed:#at: with:index
Claus Gittinger <cg@exept.de>
parents: 1204
diff changeset
   535
    ].
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   536
! !
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   537
758
0f0b16a16fa7 add method: #invalidate
ca
parents: 585
diff changeset
   538
!SelectionInTree methodsFor:'change & update'!
0f0b16a16fa7 add method: #invalidate
ca
parents: 585
diff changeset
   539
0f0b16a16fa7 add method: #invalidate
ca
parents: 585
diff changeset
   540
invalidate
0f0b16a16fa7 add method: #invalidate
ca
parents: 585
diff changeset
   541
    "called; something changed what requires a redraw but no recomputation.
0f0b16a16fa7 add method: #invalidate
ca
parents: 585
diff changeset
   542
     for example a name
0f0b16a16fa7 add method: #invalidate
ca
parents: 585
diff changeset
   543
    "
0f0b16a16fa7 add method: #invalidate
ca
parents: 585
diff changeset
   544
    self dependents do:[:aDependent|
0f0b16a16fa7 add method: #invalidate
ca
parents: 585
diff changeset
   545
        aDependent isView ifTrue:[ aDependent invalidate ]
0f0b16a16fa7 add method: #invalidate
ca
parents: 585
diff changeset
   546
    ].
0f0b16a16fa7 add method: #invalidate
ca
parents: 585
diff changeset
   547
0f0b16a16fa7 add method: #invalidate
ca
parents: 585
diff changeset
   548
762
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   549
!
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   550
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   551
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
   552
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   553
    self dependents do:[:aDependent|
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   554
        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
   555
    ]
758
0f0b16a16fa7 add method: #invalidate
ca
parents: 585
diff changeset
   556
! !
0f0b16a16fa7 add method: #invalidate
ca
parents: 585
diff changeset
   557
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   558
!SelectionInTree methodsFor:'enumerating'!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   559
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   560
each:something do:aBlock
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   561
    "evaluate a block for something or in case of a collection for each
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   562
     element in the collection
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   563
    "
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   564
    something notNil ifTrue:[
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   565
        something isCollection ifTrue:[something do:[:el|aBlock value:el]]
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   566
                              ifFalse:[aBlock value:something]
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   567
    ]
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   568
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   569
! !
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   570
496
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   571
!SelectionInTree methodsFor:'initialization'!
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   572
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   573
initialize
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   574
1166
d062a52bc7cc list attribute changed from OrderedCollection to List
Claus Gittinger <cg@exept.de>
parents: 1155
diff changeset
   575
    showRoot      := true.
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   576
    indicatorList := OrderedCollection new.
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   577
    accessLock    := Semaphore forMutualExclusion.
1166
d062a52bc7cc list attribute changed from OrderedCollection to List
Claus Gittinger <cg@exept.de>
parents: 1155
diff changeset
   578
    list          := List new.
496
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   579
! !
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   580
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   581
!SelectionInTree methodsFor:'private'!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   582
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   583
recomputeList
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   584
    "Travers the tree and build a new list."
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   585
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   586
    self listFromRoot.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   587
    self changed:#list.
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
2494
87ae868b836a method category rename
Claus Gittinger <cg@exept.de>
parents: 2038
diff changeset
   590
!SelectionInTree methodsFor:'private-hierarchy'!
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   591
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   592
collapseItem:anItem do:collapseBlock
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   593
    "collapse all children under an item; raise a notification if
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   594
     the list changed
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   595
    "
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   596
    |start stop size|
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   597
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   598
    anItem isCollapsable ifFalse:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   599
        ^ self
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
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   602
    (start := self indexOf:anItem) == 0 ifTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   603
        "/
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   604
        "/ item not visible
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   605
        "/
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   606
        collapseBlock value.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   607
    ] ifFalse:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   608
        size := anItem numberOfAllVisibleChildren.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   609
        collapseBlock value.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   610
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   611
        size == 0 ifTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   612
            "/
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   613
            "/ no children before; list not changed 
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   614
            "/
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   615
            self changed:#at: with:start
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   616
        ] ifFalse:[        
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   617
            stop  := start + size.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   618
            start := start + 1.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   619
            list removeFromIndex:start toIndex:stop.
860
64d52b8e3dbd bug fix in remove:
ca
parents: 857
diff changeset
   620
            self changed:#removeFrom: with:(Array with:start with:stop with:anItem).
857
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
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   625
expandItem:anItem do:expandBlock
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   626
    "expand all children under an item; raise a notification if
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   627
     the list changed
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   628
    "
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   629
    |start size pList|
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   630
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   631
    anItem isExpandable ifFalse:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   632
        ^ self
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   633
    ].
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   634
    expandBlock value.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   635
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   636
    (start := self indexOf:anItem) ~~ 0 ifTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   637
        anItem addVisibleChildrenTo:(pList := OrderedCollection new:2048).
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   638
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   639
        (size := pList size) ~~ 0 ifTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   640
            start := 1 + start.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   641
            list addAll:pList beforeIndex:start.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   642
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   643
            self changed:#insertCollection:
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   644
                    with:(Array with:start with:size with:anItem).
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   645
        ] ifFalse:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   646
            self changed:#at: with:start
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
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   651
listFromRoot
1204
3940e6cbde19 comment
Claus Gittinger <cg@exept.de>
parents: 1189
diff changeset
   652
    "Traverse the tree and build a new list;
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   653
     no change notification is raised
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   654
    "
842
636d8a543c35 call clearContents to reinitialize the list
ca
parents: 811
diff changeset
   655
    list clearContents.
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   656
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   657
    root notNil ifTrue:[
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   658
        showRoot ifTrue:[ list add:root ].
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   659
        root addVisibleChildrenTo:list
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
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   664
!SelectionInTree methodsFor:'queries'!
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   665
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   666
indexOf:anItem
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   667
    "returns the index of an item or 0
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   668
    "
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   669
    ^ anItem notNil ifTrue:[list identityIndexOf:anItem]
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   670
                   ifFalse:[0]
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   671
! !
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   672
849
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   673
!SelectionInTree methodsFor:'searching'!
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   674
1550
3f9efcb63b4e added detectFirstItem:
Claus Gittinger <cg@exept.de>
parents: 1304
diff changeset
   675
detectFirstItem:aOneArgBlock
3f9efcb63b4e added detectFirstItem:
Claus Gittinger <cg@exept.de>
parents: 1304
diff changeset
   676
    "detect an item the evaluation of the block returns true. 
3f9efcb63b4e added detectFirstItem:
Claus Gittinger <cg@exept.de>
parents: 1304
diff changeset
   677
     The argument to the block is the item.
3f9efcb63b4e added detectFirstItem:
Claus Gittinger <cg@exept.de>
parents: 1304
diff changeset
   678
     This recursively enumerates the tree for the first item for which
3f9efcb63b4e added detectFirstItem:
Claus Gittinger <cg@exept.de>
parents: 1304
diff changeset
   679
     the block returns true.
3f9efcb63b4e added detectFirstItem:
Claus Gittinger <cg@exept.de>
parents: 1304
diff changeset
   680
    "
3f9efcb63b4e added detectFirstItem:
Claus Gittinger <cg@exept.de>
parents: 1304
diff changeset
   681
    root notNil ifTrue:[
3f9efcb63b4e added detectFirstItem:
Claus Gittinger <cg@exept.de>
parents: 1304
diff changeset
   682
        ^ root detectFirstChild:aOneArgBlock
3f9efcb63b4e added detectFirstItem:
Claus Gittinger <cg@exept.de>
parents: 1304
diff changeset
   683
    ].
3f9efcb63b4e added detectFirstItem:
Claus Gittinger <cg@exept.de>
parents: 1304
diff changeset
   684
    ^ nil
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
!
3f9efcb63b4e added detectFirstItem:
Claus Gittinger <cg@exept.de>
parents: 1304
diff changeset
   688
849
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   689
detectItem:aOneArgBlock
1553
38d1274a3e2f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
   690
    "detect an item the evaluation of the block returns true. 
38d1274a3e2f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
   691
     The argument to the block is the item.
1550
3f9efcb63b4e added detectFirstItem:
Claus Gittinger <cg@exept.de>
parents: 1304
diff changeset
   692
     This searches top-level items only.
849
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   693
    "
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   694
    root notNil ifTrue:[
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   695
        ^ root detectChild:aOneArgBlock
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   696
    ].
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   697
    ^ nil
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
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   702
detectItem:aTwoArgBlock arguments:aListOfArgs
1553
38d1274a3e2f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
   703
    "detect an item the evaluation of the block returns true. 
38d1274a3e2f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
   704
     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
   705
     the value derived from the argument list at level.
38d1274a3e2f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
   706
     This recursively walks down the tree up to aListOfArgs size levels;
38d1274a3e2f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
   707
     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
   708
     as second argument and stop the search after 10 levels.
849
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   709
    "
1550
3f9efcb63b4e added detectFirstItem:
Claus Gittinger <cg@exept.de>
parents: 1304
diff changeset
   710
849
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   711
    root notNil ifTrue:[
1553
38d1274a3e2f checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1550
diff changeset
   712
        ^ root detectChild:aTwoArgBlock arguments:aListOfArgs
849
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   713
    ].
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   714
    ^ nil
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
! !
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   718
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   719
!SelectionInTree methodsFor:'selection'!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   720
1213
5b22dd452a58 added #selectNode:.
Claus Gittinger <cg@exept.de>
parents: 1209
diff changeset
   721
selectNode:aNode
5b22dd452a58 added #selectNode:.
Claus Gittinger <cg@exept.de>
parents: 1209
diff changeset
   722
    |index|
5b22dd452a58 added #selectNode:.
Claus Gittinger <cg@exept.de>
parents: 1209
diff changeset
   723
5b22dd452a58 added #selectNode:.
Claus Gittinger <cg@exept.de>
parents: 1209
diff changeset
   724
    (index := self indexOf:aNode) ~~ 0 ifTrue:[
5b22dd452a58 added #selectNode:.
Claus Gittinger <cg@exept.de>
parents: 1209
diff changeset
   725
        self selectionIndex:index
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
!
5b22dd452a58 added #selectNode:.
Claus Gittinger <cg@exept.de>
parents: 1209
diff changeset
   728
1234
1dee4432fd38 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1213
diff changeset
   729
selectNodes:aCollectionOfNodes
1dee4432fd38 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1213
diff changeset
   730
    | indices|
1dee4432fd38 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1213
diff changeset
   731
1dee4432fd38 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1213
diff changeset
   732
    indices := aCollectionOfNodes collect:[:aNode | self indexOf:aNode].
1dee4432fd38 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1213
diff changeset
   733
    indices := indices select:[:idx | idx ~~ 0].
1dee4432fd38 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1213
diff changeset
   734
    indices sort.
1dee4432fd38 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1213
diff changeset
   735
    self selectionIndex:indices
1dee4432fd38 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1213
diff changeset
   736
1dee4432fd38 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1213
diff changeset
   737
    "Created: / 6.3.1999 / 22:37:59 / cg"
1dee4432fd38 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1213
diff changeset
   738
!
1dee4432fd38 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1213
diff changeset
   739
906
6173137343de need method #selectedNode
tz
parents: 860
diff changeset
   740
selectedNode
6173137343de need method #selectedNode
tz
parents: 860
diff changeset
   741
    "returns selected node or nil
6173137343de need method #selectedNode
tz
parents: 860
diff changeset
   742
    "
6173137343de need method #selectedNode
tz
parents: 860
diff changeset
   743
    |nodes|
6173137343de need method #selectedNode
tz
parents: 860
diff changeset
   744
    (nodes := self selectedNodes) notNil ifTrue: [
6173137343de need method #selectedNode
tz
parents: 860
diff changeset
   745
        ^nodes first
6173137343de need method #selectedNode
tz
parents: 860
diff changeset
   746
    ].
6173137343de need method #selectedNode
tz
parents: 860
diff changeset
   747
    ^nil
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
!
6173137343de need method #selectedNode
tz
parents: 860
diff changeset
   751
857
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   752
selectedNodes
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   753
    "returns list of selected nodes or nil
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   754
    "
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   755
    |node coll|
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   756
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   757
    selection isNil ifTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   758
        ^ nil
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
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   761
    selection isCollection ifFalse:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   762
        node := list at:selection ifAbsent:nil.
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   763
      ^ node notNil ifTrue:[Array with:node] ifFalse:[nil]
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
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   766
    selection isEmpty ifTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   767
        ^ nil
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
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   770
    coll := OrderedCollection new:(selection size).
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   771
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   772
    selection do:[:idx|
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   773
        (node := list at:idx ifAbsent:nil) notNil ifTrue:[
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   774
            coll add:node
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
    ].
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   777
    ^ coll notEmpty ifTrue:[coll] ifFalse:[nil]
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
!
d8e14b853cb7 methods for adding & removing items are
ca
parents: 849
diff changeset
   780
2038
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   781
selectedNodesDo:aOneArgBlock
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   782
    "evaluate the block on eack node selected
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   783
    "
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   784
    |node|
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   785
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   786
    selection isNil ifTrue:[
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   787
        ^ nil
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   788
    ].
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   789
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   790
    selection isCollection ifFalse:[
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   791
        node := list at:selection ifAbsent:nil.
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   792
        node notNil ifTrue:[
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   793
            aOneArgBlock value:node
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   794
        ].
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   795
        ^ self
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   796
    ].
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   797
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   798
    selection do:[:i|
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   799
        node := list at:i ifAbsent:nil.
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   800
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   801
        node notNil ifTrue:[
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   802
            aOneArgBlock value:node
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
!
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   806
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   807
selection
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   808
    "get the selection or nil
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   809
    "
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   810
    ^ self selectionIndex
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   811
!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   812
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   813
selection:indexesOrNil
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   814
    "set the selection
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   815
    "
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   816
    self selectionIndex:indexesOrNil
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   817
!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   818
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   819
selectionIndex
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   820
    "get the selection or nil
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   821
    "
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   822
    ^ selection
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   823
!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   824
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   825
selectionIndex:indexesOrNil
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   826
    "set the selection
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   827
    "
496
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   828
    |oldSel|
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   829
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   830
    oldSel := selection.
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   831
    self setSelectionIndex:indexesOrNil.
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   832
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   833
    oldSel = selection ifFalse:[
2038
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   834
        self changed:#selectionIndex.
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   835
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   836
        self selectedNodesDo:[:aNode|
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   837
            aNode changedSelected
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   838
        ]
496
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
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   842
setSelection:indexesOrNil
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   843
    "set the selection without raising a notification
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   844
    "
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   845
    self setSelectionIndex:indexesOrNil
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   846
!
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   847
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   848
setSelectionIndex:indexesOrNil
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   849
    "set the selection without raising a notification
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   850
    "
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   851
    |indexes|
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   852
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   853
    indexes := indexesOrNil.
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   854
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   855
    indexes size == 0 ifTrue:[
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   856
        (indexes isCollection or:[indexes == 0]) ifTrue:[
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   857
            indexes := nil
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   858
        ]
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   859
    ].
496
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   860
    selection := indexes
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   861
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   862
! !
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   863
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   864
!SelectionInTree methodsFor:'update indication task'!
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   865
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   866
startIndicatorValidationFor:aNode
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   867
    "add a node to list of updating indications
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   868
    "
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   869
    |index|
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   870
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   871
    accessLock critical:[
1155
ff5b146ca277 run the indicator update process with a prio-range,
Claus Gittinger <cg@exept.de>
parents: 1145
diff changeset
   872
        |prio|
ff5b146ca277 run the indicator update process with a prio-range,
Claus Gittinger <cg@exept.de>
parents: 1145
diff changeset
   873
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   874
        index := indicatorList identityIndexOf:aNode.
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   875
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   876
        index ~~ 0 ifTrue:[
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   877
            indicatorList removeIndex:index.    "/ reorganize list to be faster
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   878
        ].
1155
ff5b146ca277 run the indicator update process with a prio-range,
Claus Gittinger <cg@exept.de>
parents: 1145
diff changeset
   879
        indicatorList addLast: "addFirst:" aNode.
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   880
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   881
        indicatorTask isNil ifTrue:[
1155
ff5b146ca277 run the indicator update process with a prio-range,
Claus Gittinger <cg@exept.de>
parents: 1145
diff changeset
   882
            prio := Processor activePriority.
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   883
            indicatorTask := [
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   884
                [ 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
   885
            ] forkAt:(prio - 1).
ff5b146ca277 run the indicator update process with a prio-range,
Claus Gittinger <cg@exept.de>
parents: 1145
diff changeset
   886
            indicatorTask priorityRange:(prio-1 to:prio).
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   887
        ]
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   888
    ].
1155
ff5b146ca277 run the indicator update process with a prio-range,
Claus Gittinger <cg@exept.de>
parents: 1145
diff changeset
   889
ff5b146ca277 run the indicator update process with a prio-range,
Claus Gittinger <cg@exept.de>
parents: 1145
diff changeset
   890
    "Modified: / 26.9.1998 / 15:20:44 / cg"
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   891
!
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   892
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   893
stopIndicatorValidationFor:aNodeOrList
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   894
    "remove a node or list of nodes from list of updating indications
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   895
    "
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   896
    accessLock critical:[
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   897
        aNodeOrList isCollection ifTrue:[
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   898
            aNodeOrList do:[:aNode|
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   899
                indicatorList removeIdentical:aNode ifAbsent:nil
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   900
            ]
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   901
        ] ifFalse:[
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   902
            indicatorList removeIdentical:aNodeOrList ifAbsent:nil
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
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   909
stopRunningTasks
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   910
    "stop task
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   911
    "
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   912
    accessLock critical:[ indicatorList removeAll ]
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
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   916
taskCycle
1155
ff5b146ca277 run the indicator update process with a prio-range,
Claus Gittinger <cg@exept.de>
parents: 1145
diff changeset
   917
    "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
   918
     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
   919
     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
   920
     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
   921
2038
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   922
    |node flag|
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   923
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   924
    accessLock critical:[
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   925
        indicatorList isEmpty ifTrue:[          "/ queue is empty; terminate task
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   926
            indicatorTask := nil.
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   927
            ^ false
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   928
        ].
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   929
        node := indicatorList removeFirst.      "/ run task on first node
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   930
        node hasValidIndicator ifTrue:[         "/ up to date
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   931
            ^ true
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   932
        ].
2038
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   933
        node setShowIndicator:(node defaultShowSeparator).      "/ disable registry
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   934
    ].
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   935
2038
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   936
    flag := DirectoryContents directoryNamed:(node fileName) detect:(node matchAction).
81b3b590c9d8 *** empty log message ***
ca
parents: 1818
diff changeset
   937
    node showIndicator:flag.
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   938
    ^ true
1145
3ee5513dff2a no change
Claus Gittinger <cg@exept.de>
parents: 906
diff changeset
   939
1155
ff5b146ca277 run the indicator update process with a prio-range,
Claus Gittinger <cg@exept.de>
parents: 1145
diff changeset
   940
    "Modified: / 26.9.1998 / 15:11:16 / cg"
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   941
! !
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   942
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   943
!SelectionInTree class methodsFor:'documentation'!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   944
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   945
version
2840
93e2b635838d proper #initialize
Claus Gittinger <cg@exept.de>
parents: 2697
diff changeset
   946
    ^ '$Header: /cvs/stx/stx/libwidg2/SelectionInTree.st,v 1.34 2005-08-02 13:14:45 cg Exp $'
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   947
! !