org.openbp.jaspira.option
Class Option

java.lang.Object
  extended by org.openbp.common.generic.description.DescriptionObjectImpl
      extended by org.openbp.common.generic.description.DisplayObjectImpl
          extended by org.openbp.jaspira.option.Option
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Comparable, javax.swing.tree.TreeNode, Copyable, DescriptionObject, Displayable, DisplayObject, Validatable
Direct Known Subclasses:
BooleanOption, ColorOption, DebuggerOptionModule.LinkTraceOption, ExternalAssociationPlugin.AssociationOptionModule.AssociationOption, GroupOption, IntegerOption, PasswordOption, SelectionOption, StringOption

public abstract class Option
extends DisplayObjectImpl
implements javax.swing.tree.TreeNode

This is the abstract class for all options. A option has viewable Components - the OptionWidgets. If the option has to be able to shown in a tollbar or somthing else it has to return diverent Widges! Every Option has a name and a displayname, where the displayname is used to name the option in diferent languages. The option value kan read by the OptionMgr. If you need the value of a option you have to ask vor it at the OptionMgr. If the Option value has changed a OptionChangedEvent will signal the change. to recognize this you have to install a Listener at the JaspiraEventMgr.

Author:
Jens Ferchland
See Also:
Serialized Form

Field Summary
static int DFLT_PRIORITY
          Default priority = 50
static java.util.Comparator priorityComparator
          Comperator for option ans optiongroups
static java.lang.String PROPERTY_CONDITION
          Property id for the conditional expression
static java.lang.String PROPERTY_HEADING
          Resource id for the option heading
static java.lang.String PROPERTY_ICON
          Resource id for the icon
static java.lang.String PROPERTY_OPTION_PARENT
          Resource id for the option parent
static java.lang.String PROPERTY_PRIO
          Resource id for the option priority
static java.lang.String PROPERTY_TYPE
          Resource id for the option type
static java.lang.String TYPE_GROUP
          Option type: Option group
static java.lang.String TYPE_OPTION
          Option type: Regular option
static java.lang.String TYPE_SUB_GROUP
          Option type: Group of options which will displayed in a page and not as own option tree node
 
Fields inherited from interface org.openbp.common.generic.Copyable
COPY_DEEP, COPY_FIRST_LEVEL, COPY_SHALLOW
 
Constructor Summary
Option(ResourceCollection res, java.lang.String optionName, java.lang.Object defaultValue)
          Resource constructor.
Option(java.lang.String optionName, java.lang.String displayName, java.lang.String description, java.lang.Object defaultValue, java.lang.String type, Option parent, int prio)
          Value constructor.
 
Method Summary
protected  void addOptionChild(Option opt)
          Adds a child option.
 java.util.Enumeration children()
           
abstract  OptionWidget createOptionWidget()
          Returns the widget for this option.
 boolean getAllowsChildren()
           
 OptionWidget getCachedOptionWidget()
          Returns the cached widget for this option.
 javax.swing.tree.TreeNode getChildAt(int childIndex)
           
 int getChildCount()
           
 java.lang.String getCondition()
          Gets the conditional expression that determines if the plugin should be active.
 java.lang.Object getDefaultValue()
          Returns the default value of the option.
 java.lang.String getHeading()
          Gets the option heading (title of the option widget).
 javax.swing.Icon getIcon()
          Returns icon of the otion.
 int getIndex(javax.swing.tree.TreeNode node)
           
 java.util.SortedSet getOptionChildren()
          Returns the child options of this option.
 javax.swing.tree.TreeNode getParent()
           
 int getPriority()
          Returns the priority of the option.
 java.lang.String getType()
          Returns the type of the option.
 java.lang.Object getValue()
          Gets the value of the Option.
 void install()
          Installs the option width the option manager.
 boolean isLeaf()
           
abstract  java.lang.Object loadFromString(java.lang.String cryptString)
          Deserializes the option value from a string.
protected  java.lang.Object loadOptionValue()
          Loads the option value from the setting manager.
protected  void removeOptionChild(Option opt)
          Removes a child option.
 void resetCachedOptionWidget()
          Resets the cached widget for this option.
protected  void saveOptionValue()
          Saves the option value.
abstract  java.lang.String saveToString()
          Serializes the option value to a string.
 void setValue(java.lang.Object o)
          Sets the value of this option.
 java.lang.String toString()
          Gets the display name so it can be displayed directly by the default JTree.
 void uninstall()
          Uninstalls the option from the option manager.
 
Methods inherited from class org.openbp.common.generic.description.DisplayObjectImpl
copyFrom, getDisplayName, getDisplayText, setDisplayName
 
Methods inherited from class org.openbp.common.generic.description.DescriptionObjectImpl
clone, compareTo, getDescription, getDescriptionEscape, getDescriptionText, getName, setDescription, setDescriptionEscape, setName, validate
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.openbp.common.generic.description.DescriptionObject
clone, getDescription, getDescriptionText, getName, setDescription, setName
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Field Detail

priorityComparator

public static final java.util.Comparator priorityComparator
Comperator for option ans optiongroups


PROPERTY_ICON

public static final java.lang.String PROPERTY_ICON
Resource id for the icon

See Also:
Constant Field Values

PROPERTY_TYPE

public static final java.lang.String PROPERTY_TYPE
Resource id for the option type

See Also:
Constant Field Values

PROPERTY_PRIO

public static final java.lang.String PROPERTY_PRIO
Resource id for the option priority

See Also:
Constant Field Values

PROPERTY_HEADING

public static final java.lang.String PROPERTY_HEADING
Resource id for the option heading

See Also:
Constant Field Values

PROPERTY_OPTION_PARENT

public static final java.lang.String PROPERTY_OPTION_PARENT
Resource id for the option parent

See Also:
Constant Field Values

PROPERTY_CONDITION

public static final java.lang.String PROPERTY_CONDITION
Property id for the conditional expression

See Also:
Constant Field Values

TYPE_OPTION

public static final java.lang.String TYPE_OPTION
Option type: Regular option

See Also:
Constant Field Values

TYPE_GROUP

public static final java.lang.String TYPE_GROUP
Option type: Option group

See Also:
Constant Field Values

TYPE_SUB_GROUP

public static final java.lang.String TYPE_SUB_GROUP
Option type: Group of options which will displayed in a page and not as own option tree node

See Also:
Constant Field Values

DFLT_PRIORITY

public static final int DFLT_PRIORITY
Default priority = 50

See Also:
Constant Field Values
Constructor Detail

Option

public Option(ResourceCollection res,
              java.lang.String optionName,
              java.lang.Object defaultValue)
Resource constructor.

Parameters:
res - Resource defining the option
optionName - Name of the option
defaultValue - Default Value of the option

Option

public Option(java.lang.String optionName,
              java.lang.String displayName,
              java.lang.String description,
              java.lang.Object defaultValue,
              java.lang.String type,
              Option parent,
              int prio)
Value constructor.

Parameters:
optionName - Name of the option
displayName - Display name of the option
description - Description of the option
defaultValue - Default Value of the option
type - Option type (TYPE_OPTION/TYPE_GROUP)
parent - Option parent or null
prio - Priority of the option
Method Detail

install

public void install()
Installs the option width the option manager.


uninstall

public void uninstall()
Uninstalls the option from the option manager.


toString

public java.lang.String toString()
Gets the display name so it can be displayed directly by the default JTree.

Overrides:
toString in class DescriptionObjectImpl

createOptionWidget

public abstract OptionWidget createOptionWidget()
Returns the widget for this option.

Returns:
The widget

saveToString

public abstract java.lang.String saveToString()
Serializes the option value to a string. This string value will be used to save the option using the SettingUtil class.

Returns:
A string representing the option value
This value corresponds to the value expected by loadFromString(java.lang.String).

loadFromString

public abstract java.lang.Object loadFromString(java.lang.String cryptString)
Deserializes the option value from a string. This string value will be used to save the option using the SettingUtil class.

Parameters:
cryptString - A string representing the option value or null This value corresponds to the value returned by saveToString().
Returns:
The option value

getCachedOptionWidget

public OptionWidget getCachedOptionWidget()
Returns the cached widget for this option. If no widget is currently cached, a new one will be created and initialized using the current option value.

Returns:
The widget

resetCachedOptionWidget

public void resetCachedOptionWidget()
Resets the cached widget for this option. The next call to getCachedOptionWidget() will create a new widget.


getIcon

public javax.swing.Icon getIcon()
Returns icon of the otion.

Returns:
If the icon is null, no icon will be displayed

getType

public java.lang.String getType()
Returns the type of the option.

Returns:
TYPE_OPTION/TYPE_GROUP

getPriority

public int getPriority()
Returns the priority of the option.

Returns:
The priority (default: 50)

getCondition

public java.lang.String getCondition()
Gets the conditional expression that determines if the plugin should be active.


getHeading

public java.lang.String getHeading()
Gets the option heading (title of the option widget).


getDefaultValue

public java.lang.Object getDefaultValue()
Returns the default value of the option.

Returns:
The default value or null

getValue

public java.lang.Object getValue()
Gets the value of the Option.

Returns:
The option value or the default value if not set

setValue

public void setValue(java.lang.Object o)
Sets the value of this option.

Parameters:
o - The option value

getOptionChildren

public java.util.SortedSet getOptionChildren()
Returns the child options of this option.

Returns:
A sorted set of all option children (contains Option objects)

saveOptionValue

protected void saveOptionValue()
Saves the option value.


loadOptionValue

protected java.lang.Object loadOptionValue()
Loads the option value from the setting manager.

Returns:
The option value or the default value if no such settings has been found

addOptionChild

protected void addOptionChild(Option opt)
Adds a child option.

Parameters:
opt - the new child option

removeOptionChild

protected void removeOptionChild(Option opt)
Removes a child option.

Parameters:
opt - the option to remove

getChildAt

public javax.swing.tree.TreeNode getChildAt(int childIndex)
Specified by:
getChildAt in interface javax.swing.tree.TreeNode
See Also:
TreeNode.getChildAt(int)

getChildCount

public int getChildCount()
Specified by:
getChildCount in interface javax.swing.tree.TreeNode
See Also:
TreeNode.getChildCount()

getParent

public javax.swing.tree.TreeNode getParent()
Specified by:
getParent in interface javax.swing.tree.TreeNode
See Also:
TreeNode.getParent()

getIndex

public int getIndex(javax.swing.tree.TreeNode node)
Specified by:
getIndex in interface javax.swing.tree.TreeNode
See Also:
TreeNode.getIndex(javax.swing.tree.TreeNode)

getAllowsChildren

public boolean getAllowsChildren()
Specified by:
getAllowsChildren in interface javax.swing.tree.TreeNode
See Also:
TreeNode.getAllowsChildren()

isLeaf

public boolean isLeaf()
Specified by:
isLeaf in interface javax.swing.tree.TreeNode
See Also:
TreeNode.isLeaf()

children

public java.util.Enumeration children()
Specified by:
children in interface javax.swing.tree.TreeNode
See Also:
TreeNode.children()


Copyright © 2011. All Rights Reserved.