Package org.nuiton.jaxx.runtime.swing
Class Item
- java.lang.Object
-
- org.nuiton.jaxx.runtime.swing.Item
-
public class Item extends Object
An item in a component such asJComboBoxorJTree. TheItemclass corresponds to the<item>tag in JAXX source files.
-
-
Field Summary
Fields Modifier and Type Field Description static StringLABEL_PROPERTYstatic StringSELECTED_PROPERTYstatic StringVALUE_PROPERTY
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddChild(Item item)Adds a new child node (Items can be nested in trees).voidaddPropertyChangeListener(PropertyChangeListener listener)voidaddPropertyChangeListener(String property, PropertyChangeListener listener)protected voidfirePropertyChange(String propertyName, Object oldValue, Object newValue)List<Item>getChildren()Returns a list of this item's children.StringgetId()Returns this item's ID.StringgetLabel()Returns the string that should be used to represent the item at display time.ItemgetParent()Returns theItemcontaining thisItem, ornullfor a top-levelItem.ObjectgetValue()Returns the item's actual value as it appears in the component's model.booleanisSelected()Returnstrueif this item is currently selected.voidremoveChild(Item item)Remove child node a new child nodevoidremoveChilds(List<Item> items)Remove all childs nodesvoidremovePropertyChangeListener(PropertyChangeListener listener)voidremovePropertyChangeListener(String property, PropertyChangeListener listener)voidsetLabel(String label)Sets the item's display string.voidsetParent(Item parent)Set the parent of this itemvoidsetSelected(boolean selected)Sets the item's selection state.voidsetValue(Object value)Sets the item's value as it appears in the component's model.StringtoString()
-
-
-
Field Detail
-
LABEL_PROPERTY
public static final String LABEL_PROPERTY
- See Also:
- Constant Field Values
-
VALUE_PROPERTY
public static final String VALUE_PROPERTY
- See Also:
- Constant Field Values
-
SELECTED_PROPERTY
public static final String SELECTED_PROPERTY
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Item
public Item(String id, String label, Object value, boolean selected)
Creates a new Item. This should only be called from compiled JAXX files.- Parameters:
id- the item's IDlabel- the string that should be used to represent the item visuallyvalue- the item's actual valueselected-trueif the item should be selected by default
-
-
Method Detail
-
getId
public String getId()
Returns this item's ID.- Returns:
- the JAXX ID attribute
-
getLabel
public String getLabel()
Returns the string that should be used to represent the item at display time. Ifnull,String.valueOf(getValue())will be used instead.- Returns:
- this item's display string
- See Also:
setLabel(java.lang.String)
-
setLabel
public void setLabel(String label)
Sets the item's display string. Ifnull, String.valueOf(getValue())will be used instead.- Parameters:
label- the new display string- See Also:
getLabel()
-
getValue
public Object getValue()
Returns the item's actual value as it appears in the component's model. TheItemitself is not visible from the model, only the value.- Returns:
- the item's value
- See Also:
setValue(java.lang.Object)
-
setValue
public void setValue(Object value)
Sets the item's value as it appears in the component's model. TheItemitself is not visible from the model, only the value.- Parameters:
value- the new value- See Also:
getValue()
-
isSelected
public boolean isSelected()
Returnstrueif this item is currently selected. This is a bound property.- Returns:
trueif item is selected- See Also:
setSelected(boolean)
-
setSelected
public void setSelected(boolean selected)
Sets the item's selection state. This is a bound property.- Parameters:
selected- the new selection state- See Also:
isSelected()
-
addChild
public void addChild(Item item)
Adds a new child node (Items can be nested in trees).- Parameters:
item- the new child item
-
removeChild
public void removeChild(Item item)
Remove child node a new child node- Parameters:
item- to remove
-
removeChilds
public void removeChilds(List<Item> items)
Remove all childs nodes- Parameters:
items- list of items to remove
-
getChildren
public List<Item> getChildren()
Returns a list of this item's children.- Returns:
- a list of all nested child nodes
-
getParent
public Item getParent()
Returns theItemcontaining thisItem, ornullfor a top-levelItem.- Returns:
- the item parent (or null)
-
setParent
public void setParent(Item parent)
Set the parent of this item- Parameters:
parent- the item parent (or null)
-
addPropertyChangeListener
public void addPropertyChangeListener(PropertyChangeListener listener)
-
addPropertyChangeListener
public void addPropertyChangeListener(String property, PropertyChangeListener listener)
-
removePropertyChangeListener
public void removePropertyChangeListener(PropertyChangeListener listener)
-
removePropertyChangeListener
public void removePropertyChangeListener(String property, PropertyChangeListener listener)
-
firePropertyChange
protected void firePropertyChange(String propertyName, Object oldValue, Object newValue)
-
-