Class PathPreferenceSelector

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible, RootPaneContainer, ScrollPaneConstants, WindowConstants

public class PathPreferenceSelector extends JDialog implements ScrollPaneConstants
Dialog box for selecting a file path and saving it as the default URL spec in a preference. The dialog box presents the user with a field for entering the path or the option of browsing to the path. A button allows the user to make the path the default path. The default path is stored as a URL spec via a Preferences instance provided in the constructor.
Author:
tap
See Also:
  • Field Details

    • chooser

      protected xal.tools.apputils.CustomChooser chooser
    • urlField

      protected JTextArea urlField
    • browseButton

      protected JButton browseButton
    • commitButton

      protected JButton commitButton
    • revertButton

      protected JButton revertButton
  • Constructor Details

    • PathPreferenceSelector

      public PathPreferenceSelector(Preferences defaults, String urlKey, String suffix, String description)
      Constructor
      Parameters:
      defaults - The Preferences instance that stores the default URL spec of the path.
      urlKey - The preference key used for associating the URL spec to store.
      suffix - The suffix used to filter files in the file chooser.
      description - The description used to label the files.
    • PathPreferenceSelector

      public PathPreferenceSelector(Frame owner, Preferences defaults, String urlKey, String suffix, String description)
      Constructor
      Parameters:
      owner - The frame which owns this dialog.
      defaults - The Preferences instance that stores the default URL spec of the path.
      urlKey - The preference key used for associating the URL spec to store.
      suffix - The suffix used to filter files in the file chooser.
      description - The description used to label the files.
    • PathPreferenceSelector

      public PathPreferenceSelector(Dialog owner, Preferences defaults, String urlKey, String suffix, String description)
      Constructor
      Parameters:
      owner - The dialog which owns this dialog.
      defaults - The Preferences instance that stores the default URL spec of the path.
      urlKey - The preference key used for associating the URL spec to store.
      suffix - The suffix used to filter files in the file chooser.
      description - The description used to label the files.
  • Method Details

    • setup

      protected void setup(Preferences defaults, String urlKey, String suffix, String description)
      Initialize the dialog box and the file chooser
      Parameters:
      defaults - The Preferences instance that stores the default URL spec of the path.
      urlKey - The preference key used for associating the URL spec to store.
      suffix - The suffix used to filter files in the file chooser.
      description - The description used to label the files.
    • initComponents

      protected void initComponents()
      initialize the view
    • browsePath

      protected void browsePath()
      Handle the browse button action
    • commitChanges

      protected void commitChanges()
      Handle the commit button action
    • revertPath

      protected void revertPath()
      Handle the revert button action
    • close

      protected void close()
      Hide and dispose of the dialog box.
    • textChanged

      protected void textChanged(DocumentEvent event)
      Handle the text changed event by updating the view to reflect the present state.
      Parameters:
      event - The document's "text changed" event.
    • hasSavedChanges

      public boolean hasSavedChanges()
      Determines whether the user has actually committed changes.
      Returns:
      true if the user has saved changes
    • hasUnsavedChanges

      public boolean hasUnsavedChanges()
      Determine if there are any unsaved changes
      Returns:
      true if there are unsaved changes and false if not.
    • updateView

      protected void updateView()
      Update the view to reflect the model