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
  • Field Details

  • Constructor Details

    • AttributeSelectionMap

      public AttributeSelectionMap​(java.lang.String name, java.util.HashMap<java.lang.String,​V> map, java.lang.Class<V> clazz)
    • AttributeSelectionMap

      public AttributeSelectionMap​(java.lang.String name, java.util.HashMap<java.lang.String,​V> map, java.lang.Class<V> clazz, java.lang.String selected)
  • Method Details

    • setComboWidth

      public void setComboWidth​(int width)
    • getValue

      public V getValue()
      Description copied from class: Attribute
      Returns the value of this Attribute.
      Overrides:
      getValue in class Attribute<V>
      Returns:
    • setComboRenderer

      public void setComboRenderer​(InterfaceComboBoxRenderer renderer)
    • getComboMode

      public AttributeSelectionMap.ComboMode getComboMode()
    • setComboMode

      public void setComboMode​(AttributeSelectionMap.ComboMode mode)
    • setValue

      public boolean setValue​(java.lang.Object value, boolean fire)
      Sets the current value, either as a key (if value is a String), or as the mapped value (instance of V).

      TODO: fails if V is instance of String; resolve

      Overrides:
      setValue in class Attribute<V>
      fire - Whether to notify listeners
      Returns:
    • 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 interface java.awt.event.ItemListener