y.option
Class OptionItem

java.lang.Object
  |
  +--y.option.OptionItem
Direct Known Subclasses:
BoolOptionItem, ColorOptionItem, CommentOptionItem, ComponentOptionItem, DoubleOptionItem, EnumOptionItem, FileOptionItem, IntOptionItem, PasswordOptionItem, StringOptionItem

public abstract class OptionItem
extends Object

Abstract class that serves as base class for all items that can be added to an OptionHandler.

The responsibility of an OptionItem is to provide an editor component for a specific kind of parameter or option type. It must also provide means to reset the value of the paramter to it's original value.


Field Summary
static Color COLOR_UNDEFINED
          A Color that is used in the editor to signal that the value is not defined (yet)
protected  String name
           
static Object UNDEFINED
          A value item that can be used to signal that there is no defined value yet.
 
Constructor Summary
protected OptionItem()
          Creates a new instance of OptionItem
protected OptionItem(Class classType)
          Creates a new instance of OptionItem
protected OptionItem(Class classType, String name)
          Creates a new instance of OptionItem that has the given identifying name.
protected OptionItem(String name)
          Creates a new instance of OptionItem that has the given identifying name.
 
Method Summary
abstract  boolean adoptEditorValue()
          Adopts the value from the editor component to the item.
 boolean checkEditorValue()
          Whether or not the value entered in the editor is valid for this option item.
 Class getClassType()
          Getter for property classType.
abstract  JComponent getEditor()
          Returns the editor component for the this option item.
 JComponent getEditor(GuiFactory factory, String parentName)
          Returns the editor component for the this option item.
 String getName()
          Returns the name of this OptionItem
 String getStringValue()
          Returns the stringified value of this option item if the classType property is set, it uses the y.util.ObjectStringConversion class to perform its task, otherwise it will return null.
 String getTipText()
          Returns the tooltip for the item editor.
abstract  String getType()
          Returns a unique identifier for the type of this OptionItem
abstract  Object getValue()
          Returns the value of this option item
 boolean isValueUndefined()
          Returns whether or not the editor should start up displaying an undefined value.
abstract  void resetValue()
          Resets the value of this item to its initial value.
protected  void setClassType(Class type)
           
 void setStringValue(String value)
          Sets the stringified value of this option item if the classType property is set, it uses the y.util.ObjectStringConversion class to perform its task, otherwise it will return null.
 void setTipText(String text)
          Sets the tooltip text for the item editor.
abstract  void setValue(Object value)
          Sets the value of this option item
 void setValueUndefined(boolean b)
          Whether or not the editor should start up displaying an undefined value.
 boolean wantsVisibleName()
          Whether or not the identifying name should be displayed along with this item.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

protected String name

COLOR_UNDEFINED

public static final Color COLOR_UNDEFINED
A Color that is used in the editor to signal that the value is not defined (yet)


UNDEFINED

public static final Object UNDEFINED
A value item that can be used to signal that there is no defined value yet.

Constructor Detail

OptionItem

protected OptionItem()
Creates a new instance of OptionItem


OptionItem

protected OptionItem(Class classType)
Creates a new instance of OptionItem


OptionItem

protected OptionItem(String name)
Creates a new instance of OptionItem that has the given identifying name.


OptionItem

protected OptionItem(Class classType,
                     String name)
Creates a new instance of OptionItem that has the given identifying name.

Method Detail

setClassType

protected void setClassType(Class type)

getName

public String getName()
Returns the name of this OptionItem


setTipText

public void setTipText(String text)
Sets the tooltip text for the item editor.


getTipText

public String getTipText()
Returns the tooltip for the item editor.


wantsVisibleName

public boolean wantsVisibleName()
Whether or not the identifying name should be displayed along with this item. By default this method returns true


getType

public abstract String getType()
Returns a unique identifier for the type of this OptionItem


getValue

public abstract Object getValue()
Returns the value of this option item


setValue

public abstract void setValue(Object value)
Sets the value of this option item


getStringValue

public String getStringValue()
Returns the stringified value of this option item if the classType property is set, it uses the y.util.ObjectStringConversion class to perform its task, otherwise it will return null.


setStringValue

public void setStringValue(String value)
Sets the stringified value of this option item if the classType property is set, it uses the y.util.ObjectStringConversion class to perform its task, otherwise it will return null.


getEditor

public abstract JComponent getEditor()
Returns the editor component for the this option item. Note: Use the getEditor(GuiFactory,String) variant instead.


getEditor

public JComponent getEditor(GuiFactory factory,
                            String parentName)
Returns the editor component for the this option item. Uses the given GuiFactory the create its content. The default implementation calls the no-arg getEditor() method to preserve backward compatibility. However it is suggested to override this method in order to make use of the GuiFactory.


adoptEditorValue

public abstract boolean adoptEditorValue()
Adopts the value from the editor component to the item.


resetValue

public abstract void resetValue()
Resets the value of this item to its initial value.


checkEditorValue

public boolean checkEditorValue()
Whether or not the value entered in the editor is valid for this option item.


setValueUndefined

public void setValueUndefined(boolean b)
Whether or not the editor should start up displaying an undefined value.


isValueUndefined

public boolean isValueUndefined()
Returns whether or not the editor should start up displaying an undefined value.


getClassType

public Class getClassType()
Getter for property classType.

Returns:
Value of property classType.

© Copyright 2000-2003,
yWorks GmbH.
All rights reserved.

2003