Class 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 Details

    • 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:
  • Constructor Details

    • StateManager

      public StateManager(IntegratedDataViewer idv)
      Create this manager
      Parameters:
      idv - The IDV
  • Method Details

    • 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 static 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