code cleanup
authorClaus Gittinger <cg@exept.de>
Thu, 03 Apr 2003 00:40:24 +0200
changeset 4774 5119967dbd89
parent 4773 cb614f80815a
child 4775 674138a9faee
code cleanup
AbstractFileBrowser.st
FileApplicationNoteBook.st
FileBrowserV2.st
--- a/AbstractFileBrowser.st	Wed Apr 02 23:50:57 2003 +0200
+++ b/AbstractFileBrowser.st	Thu Apr 03 00:40:24 2003 +0200
@@ -2244,18 +2244,31 @@
 !
 
 changeFileBrowserTitleTo:aString
-
-    self application:#FileBrowserV2
-         do:#changeFileBrowserTitleTo:                            
-         withArg:aString
+    self 
+        applicationNamed:#FileBrowserV2 
+        do:[:app | app changeFileBrowserTitleTo:aString]
 !
 
 copyFileList
-
-    | fileList stream|
-    fileList := self application:#DirectoryContentsBrowser do:#descriptions.
+    "copy the fileList to the clipBoard"
+
+    |itemList|
+
+    itemList := self 
+                    applicationNamed:#DirectoryContentsBrowser 
+                    do:[:app | app browserItemList].
+    self copyItemListToClipBoard:itemList.
+!
+
+copyItemListToClipBoard:itemList
+    "copy the itemList to the clipBoard"
+
+    |stream|
+
+    itemList isEmpty ifTrue:[^ self].
+
     stream := WriteStream on:''.
-    fileList do:[: item |
+    itemList do:[:item |
         stream nextPutLine:(item fileName asString).
     ].
     self window setTextSelection:stream contents.
@@ -2263,21 +2276,19 @@
 !
 
 copySelectedFilenames
-
-    | fileList stream|
-    fileList := self application:#DirectoryContentsBrowser do:#selectedFiles.
-    fileList isEmpty ifTrue:[^ self].
-    stream := WriteStream on:''.
-    fileList do:[: file |
-        stream nextPutLine:(file asString).
-    ].
-    self window setTextSelection:stream contents.
-    stream close.
+    "copy the selected fileNames to the clipBoard"
+
+    |itemList|
+
+    itemList := self 
+                    applicationNamed:#DirectoryContentsBrowser 
+                    do:[:appl | appl selectedItems].
+
+    self copyItemListToClipBoard:itemList.
 !
 
 doAddTerminal
-
-    | item dir directories|
+    |dir directories|
 
     directories := self currentDirectories value.
     
@@ -2286,9 +2297,9 @@
     ] ifFalse:[
         dir :=  directories first.
     ].
-    
-    item := (DirectoryContentsBrowser itemClass fileName:dir).
-    self fileApplicationDo:#openTerminalApplication: withArg:item.
+
+    self applicationNamed:#FileApplicationNoteBook
+        do:[:appl | appl addTerminalIn:dir].
 !
 
 doCompareTwoFiles
@@ -2315,7 +2326,9 @@
         directories := self currentDirectories value.
         upDir := directories first directory.
     ] ifFalse:[
-        rootInTreeView := self application:#DirectoryTreeBrowser do:#rootHolder.
+        rootInTreeView := self 
+                            applicationNamed:#DirectoryTreeBrowser 
+                            do:[:appl | appl rootHolder].
         upDir := rootInTreeView value asFilename directory.
     ].
     self currentFileNameHolder value:(OrderedCollection with:upDir).
@@ -2347,8 +2360,7 @@
 !
 
 doShowFileContents
-
-    ^ self application:#DirectoryContentsBrowser do:#doShowFileContents.
+    ^ self applicationNamed:#DirectoryContentsBrowser do:[:appl | appl doShowFileContents].
 !
 
 doShowProperties
@@ -2358,19 +2370,6 @@
     self fileGetInfo:true
 !
 
-fileApplicationDo:selector
-
-    ^ self application:#FileApplicationNoteBook do:selector
-!
-
-fileApplicationDo:selector withArg:arg
-    ^ self application:#FileApplicationNoteBook do:selector withArg:arg 
-!
-
-fileApplicationDo:selector withArg:arg withArg:arg2
-    ^ self application:#FileApplicationNoteBook do:selector withArg:arg withArg:arg2
-!
-
 fileGetInfo:longInfo 
     "get info on selected file - show it in a box"
 
@@ -2405,13 +2404,14 @@
 !
 
 newTextEditor
-
-    ^ self fileApplicationDo:#newTextEditor
+    ^ self applicationNamed:#FileApplicationNoteBook
+        do:[:appl | appl newTextEditor]
 !
 
 openApplByFileItem:aItem
 
-    ^ self fileApplicationDo:#openApplByFileItem: withArg:aItem
+    ^ self applicationNamed:#FileApplicationNoteBook
+        do:[:appl | appl openApplByFileItem:aItem]
 !
 
 openApplForFile:aFilename
@@ -2420,29 +2420,32 @@
 
 openCommandResultApplication
 
-    ^ self fileApplicationDo:#openCommandResultApplication
+    ^ self applicationNamed:#FileApplicationNoteBook
+        do:[:appl | appl openCommandResultApplication]
 !
 
 openSearchFileOn:aItem
 
-    ^ self fileApplicationDo:#openSearchFileOn: withArg:aItem
+    ^ self applicationNamed:#FileApplicationNoteBook
+        do:[:appl | appl openSearchFileOn:aItem]
 !
 
 openTextEditorOn:aItem
 
-    ^ self fileApplicationDo:#openTextEditorOn: withArg:aItem 
+    ^ self applicationNamed:#FileApplicationNoteBook
+        do:[:appl | appl openTextEditorOn:aItem ]
 !
 
 openTextEditorOn:aItem type:aDirDescrOrFile
-
-    ^ self fileApplicationDo:#openTextEditorOn:type: withArg:aItem withArg:aDirDescrOrFile
+    ^ self applicationNamed:#FileApplicationNoteBook
+        do:[:appl | appl openTextEditorOn:aItem type:aDirDescrOrFile]
 !
 
 updateAndSelect:aColOfFiles
 
     DirectoryContents flushCachedDirectoryFor:(self getBestDirectory).
-    self application:#DirectoryContentsBrowser do:#doUpdate.
-    self application:#DirectoryTreeBrowser do:#doUpdate.
+    self applicationNamed:#DirectoryContentsBrowser do:[:appl | appl doUpdate].
+    self applicationNamed:#DirectoryTreeBrowser     do:[:appl | appl doUpdate].
     
     aColOfFiles notNil ifTrue:[ 
         self currentFileNameHolder value:aColOfFiles 
@@ -2555,40 +2558,16 @@
 
 !AbstractFileBrowser methodsFor:'applications'!
 
-application:aApplication do:aMethod 
-
-    " perform a Method for a application "
+applicationNamed:anApplicationName do:aBlock
     |appl|
 
-    appl := self applications at:aApplication ifAbsent:nil.
+    appl := self applications at:anApplicationName ifAbsent:nil.
     appl notNil ifTrue:[
-        ^ appl perform:aMethod.
+        ^ aBlock value:appl
     ].
     ^ nil.
 !
 
-application:aApplication do:aMethod withArg:arg 
-    |appl|
-
-    appl := self applications at:aApplication ifAbsent:nil.
-    appl notNil ifTrue:[
-        ^ appl perform:aMethod with:arg
-    ].
-    ^ nil
-!
-
-application:aApplication do:aMethod withArg:arg1 withArg:arg2
-    |appl|
-
-    appl := self applications at:aApplication ifAbsent:nil.
-    appl notNil ifTrue:[
-        (arg1 notNil and:[arg2 notNil]) ifTrue:[
-            ^ appl perform:aMethod with:arg1 with:arg2
-        ]
-    ].
-    ^ nil
-!
-
 directoryContentsBrowser
     ^ self applications at:#DirectoryContentsBrowser ifAbsent:nil.
 ! !
@@ -3115,7 +3094,9 @@
     oldDirectories ~= newDirectories ifTrue:[
         self currentDirectories value:newDirectories.
         size := newDirectories size.
-        rootInTreeView := self application:#DirectoryTreeBrowser do:#rootHolder.
+        rootInTreeView := self 
+                            applicationNamed:#DirectoryTreeBrowser 
+                            do:[:appl | appl rootHolder].
         rootInTreeView := rootInTreeView notNil ifTrue:[rootInTreeView value].
         self enableDirectoryUp value:(((size == 1) and:[newDirectories first isRootDirectory not]) or:[(rootInTreeView notNil and:[rootInTreeView value asFilename isRootDirectory not])]).
         newDirectories notEmpty ifTrue:[
@@ -3749,8 +3730,7 @@
 !
 
 viewInContentsBrowserMenu
-
-    ^ self application:#DirectoryContentsBrowser do:#viewBrowserMenu
+    ^ self applicationNamed:#DirectoryContentsBrowser do:[:appl | appl viewBrowserMenu]
 !
 
 visitedDirectoriesMenu
@@ -4574,9 +4554,9 @@
     file := self firstSelectedFile.
     file notNil ifTrue:[
         item := DirectoryContentsBrowser itemClass fileName:file.
-        self fileApplicationDo:#openTextEditorWithHexPresentationOn: withArg:item.
+        self applicationNamed:#FileApplicationNoteBook
+                do:[:appl | appl openTextEditorWithHexPresentationOn:item].
     ].
-
 !
 
 installAllAsAutoloaded
@@ -4586,7 +4566,8 @@
         self withActivityIndicationDo:[
             self allItemsOfCurrentDirectory do:[:fileItem |
                 (fileItem hasMimeType and:[fileItem mimeType isSmalltalkSource]) ifTrue:[
-                    self notify:('Install as Autoloaded:', fileItem baseName).
+                        
+                    self notify:('Install as autoloaded:', fileItem baseName).
                     self installAsAutoloaded:(fileItem fileName).
                 ]
             ].
@@ -5436,8 +5417,9 @@
 !AbstractFileBrowser methodsFor:'queries-file'!
 
 allItemsOfCurrentDirectory
-
-    ^ self application:#DirectoryContentsBrowser do:#allItemsOfCurrentDirectory.
+    ^ self 
+        applicationNamed:#DirectoryContentsBrowser 
+        do:[:app | app allItemsOfCurrentDirectory].
 !
 
 anyFilesPresentWithSuffix:suffix
@@ -5483,8 +5465,7 @@
 !
 
 fileListIsEmpty
-
-    ^ self application:#DirectoryContentsBrowser do:#fileListIsEmpty.
+    ^ self applicationNamed:#DirectoryContentsBrowser do:[:appl | appl fileListIsEmpty].
 !
 
 fileListIsNotEmpty
@@ -5512,8 +5493,7 @@
 !
 
 getAllFilesAsStringCollection
-
-    ^ self application:#DirectoryContentsBrowser do:#getAllFilesAsStringCollection.
+    ^ self applicationNamed:#DirectoryContentsBrowser do:[:appl | appl getAllFilesAsStringCollection].
 !
 
 getBestDirectory
@@ -6126,5 +6106,5 @@
 !AbstractFileBrowser class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/AbstractFileBrowser.st,v 1.129 2003-04-02 21:50:57 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/AbstractFileBrowser.st,v 1.130 2003-04-02 22:40:09 cg Exp $'
 ! !
--- a/FileApplicationNoteBook.st	Wed Apr 02 23:50:57 2003 +0200
+++ b/FileApplicationNoteBook.st	Thu Apr 03 00:40:24 2003 +0200
@@ -448,10 +448,9 @@
 !
 
 openApplicationClass:aClass withItem:aItem withType:aType checkExisting:checkExisting preSetItem:aBlock
-
-    | existingAppl newAppl|
-
-    " do not open not readable items "
+    |existingAppl newAppl|
+
+    "do not open unreadable items"
     checkExisting ifTrue:[
         (aItem notNil and:[aItem isDirectory not and:[aItem fileName isReadable not]]) ifTrue:[
             Dialog warn:'Can not open unreadable file ', aItem fileName baseName.
@@ -621,6 +620,13 @@
 
 !FileApplicationNoteBook methodsFor:'actions-app-spec'!
 
+addTerminalIn:aDirectory
+    |item|
+
+    item := DirectoryContentsBrowser itemClass fileName:aDirectory.
+    self openTerminalApplication:item.
+!
+
 changeDirectoryDescription
 
     | aInfoItem|
@@ -4935,5 +4941,5 @@
 !FileApplicationNoteBook class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/FileApplicationNoteBook.st,v 1.74 2003-04-01 14:59:38 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/FileApplicationNoteBook.st,v 1.75 2003-04-02 22:40:16 cg Exp $'
 ! !
--- a/FileBrowserV2.st	Wed Apr 02 23:50:57 2003 +0200
+++ b/FileBrowserV2.st	Thu Apr 03 00:40:24 2003 +0200
@@ -1644,8 +1644,7 @@
 !FileBrowserV2 methodsFor:'startup & release'!
 
 closeRequest
-
-    (self application:#FileApplicationNoteBook do:#tryCloseApplications) not ifTrue:[
+    (self applicationNamed:#FileApplicationNoteBook do:[:appl | appl tryCloseApplications]) ifFalse:[
         ^ self
     ].
     ^ super closeRequest.
@@ -1740,7 +1739,7 @@
 !FileBrowserV2 class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/FileBrowserV2.st,v 1.78 2003-04-02 21:48:09 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/FileBrowserV2.st,v 1.79 2003-04-02 22:40:24 cg Exp $'
 ! !
 
 FileBrowserV2 initialize!