optimized
authorca
Fri, 19 Dec 2008 18:07:23 +0100
changeset 3617 86ab45e1e77f
parent 3616 24e9cca2b5f6
child 3618 ce57cd5e4726
optimized
HierarchicalFileList.st
--- a/HierarchicalFileList.st	Fri Dec 19 09:59:27 2008 +0100
+++ b/HierarchicalFileList.st	Fri Dec 19 18:07:23 2008 +0100
@@ -439,8 +439,12 @@
         ] ifFalse:[
             indicatorList removeIdentical:anItem ifAbsent:nil.
         ].
-        "/ indicatorList addFirst:anItem.
-        indicatorList add:anItem.
+        anItem isDirectory ifTrue:[
+            indicatorList add:anItem.
+        ] ifFalse:[
+            "/ files are added during drawing....
+            indicatorList addFirst:anItem.
+        ].
 
         indicatorTask isNil ifTrue:[
             prio := Processor activePriority.
@@ -693,6 +697,14 @@
     super changed:aParameter.
 ! !
 
+!HierarchicalFileList::HierarchicalFileItem methodsFor:'fetching'!
+
+fetchIndicator
+!
+
+resetFetchIndicator
+! !
+
 !HierarchicalFileList::HierarchicalFileItem methodsFor:'instance creation'!
 
 fileName:aFilename fileInfo:aFileInfoOrNil
@@ -802,6 +814,41 @@
     "always returns an empty list
     "
     ^ #()
+!
+
+defaultIcon
+    ^ FileBrowser iconForKeyMatching:#file
+!
+
+icon
+    icon isNil ifTrue:[ ^ self defaultIcon ].
+    ^ icon
+! !
+
+!HierarchicalFileList::File methodsFor:'fetching'!
+
+fetchIndicator
+    |newIcon|
+
+    icon notNil ifTrue:[^ self ].
+
+    "/ no longer fetching icon
+    icon    := self defaultIcon.    
+    newIcon := FileBrowser iconForFile:(self fileName).
+
+    icon ~~ newIcon ifTrue:[
+        icon := newIcon.
+        self iconChanged.
+    ].
+! !
+
+!HierarchicalFileList::File methodsFor:'protocol'!
+
+displayIcon:anIcon atX:x y:y on:aGC
+    icon isNil ifTrue:[
+        self model startIndicatorValidationFor:self.
+    ].
+    super displayIcon:anIcon atX:x y:y on:aGC
 ! !
 
 !HierarchicalFileList::File methodsFor:'queries'!
@@ -1229,28 +1276,52 @@
     "run monitoring cycle
         !!!!!!!! called by the HierarchicalList only !!!!!!!!"
 
-    |fileName unusedDict addedItems mergedList size modifyTime model timeChanged info|
+    |fileName directory fileInfo unusedDict addedItems mergedList size savedModifyTime
+     model timeChanged|
 
-    fileName := self fileName.
-    info := fileName linkInfo.
-    info isNil ifTrue:[^ self].
+    contentsItem resetInfo.
+
+    fileName  := contentsItem fileName.
+    fileInfo  := contentsItem info.
+    directory := fileName directory.
 
-    modifyTime := info modificationTime.
-    timeChanged := modifyTime ~= modificationTime.
-    modificationTime := modifyTime.
+    fileInfo isNil ifTrue:[
+        fileName exists ifFalse:[
+            DirectoryContents flushCachedDirectoryFor:directory.
+            self collapse.
+            children := nil.
+            self forgetAboutChildren.
+            self changed:#hierarchy.            
+        ].
+        ^ self.
+    ].
+    savedModifyTime  := modificationTime.
+    modificationTime := fileInfo modificationTime.
+    timeChanged      := (savedModifyTime ~= modificationTime).
 
-    children notNil ifTrue:[
-        timeChanged ifFalse:[
-            ^ self
+    timeChanged ifTrue:[
+        |contents|
+
+        "/ test whether the directory realy changed (rootDirectories...)
+        "/ this also will flush obsolete directories....
+        contents := DirectoryContents cachedDirectoryNamed:directory.
+
+        contents notNil ifTrue:[
+            savedModifyTime notNil ifTrue:[
+                timeChanged := (contents includesIdentical:contentsItem) not.
+            ].
         ].
     ].
 
-    DirectoryContents flushCachedDirectoryFor:fileName.
+    (children notNil and:[timeChanged not]) ifTrue:[
+        ^ self.
+    ].
+
     isExpanded ifFalse:[
         timeChanged ifTrue:[
             children := nil.
             self forgetAboutChildren.
-            self changed:#redraw.
+            self changed:#hierarchy.
         ].
         ^ self
     ].
@@ -1330,7 +1401,7 @@
 !HierarchicalFileList class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/HierarchicalFileList.st,v 1.71 2008-12-19 08:59:27 ca Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/HierarchicalFileList.st,v 1.72 2008-12-19 17:07:23 ca Exp $'
 ! !
 
 HierarchicalFileList::Directory initialize!