FileApplicationNoteBook.st
changeset 4803 9224c562e352
parent 4774 5119967dbd89
child 4855 c113852ec9ba
--- a/FileApplicationNoteBook.st	Tue Apr 08 18:30:48 2003 +0200
+++ b/FileApplicationNoteBook.st	Tue Apr 08 18:32:06 2003 +0200
@@ -774,7 +774,6 @@
 
     | appl sel|
 
-
     changedObject == self currentDirectories ifTrue:[
         self viewDirectoryDescription value ifTrue:[
             self changeDirectoryDescription.  
@@ -1148,7 +1147,7 @@
           #name: 'Archive Application'
           #min: #(#Point 10 10)
           #max: #(#Point 1024 768)
-          #bounds: #(#Rectangle 16 42 692 534)
+          #bounds: #(#Rectangle 16 46 692 538)
           #menu: #mainMenu
         )
         #component: 
@@ -1164,7 +1163,7 @@
            #(#'FileBrowserV2UISpecifications::PanelSpec'
               #name: 'VerticalPanel'
               #layout: #(#LayoutFrame 0 0.0 32 0.0 0 1.0 0 1.0)
-              #borderWidth: 1
+              #level: 0
               #whichView: #last
               #orientation: #vertical
               #visibility: #errorListVisibilityHolder
@@ -1187,7 +1186,7 @@
                     #postBuildCallback: #postBuildFileTable:
                     #properties: 
                    #(#PropertyListDictionary
-                      #dropSelector: #doDrop:
+                      #enterSelector: #dropEnter:
                       #dragArgument: #archivApplication
                       #startDragSelector: #doStartDrag:in:
                       #displayObjectSelector: #getDisplayObjects:
@@ -1196,7 +1195,7 @@
                       #dropArgument: #archivApplication
                       #canDropSelector: #canDrop:
                       #leaveSelector: #dropLeave:
-                      #enterSelector: #dropEnter:
+                      #dropSelector: #doDrop:
                     )
                   )
                  #(#SequenceViewSpec
@@ -1574,18 +1573,18 @@
 !
 
 item:aItem
-    "set the value of the instance variable 'item' (automatically generated)"
-
     | classSelector|
     
     super item:aItem.
     self removeErrorOutput.
     classSelector := self class classSelectorFor:aItem.
     (classSelector notNil and:[(Archiver respondsTo:classSelector) notNil]) ifTrue:[
-        self makeProcessFor:[
-            self archiver:((Archiver perform:classSelector) with:(self fileName)).
-            self setColumnsForArchiver.
-        ] with:'setup archiv'.
+        self 
+            makeProcessFor:[
+                self archiver:((Archiver perform:classSelector) with:(self fileName)).
+                self setColumnsForArchiver.
+            ] 
+            with:'Setup archive'.
         ^ true
     ]. 
     ^ false
@@ -1603,14 +1602,18 @@
 
 !FileApplicationNoteBook::ArchiveViewApplication methodsFor:'actions'!
 
-changeItem:aItem
-
+changeItem:aItem 
     self item:aItem.
-    self emptyList.
-    self listAllFilesFromArchiv.
+    self clearFileList.
+    self listAllFilesFromArchive.
     ^ true
 !
 
+clearFileList
+
+    self archiveFileList value removeAll.
+!
+
 copyFilesToClipboard
 
 
@@ -1645,11 +1648,6 @@
     self enableStopButton value:false.
 !
 
-emptyList
-
-    self archiveFileList value removeAll.
-!
-
 removeErrorOutput
 
     self viewErrorList value:false.
@@ -1896,14 +1894,10 @@
 !
 
 makeProcessFor:aBlock
-
     self makeProcessFor:aBlock with:''
 !
 
 makeProcessFor:aBlock with:string
-
-    | locBlock |
-
     process notNil ifTrue:[
         process waitUntilTerminated.
         terminateByMe ifTrue:[
@@ -1911,20 +1905,20 @@
             ^ self
         ].
     ].
-    locBlock := [   [        
-                    self notify:string.
-                    aBlock value.
-                    self notify:''.
+
+    process := [   [        
+                        self notify:string.
+                        aBlock value.
+                        self notify:''.
                     ] valueNowOrOnUnwindDo:[ 
                         process := nil.
                         self enableStopButton value:false.
                     ] 
-                ].
-    process := locBlock newProcess.
+                ] newProcess.
     process priority:(Processor systemBackgroundPriority).
     process name:'ArchiveApplicationProcess'.
+    process resume.
     self enableStopButton value:true.
-    process resume.
 !
 
 setColumnsForArchiver
@@ -2024,19 +2018,23 @@
 
 !FileApplicationNoteBook::ArchiveViewApplication methodsFor:'commands add'!
 
-addFilesToArchiv:colOfFiles
-
-
-    self archiver outStream:nil errorStream:(self getErrorStream) synchron:true.
-    self makeProcessFor:[
-        self archiver addFilesToArchiv:colOfFiles.
-    ] with:'add Files to archiv'.
+addFilesToArchive:colOfFiles 
+    self archiver 
+        outStream:nil
+        errorStream:(self getErrorStream)
+        synchron:true.
+
+    self 
+        makeProcessFor:[ self archiver addFilesToArchive:colOfFiles ]
+        with:'Adding files to archive'.
+
+    "/ ugly code alarm.
     (self archiver class == Archiver zipArchive) ifTrue:[
-        self listAllFilesFromArchiv.
+        self listAllFilesFromArchive
     ] ifFalse:[
-        self listFilesFromArchiv:colOfFiles.
+        self listFilesFromArchive:colOfFiles
     ].
-    ^ true.
+    ^ true
 ! !
 
 !FileApplicationNoteBook::ArchiveViewApplication methodsFor:'commands extract'!
@@ -2079,10 +2077,13 @@
 
 extractAllTo:aDirectory 
 
-    self archiver outStream:nil errorStream:(self getErrorStream) synchron:true.
-    self makeProcessFor:[
-        self archiver extractTo:aDirectory.
-    ] with:'extract all files'.
+    self archiver 
+        outStream:nil 
+        errorStream:(self getErrorStream) 
+        synchron:true.
+    self 
+        makeProcessFor:[ self archiver extractTo:aDirectory ] 
+        with:'Extracting all files'.
     ^ true.
 !
 
@@ -2122,68 +2123,80 @@
 
 extractWithDirectoryPartTo:aDirectory with:extractFiles
 
-    self archiver outStream:nil errorStream:(self getErrorStream) synchron:true.
-    self makeProcessFor:[
-        self archiver extractTo:aDirectory with:extractFiles.
-    ] with:('extract Files to ', aDirectory asString).
+    self archiver 
+        outStream:nil 
+        errorStream:(self getErrorStream) 
+        synchron:true.
+    self 
+        makeProcessFor:[ self archiver extractTo:aDirectory with:extractFiles ] 
+        with:('Extracting files to %1' bindWith:aDirectory asString).
     ^ true.
 !
 
 extractWithOutDirectoryPartTo:aDirectory with:extractFiles
 
-    self archiver outStream:nil errorStream:(self getErrorStream) synchron:true.
-    self makeProcessFor:[
-        self archiver extractWithOutDirectoryTo:aDirectory 
-                      with:(extractFiles collect:[:item| item fileName]).
-    ] with:('extract Files to ', aDirectory asString).
+    self archiver 
+        outStream:nil 
+        errorStream:(self getErrorStream) 
+        synchron:true.
+    self 
+        makeProcessFor:[
+            self archiver 
+                extractWithOutDirectoryTo:aDirectory 
+                with:(extractFiles collect:[:item| item fileName]).
+        ] 
+        with:('Extracting files to %1' bindWith:aDirectory asString).
     ^ true.
 ! !
 
 !FileApplicationNoteBook::ArchiveViewApplication methodsFor:'commands list'!
 
-listAllFilesFromArchiv
-
+listAllFilesFromArchive
     self archiveFileList value removeAll.
-    self listFilesFromArchiv:nil
-!
-
-listFilesFromArchiv:newColOfFiles
-
+    self listFilesFromArchive:nil
+!
+
+listFilesFromArchive:newColOfFiles 
     process notNil ifTrue:[
-        process waitUntilTerminated.
+        process waitUntilTerminated
     ].
-    self archiver outStream:(self getOutStream) errorStream:(self getErrorStream) synchron:true.
-    self makeProcessFor:[
-        self archiver listFilesFromArchiv:newColOfFiles.
-    ] with:'list Files'.
+
+    self archiver 
+        outStream:(self getOutStream)
+        errorStream:(self getErrorStream)
+        synchron:true.
+
+    self 
+        makeProcessFor:[self archiver listFilesFromArchive:newColOfFiles]
+        with:'List files'
 ! !
 
 !FileApplicationNoteBook::ArchiveViewApplication methodsFor:'commands remove'!
 
-removeFilesFromArchiv
-
-    | sel realSel list firtsPre stringCol stringRealSel|
+removeFilesFromArchive
+    |sel realSel list firtsPre stringCol stringRealSel|
 
     sel := self selectionHolder value.
-    stringCol := sel collect:[: item| item fileName].
+    stringCol := sel collect:[:item | item fileName].
     firtsPre := stringCol at:1.
-    stringCol from:2 do:[:el|
-         firtsPre :=  firtsPre commonPrefixWith:el.
-    ].
+    stringCol from:2 do:[:el | firtsPre := firtsPre commonPrefixWith:el].
     list := self archiveFileList value.
-    realSel := OrderedCollection new.
-    list do:[:item|
-        ((item fileName) startsWith:firtsPre) ifTrue:[
-            realSel add:item.
-        ].
-    ].
-    stringRealSel := realSel collect:[: item| item fileName].
-
-    self archiver outStream:nil errorStream:(self getErrorStream) synchron:true.
-    self makeProcessFor:[
-        self archiver removeFilesFromArchiv:stringCol.
-    ] with:'remove files'.
-
+"/    realSel := OrderedCollection new.
+"/    list do:[:item | 
+"/        ((item fileName) startsWith:firtsPre) ifTrue:[
+"/            realSel add:item
+"/        ]
+"/    ].
+    realSel := list select:[:item | (item fileName) startsWith:firtsPre].
+    stringRealSel := realSel collect:[:item | item fileName].
+
+    self archiver 
+        outStream:nil
+        errorStream:(self getErrorStream)
+        synchron:true.
+    self 
+        makeProcessFor:[ self archiver removeFilesFromArchive:stringCol ]
+        with:'Remove files'.
     self archiveFileList value removeAllFoundIn:realSel
 ! !
 
@@ -2194,18 +2207,14 @@
     ^ inDropMode
 !
 
-doDrop:aContext
-
+doDrop:aContext 
     |col source arg objects|
 
     source := aContext dropSource.
     arg := source argument.
     objects := aContext dropObjects.
-    col := OrderedCollection new.
-    objects do:[:obj|
-        col add:(obj theObject).
-    ].
-    ^ self addFilesToArchiv:col.
+    col := objects collect:[:dropObject | dropObject theObject].
+    ^ self addFilesToArchive:col
 !
 
 doStartDrag:aDropSource in:aView
@@ -2282,7 +2291,7 @@
 
 !FileApplicationNoteBook::ArchiveViewApplication methodsFor:'event handling'!
 
-processEvent:anEvent
+processEvent:anEvent 
     "filter keyboard events.
      Return true, if I have eaten the event"
 
@@ -2292,13 +2301,11 @@
         focusView := anEvent targetView.
         key := anEvent key.
         rawKey := anEvent rawKey.
-
         (focusView isSameOrComponentOf:self window) ifTrue:[
-"/            (key ~= #'Alt_L') ifTrue:[self halt.].
             (key == #Delete) ifTrue:[
-                self removeFilesFromArchiv.
+                self removeFilesFromArchive.
                 ^ true
-            ].
+            ]
         ]
     ].
     ^ false
@@ -2316,32 +2323,33 @@
     self columnDescriptors:(self class tableColumns).
 !
 
-postOpenWith:aBuilder
-
-    | currentDir contents suffix fileName file archivItem|
+postOpenWith:aBuilder 
+    |currentDir contents suffix fileName file archivItem|
 
     self windowGroup addPreEventHook:self.
     self masterApplication isNil ifTrue:[
         self masterApplication:nil.
         currentDir := Filename homeDirectory.
         contents := currentDir directoryContents.
-        fileName := contents detect:[: file |
-            suffix := file asFilename suffix asLowercase.
-            suffix = 'tgz'
-        ] ifNone:[nil].
-        fileName isNil ifTrue:[ 
-            Dialog warn:'cant find a Zip file in ', currentDir asString.
+        fileName := contents 
+                    detect:[:file | 
+                        suffix := file asFilename suffix asLowercase.
+                        suffix = 'tgz'
+                    ]
+                    ifNone:[nil].
+        fileName isNil ifTrue:[
+            Dialog warn:'cant find a Zip file in ' , currentDir asString.
             ^ self
         ].
         file := currentDir construct:fileName.
         archivItem := DirectoryContentsBrowser itemClass fileName:file.
         (self item:archivItem) ifFalse:[
-            Dialog warn:'file type of ', item fileName asString, ' not supported'.
-            ^ self.
-        ].
+            Dialog warn:'file type of ' , item fileName asString , ' not supported'.
+            ^ self
+        ]
     ].
-    self listAllFilesFromArchiv.
-    ^ super postOpenWith:aBuilder.
+    self listAllFilesFromArchive.
+    ^ super postOpenWith:aBuilder
 !
 
 release
@@ -4223,13 +4231,8 @@
 !
 
 update:something with:aParameter from:changedObject
-    "Invoked when an object that I depend upon sends a change notification."
-
-    "stub code automatically generated - please change as required"
-
     |modified itemRem contMd5CheckSum viewModified p|
 
-
     changedObject == self viewModifiedChannel ifTrue:[
         viewModified := changedObject value.
         self hasMD5 ifTrue:[
@@ -4941,5 +4944,5 @@
 !FileApplicationNoteBook class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/FileApplicationNoteBook.st,v 1.75 2003-04-02 22:40:16 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/FileApplicationNoteBook.st,v 1.76 2003-04-08 16:32:06 cg Exp $'
 ! !