ucar.unidata.idv
Class StateManager

java.lang.Object
  extended by ucar.unidata.ui.WindowHolder
      extended by ucar.unidata.idv.IdvManager
          extended by ucar.unidata.idv.StateManager
All Implemented Interfaces:
ActionListener, EventListener, IdvConstants

public class StateManager
extends IdvManager

This class manages the intialize properties that configure the IDV and the persistent store for writing preferences, etc. to the user's local .unidata/idv directory

Author:
IDV development team

Field Summary
static String PREF_SunAwtDisableMixing
          disable mixing
protected  boolean showControlsInTree
          Do we show the DisplayControl-s in the DataTree-s.
protected  String userName
          The name of the user
 
Fields inherited from class ucar.unidata.ui.WindowHolder
contents, dialog, frame, window
 
Fields inherited from interface ucar.unidata.idv.IdvConstants
ARG_B64BUNDLE, ARG_B64ISL, 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_NOERRORSINGUI, 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_MAX_PERMGENSIZE, DEFAULT_TIMEZONE, 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_GEOMETRY_BY_REF, PREF_HISTORY, PREF_IMAGE_BY_REF, PREF_LASTVERSION, PREF_LATLON_FORMAT, PREF_LEGEND_SHOWICONS, PREF_LOCALE, PREF_LOOKANDFEEL, PREF_MAX_PERMGENSIZE, PREF_MAXIMAGESIZE, PREF_MEMORY, PREF_NPOT_IMAGE, 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_THREADS_DATA, PREF_THREADS_RENDER, PREF_TIMEZONE, PREF_VERTICALCS, PREF_VERTICALUNIT, PREF_WINDOW_SHOWTOOLBAR, 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_DISPLAYLIST_GROUP, PROP_FIXFILELOCKUP, PROP_JNLPCODEBASE, PROP_JNLPTEMPLATE, PROP_JNLPTITLE, PROP_LOADINGXML, PROP_MAP_GLOBE_LEVEL, PROP_MAP_MAP_LEVEL, PROP_MINIMUMFRAMECYCLETIME, PROP_MONITORPORT, PROP_OLDCONTROLDESCRIPTORS, PROP_ONEINSTANCEPORT, PROP_PREFERENCES, PROP_PROJ_NAME, PROP_RESOURCEFILES, PROP_SHOWCLOCK, PROP_SHOWDASHBOARD, PROP_SHOWDATATREE, PROP_SHOWFORMULAS, PROP_SHOWSPLASH, PROP_SPLASHICON, PROP_UI_DESKTOP, PROP_USE_TIMEDRIVER, 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
StateManager(IntegratedDataViewer idv)
          Create this manager
 
Method Summary
 String applyMacros(String s)
          Apply macros
protected  void applyPreferences()
          _more_
protected  IdvObjectStore doMakeObjectStore()
          Factory method to create the IdvObjectStore.
static String fixIds(String id)
          Change id from application.
 String getBuildDate()
          Get the build date
 Color getColorProperty(String name, Color dflt)
          Utility method to retrieve a String property from the idv properties.
 String getDefaultHelpTarget()
          Get the default help target.
 String getDefaultHelpUrl()
          Get the default base help url.
 String getHelpRoot()
          _more_
 String getJythonVersion()
          Get the jython version
 double getNumberVersion()
          Get major-minor as a number
 Object getPreference(String pref)
          Helper method that wraps getStore().get (pref)
 Object getPreference(String pref, Object dflt)
          Helper method that wraps getStore().get (pref)
 Object getPreferenceOrProperty(String pref)
          Find either the preference with the given name or, if not found, return the property value of the given name
 boolean getPreferenceOrProperty(String pref, boolean dflt)
          Find either the preference with the given name or, if not found, return the property String value of the given name if found.
 double getPreferenceOrProperty(String pref, double dflt)
          Find either the preference with the given name or, if not found, return the property String value of the given name if found.
 String getPreferenceOrProperty(String pref, String dflt)
          Find either the preference with the given name or, if not found, return the property String value of the given name if found.
protected  List getPreferencePaths()
          Get the preference paths
 Hashtable getProperties()
          Get the hashtable of properties
 Object getProperty(String name)
          Get a property
 boolean getProperty(String name, boolean dflt)
          Utility method to retrieve a boolean property from the idv properties.
 double getProperty(String name, double dflt)
          Utility method to retrieve an int property from the idv properties.
 int getProperty(String name, int dflt)
          Utility method to retrieve an int property from the idv properties.
 String getProperty(String name, String dflt)
          Utility method to retrieve a String property from the idv properties.
 boolean getRunningIsl()
          Get the RunningIsl property.
 boolean getShouldLoadBundlesSynchronously()
          Get the flag for loading bundles synchronously
 boolean getShowControlsInTree()
          Helper method to determine whether to show DisplayControl-s in the data choosing guis.
 boolean getShowDashboardOnStart()
          Lookup in the object store whether we should popup a DataSelector in a window on start up.
 IdvObjectStore getStore()
          Create the IdvObjectStore, if needed, and return it.
 String getStoreName()
          What is the store name.
 String getStoreSystemName()
          Get the name of the top level users directory.
 String getTitle()
          Return the title property
 String getUserName()
          Return the user name
 String getVersion()
          Read in and return the current version from the resources/VERSION file.
 String getVersionAbout()
          Get the version about
 String getVersionMajor()
          Get the major version
 String getVersionMinor()
          Get the minor version
 String getVersionRevision()
          Get the version revision
 Dimension getViewSize()
          Get the ViewSize property.
protected  void initNewUserDirectory(File dir)
          This gets called when we first create the users local object store directory.
protected  void initObjectStore(IdvObjectStore store)
          Initialize the given object store.
protected  void initState(boolean interactiveMode)
          Initialize the store, properties and IdvResourceManager
protected  void initUserDirectory(File dir)
          This gets called when after we have created the IdvObjectStore object For now this method just copies the default rbi file into the directory.
 boolean isLoadingXml()
          Returns whether we are currently unpersisting application state from xml.
protected  void loadProperties()
          Initialize the list of property files and load them into the idvProperties.
protected  Hashtable processPropertyTable(Hashtable newTable)
          Change property keys from application.
 void putPreference(String pref, Object value)
          Helper method that wraps getStore().put (pref value).
 void putProperty(String name, boolean value)
          Converts the given value to a String and sets the property name to the String value
 void putProperty(String name, String value)
          Sets the property name to the given value
 void setAlwaysLoadBundlesSynchronously(boolean value)
          Set the flag to load bundles synchronously
 void setRunningIsl(boolean value)
          Set the RunningIsl property.
 void setViewSize(Dimension value)
          Set the ViewSize property.
 void writePreference(String pref, Object value)
          Puts the given value in the object store and writes out the store.
 void writePreferences()
          Writes out the store.
 
Methods inherited from class ucar.unidata.idv.IdvManager
getArgsManager, getCollabManager, getColorTableManager, getDataManager, getIdv, getIdvChooserManager, getIdvClass, getIdvProjectionManager, getIdvUIManager, getImageGenerator, getInstallManager, getJythonManager, getPersistenceManager, getPreferenceManager, getPublishManager, getResourceManager, getStateManager, getStationModelManager, getVMManager, logException, showNormalCursor, showWaitCursor, waitUntilDisplaysAreDone, waitUntilDisplaysAreDone
 
Methods inherited from class ucar.unidata.ui.WindowHolder
actionPerformed, close, doMakeContents, getContents, getDialog, getFrame, getWindow, getWindowTitle, isShowing, removeAll, setMenuBar, setWindowTitle, shouldMakeDialog, show, show, showModal, toFront, windowIsClosing
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

showControlsInTree

protected boolean showControlsInTree
Do we show the DisplayControl-s in the DataTree-s.


userName

protected String userName
The name of the user


PREF_SunAwtDisableMixing

public static final String PREF_SunAwtDisableMixing
disable mixing

See Also:
Constant Field Values
Constructor Detail

StateManager

public StateManager(IntegratedDataViewer idv)
Create this manager

Parameters:
idv - The IDV
Method Detail

setAlwaysLoadBundlesSynchronously

public void setAlwaysLoadBundlesSynchronously(boolean value)
Set the flag to load bundles synchronously

Parameters:
value - true to load bundles synchronously

getShouldLoadBundlesSynchronously

public boolean getShouldLoadBundlesSynchronously()
Get the flag for loading bundles synchronously

Returns:
true if synchronous

processPropertyTable

protected Hashtable processPropertyTable(Hashtable newTable)
Change property keys from application. to idv.

Parameters:
newTable - The table to change
Returns:
The converted table

fixIds

public static String fixIds(String id)
Change id from application. to idv.

Parameters:
id - id to change
Returns:
changed id

loadProperties

protected void loadProperties()
Initialize the list of property files and load them into the idvProperties. The algorithm is as follows: first process the property files that are hard coded from the system (e.g., /ucar/unidata/idv/resources/idv.propertes, vgee.properties, etc.), then process any command line argument property files (which are added into the propertyFiles list)

Now, we look for an "idv.properties" property (which is a semi-colon delimited list of property file paths) in the currently processed property files. If there is one then we create the list of property files, expand any %SITEPATH%, %USERPATH%, etc., macros and process the properties.

Note: Expanding the SITEPATH/USERPATH macros ends up creating the IdvObjectStore (to find the value of SITEPATH/USERPATH/etc.). The tricky thing is that the creation of the object store requires some things that we get from the properties (like the store name). These have to come from the original set of system property files.


getHelpRoot

public String getHelpRoot()
_more_

Returns:
_more_

initState

protected void initState(boolean interactiveMode)
Initialize the store, properties and IdvResourceManager

Parameters:
interactiveMode - Is the idv in interactive mode (the default)

applyPreferences

protected void applyPreferences()
_more_


getPreferencePaths

protected List getPreferencePaths()
Get the preference paths

Returns:
the paths for preferences

applyMacros

public String applyMacros(String s)
Apply macros

Parameters:
s - string
Returns:
String with macros expanded

getProperties

public Hashtable getProperties()
Get the hashtable of properties

Returns:
the properties Hashtable

getProperty

public Object getProperty(String name)
Get a property

Parameters:
name - name of the property
Returns:
the property or null

getProperty

public boolean getProperty(String name,
                           boolean dflt)
Utility method to retrieve a boolean property from the idv properties. If the property does not exists return the given default value.

Overrides:
getProperty in class IdvManager
Parameters:
name - Property name
dflt - The default value to return if name is not found
Returns:
The property value converted into a boolean or dflt if not found

getProperty

public int getProperty(String name,
                       int dflt)
Utility method to retrieve an int property from the idv properties. If the property does not exists return the given default value.

Overrides:
getProperty in class IdvManager
Parameters:
name - Property name
dflt - The default value to return if name is not found
Returns:
The property value converted into an int or dflt if not found

getProperty

public double getProperty(String name,
                          double dflt)
Utility method to retrieve an int property from the idv properties. If the property does not exists return the given default value.

Parameters:
name - Property name
dflt - The default value to return if name is not found
Returns:
The property value converted into an int or dflt if not found

getProperty

public String getProperty(String name,
                          String dflt)
Utility method to retrieve a String property from the idv properties. If the property does not exists return the given default value.

Overrides:
getProperty in class IdvManager
Parameters:
name - Property name
dflt - The default value to return if name is not found
Returns:
The property value or dflt if not found

getColorProperty

public Color getColorProperty(String name,
                              Color dflt)
Utility method to retrieve a String property from the idv properties. If the property does not exists return the given default value.

Parameters:
name - Property name
dflt - The default value to return if name is not found
Returns:
The property value or dflt if not found

putProperty

public void putProperty(String name,
                        String value)
Sets the property name to the given value

Parameters:
name - Property name
value - The value

putProperty

public void putProperty(String name,
                        boolean value)
Converts the given value to a String and sets the property name to the String value

Parameters:
name - Property name
value - The value

getStore

public IdvObjectStore getStore()
Create the IdvObjectStore, if needed, and return it.

Overrides:
getStore in class IdvManager
Returns:
The object store

getDefaultHelpUrl

public String getDefaultHelpUrl()
Get the default base help url. This looks up the idv.help.defaulturl property. If its not there then it returns DEFAULT_DOCPATH

Returns:
The base help url

getDefaultHelpTarget

public String getDefaultHelpTarget()
Get the default help target. This just returns an empty string but could be overrode by a derived class.

Returns:
The default help target

isLoadingXml

public boolean isLoadingXml()
Returns whether we are currently unpersisting application state from xml.

Returns:
Is the IDV currently loading an xml bundle

getShowControlsInTree

public boolean getShowControlsInTree()
Helper method to determine whether to show DisplayControl-s in the data choosing guis.

Returns:
Should we show data choices in the gui

getUserName

public String getUserName()
Return the user name

Returns:
The user name

getTitle

public String getTitle()
Return the title property

Returns:
The title from the properties ("idv.title")

doMakeObjectStore

protected IdvObjectStore doMakeObjectStore()
Factory method to create the IdvObjectStore. This will also call initObjectStore(IdvObjectStore)

Returns:
A new object store.

initObjectStore

protected void initObjectStore(IdvObjectStore store)
Initialize the given object store. This mostly initializes the user's local .unidata/idv directory when it is first created.

Parameters:
store - The object store to initialize

getStoreName

public String getStoreName()
What is the store name. This is either the value of the idv.store.name property or the tail class name of the IDV class (e.g., DefaultIdv).

Returns:
The name of the store. This ends up being the name of the subdirectory of the ~/.unidata/idv base directory.

getStoreSystemName

public String getStoreSystemName()
Get the name of the top level users directory. It is either the value of the idv.store.system property or "unidata/idv"

Returns:
The system name

initNewUserDirectory

protected void initNewUserDirectory(File dir)
This gets called when we first create the users local object store directory.

Parameters:
dir - The new directory

initUserDirectory

protected void initUserDirectory(File dir)
This gets called when after we have created the IdvObjectStore object For now this method just copies the default rbi file into the directory. This makes it easier for a user to do further rbi based configurations.

Parameters:
dir - The store directory

writePreference

public void writePreference(String pref,
                            Object value)
Puts the given value in the object store and writes out the store.

Parameters:
pref - The name
value - The value

writePreferences

public void writePreferences()
Writes out the store.


putPreference

public void putPreference(String pref,
                          Object value)
Helper method that wraps getStore().put (pref value). This does not write out the store.

Parameters:
pref - The name
value - The value

getPreference

public Object getPreference(String pref)
Helper method that wraps getStore().get (pref)

Parameters:
pref - The name of the preference
Returns:
The value of the preference

getPreference

public Object getPreference(String pref,
                            Object dflt)
Helper method that wraps getStore().get (pref)

Parameters:
pref - The name of the preference
dflt - The default value to use if pref is not found.
Returns:
The value of the preference of the dflt if not found

getPreferenceOrProperty

public Object getPreferenceOrProperty(String pref)
Find either the preference with the given name or, if not found, return the property value of the given name

Parameters:
pref - The preference or property name
Returns:
The value of either the preference or the property

getPreferenceOrProperty

public String getPreferenceOrProperty(String pref,
                                      String dflt)
Find either the preference with the given name or, if not found, return the property String value of the given name if found. If not found return the dflt

Parameters:
pref - The preference or property name
dflt - default
Returns:
The value of either the preference or the property

getPreferenceOrProperty

public double getPreferenceOrProperty(String pref,
                                      double dflt)
Find either the preference with the given name or, if not found, return the property String value of the given name if found. If not found return the dflt

Parameters:
pref - The preference or property name
dflt - default
Returns:
The value of either the preference or the property

getPreferenceOrProperty

public boolean getPreferenceOrProperty(String pref,
                                       boolean dflt)
Find either the preference with the given name or, if not found, return the property String value of the given name if found. If not found return the dflt

Parameters:
pref - The preference or property name
dflt - default
Returns:
The value of either the preference or the property

getShowDashboardOnStart

public boolean getShowDashboardOnStart()
Lookup in the object store whether we should popup a DataSelector in a window on start up.

Returns:
Should we show the data selector on start up

getJythonVersion

public String getJythonVersion()
Get the jython version

Returns:
The jython version

getVersionMajor

public String getVersionMajor()
Get the major version

Returns:
The major version

getVersionMinor

public String getVersionMinor()
Get the minor version

Returns:
The minor version

getVersionRevision

public String getVersionRevision()
Get the version revision

Returns:
The version revision

getVersionAbout

public String getVersionAbout()
Get the version about

Returns:
The version about

getVersion

public String getVersion()
Read in and return the current version from the resources/VERSION file.

Returns:
The IDV version

getBuildDate

public String getBuildDate()
Get the build date

Returns:
build date

getNumberVersion

public double getNumberVersion()
Get major-minor as a number

Returns:
number version

setViewSize

public void setViewSize(Dimension value)
Set the ViewSize property.

Parameters:
value - The new value for ViewSize

getViewSize

public Dimension getViewSize()
Get the ViewSize property.

Returns:
The ViewSize

setRunningIsl

public void setRunningIsl(boolean value)
Set the RunningIsl property.

Parameters:
value - The new value for RunningIsl

getRunningIsl

public boolean getRunningIsl()
Get the RunningIsl property.

Returns:
The RunningIsl