startup if old filename not present - go up to first directory in path
authorpenk
Fri, 08 Nov 2002 11:59:51 +0100
changeset 4213 b8e7d4276a33
parent 4212 c72445f6a03d
child 4214 466abfba4fe9
startup if old filename not present - go up to first directory in path
AbstractFileBrowser.st
--- a/AbstractFileBrowser.st	Fri Nov 08 11:35:52 2002 +0100
+++ b/AbstractFileBrowser.st	Fri Nov 08 11:59:51 2002 +0100
@@ -2182,8 +2182,21 @@
       if no file but a directory is selected it contains the directories 
       in contrast to currentDirectories wich have only the directories 
     "
-
-    ^ self aspectFor:#currentFileNameHolder ifAbsent:[(OrderedCollection with:(Filename currentDirectory asAbsoluteFilename)) asValue]
+    ^ self aspectFor:#currentFileNameHolder ifAbsent:[
+        (OrderedCollection with:(Filename currentDirectory asAbsoluteFilename)) asValue
+        ] notPresentDo:[:holder|
+            | filenames newFilenames|
+            filenames := holder value.
+            newFilenames := Set new.
+            filenames do:[ : filename |  | fn |
+                fn := filename.
+                [fn exists not] whileTrue:[
+                    fn := fn directory.
+                ].
+                newFilenames add:fn.
+            ].
+            newFilenames asOrderedCollection.
+        ]
 !
 
 enableDirectoryUp
@@ -2225,7 +2238,7 @@
     "
     |holder saveAspectItem aspect|
 
-    (holder := aspects at:something ifAbsent:nil) isNil ifTrue:[
+    holder := aspects at:something ifAbsent:[
         saveAspectItem := self runtimeAspectValueFor:something.
         saveAspectItem notNil ifTrue:[
             saveAspectItem isHolder ifTrue:[
@@ -2248,6 +2261,35 @@
     ^ holder
 !
 
+aspectFor:something ifAbsent:aBlock notPresentDo:notPresentBlock
+    "returns the model for an aspect
+    "
+    |holder saveAspectItem aspect|
+
+    holder := aspects at:something ifAbsent:[
+        saveAspectItem := self runtimeAspectValueFor:something.
+        saveAspectItem notNil ifTrue:[
+            saveAspectItem isHolder ifTrue:[
+                holder := ValueHolder with:saveAspectItem value 
+            ] ifFalse:[
+                holder := saveAspectItem value 
+            ].
+        ] ifFalse:[
+            aspect := self userPreferencesAspectValueFor:something.
+            aspect notNil ifTrue:[ 
+                holder := aspect asValue
+            ] ifFalse:[
+                holder := aBlock value.
+            ]
+        ].
+        holder notNil ifTrue:[  
+            holder value:(notPresentBlock value:holder).
+            aspects at:something put:holder
+        ]
+    ].
+    ^ holder
+!
+
 aspects
     ^ aspects
 !
@@ -5266,5 +5308,5 @@
 !AbstractFileBrowser class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/AbstractFileBrowser.st,v 1.56 2002-11-06 10:41:32 penk Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/AbstractFileBrowser.st,v 1.57 2002-11-08 10:59:51 penk Exp $'
 ! !