edu.iu.iv.common.util
Class MenuConfigFile

java.lang.Object
  |
  +--edu.iu.iv.common.util.MenuConfigFile

public class MenuConfigFile
extends java.lang.Object

A config file that describes the layout of the IVC user interface's menu. The config file can specify where and under what name each plugin appears, as well as the order of items in each submenu. Below is an example of the file format: # this is a comment [path] edu.iu.iv.gui.ExitPlugin: File/Exit edu.iu.iv.gui.NothingPlugin: File/Nothing, Visualization/Nothing # comments can appear on any empty line [order] : File, *, Visualization File: *, Exit Visualization: Nothing, * Each entry in the path section is a plugin classname, a colon, and a comma-delimited list of menu paths where the plugin is to appear in the menu. Each entry in the order section is a submenu's menu path followed by a colon and an ordered, comma-delimited list of the items in that submenu. The * wildcard item in each entry specifies where unknown plugins (those not listed in the path section) are to appear in the ordering if their default menu paths place them in the entry's submenu. If no * is present in an entry, unknown plugins are placed at the end of the entry's ordering.

Author:
Josh Bonner

Constructor Summary
MenuConfigFile(java.lang.String filename)
          Creates a new MenuConfigFile and initializes it from the given file.
 
Method Summary
 java.util.Map enforceOrder(java.util.Map pathToUnorderedMap)
          Uses this config file's menu ordering information to order the given submenu map.
 java.util.Map getPathOverrideMap()
          Returns the map of menu path overrides specified by this config file.
 void readFromFile(java.lang.String filename)
          Loads menu structure information from the given file.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MenuConfigFile

public MenuConfigFile(java.lang.String filename)
               throws java.io.IOException
Creates a new MenuConfigFile and initializes it from the given file.

Parameters:
filename - the file to read menu data from
Throws:
java.io.IOException - if there is an error reading from the file
Method Detail

readFromFile

public void readFromFile(java.lang.String filename)
                  throws java.io.IOException
Loads menu structure information from the given file.

Parameters:
filename - the file to read menu data from
Throws:
java.io.IOException - if there is an error reading from the file

getPathOverrideMap

public java.util.Map getPathOverrideMap()
Returns the map of menu path overrides specified by this config file. The map's keys are plugin class name Strings, and its values are Lists of menu path Strings identifying where the plugin will appear in the menu.

Returns:
the path override map

enforceOrder

public java.util.Map enforceOrder(java.util.Map pathToUnorderedMap)
Uses this config file's menu ordering information to order the given submenu map. Both the input and output map's keys are menu path Strings identifying submenus, and their values are Lists of menu path Strings specifying the order of the items in each submenu.

Parameters:
pathToUnorderedMap - a submenu map to be ordered
Returns:
the resultant ordered submenu map