diff options
author | Mark Wielaard <mark@gcc.gnu.org> | 2005-11-15 23:20:01 +0000 |
---|---|---|
committer | Mark Wielaard <mark@gcc.gnu.org> | 2005-11-15 23:20:01 +0000 |
commit | 8f523f3a1047919d3563daf1ef47ba87336ebe89 (patch) | |
tree | a5eb7cf42a51869cc8aa1fad7ad6a90cca47fdd8 /libjava/classpath/javax/swing/filechooser | |
parent | 02e549bfaaec38f68307e7f34e46ea57ea1809af (diff) | |
download | gcc-8f523f3a1047919d3563daf1ef47ba87336ebe89.zip gcc-8f523f3a1047919d3563daf1ef47ba87336ebe89.tar.gz gcc-8f523f3a1047919d3563daf1ef47ba87336ebe89.tar.bz2 |
Imported GNU Classpath 0.19 + gcj-import-20051115.
* sources.am: Regenerated.
* Makefile.in: Likewise.
* scripts/makemake.tcl: Use glob -nocomplain.
From-SVN: r107049
Diffstat (limited to 'libjava/classpath/javax/swing/filechooser')
4 files changed, 266 insertions, 191 deletions
diff --git a/libjava/classpath/javax/swing/filechooser/FileFilter.java b/libjava/classpath/javax/swing/filechooser/FileFilter.java index 42770d9..ecfa54b 100644 --- a/libjava/classpath/javax/swing/filechooser/FileFilter.java +++ b/libjava/classpath/javax/swing/filechooser/FileFilter.java @@ -1,5 +1,5 @@ /* FileFilter.java -- - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -40,41 +40,46 @@ package javax.swing.filechooser; import java.io.File; +import javax.swing.JFileChooser; + /** - * FileFilter + * The base class for filters that control the visibility of files in the + * {@link JFileChooser} component. + * + * @see JFileChooser#addChoosableFileFilter(FileFilter) + * * @author Andrew Selkirk - * @version 1.0 */ -public abstract class FileFilter { - - //------------------------------------------------------------- - // Initialization --------------------------------------------- - //------------------------------------------------------------- - - /** - * Constructor FileFilter - */ - public FileFilter() { - // TODO - } // FileFilter() - - - //------------------------------------------------------------- - // Methods ---------------------------------------------------- - //------------------------------------------------------------- - - /** - * accept - * @param file TODO - * @returns boolean - */ - public abstract boolean accept(File file); - - /** - * getDescription - * @returns String - */ - public abstract String getDescription(); - - -} // FileFilter +public abstract class FileFilter +{ + + /** + * Default constructor. + */ + public FileFilter() + { + // Nothing to do here. + } + + /** + * Returns <code>true</code> if the specified file matches the filter, and + * <code>false</code> otherwise. + * + * @param file the file. + * + * @returns A boolean. + */ + public abstract boolean accept(File file); + + /** + * Returns a description of the files that will be selected by the filter + * (for example, "Java source files"). This description will usually be + * displayed on the {@link JFileChooser} component, often in a combo box that + * is used to select the appropriate filter (in cases where more than one + * filter is available). + * + * @returns A description of the filter. + */ + public abstract String getDescription(); + +} diff --git a/libjava/classpath/javax/swing/filechooser/FileSystemView.java b/libjava/classpath/javax/swing/filechooser/FileSystemView.java index ffa41ca..f51b745 100644 --- a/libjava/classpath/javax/swing/filechooser/FileSystemView.java +++ b/libjava/classpath/javax/swing/filechooser/FileSystemView.java @@ -40,21 +40,27 @@ package javax.swing.filechooser; import java.io.File; import java.io.IOException; import java.util.ArrayList; + import javax.swing.Icon; +import javax.swing.JFileChooser; /** - * DOCUMENT ME! + * The base class providing a view of the file system for use by the + * {@link JFileChooser} component. */ public abstract class FileSystemView { + /** The instance returned by {@link #getFileSystemView()}. */ + private static FileSystemView defaultFileSystemView; + /** - * DOCUMENT ME! + * Creates a new file object with the given name in the specified directory. * - * @param dir DOCUMENT ME! - * @param filename DOCUMENT ME! + * @param dir the directory (<code>null</code> permitted). + * @param filename the file name. * - * @return DOCUMENT ME! + * @return A new file object. */ public File createFileObject(File dir, String filename) { @@ -62,11 +68,11 @@ public abstract class FileSystemView } /** - * DOCUMENT ME! + * Creates a new file object from the specified path. * - * @param path DOCUMENT ME! + * @param path the path. * - * @return DOCUMENT ME! + * @return A new file object. */ public File createFileObject(String path) { @@ -89,13 +95,16 @@ public abstract class FileSystemView } /** - * DOCUMENT ME! + * Creates a new folder with a unique name in the specified directory and + * returns a {@link File} object representing the new directory. * - * @param containingDir DOCUMENT ME! + * @param containingDir the directory to contain the new folder + * (<code>null</code> not permitted). * - * @return DOCUMENT ME! + * @return A {@link File} object representing the new directory. * - * @throws IOException DOCUMENT ME! + * @throws IOException if an exception occurs while creating the new + * directory. */ public abstract File createNewFolder(File containingDir) throws IOException; @@ -115,9 +124,9 @@ public abstract class FileSystemView } /** - * DOCUMENT ME! + * Returns the default directory. * - * @return DOCUMENT ME! + * @return The default directory. */ public File getDefaultDirectory() { @@ -125,12 +134,16 @@ public abstract class FileSystemView } /** - * DOCUMENT ME! + * Returns an array containing the files in the given directory. The + * <code>useFileHiding</code> controls whether or not hidden files are + * included in the result. * - * @param dir DOCUMENT ME! - * @param useFileHiding DOCUMENT ME! + * @param dir the directory (if <code>null</code> + * @param useFileHiding a flag that controls whether or not hidden files are + * included in the result (pass in <code>true</code> to + * exclude hidden files). * - * @return DOCUMENT ME! + * @return The files in the given directory (possibly <code>null</code>). */ public File[] getFiles(File dir, boolean useFileHiding) { @@ -143,31 +156,34 @@ public abstract class FileSystemView for (int i = 0; i < files.length; i++) if (! files[i].isHidden()) trim.add(files[i]); - File[] value = (File[]) trim.toArray(new File[0]); + File[] value = (File[]) trim.toArray(new File[trim.size()]); return value; } /** - * DOCUMENT ME! + * Returns a default {@link FileSystemView} appropriate for the platform. * - * @return DOCUMENT ME! + * @return A default {@link FileSystemView} appropriate for the platform. */ public static FileSystemView getFileSystemView() { - if (File.separator.equals("/")) - return new UnixFileSystemView(); - - // else if (File.Separator.equals("\")) - // return new Win32FileSystemView(); - // else - // return new GenericFileSystemView(); - return null; + if (defaultFileSystemView == null) + { + if (File.separator.equals("/")) + defaultFileSystemView = new UnixFileSystemView(); + // FIXME: need to implement additional views + // else if (File.Separator.equals("\")) + // return new Win32FileSystemView(); + // else + // return new GenericFileSystemView(); + } + return defaultFileSystemView; } /** - * DOCUMENT ME! + * Returns the home directory for the current user. * - * @return DOCUMENT ME! + * @return The home directory for the current user. */ public File getHomeDirectory() { @@ -175,11 +191,12 @@ public abstract class FileSystemView } /** - * DOCUMENT ME! + * Returns the parent directory for the given file/directory. * - * @param f DOCUMENT ME! + * @param f the file/directory. * - * @return DOCUMENT ME! + * @return The parent directory (or <code>null</code> if there is no parent + * directory). */ public File getParentDirectory(File f) { @@ -189,9 +206,14 @@ public abstract class FileSystemView } /** - * DOCUMENT ME! - * - * @return DOCUMENT ME! + * Returns an array containing the file system roots. On Unix-like platforms, + * this array will contain just a single item ("/"), while other platforms + * may return multiple roots. + * <p> + * This method is implemented to return <code>null</code>, subclasses must + * override this method. + * + * @return An array containing the file system roots. */ public File[] getRoots() { @@ -200,11 +222,13 @@ public abstract class FileSystemView } /** - * DOCUMENT ME! + * Returns the name of a file as it would be displayed by the underlying + * system. This implementation returns <code>null</code>, subclasses must + * override. * - * @param f DOCUMENT ME! + * @param f the file. * - * @return DOCUMENT ME! + * @return <code>null</code>. */ public String getSystemDisplayName(File f) { @@ -212,11 +236,13 @@ public abstract class FileSystemView } /** - * DOCUMENT ME! + * Returns the icon that would be displayed for the given file by the + * underlying system. This implementation returns <code>null</code>, + * subclasses must override. * - * @param f DOCUMENT ME! + * @param f the file. * - * @return DOCUMENT ME! + * @return <code>null</code>. */ public Icon getSystemIcon(File f) { @@ -224,11 +250,13 @@ public abstract class FileSystemView } /** - * DOCUMENT ME! + * Returns the type description of a file that would be displayed by the + * underlying system. This implementation returns <code>null</code>, + * subclasses must override. * - * @param f DOCUMENT ME! + * @param f the file. * - * @return DOCUMENT ME! + * @return <code>null</code>. */ public String getSystemTypeDescription(File f) { @@ -248,11 +276,13 @@ public abstract class FileSystemView } /** - * DOCUMENT ME! + * Returns <code>true</code> if the given directory represents a disk + * drive, and <code>false</code> otherwise. This default implementation + * always returns <code>false</code>. * - * @param dir DOCUMENT ME! + * @param dir the directory. * - * @return DOCUMENT ME! + * @return <code>false</code>. */ public boolean isDrive(File dir) { @@ -260,11 +290,13 @@ public abstract class FileSystemView } /** - * DOCUMENT ME! + * Returns <code>true</code> if <code>f</code> is a file or directory, and + * <code>false</code> otherwise. * - * @param f DOCUMENT ME! + * @param f the file/directory. * - * @return DOCUMENT ME! + * @return <code>true</code> if <code>f</code> is a file or directory, and + * <code>false</code> otherwise. */ public boolean isFileSystem(File f) { @@ -272,11 +304,13 @@ public abstract class FileSystemView } /** - * DOCUMENT ME! + * Returns <code>true</code> if the given directory is a file system root, + * and <code>false</code> otherwise. * - * @param dir DOCUMENT ME! + * @param dir the directory. * - * @return DOCUMENT ME! + * @return <code>true</code> if the given directory is a file system root, + * and <code>false</code> otherwise. */ public boolean isFileSystemRoot(File dir) { @@ -291,11 +325,13 @@ public abstract class FileSystemView } /** - * DOCUMENT ME! + * Returns <code>true</code> if the given directory represents a floppy + * drive, and <code>false</code> otherwise. This default implementation + * always returns <code>false</code>. * - * @param dir DOCUMENT ME! + * @param dir the directory. * - * @return DOCUMENT ME! + * @return <code>false</code>. */ public boolean isFloppyDrive(File dir) { @@ -303,11 +339,13 @@ public abstract class FileSystemView } /** - * DOCUMENT ME! + * Returns <code>true</code> if the given file is hidden, and + * <code>false</code> otherwise. * - * @param f DOCUMENT ME! + * @param f the file. * - * @return DOCUMENT ME! + * @return <code>true</code> if the given file is hidden, and + * <code>false</code> otherwise. */ public boolean isHiddenFile(File f) { @@ -315,12 +353,14 @@ public abstract class FileSystemView } /** - * DOCUMENT ME! + * Returns <code>true</code> if <code>folder</code> is the parent of + * <code>file</code>, and <code>false</code> otherwise. * - * @param folder DOCUMENT ME! - * @param file DOCUMENT ME! + * @param folder the folder (<code>null</code> not permitted). + * @param file the file (<code>null</code> not permitted). * - * @return DOCUMENT ME! + * @return <code>true</code> if <code>folder</code> is the parent of + * <code>file</code>, and <code>false</code> otherwise. */ public boolean isParent(File folder, File file) { @@ -344,11 +384,14 @@ public abstract class FileSystemView } /** - * DOCUMENT ME! + * Returns <code>true</code> if the file is traversable, and + * <code>false</code> otherwise. Here, all directories are considered + * traversable, and files are considered non-traversable. * - * @param f DOCUMENT ME! + * @param f the file or directory (<code>null</code> not permitted). * - * @return DOCUMENT ME! + * @return <code>true</code> if the file is traversable, and + * <code>false</code> otherwise. */ public Boolean isTraversable(File f) { @@ -356,6 +399,6 @@ public abstract class FileSystemView // traversable. (No files are listed when you traverse the directory) // My best guess is that as long as it's a directory, the file is // traversable. - return new Boolean(f.isDirectory()); + return Boolean.valueOf(f.isDirectory()); } } diff --git a/libjava/classpath/javax/swing/filechooser/FileView.java b/libjava/classpath/javax/swing/filechooser/FileView.java index c431fd4..ea1989f 100644 --- a/libjava/classpath/javax/swing/filechooser/FileView.java +++ b/libjava/classpath/javax/swing/filechooser/FileView.java @@ -1,5 +1,5 @@ /* FileView.java -- - Copyright (C) 2002, 2004 Free Software Foundation, Inc. + Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -43,72 +43,86 @@ import java.io.File; import javax.swing.Icon; /** - * FileView - * @author Andrew Selkirk - * @version 1.0 + * An abstract class that provides presentation information about files and + * directories. . + * + * @author Andrew Selkirk */ -public abstract class FileView { - - //------------------------------------------------------------- - // Initialization --------------------------------------------- - //------------------------------------------------------------- - - /** - * Constructor FileView - */ - public FileView() { - // TODO - } // FileView() - - - //------------------------------------------------------------- - // Methods ---------------------------------------------------- - //------------------------------------------------------------- - - /** - * getName - * @param file TODO - * @returns String - */ - public String getName(File file) { - return null; // TODO - } // getName() - - /** - * getDescription - * @param value0 TODO - * @returns String - */ - public String getDescription(File value0) { - return null; // TODO - } // getDescription() - - /** - * getTypeDescription - * @param value0 TODO - * @returns String - */ - public String getTypeDescription(File value0) { - return null; // TODO - } // getTypeDescription() - - /** - * getIcon - * @param value0 TODO - * @returns Icon - */ - public Icon getIcon(File value0) { - return null; // TODO - } // getIcon() - - /** - * isTraversable - * @param value0 TODO - * @returns Boolean - */ - public Boolean isTraversable(File value0) { - return null; // TODO - } // isTraversable() - - -} // FileView +public abstract class FileView +{ + + /** + * Creates a new <code>FileView</code> instance. + */ + public FileView() + { + // Nothing to do here. + } + + /** + * Returns the name for the specified file. This method always returns + * <code>null</code> and should be overridden by subclasses. + * + * @param file the file. + * + * @return Always <code>null</code>. + */ + public String getName(File file) + { + return null; + } + + /** + * Returns a description for the specified file. This method always returns + * <code>null</code> and should be overridden by subclasses. + * + * @param file the file. + * + * @return Always <code>null</code>. + */ + public String getDescription(File file) + { + return null; + } + + /** + * Returns a description for the type of the specified file. This method + * always returns <code>null</code> and should be overridden by subclasses. + * + * @param file the file. + * + * @return Always <code>null</code>. + */ + public String getTypeDescription(File file) + { + return null; + } + + /** + * Returns an {@link Icon} to represent the specified file. This method + * always returns <code>null</code> and should be overridden by subclasses. + * + * @param file the file. + * + * @return Always <code>null</code>. + */ + public Icon getIcon(File file) + { + return null; + } + + /** + * Returns {@link Boolean#TRUE} if the given directory is traversable, and + * {@link Boolean#FALSE} if it is not. This method always returns + * <code>null</code> and should be overridden by subclasses. + * + * @param directory the directory. + * + * @returns Always <code>null</code>. + */ + public Boolean isTraversable(File directory) + { + return null; + } + +} diff --git a/libjava/classpath/javax/swing/filechooser/UnixFileSystemView.java b/libjava/classpath/javax/swing/filechooser/UnixFileSystemView.java index f2360ec..c2f6596 100644 --- a/libjava/classpath/javax/swing/filechooser/UnixFileSystemView.java +++ b/libjava/classpath/javax/swing/filechooser/UnixFileSystemView.java @@ -43,21 +43,31 @@ import javax.swing.Icon; /** - * DOCUMENT ME! + * A concrete implementation of {@link FileSystemView} that is appropriate for + * Unix-like systems. + * + * @see FileSystemView#getFileSystemView() */ class UnixFileSystemView extends FileSystemView { - /** DOCUMENT ME! */ + /** The default name for new folders. */ private static final String NEW_FOLDER_NAME = "NewFolder"; /** - * DOCUMENT ME! + * Creates a new folder with a unique name in the specified directory and + * returns a {@link File} object representing the new directory. The name + * of the new folder is <code>NewFolder</code> or, if a directory or file + * with that name already exists, <code>NewFolder.n</code> where + * <code>n</code> is the lowest integer greater than zero that results in + * a unique directory name. * - * @param containingDir DOCUMENT ME! + * @param containingDir the directory to contain the new folder + * (<code>null</code> not permitted). * - * @return DOCUMENT ME! + * @return A {@link File} object representing the new directory. * - * @throws IOException DOCUMENT ME! + * @throws IOException if an exception occurs while creating the new + * directory. */ public File createNewFolder(File containingDir) throws IOException { @@ -82,9 +92,9 @@ class UnixFileSystemView extends FileSystemView } /** - * DOCUMENT ME! + * Returns an array containing the file system root. * - * @return DOCUMENT ME! + * @return An array containing the file system root. */ public File[] getRoots() { @@ -92,11 +102,12 @@ class UnixFileSystemView extends FileSystemView } /** - * DOCUMENT ME! + * Returns the name of a file as it would be displayed by the underlying + * system. This method is NOT YET IMPLEMENTED. * - * @param f DOCUMENT ME! + * @param f the file. * - * @return DOCUMENT ME! + * @return <code>null</code>. */ public String getSystemDisplayName(File f) { @@ -105,11 +116,12 @@ class UnixFileSystemView extends FileSystemView } /** - * DOCUMENT ME! + * Returns the icon that would be displayed for the given file by the + * underlying system. This method is NOT YET IMPLEMENTED. * - * @param f DOCUMENT ME! + * @param f the file. * - * @return DOCUMENT ME! + * @return <code>null</code>. */ public Icon getSystemIcon(File f) { @@ -118,11 +130,12 @@ class UnixFileSystemView extends FileSystemView } /** - * DOCUMENT ME! + * Returns the description of a file that would be displayed by the + * underlying system. This method is NOT YET IMPLEMENTED. * - * @param f DOCUMENT ME! + * @param f the file. * - * @return DOCUMENT ME! + * @return <code>null</code>. */ public String getSystemTypeDescription(File f) { |