cz.cuni.jagrlib.gui
Class Options

java.lang.Object
  extended by cz.cuni.jagrlib.gui.Options

public class Options
extends java.lang.Object

Class storing global Skel preferences.

See Also:
Options.java

Field Summary
static java.lang.String FILE_NAME_REG
          Default resource directory.
static java.lang.String optionsFileName
          Options file name - user preferences.
protected static java.lang.String PATH_DATA
          Default data directory.
protected static java.lang.String PATH_EDITOR
          Default external viewer/editor.
protected static java.lang.String PATH_REG
          Default path to registry database.
protected static java.lang.String PATH_RESOURCES
          Default resource directory.
protected static java.lang.String PATH_SOURCE
          Default source path.
protected static java.lang.String PATH_SYS_OPTIONS
          Default file name of system preferences.
static java.lang.String pathData
          Actual data directory.
static java.lang.String pathEditor
          Actual external viewer/editor.
static java.lang.String pathReg
          Actual path to registry database.
static java.lang.String pathResources
          Actual resource directory.
static java.lang.String pathSource
          Actual source path.
protected static java.util.Properties pref
          User options in "key->value" format.
static java.lang.String sysOptionsFileName
          Options file name - system preferences.
static java.lang.String sysOptionsOrigFileName
          Options file name - system preferences (original values).
protected static java.util.Properties system
          System options in "key->value" format.
protected static java.util.HashSet<java.lang.String> systemKeys
          Keys which are updated in 'system' rather than in 'pref'.
 
Constructor Summary
Options()
           
 
Method Summary
static java.lang.String colorToHexString(java.awt.Color c)
          Converts Color to HexString (#AARRGGBB).
static boolean getBoolean(java.lang.String key)
          Parses boolean parameter.
static java.awt.Color getColor(java.lang.String key)
          Parses color description and returns valid Color instance.
static javax.swing.ImageIcon getIcon(java.lang.String fileName)
          Retrieves icon object from resource (JAR) or disk file.
static int getInteger(java.lang.String key)
          Parses integer parameter w/o bounds checking.
static int getInteger(java.lang.String key, int min, int max, int deflt)
          Parses integer parameter and checks its bounds.
static java.io.InputStream getResource(java.lang.String fileName)
          Retrieves resource stream object from URL resource (JAR).
static java.lang.String getString(java.lang.String key)
          Parses string parameter.
static java.lang.String getString(java.lang.String key, java.lang.String deflt)
          Parses string parameter.
static void init()
          Loads preference files from the disk and [re-]initializes working values.
static void interpret()
          Interprets preference dictionaries.
static void load()
          Loads both preference files from disk to the dictionaries.
static void reflect()
          Fills both dictionaries with the actual working values.
static void save()
          Stores both preference files from dictionaries to disk files.
static void set(java.lang.String key, boolean b)
          Sets the boolean parameter.
static void set(java.lang.String key, java.awt.Color c)
          Sets the color parameter.
static void set(java.lang.String key, int i)
          Sets the integer parameter.
static void set(java.lang.String key, java.lang.String value)
          Sets the string parameter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PATH_RESOURCES

protected static final java.lang.String PATH_RESOURCES
Default resource directory.

See Also:
Constant Field Values

pathResources

public static java.lang.String pathResources
Actual resource directory.


PATH_DATA

protected static final java.lang.String PATH_DATA
Default data directory.

See Also:
Constant Field Values

pathData

public static java.lang.String pathData
Actual data directory.


FILE_NAME_REG

public static final java.lang.String FILE_NAME_REG
Default resource directory.

See Also:
Constant Field Values

PATH_REG

protected static final java.lang.String PATH_REG
Default path to registry database.

See Also:
Constant Field Values

pathReg

public static java.lang.String pathReg
Actual path to registry database.


PATH_SOURCE

protected static final java.lang.String PATH_SOURCE
Default source path.

See Also:
Constant Field Values

pathSource

public static java.lang.String pathSource
Actual source path.


PATH_EDITOR

protected static final java.lang.String PATH_EDITOR
Default external viewer/editor.

See Also:
Constant Field Values

pathEditor

public static java.lang.String pathEditor
Actual external viewer/editor.


optionsFileName

public static java.lang.String optionsFileName
Options file name - user preferences.


sysOptionsFileName

public static java.lang.String sysOptionsFileName
Options file name - system preferences.


PATH_SYS_OPTIONS

protected static final java.lang.String PATH_SYS_OPTIONS
Default file name of system preferences.

See Also:
Constant Field Values

sysOptionsOrigFileName

public static java.lang.String sysOptionsOrigFileName
Options file name - system preferences (original values).


pref

protected static java.util.Properties pref
User options in "key->value" format.


system

protected static java.util.Properties system
System options in "key->value" format.


systemKeys

protected static java.util.HashSet<java.lang.String> systemKeys
Keys which are updated in 'system' rather than in 'pref'.

Constructor Detail

Options

public Options()
Method Detail

init

public static void init()
Loads preference files from the disk and [re-]initializes working values.


save

public static void save()
                 throws java.io.IOException
Stores both preference files from dictionaries to disk files. Doesn't fill dictionaries from working state variables.

Throws:
java.io.IOException
See Also:
reflect()

load

public static void load()
                 throws java.io.IOException
Loads both preference files from disk to the dictionaries. Doesn't parse (interpret) the read values.

Throws:
java.io.IOException
See Also:
interpret()

getColor

public static java.awt.Color getColor(java.lang.String key)
Parses color description and returns valid Color instance. If the given string cannot be parsed, returns #ff000000 (black).


getBoolean

public static boolean getBoolean(java.lang.String key)
Parses boolean parameter. Returns 'false' in case of failure.


getInteger

public static int getInteger(java.lang.String key,
                             int min,
                             int max,
                             int deflt)
Parses integer parameter and checks its bounds. Returns 'deflt' in case of failure.


getInteger

public static int getInteger(java.lang.String key)
Parses integer parameter w/o bounds checking.


getString

public static java.lang.String getString(java.lang.String key,
                                         java.lang.String deflt)
Parses string parameter. Returns 'deflt' in case of failure.


getString

public static java.lang.String getString(java.lang.String key)
Parses string parameter. Returns null in case of failure.


interpret

public static void interpret()
Interprets preference dictionaries. Fills all working state variables from the actual dictionaries.


reflect

public static void reflect()
Fills both dictionaries with the actual working values. Should be called before the save() operation.


colorToHexString

public static java.lang.String colorToHexString(java.awt.Color c)
Converts Color to HexString (#AARRGGBB).

Parameters:
c - Color to be converted (const).
Returns:
String representation of the color.

set

public static void set(java.lang.String key,
                       java.lang.String value)
Sets the string parameter. interpret() should be called to reflect all changes in working state variables.


set

public static void set(java.lang.String key,
                       java.awt.Color c)
Sets the color parameter. interpret() should be called to reflect all changes in working state variables.


set

public static void set(java.lang.String key,
                       boolean b)
Sets the boolean parameter. interpret() should be called to reflect all changes in working state variables.


set

public static void set(java.lang.String key,
                       int i)
Sets the integer parameter. interpret() should be called to reflect all changes in working state variables.


getIcon

public static javax.swing.ImageIcon getIcon(java.lang.String fileName)
Retrieves icon object from resource (JAR) or disk file.


getResource

public static java.io.InputStream getResource(java.lang.String fileName)
Retrieves resource stream object from URL resource (JAR).