--- a/SelectionInTree.st Mon Mar 09 17:07:25 1998 +0100
+++ b/SelectionInTree.st Mon Mar 09 17:08:44 1998 +0100
@@ -14,7 +14,7 @@
Model subclass:#SelectionInTree
instanceVariableNames:'root list selection showRoot contentsAction labelAction
- childrenAction iconAction'
+ childrenAction iconAction indicatorList indicatorTask accessLock'
classVariableNames:''
poolDictionaries:''
category:'Interface-Support-Models'
@@ -55,6 +55,12 @@
"
! !
+!SelectionInTree class methodsFor:'instance creation'!
+
+new
+ ^ super new initialize
+! !
+
!SelectionInTree methodsFor:'accessing'!
list
@@ -75,6 +81,7 @@
root notNil ifTrue: [
root tree: nil
].
+ self stopRunningTasks.
(root := aRoot) notNil ifTrue:[
root parent:nil.
@@ -255,6 +262,8 @@
|invalidate|
self each:something do:[:aNode|
+ self stopIndicatorValidationFor:aNode.
+
aNode parent notNil ifTrue:[
aNode parent remove:aNode.
invalidate := true
@@ -262,6 +271,7 @@
].
invalidate == true ifTrue:[self recomputeList].
^ something
+
!
removeIndex:something
@@ -278,6 +288,7 @@
(SortedCollection withAll:something) reverseDo:[:anIndex|
node := list at:anIndex.
+ self stopIndicatorValidationFor:node.
node parent notNil ifTrue:[
node parent remove:node.
@@ -285,6 +296,7 @@
]
].
invalidate == true ifTrue:[self recomputeList].
+
!
removeSelection
@@ -330,8 +342,12 @@
!SelectionInTree methodsFor:'initialization'!
initialize
+
+ showRoot := true.
+ indicatorList := OrderedCollection new.
+ accessLock := Semaphore forMutualExclusion.
super initialize.
- showRoot := true.
+
! !
!SelectionInTree methodsFor:'private'!
@@ -405,8 +421,78 @@
! !
+!SelectionInTree methodsFor:'update indication task'!
+
+startIndicatorValidationFor:aNode
+ "add a node to list of updating indications
+ "
+ |index|
+
+ accessLock critical:[
+ index := indicatorList identityIndexOf:aNode.
+
+ index ~~ 0 ifTrue:[
+ indicatorList removeIndex:index. "/ reorganize list to be faster
+ ].
+ indicatorList addFirst:aNode.
+
+ indicatorTask isNil ifTrue:[
+ indicatorTask := [
+ [ self taskCycle ] whileTrue:[ Processor yield ]
+ ] forkAt:(Processor activePriority - 1)
+ ]
+ ].
+!
+
+stopIndicatorValidationFor:aNodeOrList
+ "remove a node or list of nodes from list of updating indications
+ "
+ accessLock critical:[
+ aNodeOrList isCollection ifTrue:[
+ aNodeOrList do:[:aNode|
+ indicatorList removeIdentical:aNode ifAbsent:nil
+ ]
+ ] ifFalse:[
+ indicatorList removeIdentical:aNodeOrList ifAbsent:nil
+ ]
+ ]
+
+
+!
+
+stopRunningTasks
+ "stop task
+ "
+ accessLock critical:[ indicatorList removeAll ]
+
+!
+
+taskCycle
+ "run one cycle
+ "
+ |node|
+
+ accessLock critical:[
+ indicatorList isEmpty ifTrue:[ "/ queue is empty; terminate task
+ indicatorTask := nil.
+ ^ false
+ ].
+ node := indicatorList removeFirst. "/ run task on first node
+
+ node hasValidIndicator ifTrue:[ "/ up to date
+ ^ true
+ ].
+ node setShowIndicator:false "/ disable registry
+ ].
+
+ (DirectoryContents directoryNamed:(node fileName) detect:(node matchAction)) ifTrue:[
+ node showIndicator:true
+ ].
+ ^ true
+! !
+
!SelectionInTree class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg2/SelectionInTree.st,v 1.9 1998-02-14 16:15:32 tz Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg2/SelectionInTree.st,v 1.10 1998-03-09 16:08:25 ca Exp $'
! !