Class IdvPreferenceManager

All Implemented Interfaces:
ActionListener, EventListener, IdvConstants

public class IdvPreferenceManager extends IdvManager implements ActionListener
This class is responsible for the preference dialog and managing general preference state. A set of PreferenceManager-s are added into the dialog. This class then constructs a tabbed pane window, one pane for each PreferenceManager. On the user's Ok or Apply the dialog will have each PreferenceManager apply its preferences.
Author:
IDV development team
  • Field Details

    • DATE_FORMATS

      public static final List<String> DATE_FORMATS
      Date formats
    • choosersToShow

      protected Hashtable choosersToShow
      A mapping that holds the choosers that should be shown
    • controlDescriptorsToShow

      protected Hashtable controlDescriptorsToShow
      A mapping that holds the control descriptors that should be shown
    • haveInitedControlDescriptorsToShow

      protected boolean haveInitedControlDescriptorsToShow
      Have we initialized the what control descriptors should be shown facility
    • showAllControls

      protected boolean showAllControls
      Should we show all of the display control descriptors
    • showAllChoosers

      protected boolean showAllChoosers
      Should all choosers be shown
    • haveInitedChoosersToShow

      protected boolean haveInitedChoosersToShow
      Have we initialized the what choosers should be shown facility
    • cbxToCdMap

      protected Hashtable cbxToCdMap
      mapping between checkbox and control descriptor
  • Constructor Details

    • IdvPreferenceManager

      public IdvPreferenceManager(IntegratedDataViewer idv)
      Create the dialog with the given idv
      Parameters:
      idv - The IDV
  • Method Details

    • add

      public void add(String tabLabel, String description, PreferenceManager listener, Container panel, Object data)
      Add in the given PreferenceManager with its associated GUI Container and data Object.
      Parameters:
      tabLabel - The tabbed pane label
      description - Text to make a JLabel from
      listener - The handler for this set of preferences
      panel - The gui for the preferences
      data - Associated data that is passed to the PreferenceManager when done
    • showTab

      public void showTab(String tabNameToShow)
      Show the tab whose title matches the given tabNameToShow. This can be a regular expression.
      Parameters:
      tabNameToShow - Tab name to show.
    • actionPerformed

      public void actionPerformed(ActionEvent event)
      Handle the CANCEL, HELP, OK and APPLY events
      Specified by:
      actionPerformed in interface ActionListener
      Overrides:
      actionPerformed in class WindowHolder
      Parameters:
      event - The event
    • windowIsClosing

      protected void windowIsClosing()
      Close the dialog
      Overrides:
      windowIsClosing in class WindowHolder
    • getWindowTitle

      public String getWindowTitle()
      Get the window title
      Overrides:
      getWindowTitle in class WindowHolder
      Returns:
      window title
    • show

      public void show()
      Show the dialog
      Overrides:
      show in class WindowHolder
    • initPreferences

      protected void initPreferences()
      Init the preference gui
    • apply

      public boolean apply()
      Apply the preferences
      Returns:
      ok
    • applyWidgets

      protected static void applyWidgets(Hashtable widgets, XmlObjectStore store)
      A utility that goes through the set of widgets (String preference name to UI widget), finds their value and adds it into the given store.
      Parameters:
      widgets - The preference name to GUI widget map
      store - The store to put preferences in.
    • addDisplayPreferences

      protected void addDisplayPreferences()
      Add in the user preference tab for the controls to show
    • addSystemPreferences

      protected void addSystemPreferences()
      Add in the user preference tab for the controls to show
    • exportControlsToPlugin

      public void exportControlsToPlugin()
      Export the selected control descriptors to the plugin manager
    • addChooserPreferences

      protected void addChooserPreferences()
      Add in the user preference tab for the choosers to show.
    • getDefaultTimeZone

      public TimeZone getDefaultTimeZone()
      Get the default time zone
      Returns:
      the default time zone
    • getDefaultDateFormat

      public String getDefaultDateFormat()
      Get the default date format
      Returns:
      the default time zone
    • addBasicPreferences

      protected void addBasicPreferences()
      Adds the basic preference tab
    • makePrefPanel

      public static JPanel makePrefPanel(Object[][] objects, Hashtable widgets, XmlObjectStore store)
      Make a checkbox preference panel
      Parameters:
      objects - Holds (Label, preference id, Boolean default value). If preference id is null then just show the label. If the entry is only length 2 (i.e., no value) then default to true.
      widgets - The map to store the id to widget
      store - Where toi look up the preference value
      Returns:
      The created panel
    • getDoRemoveBeforeOpening

      public boolean[] getDoRemoveBeforeOpening(String name)
      This determines whether the IDV should do a remove display and data before a bundle is loaded. It returns a 2 element boolean array. The first element is whether the open should take place at all. The second element determines whether displays and data should be removed before the load.
      Parameters:
      name - The bundle name - may be null.
      Returns:
      Element 0- did user hit cancel. Element 1 - Should remove data and displays. Element 2 Should merge element 3 did we ask the user
    • shouldShowControl

      public boolean shouldShowControl(ControlDescriptor cd)
      Should the given control descriptor be shown
      Parameters:
      cd - The control descriptor
      Returns:
      Should the cd be shown
    • shouldShowControl

      public boolean shouldShowControl(ControlDescriptor cd, boolean ignoreAllFlag)
      Should the given control descriptor be shown.
      Parameters:
      cd - The control descriptor
      ignoreAllFlag - If true then don't pay attention to the show all flag. We have this here so this can return the actual show value for the control descriptor when we are constructing the preference gui buttons.
      Returns:
      Should the cd be shown
    • shouldShowChooser

      public boolean shouldShowChooser(String chooserName)
      Check if the given chooser should be shown in the chooser gui. This will first try to read the user preference PROP_CHOOSERS (A hashtable). If null then it looks for the comma separated list of choosers from the property PROP_CHOOSERS.
      Parameters:
      chooserName - The name of the chooser.
      Returns:
      Should the chooser be shown.
    • shouldShowChooser

      protected boolean shouldShowChooser(String chooserName, boolean ignoreAllFlag)
      Should the named chooser be shown
      Parameters:
      chooserName - The chooser name
      ignoreAllFlag - If true then don't pay attention to the show all flag. We have this here so this can return the actual show value for the chooser when we are constructing the preference gui buttons.
      Returns:
      Should the chooser be shown
    • getDefaultDistanceUnit

      public Unit getDefaultDistanceUnit()
      Get the unit to be used to show distance
      Returns:
      default distance unit
    • getMouseMap

      public int[][][] getMouseMap()
      Get the mouse mapping preference. Always will return something
      Returns:
      mouse mappings
    • getWheelMap

      public int[][] getWheelMap()
      Get teh scroll wheel mappings
      Returns:
      scroll wheel mappings
    • getKeyboardMap

      public int[][] getKeyboardMap()
      Keyboard mappings
      Returns:
      keyboard mappings
    • applyEventPreferences

      protected void applyEventPreferences(XmlObjectStore theStore)
      Apply the mouse/scroll/keyboard preferences
      Parameters:
      theStore - The store
    • applyEventsToGui

      public void applyEventsToGui(List functions)
      Apply event mappings
      Parameters:
      functions - functions
    • makeEventPanel

      protected JComponent makeEventPanel()
      Make the mouse/scroll/key mapping panel
      Returns:
      mouse/scroll/key mapping panel