Class AbstractMenuMerge

java.lang.Object
com.inductiveautomation.ignition.designer.model.menu.AbstractMenuMerge
All Implemented Interfaces:
IMenuMergeModel
Direct Known Subclasses:
DockableBarMerge, JMenuMerge, MenuBarMerge, ToolbarMerge

public abstract class AbstractMenuMerge extends Object implements IMenuMergeModel

Abstract base class for all menu merges that represent a collection, for example a menu or a toolbar, as opposed to a single item. This class requires a name which is the logical name of the collection it represents. Remember that the whole point of the menu merge system is that more than one menu merge may represent the same logical name. For example, you might have 3 menu merges for the "file" menu - and they'll all merge together.

The way a menu merge works is to store lists of other menu-merge models. Each list of sub-models forms a group and has its own ordering value, which is used to separate it from other groups. The index value determines the relative ordering of all menu groups. You can add individual items to any group by using its ordering value.

You can use implicit or explicit group ordering depending on which version of the add functions you use. If you use implicit ordering, your first group has a value of 10,000 and you create new groups by calling addSeparator()

  • Field Details

    • name

      protected String name
    • displayKey

      protected String displayKey
    • icon

      protected Icon icon
    • groups

      protected SortedMap<Integer,com.inductiveautomation.ignition.designer.model.menu.AbstractMenuMerge.SeparatorGroup> groups
    • currentImplicitGroup

      protected int currentImplicitGroup
    • log

      protected org.apache.log4j.Logger log
  • Constructor Details

    • AbstractMenuMerge

      public AbstractMenuMerge(String name)
    • AbstractMenuMerge

      public AbstractMenuMerge(String name, String displayKey)
    • AbstractMenuMerge

      public AbstractMenuMerge(String name, String displayKey, Icon icon)
  • Method Details

    • addSeparator

      public void addSeparator()
      Increments the implicit group ID so that subsequent additions will start forming a new group
    • add

      public void add(Action action)
      Adds an action to the current implicit group. Wraps the action in a ActionMenuItemMerge
    • add

      public void add(IMenuMergeModel item)
      Adds a new menu merge model to the current implicit group
    • add

      public void add(int separatorGroup, Action action)
      Adds a new action, wrapped in a ActionMenuItemMerge, to the specified group number
    • add

      public void add(int separatorGroup, IMenuMergeModel item)
      Adds a new menu merge model to the specified group number
    • install

      public JComponent install(JComponent menu)
      Description copied from interface: IMenuMergeModel
      Merges this model into the menu. The JComponent will be either a CommandMenuBar or a JMenu
      Specified by:
      install in interface IMenuMergeModel
    • uninstall

      public void uninstall(JComponent menu)
      Description copied from interface: IMenuMergeModel
      Reverses the merge of this model into the given menu
      Specified by:
      uninstall in interface IMenuMergeModel
    • addSeparator

      protected abstract void addSeparator(JComponent menu)
      Subclasses must define how "separator" components get added to the parent menu item.
    • createMenu

      public abstract JComponent createMenu()
      Create the parent menu item represented by this object, that all of its children should be contained in.
    • getMenuId

      public String getMenuId()
    • setMenuId

      public void setMenuId(String moduleId)
    • getName

      public String getName()
    • iterate

      protected Iterable<JComponent> iterate(JComponent menu)
      Creates an Iterable<JComponent> for the menu. If menu is a JMenu, it'll iterate over the menu components contained within (menu components don't directly contain their children - they're contained within a private PopupMenu), otherwise it uses normal JComponent iteration.
      Parameters:
      menu - the JMenu to iterate