Search this API

y.option
Class EnumOptionItem

java.lang.Object
  extended by y.option.OptionItem
      extended by y.option.ObjectOptionItem
          extended by y.option.EnumOptionItem
All Implemented Interfaces:
AttributeOwner, BackupValueOwner, PropertyChangeReporter, VetoableChangeReporter

public class EnumOptionItem
extends ObjectOptionItem

An option item for a value that is chosen from a fixed range of possible values.

Note:
Editors for this item created by the DefaultEditorFactory and the TableEditorFactory are aware of the value range of this item; they will update the value range when commitValue is invoked, they will adopt the value range when adoptItemValue is invoked, and they will adopt the backup value range when resetValue is invoked.

 

Field Summary
static java.lang.String ATTRIBUTE_ITEM_LISTENER
          Attribute key used to store an ItemListener.
static java.lang.String ATTRIBUTE_RENDERER
          Attribute key used to store an ListCellRenderer.
static java.lang.String PROPERTY_BACKUP_ENUM
          Name of property backupEnum.
static java.lang.String PROPERTY_BACKUP_VALUE
          Name of property backupValue.
static java.lang.String PROPERTY_ENUM
          Name of property enum.
 
Fields inherited from class y.option.OptionItem
ATTRIBUTE_CONTEXT, ATTRIBUTE_GROUPS, ATTRIBUTE_LONG_DESCRIPTION, COLOR_UNDEFINED, name, PROPERTY_CLASS_TYPE, PROPERTY_ENABLED, PROPERTY_TIP_TEXT, PROPERTY_VALUE, PROPERTY_VALUE_UNDEFINED, UNDEFINED
 
Constructor Summary
EnumOptionItem(java.lang.String name)
          Creates a new instance of EnumOptionItem.
EnumOptionItem(java.lang.String name, java.lang.Object[] values, int index)
          Creates a new instance of EnumOptionItem.
EnumOptionItem(java.lang.String name, java.lang.Object[] values, java.lang.Object value)
          Creates a new instance of EnumOptionItem.
 
Method Summary
 void add(java.lang.Object item)
          Convenience method that just calls add(Object, Object) with item as both of the arguments.
 void add(java.lang.Object item, java.lang.Object i18nKey)
          Populates the choices for this EnumOptionItem.
 void addAll(java.util.Map itemI18nPairs)
          This method is a convenience for the add(Object, Object) method.
 java.lang.Object[] getBackupEnum()
          Returns the backup value range.
 java.lang.Object[] getEnum()
          Returns the range of possible values.
 java.lang.Object[] getEnumRange()
          Returns the range of possible values.
 int getIndex()
          Returns the index of the currently set value.
 java.lang.Object getInterpretedValue()
          This method can be used in conjunction with the empty constructor and the add(Object, Object) method.
 java.lang.String getStringValue()
          Returns the stringified value of this option item.
 java.lang.String getType()
          Returns "Enum".
 void resetValue()
          Overwritten to reset not only the value of this item, but the value range and the valueUndefined property as well.
 void setBackupEnum(java.lang.Object[] values)
          Sets the backup value range of the item.
 void setBackupValue(java.lang.Object value)
          Sets the backup value of the item.
 void setEnum(java.lang.Object[] values)
          Sets the range of possible values.
 void setEnum(java.lang.Object[] values, java.lang.Object value)
          Sets the range of possible values.
 void setIndex(int index)
          Specifies the index of the currently set value.
 void setInterpretedValue(java.lang.Object valueObject)
          This method can be used in conjunction with the empty constructor and the add(Object, Object) method.
 void setItemListener(java.awt.event.ItemListener il)
          Deprecated. Customize the used editors.
 void setRenderer(javax.swing.ListCellRenderer lcr)
          Deprecated. Customize the used editors.
 void setStringValue(java.lang.String value)
          Sets the stringified value of this option item.
 void setUsingIntegers(boolean use)
          This implementation invokes setClassType.
 void setValue(java.lang.Object value)
          Overwritten to update the valueUndefined property as well.
 void setValueUndefined(boolean valueUndefined)
          Overwritten to take the current state of the item into account.
 
Methods inherited from class y.option.ObjectOptionItem
getBackupValue, getValue
 
Methods inherited from class y.option.OptionItem
addEditor, addEditorListener, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, addVetoableChangeListener, adoptEditorValue, checkEditorValue, firePropertyChange, firePropertyChange, fireVetoableChange, fireVetoableChange, getAttribute, getClassType, getEditor, getEditor, getEditors, getName, getTipText, isEnabled, isValueUndefined, publishEnabled, publishValue, publishValueUndefined, removeAttribute, removeEditor, removeEditorListener, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, removeVetoableChangeListener, setAttribute, setClassType, setEnabled, setTipText, wantsVisibleName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ATTRIBUTE_ITEM_LISTENER

public static final java.lang.String ATTRIBUTE_ITEM_LISTENER
Attribute key used to store an ItemListener. This attribute exists only for legacy reasons and should not be used explicitly.


ATTRIBUTE_RENDERER

public static final java.lang.String ATTRIBUTE_RENDERER
Attribute key used to store an ListCellRenderer. This attribute exists only for legacy reasons and should not be used explicitly.


PROPERTY_BACKUP_ENUM

public static final java.lang.String PROPERTY_BACKUP_ENUM
Name of property backupEnum.


PROPERTY_BACKUP_VALUE

public static final java.lang.String PROPERTY_BACKUP_VALUE
Name of property backupValue.


PROPERTY_ENUM

public static final java.lang.String PROPERTY_ENUM
Name of property enum.

Constructor Detail

EnumOptionItem

public EnumOptionItem(java.lang.String name)
Creates a new instance of EnumOptionItem.

Parameters:
name - the name of this item

EnumOptionItem

public EnumOptionItem(java.lang.String name,
                      java.lang.Object[] values,
                      java.lang.Object value)
Creates a new instance of EnumOptionItem.

Parameters:
name - the name of this item
values - the possible values of the option
value - the initial value of the option (must be contained in values).

EnumOptionItem

public EnumOptionItem(java.lang.String name,
                      java.lang.Object[] values,
                      int index)
Creates a new instance of EnumOptionItem.

Parameters:
name - the name of this item
values - the possible values of the option
index - the array index of the initial value.
Method Detail

getType

public java.lang.String getType()
Returns "Enum".

Overrides:
getType in class ObjectOptionItem

setBackupValue

public void setBackupValue(java.lang.Object value)
Sets the backup value of the item. Handling of consistency checks, e.g. if value is contained in the underlying value range is the responsibility of the user.

Parameters:
value - the new backup value

getBackupEnum

public java.lang.Object[] getBackupEnum()
Returns the backup value range.


setBackupEnum

public void setBackupEnum(java.lang.Object[] values)
Sets the backup value range of the item.

Parameters:
values - the new backup value range

setIndex

public void setIndex(int index)
Specifies the index of the currently set value.


getIndex

public int getIndex()
Returns the index of the currently set value.


getEnumRange

public java.lang.Object[] getEnumRange()
Returns the range of possible values.


getEnum

public java.lang.Object[] getEnum()
Returns the range of possible values.


setEnum

public void setEnum(java.lang.Object[] values,
                    java.lang.Object value)
Sets the range of possible values.

Parameters:
values - the value range
value - the initial value

setEnum

public void setEnum(java.lang.Object[] values)
Sets the range of possible values. Selects the first value from the given range as initial value.

Parameters:
values - the value range

getStringValue

public java.lang.String getStringValue()
Returns the stringified value of this option item.

Overrides:
getStringValue in class OptionItem

setStringValue

public void setStringValue(java.lang.String value)
Sets the stringified value of this option item.
This implementation invokes setIndex, setValueUndefined, setValue, and/or resetValue.

Overrides:
setStringValue in class OptionItem

setUsingIntegers

public void setUsingIntegers(boolean use)
This implementation invokes setClassType.


setValueUndefined

public void setValueUndefined(boolean valueUndefined)
Overwritten to take the current state of the item into account. If the currently stored value is not contained in the currently stored values range, the passed in parameter is ignored and the call is equal to calling setValueUndefined( true ).

Overrides:
setValueUndefined in class OptionItem

setRenderer

public void setRenderer(javax.swing.ListCellRenderer lcr)
Deprecated. Customize the used editors.

Sets the ListCellRenderer for the editors to use. This implementation invokes
setAttribute( ATTRIBUTE_RENDERER, lcr );


setItemListener

public void setItemListener(java.awt.event.ItemListener il)
Deprecated. Customize the used editors.

Sets the ItemListener for the editors to use. This implementation invokes
setAttribute( ATTRIBUTE_ITEM_LISTENER, il );


addAll

public void addAll(java.util.Map itemI18nPairs)
This method is a convenience for the add(Object, Object) method. For all entries in the map, the add method will be called using the keys as the first argument and the values as the second one.


add

public void add(java.lang.Object item)
Convenience method that just calls add(Object, Object) with item as both of the arguments.


add

public void add(java.lang.Object item,
                java.lang.Object i18nKey)
Populates the choices for this EnumOptionItem. This item will keep a mapping between the two arguments. The item can can be queried and set using the getInterpretedValue() and setInterpretedValue(Object) methods. The i18nKey will be used as the internal "value".

Parameters:
item - the item that can be queried and set using the getInterpretedValue() and setInterpretedValue(Object) methods.
i18nKey - the value as it would have been set using the 3 argument constructor

getInterpretedValue

public java.lang.Object getInterpretedValue()
This method can be used in conjunction with the empty constructor and the add(Object, Object) method. It will not return the internal "value"/i18nKey, but the item, that was the first argument of the add method.
This implementation invokes isValueUndefined.

Returns:
the value associated with the current value.

setInterpretedValue

public void setInterpretedValue(java.lang.Object valueObject)
This method can be used in conjunction with the empty constructor and the add(Object, Object) method. It will set the corresponding internal "value"/i18nKey, for the item, which has previously been passed to the add method as the first value.
This implementation invokes setValue or setValueUndefined.


setValue

public void setValue(java.lang.Object value)
Overwritten to update the valueUndefined property as well.

Overrides:
setValue in class ObjectOptionItem
See Also:
OptionItem.publishValue(Object)

resetValue

public void resetValue()
Overwritten to reset not only the value of this item, but the value range and the valueUndefined property as well.

Overrides:
resetValue in class ObjectOptionItem
See Also:
OptionItem.publishValue(Object)

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