public abstract class AbstractEnumerationField extends PropertyField implements java.awt.event.ActionListener, javax.swing.ComboBoxModel
TypeSafeEnumeration
and follow the conventions described there. Additional
implementations can be supplied to support the display of other enumerating
types, in particular dynamic ones that cannot be fit into the
TypeSafeEnumeration
conventions.
For example, the field that allows the "Default Fix" to be selected is a
subclass of AbstractEnumerationField
which accepts a rule instance
in its constructor and overrides the stringOf(java.lang.Object)
and valueOf(java.lang.String)
to map between the rule's transforms and their names, and between
null
and "None". A BeanCustomizer
associated with the
Rule
class sets up this field.
Constructor and Description |
---|
AbstractEnumerationField()
Creates an enumeration property field.
|
AbstractEnumerationField(java.lang.String[] enumerals)
Creates an enumeration property field with an initial set of enumerals.
|
Modifier and Type | Method and Description |
---|---|
void |
actionPerformed(java.awt.event.ActionEvent e) |
void |
addListDataListener(javax.swing.event.ListDataListener listener) |
void |
fireContentsChanged(int index0,
int index1) |
void |
fireIntervalAdded(int index0,
int index1) |
void |
fireIntervalRemoved(int index0,
int index1) |
javax.swing.JComponent |
getComponent() |
boolean |
getComponentTracksContainerWidth() |
java.lang.Object |
getElementAt(int index) |
java.lang.Object |
getSelectedItem() |
int |
getSize() |
java.lang.Object |
getValue()
The
AbstractEnumerationField implementation maps the text selected
by the user to a value by invoking valueOf(java.lang.String) . |
void |
removeListDataListener(javax.swing.event.ListDataListener listener) |
void |
setEnumerals(java.lang.String[] newValue)
Sets the enumerals allowed for this property.
|
void |
setSelectedItem(java.lang.Object item) |
void |
setValue(java.lang.Object value)
The
AbstractEnumerationField implementation maps the value to the
text presented to the user by invoking stringOf(java.lang.Object) . |
java.lang.String |
stringOf(java.lang.Object value)
Gets the presentation string for a value of the property type.
|
java.lang.Object |
valueOf(java.lang.String text)
Gets the value of the property type corresponding to a presentation string.
|
addFieldListener, apply, equals, fireFieldChanged, fireFieldCommitted, fireFieldEntered, fireFieldExited, focusGained, focusLost, getDescriptor, getType, handleException, load, removeFieldListener, setDescriptor, setType, toString
baseline, getComponentBaseline, getLabel, getLabelText, getMnemonic, getMnemonicIndex, getName, setLabelText, setMnemonic, setMnemonicIndex, setName
public AbstractEnumerationField()
public AbstractEnumerationField(java.lang.String[] enumerals)
enumerals
- The text to be displayed for each enumeral allowed for
this property.public void setEnumerals(java.lang.String[] newValue)
newValue
- The text to be displayed for each enumeral allowed for
this property.public void setValue(java.lang.Object value)
AbstractEnumerationField
implementation maps the value to the
text presented to the user by invoking stringOf(java.lang.Object)
.setValue
in class PropertyField
public java.lang.Object getValue()
AbstractEnumerationField
implementation maps the text selected
by the user to a value by invoking valueOf(java.lang.String)
.getValue
in class PropertyField
public javax.swing.JComponent getComponent()
The AbstractEnumerationField
implementation returns a combo
box created by the constructor with this field as its co
getComponent
in class PropertyItem
public boolean getComponentTracksContainerWidth()
getComponentTracksContainerWidth
in class PropertyItem
public void actionPerformed(java.awt.event.ActionEvent e)
actionPerformed
in interface java.awt.event.ActionListener
public java.lang.Object valueOf(java.lang.String text)
AbstractEnumerationField
implementation simply returns the
text, and so must be overridden unless the property type is String
.public java.lang.String stringOf(java.lang.Object value)
AbstractEnumerationField
implementation simply casts the value
to String
, and so must be overridden unless the property type is
String
.public java.lang.Object getSelectedItem()
getSelectedItem
in interface javax.swing.ComboBoxModel
public void setSelectedItem(java.lang.Object item)
setSelectedItem
in interface javax.swing.ComboBoxModel
public java.lang.Object getElementAt(int index)
getElementAt
in interface javax.swing.ListModel
public int getSize()
getSize
in interface javax.swing.ListModel
public void addListDataListener(javax.swing.event.ListDataListener listener)
addListDataListener
in interface javax.swing.ListModel
public void removeListDataListener(javax.swing.event.ListDataListener listener)
removeListDataListener
in interface javax.swing.ListModel
public void fireIntervalAdded(int index0, int index1)
public void fireIntervalRemoved(int index0, int index1)
public void fireContentsChanged(int index0, int index1)