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 java.lang.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 Summary
Fields Modifier and Type Field Description protected int
currentImplicitGroup
protected java.lang.String
displayKey
protected java.util.SortedMap<java.lang.Integer,com.inductiveautomation.ignition.designer.model.menu.AbstractMenuMerge.SeparatorGroup>
groups
protected javax.swing.Icon
icon
protected org.apache.log4j.Logger
log
protected java.lang.String
menuId
protected java.lang.String
name
-
Constructor Summary
Constructors Constructor Description AbstractMenuMerge(java.lang.String name)
AbstractMenuMerge(java.lang.String name, java.lang.String displayKey)
AbstractMenuMerge(java.lang.String name, java.lang.String displayKey, javax.swing.Icon icon)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
add(int separatorGroup, IMenuMergeModel item)
Adds a new menu merge model to the specified group numbervoid
add(int separatorGroup, javax.swing.Action action)
Adds a new action, wrapped in aActionMenuItemMerge
, to the specified group numbervoid
add(IMenuMergeModel item)
Adds a new menu merge model to the current implicit groupvoid
add(javax.swing.Action action)
Adds an action to the current implicit group.void
addSeparator()
Increments the implicit group ID so that subsequent additions will start forming a new groupprotected abstract void
addSeparator(javax.swing.JComponent menu)
Subclasses must define how "separator" components get added to the parent menu item.abstract javax.swing.JComponent
createMenu()
Create the parent menu item represented by this object, that all of its children should be contained in.java.lang.String
getMenuId()
java.lang.String
getName()
javax.swing.JComponent
install(javax.swing.JComponent menu)
Merges this model into the menu.protected java.lang.Iterable<javax.swing.JComponent>
iterate(javax.swing.JComponent menu)
Creates an Iterable<JComponent> for the menu.void
setMenuId(java.lang.String moduleId)
void
uninstall(javax.swing.JComponent menu)
Reverses the merge of this model into the given menu
-
-
-
Field Detail
-
menuId
protected java.lang.String menuId
-
name
protected java.lang.String name
-
displayKey
protected java.lang.String displayKey
-
icon
protected javax.swing.Icon icon
-
groups
protected java.util.SortedMap<java.lang.Integer,com.inductiveautomation.ignition.designer.model.menu.AbstractMenuMerge.SeparatorGroup> groups
-
currentImplicitGroup
protected int currentImplicitGroup
-
log
protected org.apache.log4j.Logger log
-
-
Constructor Detail
-
AbstractMenuMerge
public AbstractMenuMerge(java.lang.String name)
-
AbstractMenuMerge
public AbstractMenuMerge(java.lang.String name, java.lang.String displayKey)
-
AbstractMenuMerge
public AbstractMenuMerge(java.lang.String name, java.lang.String displayKey, javax.swing.Icon icon)
-
-
Method Detail
-
addSeparator
public void addSeparator()
Increments the implicit group ID so that subsequent additions will start forming a new group
-
add
public void add(javax.swing.Action action)
Adds an action to the current implicit group. Wraps the action in aActionMenuItemMerge
-
add
public void add(IMenuMergeModel item)
Adds a new menu merge model to the current implicit group
-
add
public void add(int separatorGroup, javax.swing.Action action)
Adds a new action, wrapped in aActionMenuItemMerge
, 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 javax.swing.JComponent install(javax.swing.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 interfaceIMenuMergeModel
-
uninstall
public void uninstall(javax.swing.JComponent menu)
Description copied from interface:IMenuMergeModel
Reverses the merge of this model into the given menu- Specified by:
uninstall
in interfaceIMenuMergeModel
-
addSeparator
protected abstract void addSeparator(javax.swing.JComponent menu)
Subclasses must define how "separator" components get added to the parent menu item.
-
createMenu
public abstract javax.swing.JComponent createMenu()
Create the parent menu item represented by this object, that all of its children should be contained in.
-
getMenuId
public java.lang.String getMenuId()
-
setMenuId
public void setMenuId(java.lang.String moduleId)
-
getName
public java.lang.String getName()
-
iterate
protected java.lang.Iterable<javax.swing.JComponent> iterate(javax.swing.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
- theJMenu
to iterate
-
-