bill.util.gui
Class ProjectConfiguration

java.lang.Object
  |
  +--bill.util.gui.ProjectConfiguration

public class ProjectConfiguration
extends Object

Class responsible for reading and writing the project configuration file. This gives the project some state, so key information is not lost between executions of the project. The file stores the following:

Look and Feel The look and feel the user last selected.
Last Directory The last directory the user read or wrote a save file to. This is used to set the file selection dialog to this directory when it is created instead of it using a default directory.
Last x Files The last x files the user opened or saved. These will be displayed in the file menu as options for the user to open.
Highlighting Indicates whether required input fields should be highlighted as a visual indication to the user.
Tool Tips Indicates whether floating tool tips (hover help) should be displayed to the user.


Field Summary
protected  Configuration _parser
          The parsed project data configuration file
static String ITEM_HIGHLIGHTING
          Entry within the config document representing the highlighting state
static String ITEM_LAST_DIRECTORY
          Entry within the config document representing the last directory accessed
static String ITEM_LAST_FILE
          Entry within the config document representing the most recent files used.
static String ITEM_LOOK_FEEL
          Entry within the config document representing the look & feel
static String ITEM_MAX_LAST_FILES
          Entry within the config document representing the maximum number of "last files" to store
static String ITEM_TOOL_TIPS
          Entry within the config document representing the tool tips
static String SECTION_PROJECT
          Top level section within the config document
 
Constructor Summary
ProjectConfiguration()
          Default class instance creator.
ProjectConfiguration(String fileName)
          Default class instance creator.
 
Method Summary
 String getConfigEntry(String entry)
          Retrieves the value of the specified configuration entry from the project configuration file.
 boolean getConfigEntryAsBoolean(String entry)
          Retrieves the value of the specified configuration entry from the project configuration file as a boolean value.
 double getConfigEntryAsDouble(String entry)
          Retrieves the value of the specified configuration entry from the project configuration file as a double value.
 float getConfigEntryAsFloat(String entry)
          Retrieves the value of the specified configuration entry from the project configuration file as a float value.
 int getConfigEntryAsInteger(String entry)
          Retrieves the value of the specified configuration entry from the project configuration file as an integer value.
 int getConfigEntryAsInteger(String entry, int radix)
          Retrieves the value of the specified configuration entry from the project configuration file as an integer value.
 long getConfigEntryAsLong(String entry)
          Retrieves the value of the specified configuration entry from the project configuration file as a numeric long value.
 long getConfigEntryAsLong(String entry, int radix)
          Retrieves the value of the specified configuration entry from the project configuration file as a numeric long value.
 short getConfigEntryAsShort(String entry)
          Retrieves the value of the specified configuration entry from the project configuration file as a numeric short value.
 short getConfigEntryAsShort(String entry, int radix)
          Retrieves the value of the specified configuration entry from the project configuration file as a numeric short value.
 Configuration getConfiguration()
          Retrieves the configuration information associated with this project.
 String getFileName()
          Getter for the name of the project config save file we are working with.
 String getLastDirectory()
          Gets the string that specifies the last save file directory accessed.
 Vector getLastFiles()
          Getter for the list of last save files that have been defined.
 String getLookFeel()
          Gets the string that specifies the look and feel the user last used.
 int getMaxLastFiles()
          Gets the value that specifies the maximum number of last used files to keep track of.
 boolean isHighlighting()
          Determines if required fields should be highlighted or not.
 boolean isToolTips()
          Determines if tool tips should be displayed or not.
static void main(String[] args)
           
 void save()
          Controls the saving of the project configuration information to a file.
 void setConfigEntry(String entry, boolean value)
          Sets the value of the specified configuration entry in the project configuration file.
 void setConfigEntry(String entry, double value)
          Sets the value of the specified configuration entry in the project configuration file.
 void setConfigEntry(String entry, float value)
          Sets the value of the specified configuration entry in the project configuration file.
 void setConfigEntry(String entry, int value)
          Sets the value of the specified configuration entry in the project configuration file.
 void setConfigEntry(String entry, long value)
          Sets the value of the specified configuration entry in the project configuration file.
 void setConfigEntry(String entry, short value)
          Sets the value of the specified configuration entry in the project configuration file.
 void setConfigEntry(String entry, String value)
          Sets the value of the specified configuration entry in the project configuration file.
 void setFileName(String name)
          Setter for the project data save file name.
 void setHighlighting(boolean highlight)
          Sets the indicator that specifies whether required fields should be highlighted or not.
 void setLastDirectory(String directory)
          Sets the string that specifies the last save file directory the user accessed.
 void setLastFiles(Vector files)
          Setter for the vector of last save files.
 void setLookFeel(String lookFeel)
          Sets the string that specifies the last look & feel the user used.
 void setMaxLastFiles(int number)
          Sets the string that specifies the maximum number of last used files to keep track of.
 void setToolTips(boolean toolTips)
          Sets the indicator that specifies whether tooltips should be displayed or not.
 void updateLastFileList(String name)
          Updates the list of last names.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SECTION_PROJECT

public static final String SECTION_PROJECT
Top level section within the config document

ITEM_LOOK_FEEL

public static final String ITEM_LOOK_FEEL
Entry within the config document representing the look & feel

ITEM_TOOL_TIPS

public static final String ITEM_TOOL_TIPS
Entry within the config document representing the tool tips

ITEM_HIGHLIGHTING

public static final String ITEM_HIGHLIGHTING
Entry within the config document representing the highlighting state

ITEM_LAST_DIRECTORY

public static final String ITEM_LAST_DIRECTORY
Entry within the config document representing the last directory accessed

ITEM_MAX_LAST_FILES

public static final String ITEM_MAX_LAST_FILES
Entry within the config document representing the maximum number of "last files" to store

ITEM_LAST_FILE

public static final String ITEM_LAST_FILE
Entry within the config document representing the most recent files used. the actual entry will have a number appended to it, where 1=most recently used, 2=2nd most recently used, etc.

_parser

protected Configuration _parser
The parsed project data configuration file
Constructor Detail

ProjectConfiguration

public ProjectConfiguration()
Default class instance creator. Initializes class instance variables.

ProjectConfiguration

public ProjectConfiguration(String fileName)
Default class instance creator. Initializes class instance variables by reading the specified navigation config file.
Parameters:
fileName - Name of the navigation config file to read.
Method Detail

getConfiguration

public Configuration getConfiguration()
Retrieves the configuration information associated with this project.
Returns:
The configuration information.

getFileName

public String getFileName()
Getter for the name of the project config save file we are working with.
Returns:
Name of the config save file.

getLastFiles

public Vector getLastFiles()
Getter for the list of last save files that have been defined.
Returns:
List of defined last save files.

getConfigEntry

public String getConfigEntry(String entry)
Retrieves the value of the specified configuration entry from the project configuration file.
Parameters:
entry - The name of the entry to retrieve the value of
Returns:
The value of the entry, or null if the entry does not exist.

getConfigEntryAsBoolean

public boolean getConfigEntryAsBoolean(String entry)
Retrieves the value of the specified configuration entry from the project configuration file as a boolean value.
Parameters:
entry - The name of the entry to retrieve the value of
Returns:
The boolean value of the entry, or false if the entry does not exist.

getConfigEntryAsDouble

public double getConfigEntryAsDouble(String entry)
Retrieves the value of the specified configuration entry from the project configuration file as a double value.
Parameters:
entry - The name of the entry to retrieve the value of
Returns:
The double value of the entry, or 0 if the entry does not exist.

getConfigEntryAsFloat

public float getConfigEntryAsFloat(String entry)
Retrieves the value of the specified configuration entry from the project configuration file as a float value.
Parameters:
entry - The name of the entry to retrieve the value of
Returns:
The float value of the entry, or 0 if the entry does not exist.

getConfigEntryAsInteger

public int getConfigEntryAsInteger(String entry)
Retrieves the value of the specified configuration entry from the project configuration file as an integer value.
Parameters:
entry - The name of the entry to retrieve the value of
Returns:
The integer value of the entry, or 0 if the entry does not exist.

getConfigEntryAsInteger

public int getConfigEntryAsInteger(String entry,
                                   int radix)
Retrieves the value of the specified configuration entry from the project configuration file as an integer value.
Parameters:
entry - The name of the entry to retrieve the value of
radix - The radix to be used
Returns:
The integer value of the entry, or 0 if the entry does not exist.

getConfigEntryAsLong

public long getConfigEntryAsLong(String entry)
Retrieves the value of the specified configuration entry from the project configuration file as a numeric long value.
Parameters:
entry - The name of the entry to retrieve the value of
Returns:
The long value of the entry, or 0 if the entry does not exist.

getConfigEntryAsLong

public long getConfigEntryAsLong(String entry,
                                 int radix)
Retrieves the value of the specified configuration entry from the project configuration file as a numeric long value.
Parameters:
entry - The name of the entry to retrieve the value of
radix - The radix to be used
Returns:
The long value of the entry, or 0 if the entry does not exist.

getConfigEntryAsShort

public short getConfigEntryAsShort(String entry)
Retrieves the value of the specified configuration entry from the project configuration file as a numeric short value.
Parameters:
entry - The name of the entry to retrieve the value of
Returns:
The short value of the entry, or 0 if the entry does not exist.

getConfigEntryAsShort

public short getConfigEntryAsShort(String entry,
                                   int radix)
Retrieves the value of the specified configuration entry from the project configuration file as a numeric short value.
Parameters:
entry - The name of the entry to retrieve the value of
radix - The radix to be used
Returns:
The short value of the entry, or 0 if the entry does not exist.

getLastDirectory

public String getLastDirectory()
Gets the string that specifies the last save file directory accessed. This is equivalent to the call: getConfigEntry (ProjectConfiguration.ITEM_LAST_DIRECTORY);
Returns:
The directory name.

getLookFeel

public String getLookFeel()
Gets the string that specifies the look and feel the user last used. This is equivalent to the call: getConfigEntry (ProjectConfiguration.ITEM_LOOK_FEEL);
Returns:
The look and feel name.

getMaxLastFiles

public int getMaxLastFiles()
Gets the value that specifies the maximum number of last used files to keep track of. This is equivalent to the call: getConfigEntryAsInteger (ProjectConfiguration.ITEM_MAX_LAST_FILES);
Returns:
The maximum number of last used files to keep track of.

isToolTips

public boolean isToolTips()
Determines if tool tips should be displayed or not. This is equivalent to the call: getConfigEntryAsBoolean (ProjectConfiguration.ITEM_TOOL_TIPS)
Returns:
A value of true indicates tooltips should be displayed, false indicates they should not.

isHighlighting

public boolean isHighlighting()
Determines if required fields should be highlighted or not. This is equivalent to the call: getConfigEntryAsBoolean (ProjectConfiguration.ITEM_HIGHLIGHTING)
Returns:
A value of true indicates highlighting should be used, false indicates it should not.

setLastFiles

public void setLastFiles(Vector files)
Setter for the vector of last save files.
Parameters:
files - Vector of last files to use.

setFileName

public void setFileName(String name)
Setter for the project data save file name.
Parameters:
name - Name to set the data file name to.

setConfigEntry

public void setConfigEntry(String entry,
                           String value)
Sets the value of the specified configuration entry in the project configuration file.
Parameters:
entry - The name of the entry to set the value of
value - The value to set the entry to

setConfigEntry

public void setConfigEntry(String entry,
                           boolean value)
Sets the value of the specified configuration entry in the project configuration file.
Parameters:
entry - The name of the entry to set the value of
value - The value to set the entry to

setConfigEntry

public void setConfigEntry(String entry,
                           double value)
Sets the value of the specified configuration entry in the project configuration file.
Parameters:
entry - The name of the entry to set the value of
value - The value to set the entry to

setConfigEntry

public void setConfigEntry(String entry,
                           float value)
Sets the value of the specified configuration entry in the project configuration file.
Parameters:
entry - The name of the entry to set the value of
value - The value to set the entry to

setConfigEntry

public void setConfigEntry(String entry,
                           int value)
Sets the value of the specified configuration entry in the project configuration file.
Parameters:
entry - The name of the entry to set the value of
value - The value to set the entry to

setConfigEntry

public void setConfigEntry(String entry,
                           long value)
Sets the value of the specified configuration entry in the project configuration file.
Parameters:
entry - The name of the entry to set the value of
value - The value to set the entry to

setConfigEntry

public void setConfigEntry(String entry,
                           short value)
Sets the value of the specified configuration entry in the project configuration file.
Parameters:
entry - The name of the entry to set the value of
value - The value to set the entry to

setLastDirectory

public void setLastDirectory(String directory)
Sets the string that specifies the last save file directory the user accessed.
Parameters:
directory - The directory name.

setLookFeel

public void setLookFeel(String lookFeel)
Sets the string that specifies the last look & feel the user used.
Parameters:
lookFeel - The look & feel name.

setMaxLastFiles

public void setMaxLastFiles(int number)
Sets the string that specifies the maximum number of last used files to keep track of.
Parameters:
number - The maximum number of last used files.

setToolTips

public void setToolTips(boolean toolTips)
Sets the indicator that specifies whether tooltips should be displayed or not.
Parameters:
toolTips - Value to set the display tooltips indicator to.

setHighlighting

public void setHighlighting(boolean highlight)
Sets the indicator that specifies whether required fields should be highlighted or not.
Parameters:
highlight - Value to set the highlighting indicator to.

updateLastFileList

public void updateLastFileList(String name)
Updates the list of last names. This includes updating the vector of file names and the last accessed directory. We only update the last name list if it does not already contain the specified name. If it does contain the specified name, we move it to the front of the list. We update the last access directory by stripping it out of the file name.
Parameters:
name - The name of the file to add to the list.

save

public void save()
          throws Exception
Controls the saving of the project configuration information to a file.
Throws:
Exception - If the save fails in the Configuration class.
See Also:
Configuration.save()

main

public static void main(String[] args)