Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4810174

RFE: Missing documentation makes it difficult to extend FilesystemView

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Duplicate
    • P4
    • None
    • 1.4.1
    • client-libs

    Description



      Name: rmT116609 Date: 01/29/2003


      DESCRIPTION OF THE PROBLEM :
      I have successfully extended the FilesystemView to browser a remote filesystem (Unix or Windows) using JFileChooser. Though some tutorials exist, the common expectation on the forum is that it can't be done.

      To finally get the JFileChooser to allow DIRECTORY selection (as opposed to file selection), I had to change the value returned by my extended
      FilesystemView.isFileSystem(File).

      To know to do this, I had to look at the source to MetalFileChooserUI.java, since the API does not explain what this method is supposed to return. Always returning false from it (as I had done previously) prevents Directory selection.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. look at
      http://java.sun.com/j2se/1.4.1/docs/api/javax/swing/filecho
      oser/FileSystemView.html#isFileSystem(java.io.File)


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      I expected the documentation to give at least a 1-line comment about what this method is supposed to return, so that developers trying to extend it know what to do without browsing through Sun code.

      ---------- BEGIN SOURCE ----------
      in FilesystemView extension:
      public boolean isFileSystem(File f)
      {
        return false;//???? API does not explain this method
      }

      in code bringing up the JFileChooser:
      chooser.setFileFilter(new FileFilterWrapper(new DirectoryFileFilter
      (), "Directories Only"));
      chooser.setFileHidingEnabled(true);
      chooser.setMultiSelectionEnabled(false);
      chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

      ---------- END SOURCE ----------

      CUSTOMER WORKAROUND :
      public boolean isFileSystem(File f)
      {
      // the documentation says absolutely nothing about
      this method
      // but it appears that it will fail to do
      JFileChooser.DIRECTORIES_ONLY
      // if the isFileSystem(theDirectory) returns false.
      return f.isDirectory();
      }
      (Review ID: 180538)
      ======================================================================

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              rmandalasunw Ranjith Mandala (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: