qflib 0.98.1

de.qfs.lib.option
Class OptionGroup

java.lang.Object
  |
  +--de.qfs.lib.option.OptionGroup
Direct Known Subclasses:
ChoiceOptionGroup, NestedOptionGroup, PlainOptionGroup, RadioOptionGroup, TabbedOptionGroup, TreeOptionGroup

public abstract class OptionGroup
extends java.lang.Object

OptionGroups form a hierarchie of nested GUI components in which Options are grouped together for convenient editing. The hierarchie of the groups, their layout and labels are determined by the resources set with Option.setResources. See the package documentation for details about the resource names used.

The preferred way to create an OptionGroup is through makeGroup to create a new group, or getGroup to reuse a possibly existing group.

The AWT component displaying the OptionGroup can be accessed via getComponent. The component's name should be set by derived classes to "OptionGroup-<name>-<options>" where <name> is the resource name of the OptionGroup and <options> is the configurable name of the OptionSet being edited.

Version:
$Revision: 1.22 $
Author:
Gregor Schmid

Field Summary
protected  boolean disabled
          Whether the group is permanently disabled.
protected  boolean enabled
          The current enabled state of the group.
protected  java.util.List members
          The members of the OptionGroup.
protected  java.lang.String name
          The name of the OptionGroup.
protected  OptionSet options
          The options to group.
protected  OptionGroup parent
          The parent OptionGroup.
protected  java.lang.String title
          The title of the FramedOptionGroup's border.
protected  javax.swing.border.TitledBorder titleBorder
          The TitledBorder of the Frame.
 
Constructor Summary
protected OptionGroup()
          No arg constructor for specialized OptionGroups.
  OptionGroup(java.lang.String name, OptionSet options)
          Create a new OptionGroup.
 
Method Summary
 boolean checkValues()
          Check whether all members of the group contain valid values.
protected  void createMembers()
          Create the members of the OptionGroup.
 OptionEdit findEdit(java.lang.String name)
          Traverse the OptionGroup members and search for an OptionEdit.
 OptionGroup findGroup(java.lang.String name)
          Traverse the OptionGroup members and search for an OptionGroup.
protected  boolean getBoolean(java.lang.String res, boolean dflt)
          Get a boolean resource from the Option resources.
abstract  java.awt.Component getComponent()
          Get the AWT Component for the OptionGroup.
static OptionGroup getGroup(java.lang.String name, OptionSet options)
          Get an OptionGroup for a set of Options.
 int getIndexOfMember(java.lang.Object member)
          Find a member of the OptionGroup and get its index.
protected  int getInt(java.lang.String res, int dflt)
          Get an int resource from the Option resources.
 java.lang.Object getMember(int index)
          Get a member of the group.
 int getMemberCount()
          Get the number of members of the OptionGroup.
 java.lang.String getName()
          Get the name of the group.
 OptionGroup getParentGroup()
          Get the parent of the OptionGroup.
protected  java.lang.String getString(java.lang.String res, java.lang.String dflt)
          Get a String resource from the Option resources.
 boolean isDisabled()
          Query whether the OptionGroup is permanently disabled.
protected  void makeBorder(javax.swing.JComponent com)
          Create the border for the group if the .frame property for the group is set.
static OptionGroup makeGroup(java.lang.String name, OptionSet options)
          Create a new OptionGroup.
 void notifyOptionObservers()
          Notify the Observers of the Options being edited in this OptionGroup.
 void readValues()
          Read the values from the edit components and store them into the Options.
 void setDisabled(boolean disabled)
          Set whether the OptionGroup is permanently disabled.
 void setEnabled(boolean enabled)
          Set the enabled state for all members of the group.
 void setParentGroup(OptionGroup parent)
          Set the parent of the OptionGroup.
 void setTitle(java.lang.String title)
          Set the title of the OptionGroup.
 void update(OptionSet options)
          Update display for possibly new Options.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parent

protected OptionGroup parent
The parent OptionGroup.

members

protected java.util.List members
The members of the OptionGroup. May only contain OptionGroups and OptionEdits.

name

protected java.lang.String name
The name of the OptionGroup.

options

protected OptionSet options
The options to group.

titleBorder

protected javax.swing.border.TitledBorder titleBorder
The TitledBorder of the Frame.

title

protected java.lang.String title
The title of the FramedOptionGroup's border.

disabled

protected boolean disabled
Whether the group is permanently disabled. If this flag is true, setEnabled will be forced to disable the group.

enabled

protected boolean enabled
The current enabled state of the group.
Constructor Detail

OptionGroup

protected OptionGroup()
No arg constructor for specialized OptionGroups.

OptionGroup

public OptionGroup(java.lang.String name,
                   OptionSet options)
Create a new OptionGroup.
Parameters:
name - The name of the group.
options - The options to edit.
Method Detail

getGroup

public static OptionGroup getGroup(java.lang.String name,
                                   OptionSet options)
Get an OptionGroup for a set of Options. If a Group by that name has already been created, it will be reused and updated, otherwise a new OptionGroup is created.
Parameters:
name - The name of the group.
options - The options to edit.
Returns:
The new OptionGroup.

makeGroup

public static OptionGroup makeGroup(java.lang.String name,
                                    OptionSet options)
Create a new OptionGroup. The type of the new group is determined by the resources set with Option.setResources. See the package documentation for details about the resource names used.

A special case is type custom. The class of the OptionGroup to create is defined by the option.group.groupname.class resource. The class must have a public constructor of the form
public CustomOptionGroup (String name, OptionSet options)

Parameters:
name - The name of the group.
options - The options to edit.
Returns:
The new OptionGroup.

getName

public java.lang.String getName()
Get the name of the group.
Returns:
The name of the group.
Since:
0.98.0

checkValues

public boolean checkValues()
Check whether all members of the group contain valid values.
Returns:
True, if everything is OK.

readValues

public void readValues()
Read the values from the edit components and store them into the Options. Should only be called after checkValues succeeded.

notifyOptionObservers

public void notifyOptionObservers()
Notify the Observers of the Options being edited in this OptionGroup.

update

public void update(OptionSet options)
Update display for possibly new Options. The name and type of the Options in the OptionSet must be the same as before.
Parameters:
options - The new OptionSet.

setEnabled

public void setEnabled(boolean enabled)
Set the enabled state for all members of the group.
Parameters:
enabled - The enabled state to set.

isDisabled

public boolean isDisabled()
Query whether the OptionGroup is permanently disabled. In this case it will force calls to setEnabled to disable the group.
Returns:
True if the OptionGroup is disabled.

setDisabled

public void setDisabled(boolean disabled)
Set whether the OptionGroup is permanently disabled. In this case it will force calls to setEnabled to disable the group.
Parameters:
disabled - True to disable the group. If true, setEnabled(false) is called automatically.

setTitle

public void setTitle(java.lang.String title)
Set the title of the OptionGroup. Overrides the value read from the .title property. Only useful if the group has a frame.
Parameters:
title - The title to set.
Since:
0.98.0

getParentGroup

public OptionGroup getParentGroup()
Get the parent of the OptionGroup.
Returns:
The OptionGroup's parent.
Since:
0.98.0

setParentGroup

public void setParentGroup(OptionGroup parent)
Set the parent of the OptionGroup.
Parameters:
parent - The parent to set.
Since:
0.98.0

getMemberCount

public int getMemberCount()
Get the number of members of the OptionGroup.
Returns:
The number of the OptionGroup's members.
Since:
0.98.0

getMember

public java.lang.Object getMember(int index)
Get a member of the group.
Parameters:
index - The index of the member.
Returns:
The member, either an OptionGroup or an OptionEdit.
Since:
0.98.0

getIndexOfMember

public int getIndexOfMember(java.lang.Object member)
Find a member of the OptionGroup and get its index.
Parameters:
member - The member to look for.
Returns:
The member's index or -1.
Since:
0.98.0

findGroup

public OptionGroup findGroup(java.lang.String name)
Traverse the OptionGroup members and search for an OptionGroup.
Parameters:
name - The name of the group to search.
Returns:
The group - if found - or null.
Since:
0.98.0

findEdit

public OptionEdit findEdit(java.lang.String name)
Traverse the OptionGroup members and search for an OptionEdit.
Parameters:
name - The option name of the edit to search.
Returns:
The edit - if found - or null.
Since:
0.98.0

getComponent

public abstract java.awt.Component getComponent()
Get the AWT Component for the OptionGroup.
Returns:
The Component.

getString

protected java.lang.String getString(java.lang.String res,
                                     java.lang.String dflt)
Get a String resource from the Option resources. The resource name is built as "option.group.groupname.res"
Parameters:
res - The last part of the resource name.
dflt - Default value if the resource is undefined.
Returns:
The sresource value.
Since:
0.98.1

getBoolean

protected boolean getBoolean(java.lang.String res,
                             boolean dflt)
Get a boolean resource from the Option resources. The resource name is built as "option.group.groupname.res"
Parameters:
res - The last part of the resource name.
dflt - Default value if the resource is undefined.
Returns:
The sresource value.
Since:
0.98.1

getInt

protected int getInt(java.lang.String res,
                     int dflt)
Get an int resource from the Option resources. The resource name is built as "option.group.groupname.res"
Parameters:
res - The last part of the resource name.
dflt - Default value if the resource is undefined.
Returns:
The sresource value.
Since:
0.98.1

createMembers

protected void createMembers()
Create the members of the OptionGroup.

makeBorder

protected void makeBorder(javax.swing.JComponent com)
Create the border for the group if the .frame property for the group is set.
Parameters:
com - The component to place the border on.
Since:
0.98.0

qflib 0.98.1