Package mgui.interfaces.attributes
Class AttributeSelectionMap<V>
java.lang.Object
mgui.interfaces.AbstractInterfaceObject
mgui.interfaces.attributes.Attribute<V>
mgui.interfaces.attributes.AttributeSelectionMap<V>
- Type Parameters:
V
-
- All Implemented Interfaces:
java.awt.event.ItemListener
,java.lang.Cloneable
,java.lang.Comparable<Attribute<V>>
,java.util.EventListener
,InterfaceObject
,NamedObject
,TreeObject
,CleanableObject
,XMLObject
public class AttributeSelectionMap<V> extends Attribute<V> implements java.awt.event.ItemListener
Represents an
Attribute
with possible values mapped with String
keys.- Since:
- 1.0
- Version:
- 1.0
- Author:
- Andrew Reid
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AttributeSelectionMap.ComboMode
Nested classes/interfaces inherited from interface mgui.interfaces.xml.XMLObject
XMLObject.XMLEncoding, XMLObject.XMLType
-
Field Summary
Fields Modifier and Type Field Description protected AttributeSelectionMap.ComboMode
combo_mode
protected int
combo_width
protected java.util.HashMap<java.lang.String,V>
map
protected InterfaceComboBoxRenderer
renderer
protected java.lang.String
selected
Fields inherited from class mgui.interfaces.attributes.Attribute
isCopiable, isEditable, isNumeric, isSecret, name, object_class, value
Fields inherited from class mgui.interfaces.AbstractInterfaceObject
isDestroyed, tree_nodes
-
Constructor Summary
Constructors Constructor Description AttributeSelectionMap(java.lang.String name, java.util.HashMap<java.lang.String,V> map, java.lang.Class<V> clazz)
AttributeSelectionMap(java.lang.String name, java.util.HashMap<java.lang.String,V> map, java.lang.Class<V> clazz, java.lang.String selected)
-
Method Summary
Modifier and Type Method Description javax.swing.JComboBox
getComboBox()
Return a combo box containing this map, as either key values or mapped values (depending on the state of the ComboMode.AttributeSelectionMap.ComboMode
getComboMode()
V
getValue()
Returns the value of thisAttribute
.void
itemStateChanged(java.awt.event.ItemEvent e)
boolean
populateComboBox(javax.swing.JComboBox combo_box)
protected boolean
select(java.lang.String key)
void
setComboMode(AttributeSelectionMap.ComboMode mode)
void
setComboRenderer(InterfaceComboBoxRenderer renderer)
void
setComboWidth(int width)
boolean
setValue(java.lang.Object value, boolean fire)
Sets the current value, either as a key (ifvalue
is a String), or as the mapped value (instance of V).Methods inherited from class mgui.interfaces.attributes.Attribute
addAttributeListener, clone, compareTo, fireAttributeListeners, getDTD, getGenericInstance, getLocalName, getName, getObjectClass, getShortXML, getTreeLabel, getValueStr, getValueStr, getXML, getXML, getXMLInstance, getXMLSchema, handleXMLElementEnd, handleXMLElementStart, handleXMLString, isCopiable, isEditable, isNumeric, isSecret, issueTreeNode, removeAttributeListener, setEditable, setFromAttribute, setFromAttribute, setName, setSecret, setTreeNode, setValue, setValue, toString, writeXML, writeXML, writeXML, writeXML
Methods inherited from class mgui.interfaces.AbstractInterfaceObject
clean, destroy, isDestroyed, updateTreeNodes
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Field Details
-
map
-
selected
protected java.lang.String selected -
renderer
-
combo_mode
-
combo_width
protected int combo_width
-
-
Constructor Details
-
AttributeSelectionMap
-
AttributeSelectionMap
-
-
Method Details
-
setComboWidth
public void setComboWidth(int width) -
getValue
Description copied from class:Attribute
Returns the value of thisAttribute
. -
setComboRenderer
-
getComboMode
-
setComboMode
-
setValue
public boolean setValue(java.lang.Object value, boolean fire)Sets the current value, either as a key (ifvalue
is a String), or as the mapped value (instance of V).TODO: fails if V is instance of String; resolve
-
select
protected boolean select(java.lang.String key) -
getComboBox
public javax.swing.JComboBox getComboBox()Return a combo box containing this map, as either key values or mapped values (depending on the state of the ComboMode.- Returns:
-
populateComboBox
public boolean populateComboBox(javax.swing.JComboBox combo_box) -
itemStateChanged
public void itemStateChanged(java.awt.event.ItemEvent e)- Specified by:
itemStateChanged
in interfacejava.awt.event.ItemListener
-