1185 #multipleSelectOk: true |
1184 #multipleSelectOk: true |
1186 #verticalSpacing: 0 |
1185 #verticalSpacing: 0 |
1187 #postBuildCallback: #postBuildFileTable: |
1186 #postBuildCallback: #postBuildFileTable: |
1188 #properties: |
1187 #properties: |
1189 #(#PropertyListDictionary |
1188 #(#PropertyListDictionary |
1190 #dropSelector: #doDrop: |
1189 #enterSelector: #dropEnter: |
1191 #dragArgument: #archivApplication |
1190 #dragArgument: #archivApplication |
1192 #startDragSelector: #doStartDrag:in: |
1191 #startDragSelector: #doStartDrag:in: |
1193 #displayObjectSelector: #getDisplayObjects: |
1192 #displayObjectSelector: #getDisplayObjects: |
1194 #dropObjectSelector: #getDropObjects: |
1193 #dropObjectSelector: #getDropObjects: |
1195 #overSelector: nil |
1194 #overSelector: nil |
1196 #dropArgument: #archivApplication |
1195 #dropArgument: #archivApplication |
1197 #canDropSelector: #canDrop: |
1196 #canDropSelector: #canDrop: |
1198 #leaveSelector: #dropLeave: |
1197 #leaveSelector: #dropLeave: |
1199 #enterSelector: #dropEnter: |
1198 #dropSelector: #doDrop: |
1200 ) |
1199 ) |
1201 ) |
1200 ) |
1202 #(#SequenceViewSpec |
1201 #(#SequenceViewSpec |
1203 #name: 'ErrorList' |
1202 #name: 'ErrorList' |
1204 #initiallyDisabled: true |
1203 #initiallyDisabled: true |
1894 outStream nextPutLineBlock:(self getOutBlock). |
1892 outStream nextPutLineBlock:(self getOutBlock). |
1895 ^ outStream |
1893 ^ outStream |
1896 ! |
1894 ! |
1897 |
1895 |
1898 makeProcessFor:aBlock |
1896 makeProcessFor:aBlock |
1899 |
|
1900 self makeProcessFor:aBlock with:'' |
1897 self makeProcessFor:aBlock with:'' |
1901 ! |
1898 ! |
1902 |
1899 |
1903 makeProcessFor:aBlock with:string |
1900 makeProcessFor:aBlock with:string |
1904 |
|
1905 | locBlock | |
|
1906 |
|
1907 process notNil ifTrue:[ |
1901 process notNil ifTrue:[ |
1908 process waitUntilTerminated. |
1902 process waitUntilTerminated. |
1909 terminateByMe ifTrue:[ |
1903 terminateByMe ifTrue:[ |
1910 terminateByMe := false. |
1904 terminateByMe := false. |
1911 ^ self |
1905 ^ self |
1912 ]. |
1906 ]. |
1913 ]. |
1907 ]. |
1914 locBlock := [ [ |
1908 |
1915 self notify:string. |
1909 process := [ [ |
1916 aBlock value. |
1910 self notify:string. |
1917 self notify:''. |
1911 aBlock value. |
|
1912 self notify:''. |
1918 ] valueNowOrOnUnwindDo:[ |
1913 ] valueNowOrOnUnwindDo:[ |
1919 process := nil. |
1914 process := nil. |
1920 self enableStopButton value:false. |
1915 self enableStopButton value:false. |
1921 ] |
1916 ] |
1922 ]. |
1917 ] newProcess. |
1923 process := locBlock newProcess. |
|
1924 process priority:(Processor systemBackgroundPriority). |
1918 process priority:(Processor systemBackgroundPriority). |
1925 process name:'ArchiveApplicationProcess'. |
1919 process name:'ArchiveApplicationProcess'. |
|
1920 process resume. |
1926 self enableStopButton value:true. |
1921 self enableStopButton value:true. |
1927 process resume. |
|
1928 ! |
1922 ! |
1929 |
1923 |
1930 setColumnsForArchiver |
1924 setColumnsForArchiver |
1931 |
1925 |
1932 | newColumns archiverColumns allColumns iconColumn| |
1926 | newColumns archiverColumns allColumns iconColumn| |
2022 ^ dir |
2016 ^ dir |
2023 ! ! |
2017 ! ! |
2024 |
2018 |
2025 !FileApplicationNoteBook::ArchiveViewApplication methodsFor:'commands add'! |
2019 !FileApplicationNoteBook::ArchiveViewApplication methodsFor:'commands add'! |
2026 |
2020 |
2027 addFilesToArchiv:colOfFiles |
2021 addFilesToArchive:colOfFiles |
2028 |
2022 self archiver |
2029 |
2023 outStream:nil |
2030 self archiver outStream:nil errorStream:(self getErrorStream) synchron:true. |
2024 errorStream:(self getErrorStream) |
2031 self makeProcessFor:[ |
2025 synchron:true. |
2032 self archiver addFilesToArchiv:colOfFiles. |
2026 |
2033 ] with:'add Files to archiv'. |
2027 self |
|
2028 makeProcessFor:[ self archiver addFilesToArchive:colOfFiles ] |
|
2029 with:'Adding files to archive'. |
|
2030 |
|
2031 "/ ugly code alarm. |
2034 (self archiver class == Archiver zipArchive) ifTrue:[ |
2032 (self archiver class == Archiver zipArchive) ifTrue:[ |
2035 self listAllFilesFromArchiv. |
2033 self listAllFilesFromArchive |
2036 ] ifFalse:[ |
2034 ] ifFalse:[ |
2037 self listFilesFromArchiv:colOfFiles. |
2035 self listFilesFromArchive:colOfFiles |
2038 ]. |
2036 ]. |
2039 ^ true. |
2037 ^ true |
2040 ! ! |
2038 ! ! |
2041 |
2039 |
2042 !FileApplicationNoteBook::ArchiveViewApplication methodsFor:'commands extract'! |
2040 !FileApplicationNoteBook::ArchiveViewApplication methodsFor:'commands extract'! |
2043 |
2041 |
2044 extractAll |
2042 extractAll |
2120 ^ true |
2121 ^ true |
2121 ! |
2122 ! |
2122 |
2123 |
2123 extractWithDirectoryPartTo:aDirectory with:extractFiles |
2124 extractWithDirectoryPartTo:aDirectory with:extractFiles |
2124 |
2125 |
2125 self archiver outStream:nil errorStream:(self getErrorStream) synchron:true. |
2126 self archiver |
2126 self makeProcessFor:[ |
2127 outStream:nil |
2127 self archiver extractTo:aDirectory with:extractFiles. |
2128 errorStream:(self getErrorStream) |
2128 ] with:('extract Files to ', aDirectory asString). |
2129 synchron:true. |
|
2130 self |
|
2131 makeProcessFor:[ self archiver extractTo:aDirectory with:extractFiles ] |
|
2132 with:('Extracting files to %1' bindWith:aDirectory asString). |
2129 ^ true. |
2133 ^ true. |
2130 ! |
2134 ! |
2131 |
2135 |
2132 extractWithOutDirectoryPartTo:aDirectory with:extractFiles |
2136 extractWithOutDirectoryPartTo:aDirectory with:extractFiles |
2133 |
2137 |
2134 self archiver outStream:nil errorStream:(self getErrorStream) synchron:true. |
2138 self archiver |
2135 self makeProcessFor:[ |
2139 outStream:nil |
2136 self archiver extractWithOutDirectoryTo:aDirectory |
2140 errorStream:(self getErrorStream) |
2137 with:(extractFiles collect:[:item| item fileName]). |
2141 synchron:true. |
2138 ] with:('extract Files to ', aDirectory asString). |
2142 self |
|
2143 makeProcessFor:[ |
|
2144 self archiver |
|
2145 extractWithOutDirectoryTo:aDirectory |
|
2146 with:(extractFiles collect:[:item| item fileName]). |
|
2147 ] |
|
2148 with:('Extracting files to %1' bindWith:aDirectory asString). |
2139 ^ true. |
2149 ^ true. |
2140 ! ! |
2150 ! ! |
2141 |
2151 |
2142 !FileApplicationNoteBook::ArchiveViewApplication methodsFor:'commands list'! |
2152 !FileApplicationNoteBook::ArchiveViewApplication methodsFor:'commands list'! |
2143 |
2153 |
2144 listAllFilesFromArchiv |
2154 listAllFilesFromArchive |
2145 |
|
2146 self archiveFileList value removeAll. |
2155 self archiveFileList value removeAll. |
2147 self listFilesFromArchiv:nil |
2156 self listFilesFromArchive:nil |
2148 ! |
2157 ! |
2149 |
2158 |
2150 listFilesFromArchiv:newColOfFiles |
2159 listFilesFromArchive:newColOfFiles |
2151 |
|
2152 process notNil ifTrue:[ |
2160 process notNil ifTrue:[ |
2153 process waitUntilTerminated. |
2161 process waitUntilTerminated |
2154 ]. |
2162 ]. |
2155 self archiver outStream:(self getOutStream) errorStream:(self getErrorStream) synchron:true. |
2163 |
2156 self makeProcessFor:[ |
2164 self archiver |
2157 self archiver listFilesFromArchiv:newColOfFiles. |
2165 outStream:(self getOutStream) |
2158 ] with:'list Files'. |
2166 errorStream:(self getErrorStream) |
|
2167 synchron:true. |
|
2168 |
|
2169 self |
|
2170 makeProcessFor:[self archiver listFilesFromArchive:newColOfFiles] |
|
2171 with:'List files' |
2159 ! ! |
2172 ! ! |
2160 |
2173 |
2161 !FileApplicationNoteBook::ArchiveViewApplication methodsFor:'commands remove'! |
2174 !FileApplicationNoteBook::ArchiveViewApplication methodsFor:'commands remove'! |
2162 |
2175 |
2163 removeFilesFromArchiv |
2176 removeFilesFromArchive |
2164 |
2177 |sel realSel list firtsPre stringCol stringRealSel| |
2165 | sel realSel list firtsPre stringCol stringRealSel| |
|
2166 |
2178 |
2167 sel := self selectionHolder value. |
2179 sel := self selectionHolder value. |
2168 stringCol := sel collect:[: item| item fileName]. |
2180 stringCol := sel collect:[:item | item fileName]. |
2169 firtsPre := stringCol at:1. |
2181 firtsPre := stringCol at:1. |
2170 stringCol from:2 do:[:el| |
2182 stringCol from:2 do:[:el | firtsPre := firtsPre commonPrefixWith:el]. |
2171 firtsPre := firtsPre commonPrefixWith:el. |
|
2172 ]. |
|
2173 list := self archiveFileList value. |
2183 list := self archiveFileList value. |
2174 realSel := OrderedCollection new. |
2184 "/ realSel := OrderedCollection new. |
2175 list do:[:item| |
2185 "/ list do:[:item | |
2176 ((item fileName) startsWith:firtsPre) ifTrue:[ |
2186 "/ ((item fileName) startsWith:firtsPre) ifTrue:[ |
2177 realSel add:item. |
2187 "/ realSel add:item |
2178 ]. |
2188 "/ ] |
2179 ]. |
2189 "/ ]. |
2180 stringRealSel := realSel collect:[: item| item fileName]. |
2190 realSel := list select:[:item | (item fileName) startsWith:firtsPre]. |
2181 |
2191 stringRealSel := realSel collect:[:item | item fileName]. |
2182 self archiver outStream:nil errorStream:(self getErrorStream) synchron:true. |
2192 |
2183 self makeProcessFor:[ |
2193 self archiver |
2184 self archiver removeFilesFromArchiv:stringCol. |
2194 outStream:nil |
2185 ] with:'remove files'. |
2195 errorStream:(self getErrorStream) |
2186 |
2196 synchron:true. |
|
2197 self |
|
2198 makeProcessFor:[ self archiver removeFilesFromArchive:stringCol ] |
|
2199 with:'Remove files'. |
2187 self archiveFileList value removeAllFoundIn:realSel |
2200 self archiveFileList value removeAllFoundIn:realSel |
2188 ! ! |
2201 ! ! |
2189 |
2202 |
2190 !FileApplicationNoteBook::ArchiveViewApplication methodsFor:'drag & drop'! |
2203 !FileApplicationNoteBook::ArchiveViewApplication methodsFor:'drag & drop'! |
2191 |
2204 |
2192 canDrop:aContext |
2205 canDrop:aContext |
2193 |
2206 |
2194 ^ inDropMode |
2207 ^ inDropMode |
2195 ! |
2208 ! |
2196 |
2209 |
2197 doDrop:aContext |
2210 doDrop:aContext |
2198 |
|
2199 |col source arg objects| |
2211 |col source arg objects| |
2200 |
2212 |
2201 source := aContext dropSource. |
2213 source := aContext dropSource. |
2202 arg := source argument. |
2214 arg := source argument. |
2203 objects := aContext dropObjects. |
2215 objects := aContext dropObjects. |
2204 col := OrderedCollection new. |
2216 col := objects collect:[:dropObject | dropObject theObject]. |
2205 objects do:[:obj| |
2217 ^ self addFilesToArchive:col |
2206 col add:(obj theObject). |
|
2207 ]. |
|
2208 ^ self addFilesToArchiv:col. |
|
2209 ! |
2218 ! |
2210 |
2219 |
2211 doStartDrag:aDropSource in:aView |
2220 doStartDrag:aDropSource in:aView |
2212 "set the cursors before starting the drag & drop operation |
2221 "set the cursors before starting the drag & drop operation |
2213 " |
2222 " |
2280 ^ ret |
2289 ^ ret |
2281 ! ! |
2290 ! ! |
2282 |
2291 |
2283 !FileApplicationNoteBook::ArchiveViewApplication methodsFor:'event handling'! |
2292 !FileApplicationNoteBook::ArchiveViewApplication methodsFor:'event handling'! |
2284 |
2293 |
2285 processEvent:anEvent |
2294 processEvent:anEvent |
2286 "filter keyboard events. |
2295 "filter keyboard events. |
2287 Return true, if I have eaten the event" |
2296 Return true, if I have eaten the event" |
2288 |
2297 |
2289 |focusView key rawKey| |
2298 |focusView key rawKey| |
2290 |
2299 |
2291 anEvent isKeyPressEvent ifTrue:[ |
2300 anEvent isKeyPressEvent ifTrue:[ |
2292 focusView := anEvent targetView. |
2301 focusView := anEvent targetView. |
2293 key := anEvent key. |
2302 key := anEvent key. |
2294 rawKey := anEvent rawKey. |
2303 rawKey := anEvent rawKey. |
2295 |
|
2296 (focusView isSameOrComponentOf:self window) ifTrue:[ |
2304 (focusView isSameOrComponentOf:self window) ifTrue:[ |
2297 "/ (key ~= #'Alt_L') ifTrue:[self halt.]. |
|
2298 (key == #Delete) ifTrue:[ |
2305 (key == #Delete) ifTrue:[ |
2299 self removeFilesFromArchiv. |
2306 self removeFilesFromArchive. |
2300 ^ true |
2307 ^ true |
2301 ]. |
2308 ] |
2302 ] |
2309 ] |
2303 ]. |
2310 ]. |
2304 ^ false |
2311 ^ false |
2305 ! ! |
2312 ! ! |
2306 |
2313 |
2314 "/ fileTable registerImage:anIcon key:aKey. |
2321 "/ fileTable registerImage:anIcon key:aKey. |
2315 "/ ]. |
2322 "/ ]. |
2316 self columnDescriptors:(self class tableColumns). |
2323 self columnDescriptors:(self class tableColumns). |
2317 ! |
2324 ! |
2318 |
2325 |
2319 postOpenWith:aBuilder |
2326 postOpenWith:aBuilder |
2320 |
2327 |currentDir contents suffix fileName file archivItem| |
2321 | currentDir contents suffix fileName file archivItem| |
|
2322 |
2328 |
2323 self windowGroup addPreEventHook:self. |
2329 self windowGroup addPreEventHook:self. |
2324 self masterApplication isNil ifTrue:[ |
2330 self masterApplication isNil ifTrue:[ |
2325 self masterApplication:nil. |
2331 self masterApplication:nil. |
2326 currentDir := Filename homeDirectory. |
2332 currentDir := Filename homeDirectory. |
2327 contents := currentDir directoryContents. |
2333 contents := currentDir directoryContents. |
2328 fileName := contents detect:[: file | |
2334 fileName := contents |
2329 suffix := file asFilename suffix asLowercase. |
2335 detect:[:file | |
2330 suffix = 'tgz' |
2336 suffix := file asFilename suffix asLowercase. |
2331 ] ifNone:[nil]. |
2337 suffix = 'tgz' |
2332 fileName isNil ifTrue:[ |
2338 ] |
2333 Dialog warn:'cant find a Zip file in ', currentDir asString. |
2339 ifNone:[nil]. |
|
2340 fileName isNil ifTrue:[ |
|
2341 Dialog warn:'cant find a Zip file in ' , currentDir asString. |
2334 ^ self |
2342 ^ self |
2335 ]. |
2343 ]. |
2336 file := currentDir construct:fileName. |
2344 file := currentDir construct:fileName. |
2337 archivItem := DirectoryContentsBrowser itemClass fileName:file. |
2345 archivItem := DirectoryContentsBrowser itemClass fileName:file. |
2338 (self item:archivItem) ifFalse:[ |
2346 (self item:archivItem) ifFalse:[ |
2339 Dialog warn:'file type of ', item fileName asString, ' not supported'. |
2347 Dialog warn:'file type of ' , item fileName asString , ' not supported'. |
2340 ^ self. |
2348 ^ self |
2341 ]. |
2349 ] |
2342 ]. |
2350 ]. |
2343 self listAllFilesFromArchiv. |
2351 self listAllFilesFromArchive. |
2344 ^ super postOpenWith:aBuilder. |
2352 ^ super postOpenWith:aBuilder |
2345 ! |
2353 ! |
2346 |
2354 |
2347 release |
2355 release |
2348 |
2356 |
2349 self archiver release. |
2357 self archiver release. |