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 classAttributeSelectionMap.ComboModeNested classes/interfaces inherited from interface mgui.interfaces.xml.XMLObject
XMLObject.XMLEncoding, XMLObject.XMLType -
Field Summary
Fields Modifier and Type Field Description protected AttributeSelectionMap.ComboModecombo_modeprotected intcombo_widthprotected java.util.HashMap<java.lang.String,V>mapprotected InterfaceComboBoxRendererrendererprotected java.lang.StringselectedFields inherited from class mgui.interfaces.attributes.Attribute
isCopiable, isEditable, isNumeric, isSecret, name, object_class, valueFields 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.JComboBoxgetComboBox()Return a combo box containing this map, as either key values or mapped values (depending on the state of the ComboMode.AttributeSelectionMap.ComboModegetComboMode()VgetValue()Returns the value of thisAttribute.voiditemStateChanged(java.awt.event.ItemEvent e)booleanpopulateComboBox(javax.swing.JComboBox combo_box)protected booleanselect(java.lang.String key)voidsetComboMode(AttributeSelectionMap.ComboMode mode)voidsetComboRenderer(InterfaceComboBoxRenderer renderer)voidsetComboWidth(int width)booleansetValue(java.lang.Object value, boolean fire)Sets the current value, either as a key (ifvalueis 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, writeXMLMethods inherited from class mgui.interfaces.AbstractInterfaceObject
clean, destroy, isDestroyed, updateTreeNodesMethods 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:AttributeReturns 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 (ifvalueis 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:
itemStateChangedin interfacejava.awt.event.ItemListener
-