Package jadex.base.gui.filechooser
Class RemoteFileSystemView
- java.lang.Object
-
- javax.swing.filechooser.FileSystemView
-
- jadex.base.gui.filechooser.RemoteFileSystemView
-
public class RemoteFileSystemView extends javax.swing.filechooser.FileSystemViewRemote file system view. Is programmed asynchronously, i.e. delivers always what it has and then initiates a background search for retrieving current values. When values arrive a refresh operation is used to update the chooser.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.MapchildrenThe cache of children files (String parent -> File[] children).protected javax.swing.JFileChooserchooserThe filechooser.protected RemoteFilecurrentdirThe current directory.protected RemoteFiledefaultdirThe default directory.protected IExternalAccessextaThe external access.protected RemoteFilehomedirThe home directory.protected java.util.MapparentsThe cache of parent files (String child -> File[] parent).
-
Constructor Summary
Constructors Constructor Description RemoteFileSystemView(IExternalAccess exta)Create a new file system view.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearCache()Clear the cache.java.io.FilecreateFileObject(java.io.File dir, java.lang.String filename)Returns a File object constructed in dir from the given filename.java.io.FilecreateFileObject(java.lang.String path)Returns a File object constructed from the given path string.java.io.FilecreateNewFolder(java.io.File containingDir)Creates a new folder with a default folder name.java.io.FilegetCurrentDirectory()Get the current directory of the remote VM.java.io.FilegetDefaultDirectory()Return the user's default starting directory for the file chooser.java.io.File[]getFiles(java.io.File dir, boolean useFileHiding)Gets the list of shown (i.e.java.io.FilegetHomeDirectory()java.io.FilegetParentDirectory(java.io.File dir)Returns the parent directory ofdir.java.io.File[]getRoots()Returns all root partitions on this system.java.lang.StringgetSystemDisplayName(java.io.File f)Name of a file, directory, or folder as it would be displayed in a system file browser.java.lang.StringgetSystemTypeDescription(java.io.File f)Type description for a file, directory, or folder as it would be displayed in a system file browser.IFuture<java.lang.Void>init()Initialize the remote file system view such that home, default and current directory as well as roots are available.booleanisHiddenFile(java.io.File f)Returns whether a file is hidden or not.booleanisParent(java.io.File folder, java.io.File file)On Windows, a file can appear in multiple folders, other than its parent directory in the filesystem.java.lang.BooleanisTraversable(java.io.File f)Returns true if the file (directory) can be visited.static voidmain(java.lang.String[] args)Main for testing.voidsetFileChooser(javax.swing.JFileChooser chooser)Set the file chooser.
-
-
-
Field Detail
-
exta
protected IExternalAccess exta
The external access.
-
children
protected java.util.Map children
The cache of children files (String parent -> File[] children).
-
parents
protected java.util.Map parents
The cache of parent files (String child -> File[] parent).
-
chooser
protected javax.swing.JFileChooser chooser
The filechooser.
-
homedir
protected RemoteFile homedir
The home directory.
-
defaultdir
protected RemoteFile defaultdir
The default directory.
-
currentdir
protected RemoteFile currentdir
The current directory.
-
-
Constructor Detail
-
RemoteFileSystemView
public RemoteFileSystemView(IExternalAccess exta)
Create a new file system view.
-
-
Method Detail
-
init
public IFuture<java.lang.Void> init()
Initialize the remote file system view such that home, default and current directory as well as roots are available.
-
setFileChooser
public void setFileChooser(javax.swing.JFileChooser chooser)
Set the file chooser.
-
isTraversable
public java.lang.Boolean isTraversable(java.io.File f)
Returns true if the file (directory) can be visited. Returns false if the directory cannot be traversed.- Overrides:
isTraversablein classjavax.swing.filechooser.FileSystemView- Parameters:
f- theFile- Returns:
trueif the file/directory can be traversed, otherwisefalse- Since:
- 1.4
- See Also:
JFileChooser.isTraversable(java.io.File),FileView.isTraversable(java.io.File)
-
getSystemDisplayName
public java.lang.String getSystemDisplayName(java.io.File f)
Name of a file, directory, or folder as it would be displayed in a system file browser. Example from Windows: the "M:\" directory displays as "CD-ROM (M:)" The default implementation gets information from the ShellFolder class.- Overrides:
getSystemDisplayNamein classjavax.swing.filechooser.FileSystemView- Parameters:
f- aFileobject- Returns:
- the file name as it would be displayed by a native file chooser
- Since:
- 1.4
- See Also:
JFileChooser.getName(java.io.File)
-
getSystemTypeDescription
public java.lang.String getSystemTypeDescription(java.io.File f)
Type description for a file, directory, or folder as it would be displayed in a system file browser. Example from Windows: the "Desktop" folder is desribed as "Desktop". Override for platforms with native ShellFolder implementations.- Overrides:
getSystemTypeDescriptionin classjavax.swing.filechooser.FileSystemView- Parameters:
f- aFileobject- Returns:
- the file type description as it would be displayed by a native file chooser or null if no native information is available.
- Since:
- 1.4
- See Also:
JFileChooser.getTypeDescription(java.io.File)
-
isParent
public boolean isParent(java.io.File folder, java.io.File file)On Windows, a file can appear in multiple folders, other than its parent directory in the filesystem. Folder could for example be the "Desktop" folder which is not the same as file.getParentFile().- Overrides:
isParentin classjavax.swing.filechooser.FileSystemView- Parameters:
folder- aFileobject repesenting a directory or special folderfile- aFileobject- Returns:
trueiffolderis a directory or special folder and containsfile.- Since:
- 1.4
-
createNewFolder
public java.io.File createNewFolder(java.io.File containingDir) throws java.io.IOExceptionCreates a new folder with a default folder name.- Specified by:
createNewFolderin classjavax.swing.filechooser.FileSystemView- Throws:
java.io.IOException
-
isHiddenFile
public boolean isHiddenFile(java.io.File f)
Returns whether a file is hidden or not.- Overrides:
isHiddenFilein classjavax.swing.filechooser.FileSystemView
-
getRoots
public java.io.File[] getRoots()
Returns all root partitions on this system. For example, on Windows, this would be the "Desktop" folder, while on DOS this would be the A: through Z: drives.- Overrides:
getRootsin classjavax.swing.filechooser.FileSystemView
-
getHomeDirectory
public java.io.File getHomeDirectory()
- Overrides:
getHomeDirectoryin classjavax.swing.filechooser.FileSystemView
-
getCurrentDirectory
public java.io.File getCurrentDirectory()
Get the current directory of the remote VM.
-
getDefaultDirectory
public java.io.File getDefaultDirectory()
Return the user's default starting directory for the file chooser.- Overrides:
getDefaultDirectoryin classjavax.swing.filechooser.FileSystemView- Returns:
- a
Fileobject representing the default starting folder - Since:
- 1.4
-
createFileObject
public java.io.File createFileObject(java.io.File dir, java.lang.String filename)Returns a File object constructed in dir from the given filename.- Overrides:
createFileObjectin classjavax.swing.filechooser.FileSystemView
-
createFileObject
public java.io.File createFileObject(java.lang.String path)
Returns a File object constructed from the given path string.- Overrides:
createFileObjectin classjavax.swing.filechooser.FileSystemView
-
getFiles
public java.io.File[] getFiles(java.io.File dir, boolean useFileHiding)Gets the list of shown (i.e. not hidden) files.- Overrides:
getFilesin classjavax.swing.filechooser.FileSystemView
-
getParentDirectory
public java.io.File getParentDirectory(java.io.File dir)
Returns the parent directory ofdir.- Overrides:
getParentDirectoryin classjavax.swing.filechooser.FileSystemView- Parameters:
dir- theFilebeing queried- Returns:
- the parent directory of
dir, ornullifdirisnull
-
clearCache
public void clearCache()
Clear the cache.
-
main
public static void main(java.lang.String[] args) throws java.lang.ExceptionMain for testing.- Throws:
java.lang.Exception
-
-