java.lang.Object
com.inductiveautomation.ignition.designer.model.menu.AbstractMenuMerge
com.inductiveautomation.ignition.designer.model.menu.JMenuMerge
All Implemented Interfaces:
IMenuMergeModel

public class JMenuMerge extends AbstractMenuMerge

Represents a menu merge for a JMenu. This may be a top-level menu (like "file") or a sub-menu. That is, a JMenuMerge can contain a mix of other JMenuMerge children and individual item merges. This class has convenience functions that allow for easily adding menu items based on StateChangeActions and JMenuItems.

To create JMenuMerges that merge items into the main menus, use the constants found in WellKnownMenuConstants . For example, suppose a module wanted to add a menu item to the File > New menu. You would create a JMenuMerge using the file menu's name, and add it at the file menu's location. You would create the following MenuBarMerge and return it from your Designer module hook's DesignerModuleHook.getModuleMenu() function.

 Action myNewAction = new AbstractAction("New Thingamajig") {
 public void actionPerformed(ActionEvent ae) {
        System.out.println("Do something here...");
    }
 };

 MenuBarMerge menu = new MenuBarMerge("mymodule-id");

 JMenuMerge file = new JMenuMerge(WellKnownMenuConstants.FILE_MENU_NAME);
 JMenuMerge fileNew = new JMenuMerge("new");
 fileNew.add(myNewAction);
 file.add(WellKnownMenuConstants.FILE_OPENSAVE_GROUP, fileNew);
 menu.add(WellKnownMenuConstants.FILE_MENU_LOCATION, file);
 

  • Constructor Details

    • JMenuMerge

      public JMenuMerge(String name)
    • JMenuMerge

      public JMenuMerge(String name, String displayKey)
    • JMenuMerge

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

    • addCheckBox

      public void addCheckBox(StateChangeAction action)
    • addRadioGroup

      public void addRadioGroup(StateChangeAction... actions)
    • add

      public void add(JMenuItem menuItem)
    • add

      public void add(JMenu menu)
      Used to add opaque (non-mergable) menus
    • addCheckBox

      public void addCheckBox(int separatorGroup, StateChangeAction action)
    • addRadioGroup

      public void addRadioGroup(int separatorGroup, StateChangeAction... actions)
    • add

      public void add(int separatorGroup, JMenuItem menuItem)
    • add

      public void add(int separatorGroup, JMenu menu)
      Used to add opaque (non-mergable) menus
    • install

      public JComponent install(JComponent menuToInstall)
      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
      Overrides:
      install in class AbstractMenuMerge
    • uninstall

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

      public JMenu createMenu()
      Description copied from class: AbstractMenuMerge
      Create the parent menu item represented by this object, that all of its children should be contained in.
      Specified by:
      createMenu in class AbstractMenuMerge
    • addSeparator

      protected void addSeparator(JComponent menu)
      Description copied from class: AbstractMenuMerge
      Subclasses must define how "separator" components get added to the parent menu item.
      Specified by:
      addSeparator in class AbstractMenuMerge
    • dispose

      public void dispose()
      removes all internal bindings which allows this merge to be garbage collected.