exchange #ifNotNil and #ifNil
authorca
Thu, 17 Oct 2002 13:19:47 +0200
changeset 2306 d25ae934c8d8
parent 2305 a31516be9bd1
child 2307 4a9e9f71537a
exchange #ifNotNil and #ifNil
HierarchicalFileList.st
--- a/HierarchicalFileList.st	Thu Oct 17 09:05:40 2002 +0200
+++ b/HierarchicalFileList.st	Thu Oct 17 13:19:47 2002 +0200
@@ -69,15 +69,20 @@
 
 examples
 "
+    open filebrowser without monitoring cycle
+
                                                                     [exBegin]
-    |top sel list|
+    |top sel list directory|
 
     list := HierarchicalFileList new.
-    list directory:(Filename homeDirectory).
-    list directory:(Filename currentDirectory).
     list showRoot:false.
     list matchBlock:[:fn :isDir| true ].
 
+    directory := Filename currentDirectory.
+    directory := Filename homeDirectory.
+
+    list directory:(directory asAbsoluteFilename).
+
     top := StandardSystemView new; extent:300@300.
     sel := ScrollableView for:HierarchicalListView miniScroller:true
                        origin:0.0@0.0 corner:1.0@1.0 in:top.
@@ -90,6 +95,34 @@
 
     top open.
                                                                 [exEnd]
+
+
+    open filebrowser and monitore contents
+                                                                    [exBegin]
+    |top sel list directory|
+
+    list := HierarchicalFileList new.
+    list showRoot:false.
+    list matchBlock:[:fn :isDir| true ].
+
+    directory := Filename currentDirectory.
+    directory := Filename homeDirectory.
+
+    list directory:(directory asAbsoluteFilename).
+
+    top := StandardSystemView new; extent:300@300.
+    sel := ScrollableView for:HierarchicalListView miniScroller:true
+                       origin:0.0@0.0 corner:1.0@1.0 in:top.
+
+    sel doubleClickAction:[:i| (list at:i) toggleExpand ].
+    sel   indicatorAction:[:i| (list at:i) toggleExpand ].
+
+    sel hasConstantHeight:true.
+    sel list:list.
+    list monitoringTaskDelay:0.5.
+    top open.
+                                                                [exEnd]
+
 "
 ! !
 
@@ -176,12 +209,12 @@
     "stop update-task
     "
     self criticalDo:[
-        indicatorList ifNotNil:[
+        indicatorList notNil ifTrue:[
             indicatorList do:[:el| el resetFetchIndicator ].
             indicatorList removeAll.
         ]
     ].
-    aRoot ifNotNil:[
+    aRoot notNil ifTrue:[
         self showRoot ifFalse:[aRoot setExpanded:true ]
     ].
     ^ super root:aRoot
@@ -297,7 +330,7 @@
     anItem isDirectory ifFalse:[^ #()].
 
     contents := DirectoryContents directoryNamed:anItem fileName.
-    contents ifNil:[ ^ #() ].
+    contents isNil ifTrue:[ ^ #() ].
 
     list := OrderedCollection new.
     matchBlock := self matchBlockFor:anItem.
@@ -332,12 +365,13 @@
 iconFor:anItem
     "returns the icon for an item
     "
-
-    (anItem isExpanded and:[anItem hasChildren]) ifTrue:[
-        ^ FileBrowser iconForKeyMatching:#directoryOpen
-    ].
-    (anItem isRemoteDirectory) ifTrue:[
-        ^ FileBrowser iconForKeyMatching:#directoryNetwork
+    anItem isDirectory ifTrue:[
+        (anItem isExpanded and:[anItem hasChildren]) ifTrue:[
+            ^ FileBrowser iconForKeyMatching:#directoryOpen
+        ].
+        (anItem isRemoteDirectory) ifTrue:[
+            ^ FileBrowser iconForKeyMatching:#directoryNetwork
+        ].
     ].
     ^ FileBrowser iconForFile:(anItem fileName)
 !
@@ -402,7 +436,7 @@
         "/ indicatorList addFirst:anItem.
         indicatorList add:anItem.
 
-        indicatorTask ifNil:[
+        indicatorTask isNil ifTrue:[
             prio := Processor activePriority.
             indicatorTask := [ self updateIndicatorCycle. ] forkAt:(prio - 1).
             indicatorTask priorityRange:(prio-1 to:prio).
@@ -414,7 +448,7 @@
     "stop the indicator validation for an item
     "
     self criticalDo:[
-        indicatorList ifNotNil:[
+        indicatorList notNil ifTrue:[
             indicatorList removeIdentical:anItem ifAbsent:nil.
             anItem resetFetchIndicator.
         ]
@@ -448,13 +482,13 @@
                 item := indicatorTask := task := nil
             ]
         ].
-        item ifNotNil:[
+        item notNil ifTrue:[
             item fetchIndicator.
             Processor yield.
         ].
      ]
     ] valueNowOrOnUnwindDo:[
-        task ifNotNil:[
+        task notNil ifTrue:[
             "/ oops, process terminated
             self criticalDo:[
                 "/ test whether a new task already started
@@ -561,7 +595,7 @@
 
     icon isNil ifTrue:[
         model := self model.
-        model ifNil:[^ nil].
+        model isNil ifTrue:[^ nil].
 
         icon := model iconFor:self.
     ].
@@ -759,13 +793,13 @@
     "
     |model|
 
-    children ifNotNil:[ ^ children ].
+    children notNil ifTrue:[ ^ children ].
 
     model := self model.
-    model ifNil:[ ^ nil ].
+    model isNil ifTrue:[ ^ nil ].
 
     model criticalDo:[
-        children ifNil:[ self readChildren ].
+        children isNil ifTrue:[ self readChildren ].
     ].
     ^ children
 !
@@ -773,7 +807,7 @@
 flushChildren
     "flush the children because node not visible ....
     "
-    children ifNotNil:[
+    children notNil ifTrue:[
         "keep hasChildren information
         "
         children size ~~ 0 ifTrue:[ fetchOperation := #hasChildren ]
@@ -789,7 +823,7 @@
 
     model := self model.
 
-    model ifNil:[
+    model isNil ifTrue:[
         "/ must reread later
         fetchOperation := modificationTime := children := nil.
       ^ nil
@@ -871,7 +905,7 @@
     "fetch the indicator value which indicates whether children exists or not
      called by the list
     "
-    children ifNotNil:[
+    children notNil ifTrue:[
         "/ children already read
         fetchOperation := nil.
       ^ self
@@ -914,7 +948,7 @@
       ^ children size ~~ 0
     ].
 
-    fetchOperation ifNotNil:[
+    fetchOperation notNil ifTrue:[
         ^ fetchOperation == #hasChildren
     ].
 
@@ -982,12 +1016,12 @@
     |unusedDict addedItems mergedList size modifyTime model timeChanged|
 
     modifyTime := self fileName modificationTime.
-    modifyTime ifNil:[^ self].
+    modifyTime isNil ifTrue:[^ self].
 
     timeChanged := (modificationTime isNil or:[modifyTime > modificationTime]).
     modificationTime := modifyTime.
 
-    children ifNotNil:[
+    children notNil ifTrue:[
         timeChanged ifFalse:[
             ^ self
         ].
@@ -1001,7 +1035,7 @@
         ^ self
     ].
     model := self model.
-    children ifNil:[ children := #() ].         "/ disable update during merge
+    children isNil ifTrue:[ children := #() ].         "/ disable update during merge
 
 
     fetchOperation := nil.
@@ -1075,5 +1109,5 @@
 !HierarchicalFileList class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/HierarchicalFileList.st,v 1.35 2002-10-15 16:40:38 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/HierarchicalFileList.st,v 1.36 2002-10-17 11:19:47 ca Exp $'
 ! !