/[classpath]/classpath/javax/swing/filechooser/FileSystemView.java
ViewVC logotype

Diff of /classpath/javax/swing/filechooser/FileSystemView.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.9 by trebligd, Tue Oct 11 09:30:16 2005 UTC revision 1.10 by trebligd, Wed Nov 2 10:31:18 2005 UTC
# Line 40  package javax.swing.filechooser; Line 40  package javax.swing.filechooser;
40  import java.io.File;  import java.io.File;
41  import java.io.IOException;  import java.io.IOException;
42  import java.util.ArrayList;  import java.util.ArrayList;
43    
44  import javax.swing.Icon;  import javax.swing.Icon;
45    import javax.swing.JFileChooser;
46    
47    
48  /**  /**
49   * DOCUMENT ME!   * The base class providing a view of the file system for use by the
50     * {@link JFileChooser} component.
51   */   */
52  public abstract class FileSystemView  public abstract class FileSystemView
53  {  {
# Line 52  public abstract class FileSystemView Line 55  public abstract class FileSystemView
55    private static FileSystemView defaultFileSystemView;    private static FileSystemView defaultFileSystemView;
56        
57    /**    /**
58     * DOCUMENT ME!     * Creates a new file object with the given name in the specified directory.
59     *     *
60     * @param dir DOCUMENT ME!     * @param dir  the directory (<code>null</code> permitted).
61     * @param filename DOCUMENT ME!     * @param filename  the file name.
62     *     *
63     * @return DOCUMENT ME!     * @return A new file object.
64     */     */
65    public File createFileObject(File dir, String filename)    public File createFileObject(File dir, String filename)
66    {    {
# Line 65  public abstract class FileSystemView Line 68  public abstract class FileSystemView
68    }    }
69    
70    /**    /**
71     * DOCUMENT ME!     * Creates a new file object from the specified path.
72     *     *
73     * @param path DOCUMENT ME!     * @param path  the path.
74     *     *
75     * @return DOCUMENT ME!     * @return A new file object.
76     */     */
77    public File createFileObject(String path)    public File createFileObject(String path)
78    {    {
# Line 92  public abstract class FileSystemView Line 95  public abstract class FileSystemView
95    }    }
96    
97    /**    /**
98     * DOCUMENT ME!     * Creates a new folder with a unique name in the specified directory and
99       * returns a {@link File} object representing the new directory.
100     *     *
101     * @param containingDir DOCUMENT ME!     * @param containingDir  the directory to contain the new folder
102       *                       (<code>null</code> not permitted).
103     *     *
104     * @return DOCUMENT ME!     * @return A {@link File} object representing the new directory.
105     *     *
106     * @throws IOException DOCUMENT ME!     * @throws IOException if an exception occurs while creating the new
107       *                     directory.
108     */     */
109    public abstract File createNewFolder(File containingDir)    public abstract File createNewFolder(File containingDir)
110                                  throws IOException;                                  throws IOException;
# Line 118  public abstract class FileSystemView Line 124  public abstract class FileSystemView
124    }    }
125    
126    /**    /**
127     * DOCUMENT ME!     * Returns the default directory.
128     *     *
129     * @return DOCUMENT ME!     * @return The default directory.
130     */     */
131    public File getDefaultDirectory()    public File getDefaultDirectory()
132    {    {
# Line 128  public abstract class FileSystemView Line 134  public abstract class FileSystemView
134    }    }
135    
136    /**    /**
137     * DOCUMENT ME!     * Returns an array containing the files in the given directory.  The
138     *     * <code>useFileHiding</code> controls whether or not hidden files are
139     * @param dir DOCUMENT ME!     * included in the result.
140     * @param useFileHiding DOCUMENT ME!     *
141       * @param dir  the directory (if <code>null</code>
142       * @param useFileHiding  a flag that controls whether or not hidden files are
143       *                       included in the result (pass in <code>true</code> to
144       *                       exclude hidden files).
145     *     *
146     * @return DOCUMENT ME!     * @return The files in the given directory (possibly <code>null</code>).
147     */     */
148    public File[] getFiles(File dir, boolean useFileHiding)    public File[] getFiles(File dir, boolean useFileHiding)
149    {    {
# Line 161  public abstract class FileSystemView Line 171  public abstract class FileSystemView
171        {        {
172          if (File.separator.equals("/"))          if (File.separator.equals("/"))
173            defaultFileSystemView = new UnixFileSystemView();            defaultFileSystemView = new UnixFileSystemView();
174            // FIXME: need to implement additional views
175          // else if (File.Separator.equals("\"))          // else if (File.Separator.equals("\"))
176          //   return new Win32FileSystemView();          //   return new Win32FileSystemView();
177          // else          // else
# Line 170  public abstract class FileSystemView Line 181  public abstract class FileSystemView
181    }    }
182    
183    /**    /**
184     * DOCUMENT ME!     * Returns the home directory for the current user.
185     *     *
186     * @return DOCUMENT ME!     * @return The home directory for the current user.
187     */     */
188    public File getHomeDirectory()    public File getHomeDirectory()
189    {    {
# Line 180  public abstract class FileSystemView Line 191  public abstract class FileSystemView
191    }    }
192    
193    /**    /**
194     * DOCUMENT ME!     * Returns the parent directory for the given file/directory.
195     *     *
196     * @param f DOCUMENT ME!     * @param f  the file/directory.
197     *     *
198     * @return DOCUMENT ME!     * @return The parent directory (or <code>null</code> if there is no parent
199       *         directory).
200     */     */
201    public File getParentDirectory(File f)    public File getParentDirectory(File f)
202    {    {
# Line 194  public abstract class FileSystemView Line 206  public abstract class FileSystemView
206    }    }
207    
208    /**    /**
209     * DOCUMENT ME!     * Returns an array containing the file system roots.  On Unix-like platforms,
210       * this array will contain just a single item ("/"), while other platforms
211       * may return multiple roots.
212       * <p>
213       * This method is implemented to return <code>null</code>, subclasses must
214       * override this method.
215     *     *
216     * @return DOCUMENT ME!     * @return An array containing the file system roots.
217     */     */
218    public File[] getRoots()    public File[] getRoots()
219    {    {
# Line 205  public abstract class FileSystemView Line 222  public abstract class FileSystemView
222    }    }
223    
224    /**    /**
225     * DOCUMENT ME!     * Returns the name of a file as it would be displayed by the underlying
226       * system.  This implementation returns <code>null</code>, subclasses must
227       * override.
228     *     *
229     * @param f DOCUMENT ME!     * @param f  the file.
230     *     *
231     * @return DOCUMENT ME!     * @return <code>null</code>.
232     */     */
233    public String getSystemDisplayName(File f)    public String getSystemDisplayName(File f)
234    {    {
# Line 217  public abstract class FileSystemView Line 236  public abstract class FileSystemView
236    }    }
237    
238    /**    /**
239     * DOCUMENT ME!     * Returns the icon that would be displayed for the given file by the
240       * underlying system.  This implementation returns <code>null</code>,
241       * subclasses must override.
242     *     *
243     * @param f DOCUMENT ME!     * @param f  the file.
244     *     *
245     * @return DOCUMENT ME!     * @return <code>null</code>.
246     */     */
247    public Icon getSystemIcon(File f)    public Icon getSystemIcon(File f)
248    {    {
# Line 229  public abstract class FileSystemView Line 250  public abstract class FileSystemView
250    }    }
251    
252    /**    /**
253     * DOCUMENT ME!     * Returns the type description of a file that would be displayed by the
254       * underlying system.  This implementation returns <code>null</code>,
255       * subclasses must override.
256     *     *
257     * @param f DOCUMENT ME!     * @param f  the file.
258     *     *
259     * @return DOCUMENT ME!     * @return <code>null</code>.
260     */     */
261    public String getSystemTypeDescription(File f)    public String getSystemTypeDescription(File f)
262    {    {
# Line 253  public abstract class FileSystemView Line 276  public abstract class FileSystemView
276    }    }
277    
278    /**    /**
279     * DOCUMENT ME!     * Returns <code>true</code> if the given directory represents a disk
280       * drive, and <code>false</code> otherwise.  This default implementation
281       * always returns <code>false</code>.
282     *     *
283     * @param dir DOCUMENT ME!     * @param dir  the directory.
284     *     *
285     * @return DOCUMENT ME!     * @return <code>false</code>.
286     */     */
287    public boolean isDrive(File dir)    public boolean isDrive(File dir)
288    {    {
# Line 265  public abstract class FileSystemView Line 290  public abstract class FileSystemView
290    }    }
291    
292    /**    /**
293     * DOCUMENT ME!     * Returns <code>true</code> if <code>f</code> is a file or directory, and
294       * <code>false</code> otherwise.
295     *     *
296     * @param f DOCUMENT ME!     * @param f  the file/directory.
297     *     *
298     * @return DOCUMENT ME!     * @return <code>true</code> if <code>f</code> is a file or directory, and
299       * <code>false</code> otherwise.
300     */     */
301    public boolean isFileSystem(File f)    public boolean isFileSystem(File f)
302    {    {
# Line 277  public abstract class FileSystemView Line 304  public abstract class FileSystemView
304    }    }
305    
306    /**    /**
307     * DOCUMENT ME!     * Returns <code>true</code> if the given directory is a file system root,
308       * and <code>false</code> otherwise.
309     *     *
310     * @param dir DOCUMENT ME!     * @param dir  the directory.
311     *     *
312     * @return DOCUMENT ME!     * @return <code>true</code> if the given directory is a file system root,
313       *          and <code>false</code> otherwise.
314     */     */
315    public boolean isFileSystemRoot(File dir)    public boolean isFileSystemRoot(File dir)
316    {    {
# Line 296  public abstract class FileSystemView Line 325  public abstract class FileSystemView
325    }    }
326    
327    /**    /**
328     * DOCUMENT ME!     * Returns <code>true</code> if the given directory represents a floppy
329       * drive, and <code>false</code> otherwise.  This default implementation
330       * always returns <code>false</code>.
331     *     *
332     * @param dir DOCUMENT ME!     * @param dir  the directory.
333     *     *
334     * @return DOCUMENT ME!     * @return <code>false</code>.
335     */     */
336    public boolean isFloppyDrive(File dir)    public boolean isFloppyDrive(File dir)
337    {    {
# Line 308  public abstract class FileSystemView Line 339  public abstract class FileSystemView
339    }    }
340    
341    /**    /**
342     * DOCUMENT ME!     * Returns <code>true</code> if the given file is hidden, and
343       * <code>false</code> otherwise.
344     *     *
345     * @param f DOCUMENT ME!     * @param f  the file.
346     *     *
347     * @return DOCUMENT ME!     * @return <code>true</code> if the given file is hidden, and
348       *         <code>false</code> otherwise.
349     */     */
350    public boolean isHiddenFile(File f)    public boolean isHiddenFile(File f)
351    {    {
# Line 320  public abstract class FileSystemView Line 353  public abstract class FileSystemView
353    }    }
354    
355    /**    /**
356     * DOCUMENT ME!     * Returns <code>true</code> if <code>folder</code> is the parent of
357       * <code>file</code>, and <code>false</code> otherwise.
358     *     *
359     * @param folder DOCUMENT ME!     * @param folder  the folder (<code>null</code> not permitted).
360     * @param file DOCUMENT ME!     * @param file  the file (<code>null</code> not permitted).
361     *     *
362     * @return DOCUMENT ME!     * @return <code>true</code> if <code>folder</code> is the parent of
363       *         <code>file</code>, and <code>false</code> otherwise.
364     */     */
365    public boolean isParent(File folder, File file)    public boolean isParent(File folder, File file)
366    {    {
# Line 349  public abstract class FileSystemView Line 384  public abstract class FileSystemView
384    }    }
385    
386    /**    /**
387     * DOCUMENT ME!     * Returns <code>true</code> if the file is traversable, and
388       * <code>false</code> otherwise.  Here, all directories are considered
389       * traversable, and files are considered non-traversable.
390     *     *
391     * @param f DOCUMENT ME!     * @param f  the file or directory (<code>null</code> not permitted).
392     *     *
393     * @return DOCUMENT ME!     * @return <code>true</code> if the file is traversable, and
394       *         <code>false</code> otherwise.
395     */     */
396    public Boolean isTraversable(File f)    public Boolean isTraversable(File f)
397    {    {

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.10

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26