ucar.unidata.idv
Class IdvPreferenceManager

java.lang.Object
  extended by ucar.unidata.ui.WindowHolder
      extended by ucar.unidata.idv.IdvManager
          extended by ucar.unidata.idv.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 Summary
protected  Hashtable cbxToCdMap
          mapping between checkbox and control descriptor
protected  Hashtable choosersToShow
          A mapping that holds the choosers that should be shown
protected  Hashtable controlDescriptorsToShow
          A mapping that holds the control descriptors that should be shown
protected  boolean haveInitedChoosersToShow
          Have we initialized the what choosers should be shown facility
protected  boolean haveInitedControlDescriptorsToShow
          Have we initialized the what control descriptors should be shown facility
protected  boolean showAllChoosers
          Should all choosers be shown
protected  boolean showAllControls
          Should we show all of the display control descriptors
 
Fields inherited from class ucar.unidata.ui.WindowHolder
contents, dialog, frame, window
 
Fields inherited from interface ucar.unidata.idv.IdvConstants
ARG_B64BUNDLE, ARG_BUNDLE, ARG_CATALOG, ARG_CHOOSER, ARG_CLEARDEFAULT, ARG_CODE, ARG_CONNECT, ARG_CURRENTTIME, ARG_DATA, ARG_DEBUG, ARG_DEFAULT, ARG_DISPLAY, ARG_DXML, ARG_FIXEDTIME, ARG_HELP, ARG_IMAGE, ARG_IMAGESERVER, ARG_INSTALLPLUGIN, ARG_ISLFILE, ARG_ISLINTERACTIVE, ARG_LISTRESOURCES, ARG_MAINCLASS, ARG_MOVIE, ARG_MSG_DEBUG, ARG_MSG_RECORD, ARG_NODEFAULT, ARG_NOGUI, ARG_NOONEINSTANCE, ARG_NOPLUGINS, ARG_NOPREF, ARG_ONEINSTANCEPORT, ARG_PLUGIN, ARG_PORT, ARG_PRINTJNLP, ARG_PROPERTIES, ARG_SCRIPT, ARG_SERVER, ARG_SETFILES, ARG_SITEPATH, ARG_TEMPLATE, ARG_TEST, ARG_TESTEVAL, ARG_TRACE, ARG_TRACEONLY, ARG_USERPATH, DEFAULT_DATE_FORMAT, DEFAULT_DOCPATH, DEFAULT_TIMEZONE, FILE_VMSTATE, FILTER_CPT, FILTER_ISL, FILTER_JNLP, FILTER_XIDV, FILTER_XIDVZIDV, FILTER_XML, FILTER_ZIDV, ID_COMMANDSTORUN, ID_DATASOURCES, ID_DISPLAYCONTROLS, ID_IDV, ID_JYTHON, ID_MESSAGE, ID_MISCHASHTABLE, ID_VERSION, ID_VIEWMANAGERS, ID_WINDOWS, INITIAL_PROBE_EARTHLOCATION, NULL_DATA_SELECTION, NULL_STRING, PREF_ARCHIVEDIR, PREF_ARCHIVENAME, PREF_AUTODISPLAYS_ENABLE, PREF_AUTODISPLAYS_SHOWGUI, PREF_AUTOSELECTDATA, PREF_CACHESIZE, PREF_CONTROLSINTABS, PREF_DATAPREFIX, PREF_DATE_FORMAT, PREF_DISTANCEUNIT, PREF_DOCACHE, PREF_EMBEDDATACHOOSERINDASHBOARD, PREF_EMBEDFIELDSELECTORINDASHBOARD, PREF_EMBEDLEGENDINDASHBOARD, PREF_EMBEDQUICKLINKSINDASHBOARD, PREF_EVENT_KEYBOARDMAP, PREF_EVENT_MOUSEMAP, PREF_EVENT_WHEELMAP, PREF_FAST_RENDER, PREF_FIELD_CACHETHRESHOLD, PREF_FILEREADDIR, PREF_FILEWRITEDIR, PREF_HISTORY, PREF_LASTVERSION, PREF_LATLON_FORMAT, PREF_LOCALE, PREF_LOOKANDFEEL, PREF_MAXIMAGESIZE, PREF_OPEN_ASK, PREF_OPEN_MERGE, PREF_OPEN_REMOVE, PREF_PROJ_LIST, PREF_SAMPLINGMODE, PREF_SHOWCONTROLWINDOW, PREF_SHOWDASHBOARD, PREF_SHOWDECODEDIALOG, PREF_SHOWHIDDENFILES, PREF_SHOWQUITCONFIRM, PREF_SITEPATH, PREF_TIMEZONE, PREF_VERTICALCS, PREF_VERTICALUNIT, PREF_ZIDV_ASK, PREF_ZIDV_DIRECTORY, PREF_ZIDV_SAVETOTMP, PROP_3DMODE, PROP_ABOUTTEXT, PROP_APPRESOURCEPATH, PROP_CHOOSERS, PROP_CHOOSERS_ALL, PROP_CONTROLDESCRIPTORS, PROP_CONTROLDESCRIPTORS_ALL, PROP_DATAHOLDERBOUNDS, PROP_DEFAULTLOCATIONS, PROP_JNLPCODEBASE, PROP_JNLPTEMPLATE, PROP_JNLPTITLE, PROP_LOADINGXML, PROP_OLDCONTROLDESCRIPTORS, PROP_ONEINSTANCEPORT, PROP_PREFERENCES, PROP_PROJ_NAME, PROP_RESOURCEFILES, PROP_SHOWDASHBOARD, PROP_SHOWDATATREE, PROP_SHOWFORMULAS, PROP_SHOWSPLASH, PROP_SPLASHICON, PROP_UI_DESKTOP, PROP_VERSIONFILE, PROP_WINDOW_SCREENSIZEOFFSET, PROP_WINDOW_SIZEHEIGHT, PROP_WINDOW_SIZEWIDTH, PROP_WINDOW_USESCREENSIZE, SUFFIX_BAT, SUFFIX_CPT, SUFFIX_ISL, SUFFIX_JNLP, SUFFIX_RBI, SUFFIX_SH, SUFFIX_XIDV, SUFFIX_XML, SUFFIX_ZIDV
 
Constructor Summary
IdvPreferenceManager(IntegratedDataViewer idv)
          Create the dialog with the given idv
 
Method Summary
 void actionPerformed(ActionEvent event)
          Handle the CANCEL, HELP, OK and APPLY events
 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.
protected  void addBasicPreferences()
          Adds the basic preference tab
protected  void addChooserPreferences()
          Add in the user preference tab for the choosers to show.
protected  void addDisplayPreferences()
          Add in the user preference tab for the controls to show
 boolean apply()
          Apply the preferences
protected  void applyEventPreferences(XmlObjectStore theStore)
          Apply teh mouse/scroll/keyboard preferences
 void applyEventsToGui(List functions)
          Apply event mappings
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.
 void exportControlsToPlugin()
          Export the selected control descriptors to the plugin manager
 String getDefaultDateFormat()
          Get the default date format
 Unit getDefaultDistanceUnit()
          Get the unit to be used to show distance
 TimeZone getDefaultTimeZone()
          Get the default time zone
 boolean[] getDoRemoveBeforeOpening(String name)
          This determines whether the IDV should do a remove display and data before a bundle is loaded.
 int[][] getKeyboardMap()
          Keyboard mappings
 int[][][] getMouseMap()
          Get the mouse mapping preference.
 int[][] getWheelMap()
          Get teh scroll wheel mappings
 String getWindowTitle()
          Get the window title
protected  void initPreferences()
          Init the preference gui
protected  JComponent makeEventPanel()
          Make the mouse/scroll/key mapping panel
static JPanel makePrefPanel(Object[][] objects, Hashtable widgets, XmlObjectStore store)
          Make a checkbox preference panel
 boolean shouldShowChooser(String chooserName)
          Check if the given chooser should be shown in the chooser gui.
protected  boolean shouldShowChooser(String chooserName, boolean ignoreAllFlag)
          Should the named chooser be shown
 boolean shouldShowControl(ControlDescriptor cd)
          Should the given control descriptor be shown
 boolean shouldShowControl(ControlDescriptor cd, boolean ignoreAllFlag)
          Should the given control descriptor be shown.
 void show()
          Show the dialog
 void showTab(String tabNameToShow)
          Show the tab whose title matches the given tabNameToShow.
protected  void windowIsClosing()
          Close the dialog
 
Methods inherited from class ucar.unidata.idv.IdvManager
getArgsManager, getCollabManager, getColorTableManager, getDataManager, getIdv, getIdvChooserManager, getIdvClass, getIdvProjectionManager, getIdvUIManager, getImageGenerator, getJythonManager, getPersistenceManager, getPreferenceManager, getProperty, getProperty, getProperty, getPublishManager, getResourceManager, getStateManager, getStationModelManager, getStore, getVMManager, logException, showNormalCursor, showWaitCursor, waitUntilDisplaysAreDone
 
Methods inherited from class ucar.unidata.ui.WindowHolder
close, doMakeContents, getContents, getDialog, getFrame, getWindow, isShowing, removeAll, setWindowTitle, shouldMakeDialog, show, showModal, toFront
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

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


controlDescriptorsToShow

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


haveInitedChoosersToShow

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


choosersToShow

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


showAllChoosers

protected boolean showAllChoosers
Should all choosers be shown


cbxToCdMap

protected Hashtable cbxToCdMap
mapping between checkbox and control descriptor

Constructor Detail

IdvPreferenceManager

public IdvPreferenceManager(IntegratedDataViewer idv)
Create the dialog with the given idv

Parameters:
idv - The IDV
Method Detail

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


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.

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 teh 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