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

Create common File Open / Save Dialogs

XMLWordPrintable

      Add built-in support for File dialogs (open and save). Although glass already has this support, it needs to be surfaced as public API. There should be a goal towards common use cases and minimal API, and using native dialogs rather than custom controls.

      An example of such an API follows, and is modeled closely on the underlying Glass design:

      /**
       * A classic FileDialog. On some platforms where file access may be restricted or
       * not part of the user model (for example, on some mobile devices), opening
       * a file dialog may always result in a no-op (that is, null file(s) being returned).
       * <p>
       * If the same FileDialog is reused, it will remember the last directory that
       * had been visited.
       */
      public final class FileDialog {
          /**
           * Defines an extension filter, used for filtering which files can be chosen
           * in a FileDialog based on the file name extensions. An optional description
           * may be provided.
           */
          public static final class ExtensionFilter {
              /**
               * Creates an {@code ExtensionFilter} with the specified description
               * and the file name extensions.
               *
               * @param description the textual description for the filter
               * @param extensions the accepted file name extensions
               * @throws IllegalArgumentException
               * if the description of the filter is {@code null} or empty
               * @throws IllegalArgumentException
               * if the extensions is {@code null}, empty or contains an empty string
               */
              public ExtensionFilter(String description, List<String> extensions) { ... }
              public ExtensionFilter(String description, String... extensions) { ... }
              public final String getDescription() { ... }
              public final List<String> getExtensions() { ... }
          }

          public final String getText() { ... }
          public final void setText(String value) { ... }
          public final StringProperty textProperty() { ... }

          public final File getInitialDirectory() { ... }
          public final void setInitialDirectory(File value) { ... }
          public final ObjectProperty<File> initialDirectoryProperty() { ... }

          public final File getPreviousDirectory() { ... }
          public final ReadOnlyObjectProperty<File> previousDirectoryProperty() { ... }

          public final ObservableList<ExtensionFilter> getExtensionFilters() { ... }

          public FileDialog() { }

          public File open() { ... }

          public List<File> openMultiple() { ... }

          public File save() { ... }
      }

            lnerad Ľubomír Nerád (Inactive)
            rbair Richard Bair (Inactive)
            Votes:
            4 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: