SelectionInTree.st
author ca
Thu, 09 Apr 1998 13:37:54 +0200
changeset 849 f7d8363fc24f
parent 842 636d8a543c35
child 857 d8e14b853cb7
permissions -rw-r--r--
support more detectItem mechanisms
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
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    15
Model subclass:#SelectionInTree
762
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
    16
	instanceVariableNames:'root list selection showRoot contentsAction labelAction
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
    17
		childrenAction iconAction indicatorList indicatorTask accessLock'
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    18
	classVariableNames:''
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    19
	poolDictionaries:''
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    20
	category:'Interface-Support-Models'
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    21
!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    22
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    23
!SelectionInTree class methodsFor:'documentation'!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    24
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    25
copyright
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    26
"
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    27
 COPYRIGHT (c) 1997 by eXept Software AG / Claus Gittinger
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    28
              All Rights Reserved
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    29
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    30
 This software is furnished under a license and may be used
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    31
 only in accordance with the terms of that license and with the
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    32
 inclusion of the above copyright notice.   This software may not
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    33
 be provided or otherwise made available to, or used by, any
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    34
 other person.  No title to or ownership of the software is
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    35
 hereby transferred.
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    36
"
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    37
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
documentation
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    42
"
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    43
    list and selection holder for hierarchical list structures. Used
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    44
    to buildup file-trees, class tress etc.
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    45
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    46
    Especially suited for use with SelectionInTreeView.
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    47
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    48
    [See also:]
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    49
        TreeItem
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    50
        SelectionInTreeView
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    51
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    52
    [Author:]
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    53
        W. Olberding
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    54
        Claus Atzkern
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    55
"
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    56
! !
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    57
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
    58
!SelectionInTree class methodsFor:'instance creation'!
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
    59
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
    60
new
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
    61
    ^ super new initialize
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
    62
! !
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
    63
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    64
!SelectionInTree methodsFor:'accessing'!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    65
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    66
list
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    67
    "get list oc currently shown objects
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    68
    "
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    69
    ^ list
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    70
!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    71
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    72
root
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    73
    "get the root node
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    74
    "
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    75
    ^ root
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    76
!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    77
509
c6c9f5ecb977 add method expand
ca
parents: 496
diff changeset
    78
root:aRoot
c6c9f5ecb977 add method expand
ca
parents: 496
diff changeset
    79
    "set a new root
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
    80
    "
762
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
    81
    root notNil ifTrue: [
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
    82
        root tree: nil
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
    83
    ].
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
    84
    self stopRunningTasks.
762
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
    85
515
2c09c8688bb8 set parent of root allways to nil
ca
parents: 509
diff changeset
    86
    (root := aRoot) notNil ifTrue:[
762
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
    87
        root parent:nil.
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
    88
        root tree: self.
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
    89
    ]. 
496
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
    90
    self recomputeList.
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
    91
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
    92
! !
491
c7d57a5e7a21 change root, do not remove children
ca
parents: 482
diff changeset
    93
496
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
    94
!SelectionInTree methodsFor:'accessing behavior'!
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
    95
762
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
    96
childrenAction
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
    97
    "get children action block
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
    98
    "
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
    99
    ^childrenAction
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   100
!
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   101
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   102
childrenAction:aBlock
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   103
    "set children action block
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   104
    "
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   105
    childrenAction := aBlock.
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   106
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   107
    self changed:#list.
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   108
    
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   109
!
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   110
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   111
contentsAction
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   112
    "get contents action block
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   113
    "
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   114
    ^contentsAction
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   115
!
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   116
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   117
contentsAction:aBlock
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   118
    "set contents action block
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   119
    "
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   120
    contentsAction := aBlock.
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   121
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   122
    self changed:#list.
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   123
    
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   124
!
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   125
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   126
iconAction
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   127
    "get icon action block
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   128
    "
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   129
    ^iconAction
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   130
!
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   131
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   132
iconAction:aBlock
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   133
    "set icon action block
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   134
    "
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   135
    iconAction := aBlock.
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   136
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   137
    self changed:#list.
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   138
    
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   139
!
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   140
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   141
labelAction
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   142
    "get label action block
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   143
    "
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   144
    ^labelAction
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   145
!
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   146
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   147
labelAction:aBlock
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   148
    "set label action block
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
    labelAction := aBlock.
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   151
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   152
    self changed:#list.
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
!
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   155
496
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   156
showRoot
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   157
    "list with or without root
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   158
    "
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   159
    ^ showRoot
491
c7d57a5e7a21 change root, do not remove children
ca
parents: 482
diff changeset
   160
!
c7d57a5e7a21 change root, do not remove children
ca
parents: 482
diff changeset
   161
496
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   162
showRoot:aState
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   163
    "list with or without root
491
c7d57a5e7a21 change root, do not remove children
ca
parents: 482
diff changeset
   164
    "
496
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   165
    aState ~~ showRoot ifTrue:[
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   166
        showRoot := aState.
491
c7d57a5e7a21 change root, do not remove children
ca
parents: 482
diff changeset
   167
496
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   168
        root notNil ifTrue:[
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   169
            aState ifTrue:[list addFirst:root]
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   170
                  ifFalse:[list removeFirst].
491
c7d57a5e7a21 change root, do not remove children
ca
parents: 482
diff changeset
   171
496
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   172
            self changed:#list.
491
c7d57a5e7a21 change root, do not remove children
ca
parents: 482
diff changeset
   173
        ].
c7d57a5e7a21 change root, do not remove children
ca
parents: 482
diff changeset
   174
    ].
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   175
! !
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   176
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   177
!SelectionInTree methodsFor:'accessing hierarchy'!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   178
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   179
collapse:something 
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   180
    "collapse a node or collection of nodes
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   181
    "
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   182
    |invalidate|
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   183
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   184
    self each:something do:[:aNode|
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   185
        aNode isCollapsable ifTrue:[
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   186
            aNode collapse.
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   187
            invalidate := true
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   188
        ]
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   189
    ].
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   190
    invalidate == true ifTrue:[self recomputeList]
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   191
!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   192
509
c6c9f5ecb977 add method expand
ca
parents: 496
diff changeset
   193
expand
c6c9f5ecb977 add method expand
ca
parents: 496
diff changeset
   194
    "expand the root
c6c9f5ecb977 add method expand
ca
parents: 496
diff changeset
   195
    "
c6c9f5ecb977 add method expand
ca
parents: 496
diff changeset
   196
    self expand:root
c6c9f5ecb977 add method expand
ca
parents: 496
diff changeset
   197
!
c6c9f5ecb977 add method expand
ca
parents: 496
diff changeset
   198
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   199
expand:something 
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   200
    "expand a node or collection of nodes
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   201
    "
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   202
    |invalidate|
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   203
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   204
    self each:something do:[:aNode|
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   205
        aNode isExpandable ifTrue:[
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   206
            aNode expand.
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   207
            invalidate := true
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   208
        ]
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   209
    ].
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   210
    invalidate == true ifTrue:[self recomputeList]
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   211
! !
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   212
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   213
!SelectionInTree methodsFor:'adding & removing'!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   214
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   215
add:something after:aChild
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   216
    "add a node or collection of nodes to parent after a child
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   217
    "
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   218
    "add a node or collection of nodes to after a child
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   219
    "
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   220
    aChild notNil ifTrue:[
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   221
        aChild parent add:something after:aChild.
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   222
        self recomputeList
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   223
    ]
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   224
!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   225
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   226
add:something afterIndex:anIndex below:aParent
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   227
    "add a node or collection of nodes to parent after an index
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   228
    "
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   229
    aParent add:something afterIndex:anIndex.
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   230
    self recomputeList
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   231
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   232
!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   233
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   234
add:something before:aChild
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   235
    "add a node or collection of nodes to before a child
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   236
    "
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   237
    aChild notNil ifTrue:[
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   238
        aChild parent add:something before:aChild.
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   239
        self recomputeList
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   240
    ]
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   241
!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   242
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   243
add:something beforeIndex:anIndex below:aParent
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   244
    "add a node or collection of nodes to parent before an index
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   245
    "
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   246
    aParent add:something beforeIndex:anIndex.
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   247
    self recomputeList
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   248
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   249
!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   250
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   251
add:something below:aParent
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   252
    "add a node or collection of nodes to parent
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   253
    "
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   254
    aParent add:something.
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   255
    self recomputeList
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   256
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   257
!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   258
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   259
remove:something
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   260
    "remove a node or collection of nodes
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   261
    "
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   262
    |invalidate|
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   263
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   264
    self each:something do:[:aNode|
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   265
        self stopIndicatorValidationFor:aNode.
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   266
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   267
        aNode parent notNil ifTrue:[
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   268
            aNode parent remove:aNode.
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   269
            invalidate := true
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   270
        ]
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   271
    ].
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   272
    invalidate == true ifTrue:[self recomputeList].
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   273
  ^ something
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   274
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   275
!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   276
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   277
removeIndex:something
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   278
    "remove a node at index or collection of indexed nodes
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   279
    "
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   280
    |invalidate node|
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   281
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   282
    something isCollection ifFalse:[
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   283
        (something isNil or:[something == 0]) ifFalse:[
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   284
            ^ self remove:(list at:something)
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   285
        ].
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   286
      ^ nil
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   287
    ].
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   288
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   289
    (SortedCollection withAll:something) reverseDo:[:anIndex|
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   290
        node := list at:anIndex.
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   291
        self stopIndicatorValidationFor:node.
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   292
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   293
        node parent notNil ifTrue:[
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   294
            node parent remove:node.
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   295
            invalidate := true
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   296
        ]
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   297
    ].
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   298
    invalidate == true ifTrue:[self recomputeList].
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
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
removeSelection
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   303
    "remove selected nodes
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   304
    "
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   305
    self removeIndex:(self selectionIndex).
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   306
    self selectionIndex:nil
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   307
! !
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   308
758
0f0b16a16fa7 add method: #invalidate
ca
parents: 585
diff changeset
   309
!SelectionInTree methodsFor:'change & update'!
0f0b16a16fa7 add method: #invalidate
ca
parents: 585
diff changeset
   310
0f0b16a16fa7 add method: #invalidate
ca
parents: 585
diff changeset
   311
invalidate
0f0b16a16fa7 add method: #invalidate
ca
parents: 585
diff changeset
   312
    "called; something changed what requires a redraw but no recomputation.
0f0b16a16fa7 add method: #invalidate
ca
parents: 585
diff changeset
   313
     for example a name
0f0b16a16fa7 add method: #invalidate
ca
parents: 585
diff changeset
   314
    "
0f0b16a16fa7 add method: #invalidate
ca
parents: 585
diff changeset
   315
    self dependents do:[:aDependent|
0f0b16a16fa7 add method: #invalidate
ca
parents: 585
diff changeset
   316
        aDependent isView ifTrue:[ aDependent invalidate ]
0f0b16a16fa7 add method: #invalidate
ca
parents: 585
diff changeset
   317
    ].
0f0b16a16fa7 add method: #invalidate
ca
parents: 585
diff changeset
   318
0f0b16a16fa7 add method: #invalidate
ca
parents: 585
diff changeset
   319
762
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   320
!
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   321
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   322
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
   323
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   324
    self dependents do:[:aDependent|
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   325
        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
   326
    ]
758
0f0b16a16fa7 add method: #invalidate
ca
parents: 585
diff changeset
   327
! !
0f0b16a16fa7 add method: #invalidate
ca
parents: 585
diff changeset
   328
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   329
!SelectionInTree methodsFor:'enumerating'!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   330
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   331
each:something do:aBlock
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   332
    "evaluate a block for something or in case of a collection for each
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   333
     element in the collection
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   334
    "
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   335
    something notNil ifTrue:[
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   336
        something isCollection ifTrue:[something do:[:el|aBlock value:el]]
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   337
                              ifFalse:[aBlock value:something]
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   338
    ]
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   339
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   340
! !
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   341
496
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   342
!SelectionInTree methodsFor:'initialization'!
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   343
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   344
initialize
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   345
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   346
    showRoot := true.
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   347
    indicatorList := OrderedCollection new.
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   348
    accessLock    := Semaphore forMutualExclusion.
842
636d8a543c35 call clearContents to reinitialize the list
ca
parents: 811
diff changeset
   349
    list          := OrderedCollection new:128.
496
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   350
    super initialize.
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   351
496
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   352
! !
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   353
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   354
!SelectionInTree methodsFor:'private'!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   355
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   356
recomputeList
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   357
    "Travers the tree and build a new list."
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   358
842
636d8a543c35 call clearContents to reinitialize the list
ca
parents: 811
diff changeset
   359
    list clearContents.
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   360
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   361
    root notNil ifTrue:[
762
df337e82f064 supports dynamic read behavior for contents, label, children, and icon of tree items
tz
parents: 758
diff changeset
   362
        showRoot ifTrue:[   
496
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   363
            list add:root
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   364
        ].
842
636d8a543c35 call clearContents to reinitialize the list
ca
parents: 811
diff changeset
   365
        root recomputeList:list.
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   366
    ].
585
5a0ed2305998 bug fixes:
ca
parents: 515
diff changeset
   367
    self changed:#list.
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   368
! !
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   369
849
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   370
!SelectionInTree methodsFor:'searching'!
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   371
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   372
detectItem:aOneArgBlock
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   373
    "detect an item the evaluation of the block returns true. The
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   374
     argument to the block is the item.
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   375
    "
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   376
    root notNil ifTrue:[
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   377
        ^ root detectChild:aOneArgBlock
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   378
    ].
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   379
    ^ nil
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   380
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   381
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   382
!
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   383
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   384
detectItem:aTwoArgBlock arguments:aListOfArgs
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   385
    "detect an item the evaluation of the block returns true. The
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   386
     first argument to the block is the item, the second argument
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   387
     the value derived from the argument list at an index
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   388
    "
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   389
    root notNil ifTrue:[
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   390
        ^ root detectChild:aTwoArgBlock arguments:aListOfArgs index:1
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   391
    ].
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   392
    ^ nil
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   393
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   394
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   395
! !
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   396
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   397
!SelectionInTree methodsFor:'selection'!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   398
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   399
selection
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   400
    "get the selection or nil
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   401
    "
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   402
    ^ self selectionIndex
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   403
!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   404
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   405
selection:indexesOrNil
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   406
    "set the selection
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   407
    "
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   408
    self selectionIndex:indexesOrNil
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   409
!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   410
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   411
selectionIndex
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   412
    "get the selection or nil
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   413
    "
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   414
    ^ selection
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   415
!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   416
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   417
selectionIndex:indexesOrNil
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   418
    "set the selection
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   419
    "
496
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   420
    |oldSel|
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   421
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   422
    oldSel := selection.
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   423
    self setSelectionIndex:indexesOrNil.
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   424
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   425
    oldSel = selection ifFalse:[
585
5a0ed2305998 bug fixes:
ca
parents: 515
diff changeset
   426
        self changed:#selectionIndex
496
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   427
    ]
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   428
!
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   429
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   430
setSelection:indexesOrNil
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   431
    "set the selection without raising a notification
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   432
    "
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   433
    self setSelectionIndex:indexesOrNil
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   434
!
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   435
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   436
setSelectionIndex:indexesOrNil
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   437
    "set the selection without raising a notification
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   438
    "
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   439
    |indexes|
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   440
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   441
    indexes := indexesOrNil.
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   442
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   443
    indexes size == 0 ifTrue:[
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   444
        (indexes isCollection or:[indexes == 0]) ifTrue:[
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   445
            indexes := nil
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   446
        ]
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   447
    ].
496
d511fde77222 show or hide root directory
ca
parents: 491
diff changeset
   448
    selection := indexes
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   449
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   450
! !
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   451
811
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   452
!SelectionInTree methodsFor:'update indication task'!
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   453
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   454
startIndicatorValidationFor:aNode
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   455
    "add a node to list of updating indications
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   456
    "
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   457
    |index|
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   458
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   459
    accessLock critical:[
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   460
        index := indicatorList identityIndexOf:aNode.
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   461
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   462
        index ~~ 0 ifTrue:[
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   463
            indicatorList removeIndex:index.    "/ reorganize list to be faster
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   464
        ].
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   465
        indicatorList addFirst:aNode.
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   466
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   467
        indicatorTask isNil ifTrue:[
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   468
            indicatorTask := [
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   469
                [ self taskCycle ] whileTrue:[ Processor yield ]
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   470
            ] forkAt:(Processor activePriority - 1)
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   471
        ]
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   472
    ].
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   473
!
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   474
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   475
stopIndicatorValidationFor:aNodeOrList
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   476
    "remove a node or list of nodes from list of updating indications
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   477
    "
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   478
    accessLock critical:[
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   479
        aNodeOrList isCollection ifTrue:[
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   480
            aNodeOrList do:[:aNode|
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   481
                indicatorList removeIdentical:aNode ifAbsent:nil
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   482
            ]
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   483
        ] ifFalse:[
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   484
            indicatorList removeIdentical:aNodeOrList ifAbsent:nil
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   485
        ]
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   486
    ]
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   487
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   488
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   489
!
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   490
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   491
stopRunningTasks
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   492
    "stop task
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   493
    "
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   494
    accessLock critical:[ indicatorList removeAll ]
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   495
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   496
!
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   497
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   498
taskCycle
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   499
    "run one cycle
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   500
    "
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   501
    |node|
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   502
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   503
    accessLock critical:[
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   504
        indicatorList isEmpty ifTrue:[          "/ queue is empty; terminate task
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   505
            indicatorTask := nil.
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   506
            ^ false
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   507
        ].
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   508
        node := indicatorList removeFirst.      "/ run task on first node
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   509
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   510
        node hasValidIndicator ifTrue:[         "/ up to date
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   511
            ^ true
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   512
        ].
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   513
        node setShowIndicator:false             "/ disable registry
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   514
    ].
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   515
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   516
    (DirectoryContents directoryNamed:(node fileName) detect:(node matchAction)) ifTrue:[
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   517
        node showIndicator:true
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   518
    ].
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   519
    ^ true
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   520
! !
a688e8f11bc6 async. reading of directory indicators
ca
parents: 762
diff changeset
   521
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   522
!SelectionInTree class methodsFor:'documentation'!
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   523
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   524
version
849
f7d8363fc24f support more detectItem mechanisms
ca
parents: 842
diff changeset
   525
    ^ '$Header: /cvs/stx/stx/libwidg2/SelectionInTree.st,v 1.12 1998-04-09 11:37:54 ca Exp $'
458
e4b907c8f0ce intitial checkin
ca
parents:
diff changeset
   526
! !