Class IdvResourceManager

All Implemented Interfaces:
ActionListener, EventListener, HyperlinkListener, IdvConstants

public class IdvResourceManager extends IdvManager implements HyperlinkListener
This class manages the set of resources that are used to instantiate the IDV. The idea is that the idv has a number of "rbi" (resource bundle for the idv) files that define the different collections of resources. For each collection (e.g., colortables, derived quantities) there is a list of locations that specify the file (either xml or text) that defines the particular resource.

For example in resources/idv.rbi we have:

 <resources name="idv.resource.colortables">
   <resource location="%USERPATH%/colortables.xml"/>
   <resource location="%SITEPATH%/colortables.xml"/>
   <resource location="%IDVPATH%/colortables.xml"/>
 </resources>
 
This defines the collection of color table resources. The %USERPATH%, etc., are macros that are replaced with the corresponding value.

This class has a set of static IdvResource and XmlIdvResource members, one for each resource collection, e.g., RSC_COLORTABLES. The IdvResource objects are those that point to text resources. The XmlIdvResource objects point to xml files. These objects provide methods to access the ResourceCollection and XmlResourceCollection objects that actually do the work of reading in the resources, creating the xml doms, etc.

Author:
IDV development team
  • Field Details

  • Constructor Details

    • IdvResourceManager

      public IdvResourceManager(IntegratedDataViewer idv)
      Create me
      Parameters:
      idv - The IDV
  • Method Details

    • getResources

      public List getResources()
      Get the resources
      Returns:
      List of all resources
    • getResourcesForUser

      public List getResourcesForUser()
      Get the list of resources for the user
      Returns:
      the list of resources
    • getResources

      public ResourceCollection getResources(IdvResourceManager.IdvResource resource)
      Create, if needed, and return the ResourceCollection that is represented by the given resource.
      Parameters:
      resource - The resource
      Returns:
      The resource collection
    • getXmlResources

      public XmlResourceCollection getXmlResources(IdvResourceManager.IdvResource resource)
      Create, if needed, and return the XmlResourceCollection that is represented by the given resource.
      Parameters:
      resource - The resource
      Returns:
      The resource collection
    • clearDefaultBundles

      public void clearDefaultBundles()
      Remove all default bundles
    • showHtmlView

      public void showHtmlView()
      Show the html representation of the list of resources
    • getHtmlView

      public String getHtmlView()
      Create the html representation of the list of resources.
      Returns:
      The html
    • hyperlinkUpdate

      public void hyperlinkUpdate(HyperlinkEvent e)
      Respond to events from the html view. Bring up the editor for the resource if there is one, etc.
      Specified by:
      hyperlinkUpdate in interface HyperlinkListener
      Parameters:
      e - The event
    • processRbi

      public void processRbi(Element root)
      Process the top level root of the rbi xml file
      Parameters:
      root - The root of the rbi file
    • processRbi

      protected void processRbi(Element root, boolean payAttentionToLoadMore)
      Process the top level root of the rbi xml file
      Parameters:
      root - The root of the rbi file
      payAttentionToLoadMore - Flags whether we should stop processing when we encounter a "loadmore" tag in the rbi xml
    • createResourceCollection

      protected ResourceCollection createResourceCollection(String id)
      Create, if needed, and return the ResourceCollection defined by the given id
      Parameters:
      id - The id of the resource, e.g., idv.resource.colortables
      Returns:
      The resource collection
    • createXmlResourceCollection

      protected XmlResourceCollection createXmlResourceCollection(String id)
      Create, if needed, and return the XmlResourceCollection defined by the given id
      Parameters:
      id - The id of the resource, e.g., idv.resource.colortables
      Returns:
      The xml resource collection
    • getResources

      public ResourceCollection getResources(String id)
      Lookup up in the resource collections map the ResouceCollection with the given id
      Parameters:
      id - The resource id
      Returns:
      The resource collection or null if not found
    • removeResources

      public void removeResources(String id)
      Remove the resources identified by id
      Parameters:
      id - id of the resource to remove
    • getXmlResources

      public XmlResourceCollection getXmlResources(String name)
      Lookup up in the resource collections map the XmlResouceCollection with the given id
      Parameters:
      name - The resource name
      Returns:
      The xml resource collection or null if not found
    • init

      protected void init(List rbiFiles)
      Create the set of resources (defined in the idv.properties file) and do the relevant initializations.
      Parameters:
      rbiFiles - List of rbi files
    • getResourceList

      protected List getResourceList(String propName)
      Do a property lookup of the given resource list property. Turn the String property value (";" delimited) into a List of Strings Do a textual substitution of a set of macros with their values (e.g., %USERPATH%).
      Parameters:
      propName - The property name
      Returns:
      List of expanded Strings
    • getResourcePaths

      public List getResourcePaths(List paths)
      For each string in the given paths list do a textual substitution of a set of macros with their values (e.g., %USERPATH%).
      Parameters:
      paths - Incoming strings
      Returns:
      Expanded strings
    • clearResourceMacros

      public void clearResourceMacros()
      Clear the macro values
    • getMacroMap

      protected Hashtable getMacroMap()
      Get map of macro name -> value. eg: the SITEPATH, USERPATH, etc.
      Returns:
      macros
    • getResourcePath

      public String getResourcePath(String path)
      Do the macro expansion
      Parameters:
      path - Macro containing patha
      Returns:
      Expanded path
    • getLocationList

      public List getLocationList()
      Create (if null) and return the list NamedStationTable-s defined by the locationResources XmlResourceCollection.
      Returns:
      List of named station tables
    • getIdvResourcePath

      public String getIdvResourcePath()
      Return the path used to substitute the %IDVPATH% macro for in the resource list properties.
      Returns:
      idv path
    • getUserHome

      public String getUserHome()
      Return the path used to substitute the %USERHOME% macro for in the resource list properties.
      Returns:
      idv path
    • getDataResourcePath

      public String getDataResourcePath()
      Return the path used to substitute the %DATAPATH% macro for in the resource list properties.
      Returns:
      The data path
    • getAppResourcePath

      public String getAppResourcePath()
      Return the path used to substitute the %APPPATH% macro for in the resource list properties.
      Returns:
      The app path
    • getSitePath

      public String getSitePath()
      Return the path used to substitute the %SITEPATH% macro for in the resource list properties.
      Returns:
      The site path
    • getUserPath

      public String getUserPath()
      Return the path used to substitute the %USERPATH% macro for in the resource list properties.
      Returns:
      The user path (e.g., ~/.unidata/idv/DefaultIdv)
    • removeLocalMaps

      public boolean removeLocalMaps(boolean forGlobe)
      Remove any local maps.xml file
      Parameters:
      forGlobe - if true then use the globemaps resource
      Returns:
      Was there one removed
    • getMapResources

      public XmlResourceCollection getMapResources(boolean forGlobe)
      _more_
      Parameters:
      forGlobe - _more_
      Returns:
      _more_
    • getMaps

      public List<MapData> getMaps()
      _more_
      Returns:
      _more_
    • createMapInfo

      public MapInfo createMapInfo(boolean forGlobe)
      A utility to instantiate a MapInfo from the maps resources
      Parameters:
      forGlobe - if true then use the globemaps resource
      Returns:
      The MapInfo holding the map stuff.
    • writeMapState

      public void writeMapState(String mapsXml, boolean forGlobe)
      Write out the given maps xml to the writable resource
      Parameters:
      mapsXml - The maps xml
      forGlobe - if true then use the globemaps resource
    • getDefaultStations

      public NamedStationTable getDefaultStations()
      Find the default NamedStationTable
      Returns:
      The default stations
    • findLocationsByType

      public List findLocationsByType(String type)
      Find the NamedStationTable with the given name
      Parameters:
      type - type
      Returns:
      The list of stations
    • findLocations

      public NamedStationTable findLocations(String name)
      Find the NamedStationTable with the given name
      Parameters:
      name - Name of station
      Returns:
      The station
    • getResourceUrlBase

      public String getResourceUrlBase()
      A hardcoded url base to find resources at
      Returns:
      http url resource base
    • getTransects

      public List getTransects()
      Get the list of transects
      Returns:
      List of transects
    • writeTransects

      public void writeTransects(List t)
      Write the non-system transects in the list to the users transects resource file
      Parameters:
      t - List of transects
    • getDisplaySettings

      public List<DisplaySetting> getDisplaySettings()
      Get all display settings
      Returns:
      display settings
    • findDisplaySetting

      public DisplaySetting findDisplaySetting(String name)
      Find display setting by name
      Parameters:
      name - name
      Returns:
      displaysetting
    • displaySettingChanged

      public void displaySettingChanged(DisplaySetting displaySetting)
      handle when a display setting changed
      Parameters:
      displaySetting - display setting that changed
    • addDisplaySetting

      public void addDisplaySetting(DisplaySetting displaySetting)
      Add new display setting
      Parameters:
      displaySetting - display setting
    • removeDisplaySettings

      public void removeDisplaySettings(List<DisplaySetting> list)
      Remove list of display settings
      Parameters:
      list - list
    • removeDisplaySetting

      public void removeDisplaySetting(DisplaySetting displaySetting)
      Remove display setting
      Parameters:
      displaySetting - display setting
    • getDisplaySettingsTimestamp

      public long getDisplaySettingsTimestamp()
      get timestamp
      Returns:
      timestamp_
    • getTranslationsHashtable

      public Map<String,Map<Integer,String>> getTranslationsHashtable()