AbstractFileBrowser.st
changeset 6352 1dfde810826f
parent 6346 3b3d962e691c
child 6369 7b21b4675578
equal deleted inserted replaced
6351:1db1881129a3 6352:1dfde810826f
  3598     "move the selected file(s) to another directory"
  3598     "move the selected file(s) to another directory"
  3599 
  3599 
  3600     |destinationDirectory|
  3600     |destinationDirectory|
  3601 
  3601 
  3602     destinationDirectory := Dialog 
  3602     destinationDirectory := Dialog 
  3603                                 requestDirectoryName:(resources at:'Move Selected Items To:') withCRs 
  3603                                 requestDirectoryName:(resources stringWithCRs:'Move Selected Items To:') 
  3604                                 default:(LastMoveDestination ? self currentDirectory)
  3604                                 default:(LastMoveDestination ? self currentDirectory)
  3605                                 ok:'Move'
  3605                                 ok:'Move'
  3606                                 abort:nil.
  3606                                 abort:nil.
  3607     destinationDirectory isEmptyOrNil ifTrue:[^ self].
  3607     destinationDirectory isEmptyOrNil ifTrue:[^ self].
  3608 
  3608 
  4725         dir := directories first.
  4725         dir := directories first.
  4726 "/        self label: myName, '- gathering file names ...'.
  4726 "/        self label: myName, '- gathering file names ...'.
  4727         [
  4727         [
  4728             fileNames := dir recursiveDirectoryContents.
  4728             fileNames := dir recursiveDirectoryContents.
  4729         ] on:FileStream openErrorSignal do:[:ex|
  4729         ] on:FileStream openErrorSignal do:[:ex|
  4730             self warn:('Cannot access: %1\(%2)' 
  4730             self warn:(resources stringWithCRs:'Cannot access: %1\(%2)' 
  4731                             bindWith:ex pathName
  4731                             with:ex pathName
  4732                             with:ex description) withCRs.
  4732                             with:ex description).
  4733             ^ self
  4733             ^ self
  4734         ].
  4734         ].
  4735         fileNames := fileNames 
  4735         fileNames := fileNames 
  4736                         collect:[:fn | dir construct:fn]
  4736                         collect:[:fn | dir construct:fn]
  4737                         thenSelect:[:fn | fn isDirectory not].
  4737                         thenSelect:[:fn | fn isDirectory not].
  4856                                     collect:[:fn | dir construct:fn]
  4856                                     collect:[:fn | dir construct:fn]
  4857                                     thenSelect:[:fn | fn isDirectory not].
  4857                                     thenSelect:[:fn | fn isDirectory not].
  4858                     allFiles addAll:fileNames.
  4858                     allFiles addAll:fileNames.
  4859                 ]
  4859                 ]
  4860             ] on:FileStream openErrorSignal do:[:ex|
  4860             ] on:FileStream openErrorSignal do:[:ex|
  4861                 self warn:('Cannot access: %1\(%2)' 
  4861                 self warn:(resources stringWithCRs:'Cannot access: %1\(%2)' 
  4862                                 bindWith:ex pathName
  4862                                 with:ex pathName
  4863                                 with:ex description) withCRs.
  4863                                 with:ex description).
  4864                 ex proceedWith:nil.
  4864                 ex proceedWith:nil.
  4865             ].
  4865             ].
  4866         ].
  4866         ].
  4867 
  4867 
  4868         infoDir := Dictionary new.
  4868         infoDir := Dictionary new.
  5021     numFiles > 1 ifTrue:[
  5021     numFiles > 1 ifTrue:[
  5022         msg := 'Replace contents of %1 files with output of %3-filter ?'.
  5022         msg := 'Replace contents of %1 files with output of %3-filter ?'.
  5023     ].
  5023     ].
  5024 
  5024 
  5025     (Dialog 
  5025     (Dialog 
  5026         confirm:(msg bindWith:numFiles with:selectedFiles first baseName allBold with:whichFilter) withCRs
  5026         confirm:(resources stringWithCRs:msg with:numFiles with:selectedFiles first baseName allBold with:whichFilter)
  5027         initialAnswer:false
  5027         initialAnswer:false
  5028     ) ifFalse:[
  5028     ) ifFalse:[
  5029         ^ self
  5029         ^ self
  5030     ].
  5030     ].
  5031 
  5031 
  5110 
  5110 
  5111     selectedFiles := self currentFileNameHolder value.
  5111     selectedFiles := self currentFileNameHolder value.
  5112     (numFiles := selectedFiles size) <= 1 ifTrue:[^ self].
  5112     (numFiles := selectedFiles size) <= 1 ifTrue:[^ self].
  5113 
  5113 
  5114     msg := 'Join each of the %1 files into single file named:\\Attention: order in which files were selected is relevant here !!'.
  5114     msg := 'Join each of the %1 files into single file named:\\Attention: order in which files were selected is relevant here !!'.
  5115     outFileName := Dialog 
  5115     outFileName := Dialog request:(resources stringWithCRs:msg with:numFiles with:selectedFiles first baseName).
  5116         request:(msg bindWith:numFiles with:selectedFiles first baseName) withCRs.
       
  5117     outFileName isEmptyOrNil ifTrue:[^ self].
  5116     outFileName isEmptyOrNil ifTrue:[^ self].
  5118     outFile := selectedFiles first directory construct:outFileName.
  5117     outFile := selectedFiles first directory construct:outFileName.
  5119 
  5118 
  5120     outStream := outFile writeStream.
  5119     outStream := outFile writeStream.
  5121 
  5120 
  5740 
  5739 
  5741     msg := (numFiles > 1) 
  5740     msg := (numFiles > 1) 
  5742                 ifTrue:'Split each of the %1 files into pieces of size (in kB):'
  5741                 ifTrue:'Split each of the %1 files into pieces of size (in kB):'
  5743                 ifFalse:'Split %2 into pieces of size (in kB):'.
  5742                 ifFalse:'Split %2 into pieces of size (in kB):'.
  5744 
  5743 
  5745     sizeString := Dialog 
  5744     sizeString := Dialog request:(resources stringWithCRs:msg with:numFiles with:selectedFiles first baseName).
  5746         request:(msg bindWith:numFiles with:selectedFiles first baseName) withCRs.
       
  5747     sizeString isEmptyOrNil ifTrue:[^ self].
  5745     sizeString isEmptyOrNil ifTrue:[^ self].
  5748     kiloBytes := Integer readFrom:sizeString onError:nil.
  5746     kiloBytes := Integer readFrom:sizeString onError:nil.
  5749     kiloBytes isNil ifTrue:[^ self].
  5747     kiloBytes isNil ifTrue:[^ self].
  5750 
  5748 
  5751     selectedFiles do:[:fileName |
  5749     selectedFiles do:[:fileName |
  5769     numFiles > 1 ifTrue:[
  5767     numFiles > 1 ifTrue:[
  5770         msg := 'Really truncate %1 files to zero length ?\\WARNING: contents of files is lost !!\This cannot be undone.'.
  5768         msg := 'Really truncate %1 files to zero length ?\\WARNING: contents of files is lost !!\This cannot be undone.'.
  5771     ].
  5769     ].
  5772 
  5770 
  5773     (Dialog 
  5771     (Dialog 
  5774         confirm:(msg bindWith:numFiles with:selectedFiles first baseName allBold) withCRs
  5772         confirm:(resources stringWithCRs:msg with:numFiles with:selectedFiles first baseName allBold)
  5775         initialAnswer:false
  5773         initialAnswer:false
  5776     ) ifFalse:[
  5774     ) ifFalse:[
  5777         ^ self
  5775         ^ self
  5778     ].
  5776     ].
  5779 
  5777 
  6777 ! !
  6775 ! !
  6778 
  6776 
  6779 !AbstractFileBrowser class methodsFor:'documentation'!
  6777 !AbstractFileBrowser class methodsFor:'documentation'!
  6780 
  6778 
  6781 version
  6779 version
  6782     ^ '$Header: /cvs/stx/stx/libtool/AbstractFileBrowser.st,v 1.299 2005-07-12 13:56:43 cg Exp $'
  6780     ^ '$Header: /cvs/stx/stx/libtool/AbstractFileBrowser.st,v 1.300 2005-07-13 15:41:54 cg Exp $'
  6783 ! !
  6781 ! !