cdox.util.conf
Class AbstractOption

java.lang.Object
  extended bycdox.util.conf.AbstractOption
Direct Known Subclasses:
KeyStrokeOption, LanguageOption, YesNoOption

public abstract class AbstractOption
extends java.lang.Object

This class is the abstract superclass for various options.

Version:
May 22nd 2002
Author:
Rutger Bezema, Andreas Schmitz

Field Summary
protected  java.lang.String key
          The preferences key for this option.
protected  org.w3c.dom.Element node
          The DOM node where this option is described.
protected  java.util.prefs.Preferences prefs
          The preferences node for this option.
 
Constructor Summary
protected AbstractOption(java.lang.String cls, java.lang.String key, org.w3c.dom.Node n)
          Constructs new one.
 
Method Summary
abstract  boolean commitChanges()
          Causes the option to write its changes to its preferences node.
abstract  javax.swing.JComponent getComponent()
          Returns a component which is used to alter this option.
abstract  javax.swing.JLabel getText()
          Returns a JLabel which describes the option.
protected static java.lang.String getTextByLanguage(org.w3c.dom.Node parent, java.lang.String element, Localizer lang)
          Returns the #text node value of the matching element (if any).
abstract  void reset()
          Resets the values to the original ones, either from the preferences, or, if they don't exist, to the ones in the XML file.
 void setMapping(java.util.HashMap map)
          This method might be overridden by subclasses that need to provide its values as objects.
abstract  void setToDefault()
          Causes the preferences to re-read its default value from the DOM document and thus resetting its value in the component.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

prefs

protected java.util.prefs.Preferences prefs
The preferences node for this option.


key

protected java.lang.String key
The preferences key for this option.


node

protected org.w3c.dom.Element node
The DOM node where this option is described.

Constructor Detail

AbstractOption

protected AbstractOption(java.lang.String cls,
                         java.lang.String key,
                         org.w3c.dom.Node n)
Constructs new one. The DOM node must be the element node of this option, for example the "keystroke" node (for a keystroke).

Parameters:
cls - a string that is used to determine the preferences node where the option will be stored.
key - the preferences key.
n - the DOM node where this option is described.
Method Detail

getText

public abstract javax.swing.JLabel getText()
Returns a JLabel which describes the option. This method should be invoked only once.

Returns:
a JLabel.

getComponent

public abstract javax.swing.JComponent getComponent()
Returns a component which is used to alter this option. This method should be invoked only once.

Returns:
a JComponent value.

commitChanges

public abstract boolean commitChanges()
Causes the option to write its changes to its preferences node. The preferences' flush() method is NOT invoked by this method.

Returns:
true, if the application must be restarted in order to get the changes into effect.

setToDefault

public abstract void setToDefault()
Causes the preferences to re-read its default value from the DOM document and thus resetting its value in the component.


reset

public abstract void reset()
Resets the values to the original ones, either from the preferences, or, if they don't exist, to the ones in the XML file.


setMapping

public void setMapping(java.util.HashMap map)
This method might be overridden by subclasses that need to provide its values as objects. The mapping should use the key value used in the xml file as key value.

Parameters:
map - the map where to store the mappings.

getTextByLanguage

protected static java.lang.String getTextByLanguage(org.w3c.dom.Node parent,
                                                    java.lang.String element,
                                                    Localizer lang)
Returns the #text node value of the matching element (if any). Uses the localizer to determine the element which matches the language of the localizer (by comparing the language to the xml:lang attribute).

Parameters:
parent - the node, which must be the parent of matching elements.
element - the name of the element that is searched for.
lang - the localizer whose language should be searched for.
Returns:
the text or null, if no language/element pair matches the language.