eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'FileBrowser':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: FileBrowser


Inheritance:

   Object
   |
   +--GraphicsMedium
      |
      +--DisplaySurface
         |
         +--SimpleView
            |
            +--View
               |
               +--TopView
                  |
                  +--StandardSystemView
                     |
                     +--FileBrowser

Package:
stx:libtool
Category:
Interface-Tools-File
Version:
rev: 1.743 date: 2024/03/26 12:59:54
user: cg
file: FileBrowser.st directory: libtool
module: stx stc-classLibrary: libtool

Description:


Notice: this is the old (V1) FileBrowser, which has now been 
        more or less obsoleted by the FileBrowserV2
        (which is the default file browser now)

this used to be a very simple demo application,
but migrated into a quite nice tool, includes all kinds of 
warning and information boxes, background processes for directory-
reading and internationalized strings. 
A good example for beginners, on how to do things .... 
(and maybe how not to do things ;-, since some
 stuff is historic and was implemented at times when better mechanisms
 were not available)

See additional information in 'doc/misc/fbrowser.doc'.

WARNING: files edited with FileBrowser will have leading spaces (multiple-8)
         being replaced by tabs. If tabs are to be preserved at other
         positions (for example, sendmail-config files) they will be
         corrupt after being written.

[instance variables]:

    checkDelta      <Integer>       number of seconds of check interval
                                    (looks ever so often if shown directory
                                     has changed). You may make this number
                                    higher, if your network-times are
                                    incorrect and thus, the filebrowser
                                    checks too often.

    compressTabs    <Boolean>       if true, leading spaces will be
                                    replaced by tabs when saving text

some of the defaults (long/short list etc.) can be set by the resource file;
see FileBrowser>>initialize for more details..

copyright

COPYRIGHT (c) 1991 by Claus Gittinger All Rights Reserved This software is furnished under a license and may be used only in accordance with the terms of that license and with the inclusion of the above copyright notice. This software may not be provided or otherwise made available to, or used by, any other person. No title to or ownership of the software is hereby transferred.

Class protocol:

aspects
o  directoryBookmarks

o  directoryHistory
a global visitedDirectories list

defaults
o  default
the class to be used for file browsing (from the preferences).
This is now usually FileBrowserV2, but may also be AppSpecificFileBrowser
in end user apps (eg. expecco)

Usage example(s):

  FileBrowser default open

o  defaultIcon
return the file browsers default window icon

fileList user interaction
o  goodRenameDefaultForFile: oldName lastOld: lastOldName lastNew: lastNewName

history
o  addToCommandHistory: aCommandString for: aFilename

o  addToVisitedFileHistory: path
already been there before; move the entry to
the beginning, so it will fall out later.

instance creation
o  on: aDirectoryPath
return a new FileBrowser in a pathname

Usage example(s):

     (FileBrowser on:'/usr/local/bin') open
     (FileBrowser on:'/etc'          ) open
     (FileBrowser on:'..'            ) open
     (FileBrowser on:'.'             ) open

o  openOn: aDirectoryPath
start a new FileBrowser in a pathname

Usage example(s):

     FileBrowser openOn:'/etc'
     FileBrowser openOn:'..'
     FileBrowser openOn:'.'

o  openOn: aDirectoryPath withExtent: extent
start a new FileBrowser in a pathname

Usage example(s):

     FileBrowser openOn:'/etc'           withExtent:200@300
     FileBrowser openOn:'..'             withExtent:200@300
     FileBrowser openOn:'.'              withExtent:200@300

o  openOnDirectory: aDirectoryPath
start a new FileBrowser in a pathname

o  openOnFileNamed: aFilename
start a new FileBrowser on a file

Usage example(s):

     FileBrowser openOnFileNamed:'Makefile'
     FileBrowser openOnFileNamed:'../Makefile'
     FileBrowser openOnFileNamed:'/tmp/foo'

interface specs
o  fileSearchDialogSpec
This resource specification was automatically generated
by the UIPainter of ST/X.

Usage example(s):

     UIPainter new openOnClass:FileBrowser andSelector:#fileSearchDialogSpec

menu specs
o  baseBookmarksMenuSpec
This resource specification was automatically generated
by the MenuEditor of ST/X.

Usage example(s):

     MenuEditor new openOnClass:FileBrowser andSelector:#baseBookmarksMenuSpec
     (Menu new fromLiteralArrayEncoding:(FileBrowser baseBookmarksMenuSpec)) startUp

o  baseDirectoryMenuSpec
This resource specification was automatically generated
by the MenuEditor of ST/X.

Usage example(s):

     MenuEditor new openOnClass:FileBrowser andSelector:#baseDirectoryMenuSpec
     (Menu new fromLiteralArrayEncoding:(FileBrowser baseDirectoryMenuSpec)) startUp

o  bookmarksMenuSpec
add the history items ...

o  cvsMenuSpec
This resource specification was automatically generated
by the MenuEditor of ST/X.

Usage example(s):

     MenuEditor new openOnClass:FileBrowser andSelector:#cvsMenuSpec
     (Menu new fromLiteralArrayEncoding:(FileBrowser cvsMenuSpec)) startUp

o  directoryMenuSpec
This resource specification was automatically generated
by the MenuEditor of ST/X.

Usage example(s):

     MenuEditor new openOnClass:FileBrowser andSelector:#directoryMenuSpec
     (Menu new fromLiteralArrayEncoding:(FileBrowser directoryMenuSpec)) startUp

o  editMenuSpec
This resource specification was automatically generated
by the MenuEditor of ST/X.

Usage example(s):

     MenuEditor new openOnClass:FileBrowser andSelector:#editMenuSpec
     (Menu new fromLiteralArrayEncoding:(FileBrowser editMenuSpec)) startUp

o  fileMenuSpec
This resource specification was automatically generated
by the MenuEditor of ST/X.

Usage example(s):

     MenuEditor new openOnClass:FileBrowser andSelector:#fileMenuSpec
     (Menu new fromLiteralArrayEncoding:(FileBrowser fileMenuSpec)) startUp

o  helpMenuSpec
This resource specification was automatically generated
by the MenuEditor of ST/X.

Usage example(s):

     MenuEditor new openOnClass:FileBrowser andSelector:#helpMenuSpec
     (Menu new fromLiteralArrayEncoding:(FileBrowser helpMenuSpec)) startUp

o  historyMenuSpec
This resource specification was automatically generated
by the MenuEditor of ST/X.

o  menuPopUp
This resource specification was automatically generated
by the MenuEditor of ST/X.

Usage example(s):

     MenuEditor new openOnClass:FileBrowser andSelector:#menuPopUp
     (Menu new fromLiteralArrayEncoding:(FileBrowser menuPopUp)) startUp

o  menuSpec
This resource specification was automatically generated
by the MenuEditor of ST/X.

Usage example(s):

     MenuEditor new openOnClass:FileBrowser andSelector:#menuSpec
     (Menu new fromLiteralArrayEncoding:(FileBrowser menuSpec)) startUp

o  toolsMenuSpec
This resource specification was automatically generated
by the MenuEditor of ST/X.

Usage example(s):

     MenuEditor new openOnClass:FileBrowser andSelector:#toolsMenuSpec
     (Menu new fromLiteralArrayEncoding:(FileBrowser toolsMenuSpec)) startUp

o  viewMenuSpec
This resource specification was automatically generated
by the MenuEditor of ST/X.

Usage example(s):

     MenuEditor new openOnClass:FileBrowser andSelector:#viewMenuSpec
     (Menu new fromLiteralArrayEncoding:(FileBrowser viewMenuSpec)) startUp

o  visitedFileMenuSpec
add the history items ...

queries
o  isVisualStartable
return true, if this application can be started via #open.
(to allow start of a change browser via double-click in the browser)


Instance protocol:

aspects
o  anyFilesPresentWithSuffix: suffix

o  anySTFilesPresent

o  autoUpdate

o  canAddToClassPath

o  canAddToSourcePath

o  canCreateNewProject

o  canDoTerminal

o  canDoTerminalAndSystemIsDOS

o  canDoTerminalAndSystemIsUnix

o  canReadAbbrevFile

o  canRemoveCVSContainer

o  canRemoveFromClassPath

o  canRemoveFromSourcePath

o  currentDirectoryIsNotTop

o  directoryHistory
a global visitedDirectories list

o  dosEOLMode

o  hasASN1

o  hasASN1AndSelection

o  hasBookmarks

o  hasBookmarksToRemove

o  hasCBrowser

o  hasFilenameSelectionInCodeView

o  hasJava

o  hasJavaAndSelection

o  hasMD5

o  hasMP3Player

o  hasMP3PlayerAndSelection

o  hasSelection
aspect holding true, if a file is selected

o  hasSnapshotSelection

o  hasVisitHistory

o  hasZipFileSelected

o  hasZipFileSelectedHolder

o  javaSupportLoaded

o  showingBigImagePreview

o  showingDetails

o  showingHiddenFiles

o  showingTimeAndDate

o  singleSelectedFile

o  singleSelectedFileOrCurrentDirectory

o  sortByWhat

o  sortCaseless
aspect for sort caseless

o  systemIsDOS

o  systemIsUnix

o  systemIsVMS

change & update
o  update: what with: someArgument from: changedObject
system wants to shut down this
- if text was modified, pop up, and ask user and save if requested.

drag & drop
o  canDropObjects: aCollectionOfDropObjects
I accept file- and textObjects only

o  dropObjects: aCollectionOfDropObjects at: aPoint
handle drops

o  dropSingleObject: someObject at: aPoint
handle drops; if it's a directory, change to it.
If it's a file, change to its directory and select the file.
If it's text, paste it into the codeView.

events
o  handlesKeyPress: key inView: view
this method is reached via delegation: are we prepared to handle
a keyPress in some other view ?

o  keyPress: key x: x y: y view: view
this method is reached via delegation from the fileListView

o  mapped
whant to know about changed history

o  visibilityChange: how
start checking again

fileList user interaction
o  bigImagePreviewSettingChanged
invoked, when big image preview flag changed

o  changeDisplayMode
toggle from long to short listing (and vice-versa)

o  changeDotFileVisibility
turn on/off visibility of files whose name starts with '.'

o  confirmAndRemove: fileNames
remove fileNames with user confirmation.
TODO: Should be enhanced, to look for a ~/.trash directory
and move files there if it exists (without asking in this case).

o  convertImageToGIF

o  detailsSettingChanged
invoked, when detail (i.e. long / short) listing flag changed

o  fileDoubleClick: lineNr
double click on a file - get its contents

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  fileEncoding
open a dialog to allow change of the file's character encoding.
Files are converted to internal encoding when read, and converted back
to this encoding when saved.
The default encoding is nil, which means that files are already in
the internal encoding (which is iso8859).
Notice: currently, not too many encodings are supported by the system.

o  fileExecute
if text was modified show a queryBox,
otherwise pop up execute box immediately

o  fileFileIn
fileIn the selected file(s)

o  fileFileIn: fileName lazy: lazy
fileIn fileName

o  fileFileInLazy
fileIn the selected file(s). Do a quick load (no compilation)

o  fileFileInLazy: lazy
fileIn the selected file(s)

o  fileFileInToNameSpace
fileIn the selected file(s)<into a nameSpace

o  fileFindAllDuplicates
scan directory and all subdirs for duplicate files

o  fileFindDuplicates
scan directory for duplicate files; show info in codeView

o  fileFindFile
The following is tricky:
the pauseToggle & killButton will
be handled by their own windowGroup process.
This means, that they respond to events even though
I myself am reading the commands output.

o  fileGet
get contents of selected file into subView.
If text was modified show a queryBox,
otherwise get it immediately

o  fileGet: viaDoubleClick
get contents of selected file into subView.
If text was modified show a queryBox,
otherwise get it immediately

o  fileGetInfo
show short file (stat)-info

o  fileGetInfo: longInfo
get info on selected file - show it in a box

o  fileGetLongInfo
show long stat (file)-info

o  fileHexDump
show a hex dump (similar to od -x)
Only needed with non-Unix systems.

o  fileInsert
insert contents of file at the cursor position

o  fileListDoubleClick: lineNr
double click on a file - get its contents

o  fileListMenu
return the menu to show in the fileList

o  fileListMenu_old
return the menu to show in the fileList

o  filePrint
send a files contents to the printer (not in the menu)

o  fileRemove
remove the selected file(s).
Query if user really wants to remove the file, except if
shift-key is pressed.
TODO: Should be enhanced, to look for a ~/.trash directory
and move files there if it exists (without asking in this case).

o  fileRename
rename the selected file(s)

o  fileSelect: lineNr
selected a file - do nothing here

o  fileSpawn
start another FileBrowser on the selected directory or
on the same directory if none is selected.

o  hasSlideShow

o  installAllAsAutoloaded
install all classes found here as autoloaded classes

o  installAsAutoloaded: aFilename
install aFilename as autoloaded class

o  loadImageThenDo: aBlock

o  newDirectory
ask for and create a new directory

o  newFile
ask for and create a new file

o  newHardLink
ask for and create a hard link (unix only)

o  newLinkWithType: hardOrSoftSymbol
ask for and create a link (unix only)

o  newSoftLink
ask for and create a soft link (unix only)

o  openASN1Browser

o  openAppletViewer
Java markAllClassesUninitialized.

o  openCBrowser

o  openChangesBrowser
open a change browser on the selected file(s)

o  openDiffView
open a diff-view

o  openEditor

o  openHTMLReader

o  openImageEditor

o  openImageInspector

o  openImagePreview

o  openMP3Player

o  openSelectedFilename

o  openSlideShow

o  openSnapshotImageBrowser
Sorry, for now, only the old browser can handle snapShotImages.

o  openTerminal

o  openTool: aToolClass
open a tool on the selected file(s)

o  openTool: aToolClass ignoreDirectories: ignoreDirs
open a tool on the selected file(s)

o  openTool: aToolClass with: aSelector ignoreDirectories: ignoreDirs
open a tool on the selected file(s)

o  openZipTool

o  readAbbrevFile
read the abbrev file and install classes found there as autoloaded classes

o  revisitFile: aFileName

o  showOrHideTabView
depending on the showLongList setting, show or hde the tabSpec view

help
o  helpTextFor: aComponent
(comment from inherited method)
this will vanish - it's temporarily here to allow for stdSysViews to be
used as a masterApp for dialogs

initialization & release
o  createTabRulerIn: topFrame
self is3D

o  currentDirectory: aDirectoryPath
set the directory to be browsed

o  destroy
destroy view and boxes

o  initEvents

o  initialize
native ST/X encoding

o  initializeCommandViewIn: frame
set up the command view - can be redefined in subclasses as empty,
if no commandView is wanted

o  initializeFilterPattern
set an initial matchpattern - can be redefined in subclasses

o  initializeInfoViewsFor: aTextView
set up the contents view - can be redefined in subclasses for
different view types (SoundFileBrowser/ImageBrowsers etc.)

o  initializeSubViewIn: frame
set up the contents view - can be redefined in subclasses for
different view types (SoundFileBrowser/ImageBrowsers etc.)

o  postRealize
(comment from inherited method)
postRealize actions - tell the application (if any).

menu actions
o  addBookmark

o  addBookmark: path

o  copyCommandHistory
copy the command history to the clipBoard

o  copyFileList
copy fileList (names only) to the clipBoard

o  copySelectedFileName
copy the selected filename to the clipBoard (for easy paste)

o  copySelectedPathName
copy the selected files pathname to the clipBoard (for easy paste)

o  createProjectAndOpenProjectBrowser

o  menuExit

o  menuOSCommand

o  menuShowFileBrowserDocumentation

o  openAboutThisApplication
opens an about box for this application.

o  pullDownMenu
return the top (pullDown) menu

o  removeBookmark

o  showAboutSTX

o  sortChanged
Transcript show:'fBrowser:'; showCR:sortByWhat value.

menu actions-cvs
o  cvsAddAndCommitSelection
add files (or all in current directory) and commit

o  cvsAddSelection
add files (or all in current directory)

o  cvsAddSelectionWithCommit: withCommit
add files (or all in current directory) with optional commit

o  cvsCommitSelection
commit files (or all in current directory)

o  cvsRemoveFileAndContainer
remove the selected file(s) and their CVS containers.
Query if user really wants to really remove them.

o  cvsUpdateDirectoryLocal
update this directory

o  cvsUpdateDirectoryRecursive
update this directory

o  cvsUpdateSelection
update selected files

o  doRemoveAndRemoveFromCVS: filesToRemove
remove the selected file(s) and their CVS containers - no questions asked

misc user interaction
o  closeRequest
asks for permission before closing

o  discardChangesDialog
ask the user if changes should be discarded,
return true if changes should be discarded, false otherwise

o  entryCompletion: contents
find the last word.

o  filterPatternChanged

pathField user interaction
o  addDirToJavaClassPath
add the current path to javas classPath
(only available with ST/J System

o  addDirToJavaSourcePath
add the current path to java's sourcePath
(only available with ST/J System

o  bookmarksMenu
return the bookmarksMenu for the path label

o  changeCurrentDirectory
if text was modified show a queryBox,
otherwise ask for & change to that directory

o  changeDirectoryTo: aDirectoryName
sent from label menu to change back to a previous directory

o  changeToDefaultDirectory
if text was modified show a queryBox,
otherwise change immediately to the default directory

o  changeToHomeDirectory
if text was modified show a queryBox,
otherwise change immediately to the home directory

o  changeToParentDirectory
if text was modified show a queryBox,
otherwise change immediately to the parent directory

o  copyPath
copy current path into cut & paste buffer

o  fileAddToJavaClassPath
add the current path to javas classPath
(only available with ST/J System

o  fileAddToJavaSourcePath
add the current path to java's sourcePath
(only available with ST/J System

o  fileRemoveFromJavaClassPath
remove the current path from javas classPath
(only available with ST/J System

o  fileRemoveFromJavaSourcePath
remove the current path from javas sourcePath
(only available with ST/J System

o  historyMenuSpec
return the historyMenu for the path label

o  labelMenu
return the popUpMenu for the path label

o  labelMenu_old
return the popUpMenu for the path label

o  pathChanged: newPath
change directory to newPath. If newPath is a filename, change
to its directory and get get the file.

o  queryForDirectoryToChange
query for new directory

o  removeDirFromJavaClassPath
remove the current path from javas classPath
(only available with ST/J System

o  removeDirFromJavaSourcePath
remove the current path from javas sourcePath
(only available with ST/J System

private
o  ask: question yesButton: yesButtonText
common method to ask a yes/no question; return true or false

o  ask: question yesButton: yesButtonText noButton: noButtonText
common method to ask a yes/no question

o  askForCommandFor: fileName thenDo: aBlock
marked as obsolete by exept MBP at 01-06-2023

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  askIfModified: question yesButton: yesButtonText
tell user, that code has been modified - let her confirm

o  getSelectedFileName
returns the currently selected file; shows an error if
multiple files are selected

o  onlyOneSelection
show a warning, that only one file must be selected for
this operation

o  scheduleCheckBlock
not yet opened

o  selectFile: aFilename

o  selectedFilesDo: aBlock
evaluate aBlock on all selected files;
show a wait cursor while doing this

o  show: something
show something in subview and undef acceptAction

o  showAlert: aString with: anErrorString
show an alertbox, displaying the last Unix-error

o  withoutHiddenFiles: aCollection
remove hidden files (i.e. those that start with '.') from
the list in aCollection

private-actions & command execution
o  binaryFileAction: aFilename
for some binary files, if double clicked, we can do some useful
action ...

o  doExecuteCommand: commandArg replace: replace
execute a unix command inserting the output of the command.
If replace is true, all text is replaced by the commands output;
otherwise, its inserted as selected text at the cursor position.

o  imageAction: aFilename
for some image files, if double clicked, we can do some useful
action ...

o  initialCommandFor: fileName into: aBox
set a useful initial command in execute-command box.

o  nonBinaryFileAction: aFilename
for some nonBinary files, if double clicked, we can do some useful
action ...

private-directory stuff
o  changeToPreviousDirectory
if text was modified show a queryBox,
otherwise change immediately to previous directory.

o  checkIfDirectoryHasChanged
every checkDelta secs, check if directoy has changed and update the list if so.
Also, we check if the file shown has been touched in the meanwhile (for example,
from another browser) and say 'outdated' in the label if so.
This avoids confusion if the same file is being edited by two browsers. (or other editors).
If the text shown in the codeView has been edited, 'modified' is shown.

o  doChangeCurrentDirectoryTo: fileName updateHistory: updateHistory
verify argument is name of a readable & executable directory
and if so, go there

o  doChangeToDefaultDirectory
go to the default (= current) directory

o  doChangeToHomeDirectory
go to home directory

o  doChangeToParentDirectory
go to parent directory

o  doCreateDirectory: newName

o  setCurrentDirectory: aPathName
setup for another directory

o  updateCurrentDirectoryIfChanged
workaround: DOS has no directory modifiation time ...

private-file I/O
o  readFile: fileName
read in the file, answer its contents as StringCollection

o  readFile: fileName lineDelimiter: aCharacter encoding: encoding
read in the file, return its contents as StringCollection.
The file's lines are delimited by aCharacter.
If encoding is nonNil, the file is assumed to be coded according to
that symbol, and #decodeString: should be able to convert it.

o  readStream: aStream
read in from aStream, answer its contents as StringCollection

o  readStream: aStream lineDelimiter: aCharacter encoding: fileEncodingArg
read from aStream, answer its contents as StringCollection.
The file's lines are delimited by aCharacter.
If encoding is nonNil, the file is assumed to be coded according to
that symbol, and #decodeString: should be able to convert it.

o  showFile: fileName
show contents of fileName in subView

o  showFile: fileName insert: insert encoding: encoding
show/insert contents of fileName in subView

o  showFile: fileNameString insert: insert encoding: encoding doubleClick: viaDoubleClick
show/insert contents of fileName in subView

o  writeFile: fileName text: someText encoding: encoding
must do it lineWise ...

private-file stuff
o  doCreateFile: newName
create an empty file

o  doFileGet: viaDoubleClick
get selected file - show contents in subView.
This is invoked either by the 'get file' menu item, or via double click.
When invoked via the menu (viaDoubleClick argument is false),
the automatic file action is not performed - instead, the file is always
shown in the codeView (if possible).
This distinction was done to allow xpm or xbm files (which have an automatic
action) to be edited.

o  doFindFileNamed: namePatterns ignoreCase: ignCaseInName containingString: contentsString ignoreCaseInContents: ignCaseInString sameContentsAsFile: filenameToCompareContentsOrNil sameContentsAs: bytesToCompareContentsOrNil in: aDirectory
contents compare ...

o  doOpenFile: fileName viaDoubleClick: viaDoubleClick
get selected file - show contents in subView.
This is invoked either by the 'get file' menu item, or via double click.
When invoked via the menu (viaDoubleClick argument is false),
the automatic file action is not performed - instead, the file is always
shown in the codeView (if possible).
This distinction was done to allow xpm or xbm files (which have an automatic
action) to be edited.

o  doRemove: filesToRemove
remove the selected file(s) - no questions asked

o  doRename: oldName to: newName
rename a file (or directory)

private-file type & info
o  fileTypeSpecificActions
any special fileTypeSpecific actions are done here,
when a new file is selected

o  getFileInfoString: longInfo
get stat info on selected file - return a string which can be
shown in a box

o  getInfoFile
get filename of a description-file (.dir.info, README etc.);
This file is automatically shown when a directory is entered.
You can add more names below if you like.

o  showInfo
show directory info when dir has changed

o  sizePrintString: size
helper for update-directory to return a string with a files size.
This one gives the size in byte, Kb or Mb depending on size.
If you don't like this, just uncomment the first statement below.

private-presentation
o  defineTabulatorsForLongList
define the tabs for the long list

o  defineTabulatorsForShortList
define the tabs for the short list

o  iconForFile: aFilename
given a fileName, return an appropriate icon

o  iconForKeyMatching: mimeTypeOrKey
global icons

o  stopImageRenderProcess

o  stopUpdateProcess

o  updateCurrentDirectory
update listView with directory contents

queries
o  fileName
return my current fileName - during fileIn, the file
which is being loaded is returned.
This is provided for VW fileIn scripts, which walk the
context hierarchy and ask the fileBrowser for the name.

Usage example(s):

     (FileBrowser openOnFileNamed:'Makefile') fileName

o  path
return my currentDirectories pathName;
sent from the pathField to acquire the pathname when I changed directory



ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Mon, 18 Nov 2024 06:54:55 GMT