Class IconAdder

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, EventListener, Accessible, ListSelectionListener
Direct Known Subclasses:
MultiSensorIconAdder, SlipIconAdder

public class IconAdder extends JPanel implements ListSelectionListener
Provides a simple editor for selecting N NamedIcons. Class for Icon Editors implements "Drag n Drop". Allows drops from icons dragged from a Catalog preview pane.

See SensorIcon for an item that might want to have that type of information, and PanelEditor for an example of how to use this.

See Also:
  • Field Details

  • Constructor Details

  • Method Details

    • reset

      public void reset()
    • initDefaultIcons

      public void initDefaultIcons()
    • getDefaultIconNode

    • makeIcons

      protected void makeIcons(CatalogTreeNode n)
      Build iconMap and orderArray from user's choice of defaults.
      Parameters:
      n - the root in a catalog from which icons are made
    • setIcon

      protected void setIcon(int order, String label, NamedIcon icon)
      Parameters:
      order - the index to icon's name and the inverse order that icons are drawn in doIconPanel()
      label - the icon name displayed in the icon panel and the key to the icon button in _iconMap, supplied as I18N string
      icon - the icon displayed in the icon button
    • setIcon

      public void setIcon(int order, String label, String name)
      Install the icons used to represent all the states of the entity being edited.
      Parameters:
      order - (reverse) order of display, (0 last, to N first)
      label - the state name to display. Must be unique from all other calls to this method
      name - the resource name of the icon image to display
    • setParent

      public void setParent(JFrame parent)
    • pack

      void pack()
    • getNumIcons

      public int getNumIcons()
    • makeIconPanel

      public void makeIconPanel(boolean useDefaults)
      After all the calls to setIcon(...) are made, make the icon display. Two columns to save space for subsequent panels.
      Parameters:
      useDefaults - true to use user-specified defaults; false otherwise
    • doIconPanel

      protected void doIconPanel()
    • setPickList

      public void setPickList(PickListModel<? extends NamedBean> tableModel)
      After the calls to makeIconPanel(), optionally make a pick list table for managed elements. (Not all Icon Editors use pick lists).
      Parameters:
      tableModel - the model from which the table is created
    • setSelection

      public void setSelection(NamedBean bean)
    • valueChanged

      When a Pick list is installed, table selection controls the Add button.
      Specified by:
      valueChanged in interface ListSelectionListener
    • getTableSelection

      Used by Panel Editor to make the final installation of the icon(s) into the user's Panel.

      Note! the selection is cleared. When two successive calls are made, the 2nd will always return null, regardless of the 1st return.

      Returns:
      the selected item
    • getIcon

      public NamedIcon getIcon(String key)
      Get a new NamedIcon object for your own use.
      Parameters:
      key - Name of key (label)
      Returns:
      Unique object
    • getIconMap

      Get a new Hashtable of only the icons selected for display.
      Returns:
      a map of icons using the icon labels as keys
    • complete

      public void complete(ActionListener addIconAction, boolean changeIcon, boolean addToTable, boolean update)
    • addAdditionalButtons

      protected void addAdditionalButtons(JPanel p)
    • addIconIsEnabled

      public boolean addIconIsEnabled()
    • addToTable

      void addToTable()
    • addCatalog

      public void addCatalog()
    • closeCatalog

      void closeCatalog()
    • addDirectoryToCatalog

      public void addDirectoryToCatalog()
    • dispose

      public void dispose()
      Clean up when its time to make it all go away