FileBrowser.st
changeset 6357 95e37428f3aa
parent 6295 11ae28df92c3
child 6390 5165b2d373d9
equal deleted inserted replaced
6356:cff12ff7dc25 6357:95e37428f3aa
  2199     list list:encodingNames.
  2199     list list:encodingNames.
  2200     list selectionIndex:(encodings indexOf:fileEncoding ifAbsent:1).
  2200     list selectionIndex:(encodings indexOf:fileEncoding ifAbsent:1).
  2201 
  2201 
  2202     dialog := Dialog new.
  2202     dialog := Dialog new.
  2203 
  2203 
  2204     dialog addTextLabel:(resources string:'ENCODING_MSG') withCRs.
  2204     dialog addTextLabel:(resources stringWithCRs:'ENCODING_MSG') .
  2205     dialog addVerticalSpace.
  2205     dialog addVerticalSpace.
  2206     dialog addListBoxOn:list withNumberOfLines:5.
  2206     dialog addListBoxOn:list withNumberOfLines:5.
  2207 
  2207 
  2208     dialog addAbortAndOkButtons.
  2208     dialog addAbortAndOkButtons.
  2209     dialog open.
  2209     dialog open.
  3280     "ask for and create a new directory"
  3280     "ask for and create a new directory"
  3281 
  3281 
  3282     |queryBox|
  3282     |queryBox|
  3283 
  3283 
  3284     queryBox := FilenameEnterBox 
  3284     queryBox := FilenameEnterBox 
  3285                     title:(resources at:'Create new directory:') withCRs
  3285                     title:(resources stringWithCRs:'Create new directory:') 
  3286                     okText:(resources at:'Create')
  3286                     okText:(resources at:'Create')
  3287                     action:[:newName | self doCreateDirectory:newName].
  3287                     action:[:newName | self doCreateDirectory:newName].
  3288     queryBox show.
  3288     queryBox show.
  3289     queryBox destroy.
  3289     queryBox destroy.
  3290 
  3290 
  3295     "ask for and create a new file"
  3295     "ask for and create a new file"
  3296 
  3296 
  3297     |sel queryBox|
  3297     |sel queryBox|
  3298 
  3298 
  3299     queryBox := FilenameEnterBox 
  3299     queryBox := FilenameEnterBox 
  3300                     title:(resources at:'Create new file:') withCRs
  3300                     title:(resources stringWithCRs:'Create new file:')
  3301                     okText:(resources at:'Create')
  3301                     okText:(resources at:'Create')
  3302                     action:[:newName | newName isEmpty ifFalse:[
  3302                     action:[:newName | newName isEmpty ifFalse:[
  3303                                            self doCreateFile:newName.
  3303                                            self doCreateFile:newName.
  3304                                            self selectFile:newName.
  3304                                            self selectFile:newName.
  3305                                        ]
  3305                                        ]
  5160     "query for new directory"
  5160     "query for new directory"
  5161 
  5161 
  5162     |queryBox dirName|
  5162     |queryBox dirName|
  5163 
  5163 
  5164     queryBox := FilenameEnterBox 
  5164     queryBox := FilenameEnterBox 
  5165                     title:(resources at:'Change directory to:') withCRs
  5165                     title:(resources stringWithCRs:'Change directory to:')
  5166                     okText:(resources at:'Change')
  5166                     okText:(resources at:'Change')
  5167                     action:[:newName | dirName := newName].
  5167                     action:[:newName | dirName := newName].
  5168 "/    queryBox initialText:''.
  5168 "/    queryBox initialText:''.
  5169     queryBox show.
  5169     queryBox show.
  5170     queryBox destroy.
  5170     queryBox destroy.
  5837                     msg := 'FileBrowser:\\directory %1 is gone ?!!?'
  5837                     msg := 'FileBrowser:\\directory %1 is gone ?!!?'
  5838                 ] ifTrue:[
  5838                 ] ifTrue:[
  5839                     msg := 'FileBrowser:\\directory %1 is no longer readable ?!!?'
  5839                     msg := 'FileBrowser:\\directory %1 is no longer readable ?!!?'
  5840                 ].
  5840                 ].
  5841                 "/ sigh - avoid translating backslashes in WIN-filenames
  5841                 "/ sigh - avoid translating backslashes in WIN-filenames
  5842                 msg := (resources string:msg) withCRs.
  5842                 msg := resources stringWithCRs:msg with:currentDirectory pathName allBold.
  5843                 Dialog warn:(msg bindWith:currentDirectory pathName allBold).
  5843                 Dialog warn:msg.
  5844 
  5844 
  5845                 fileListView contents:nil.
  5845                 fileListView contents:nil.
  5846                 newLabel := myName , ': directory is gone !!'.
  5846                 newLabel := myName , ': directory is gone !!'.
  5847             ].
  5847             ].
  5848 
  5848 
  5922                 msg := '''%1'' is not a directory or unreadable !!'
  5922                 msg := '''%1'' is not a directory or unreadable !!'
  5923             ] ifFalse:[
  5923             ] ifFalse:[
  5924                 msg := '''%1'' is not a directory !!'
  5924                 msg := '''%1'' is not a directory !!'
  5925             ]
  5925             ]
  5926         ].
  5926         ].
  5927         msg := (resources string:msg) withCRs.
  5927         msg := resources stringWithCRs:msg with:fileName allBold.
  5928         Dialog warn:(msg bindWith:fileName allBold).
  5928         Dialog warn:msg.
  5929     ]
  5929     ]
  5930 
  5930 
  5931     "Modified: / 18.9.1997 / 18:22:30 / stefan"
  5931     "Modified: / 18.9.1997 / 18:22:30 / stefan"
  5932     "Modified: / 27.4.1999 / 17:10:14 / cg"
  5932     "Modified: / 27.4.1999 / 17:10:14 / cg"
  5933 !
  5933 !
  6147         path exists ifFalse:[
  6147         path exists ifFalse:[
  6148             msg := '''%1'' does not exist !!'.
  6148             msg := '''%1'' does not exist !!'.
  6149         ] ifTrue:[
  6149         ] ifTrue:[
  6150             msg := '''%1'' is not a regular file !!'.
  6150             msg := '''%1'' is not a regular file !!'.
  6151         ].
  6151         ].
  6152         msg := (resources string:msg) withCRs.
  6152         msg := resources stringWithCRs:msg with:fileNameString allBold.
  6153         Dialog warn:(msg bindWith:fileNameString allBold).
  6153         Dialog warn:msg.
  6154         ^ self
  6154         ^ self
  6155     ].
  6155     ].
  6156 
  6156 
  6157     enc := encoding.
  6157     enc := encoding.
  6158     ok := true.
  6158     ok := true.
  6500             self doChangeCurrentDirectoryTo:fileName updateHistory:true.
  6500             self doChangeCurrentDirectoryTo:fileName updateHistory:true.
  6501             winLbl := myName.
  6501             winLbl := myName.
  6502             iconLbl := myName
  6502             iconLbl := myName
  6503         ] ifFalse:[
  6503         ] ifFalse:[
  6504             f exists ifFalse:[
  6504             f exists ifFalse:[
  6505                 Dialog warn:(resources string:'oops, ''%1'' is gone or unreadable.' withCRs with:f pathName allBold).
  6505                 Dialog warn:(resources stringWithCRs:'oops, ''%1'' is gone or unreadable.' with:f pathName allBold).
  6506                 ^ self
  6506                 ^ self
  6507             ].
  6507             ].
  6508             timeOfFileRead := f modificationTime.
  6508             timeOfFileRead := f modificationTime.
  6509             self showFile:fileName insert:false encoding:fileEncoding doubleClick:viaDoubleClick.
  6509             self showFile:fileName insert:false encoding:fileEncoding doubleClick:viaDoubleClick.
  6510             currentFileName := fileName.
  6510             currentFileName := fileName.
  6578                     (f isSymbolicLink not and:[f isDirectory]) ifTrue:[
  6578                     (f isSymbolicLink not and:[f isDirectory]) ifTrue:[
  6579                         f isNonEmptyDirectory ifTrue:[
  6579                         f isNonEmptyDirectory ifTrue:[
  6580                             yesToAll ifFalse:[
  6580                             yesToAll ifFalse:[
  6581                                 idx == filesToRemove size ifTrue:[
  6581                                 idx == filesToRemove size ifTrue:[
  6582                                     answer := Dialog
  6582                                     answer := Dialog
  6583                                                 confirmWithCancel:(resources string:'Directory ''%1'' is not empty\remove anyway ?' with:fileName allBold) withCRs
  6583                                                 confirmWithCancel:(resources stringWithCRs:'Directory ''%1'' is not empty\remove anyway ?' with:fileName allBold) 
  6584                                                 labels:(resources array:#('Cancel' 'Remove'))
  6584                                                 labels:(resources array:#('Cancel' 'Remove'))
  6585                                                 values:#(false true) 
  6585                                                 values:#(false true) 
  6586                                                 default:2.
  6586                                                 default:2.
  6587                                 ] ifFalse:[
  6587                                 ] ifFalse:[
  6588                                     answer := Dialog
  6588                                     answer := Dialog
  6589                                                 confirmWithCancel:(resources string:'Directory ''%1'' is not empty\remove anyway ?' with:fileName allBold) withCRs
  6589                                                 confirmWithCancel:(resources stringWithCRs:'Directory ''%1'' is not empty\remove anyway ?' with:fileName allBold)
  6590                                                 labels:(resources array:#('Cancel' 'Remove All' 'Remove'))
  6590                                                 labels:(resources array:#('Cancel' 'Remove All' 'Remove'))
  6591                                                 values:#(false #removeAll true) 
  6591                                                 values:#(false #removeAll true) 
  6592                                                 default:3.
  6592                                                 default:3.
  6593                                 ].
  6593                                 ].
  6594                                 answer == false ifTrue:[
  6594                                 answer == false ifTrue:[
  7030                          or:[matchPattern compoundMatch:aName ignoreCase:ignoreCase]
  7030                          or:[matchPattern compoundMatch:aName ignoreCase:ignoreCase]
  7031                       ].
  7031                       ].
  7032         ].
  7032         ].
  7033 
  7033 
  7034         files size == 0 ifTrue:[
  7034         files size == 0 ifTrue:[
  7035             Dialog warn:((resources string:'Directory ''%1'' is gone.') 
  7035             Dialog warn:(resources stringWithCRs:'Directory ''%1'' is gone.' with:currentDirectory pathName allBold).
  7036                         withCRs 
       
  7037                             bindWith:currentDirectory pathName allBold).
       
  7038             ^ self
  7036             ^ self
  7039         ].
  7037         ].
  7040         (sortByWhat value == #name) ifTrue:[
  7038         (sortByWhat value == #name) ifTrue:[
  7041             sortCaseless value == true ifTrue:[
  7039             sortCaseless value == true ifTrue:[
  7042                 files sort:[:a :b | a asLowercase < b asLowercase]
  7040                 files sort:[:a :b | a asLowercase < b asLowercase]
  7514 ! !
  7512 ! !
  7515 
  7513 
  7516 !FileBrowser class methodsFor:'documentation'!
  7514 !FileBrowser class methodsFor:'documentation'!
  7517 
  7515 
  7518 version
  7516 version
  7519     ^ '$Header: /cvs/stx/stx/libtool/FileBrowser.st,v 1.603 2005-05-06 09:21:27 cg Exp $'
  7517     ^ '$Header: /cvs/stx/stx/libtool/FileBrowser.st,v 1.604 2005-07-13 15:53:02 cg Exp $'
  7520 ! !
  7518 ! !