FileBrowser.st
changeset 3765 8309f42ebf29
parent 3762 c6dd99988ca8
child 3766 e32fe0b85f6b
--- a/FileBrowser.st	Wed Jul 31 17:28:34 2002 +0200
+++ b/FileBrowser.st	Wed Jul 31 17:38:35 2002 +0200
@@ -1298,12 +1298,18 @@
             #enabled: #canCreateNewProject
           )
          #(#MenuItem
-            #label: 'Install autoloaded'
+            #label: 'Install Autoloaded'
             #translateLabel: true
             #value: #readAbbrevFile
             #enabled: #canReadAbbrevFile
           )
          #(#MenuItem
+            #label: 'Install all as Autoloaded'
+            #translateLabel: true
+            #value: #installAllAsAutoloaded
+            #enabled: #anySTFilesPresent
+          )
+         #(#MenuItem
             #label: 'Editor'
             #translateLabel: true
             #value: #openEditor
@@ -1438,6 +1444,17 @@
 
 !FileBrowser methodsFor:'aspects'!
 
+anyFilesPresentWithSuffix:suffix
+    ^ currentDirectory notNil
+      and:[currentDirectory 
+               directoryContents 
+                   contains:[:f| f asFilename suffix = suffix]]
+!
+
+anySTFilesPresent
+    ^ self anyFilesPresentWithSuffix:'st'
+!
+
 autoUpdate
     ^ doAutoUpdate
 
@@ -1485,11 +1502,9 @@
 canCreateNewProject
     ^ [ 
         currentDirectory notNil
-        and:[((currentDirectory directoryContents 
-                select:[:f| f endsWith:'.prj']) size == 0)
-        and:[((currentDirectory directoryContents 
-                select:[:f| f endsWith:'.st']) size > 0)
-      ]]]
+        and:[(self anyFilesPresentWithSuffix:'prj') not
+        and:[(self anyFilesPresentWithSuffix:'st')]]
+      ]
 !
 
 canDoTerminal
@@ -3192,6 +3207,30 @@
     "Modified: / 29.12.2001 / 21:59:01 / cg"
 !
 
+installAllAsAutoloaded
+    "install all classes found here as autoloaded classes"
+
+    currentDirectory directoryContentsDo:[:fileNameString |
+        |fn|
+
+        fn := (currentDirectory construct:fileNameString).
+        (fn hasSuffix:'st') ifTrue:[
+            self installAsAutoloaded:fn
+        ]
+    ].
+!
+
+installAsAutoloaded:aFilename
+    "install aFilename as autoloaded class"
+
+    |chunks s|
+
+    chunks := ChangeSet fromStream:(s := aFilename asFilename readStream). s close.
+    chunks 
+        select:[:eachChunk | eachChunk isClassDefinitionChange]
+        thenDo:[:eachClassChunk | eachClassChunk installAsAutoloadedClassIfNotPrivate].
+!
+
 loadImageAndPerform:aSelectorOrBlock
     |img path|
 
@@ -7850,5 +7889,5 @@
 !FileBrowser class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/FileBrowser.st,v 1.480 2002-07-31 13:21:48 penk Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/FileBrowser.st,v 1.481 2002-07-31 15:38:35 cg Exp $'
 ! !