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()
Modifier and Type | Field and 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 and 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) |
Modifier and Type | Method and Description |
---|---|
void |
add(javax.swing.Action action)
Adds an action to the current implicit group.
|
void |
add(IMenuMergeModel item)
Adds a new menu merge model to the current implicit group
|
void |
add(int separatorGroup,
javax.swing.Action action)
Adds a new action, wrapped in a
ActionMenuItemMerge , to the specified group number |
void |
add(int separatorGroup,
IMenuMergeModel item)
Adds a new menu merge model to the specified group number
|
void |
addSeparator()
Increments the implicit group ID so that subsequent additions will start forming a new group
|
protected 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
|
protected java.lang.String menuId
protected java.lang.String name
protected java.lang.String displayKey
protected javax.swing.Icon icon
protected java.util.SortedMap<java.lang.Integer,com.inductiveautomation.ignition.designer.model.menu.AbstractMenuMerge.SeparatorGroup> groups
protected int currentImplicitGroup
protected org.apache.log4j.Logger log
public AbstractMenuMerge(java.lang.String name)
public AbstractMenuMerge(java.lang.String name, java.lang.String displayKey)
public AbstractMenuMerge(java.lang.String name, java.lang.String displayKey, javax.swing.Icon icon)
public void addSeparator()
public void add(javax.swing.Action action)
ActionMenuItemMerge
public void add(IMenuMergeModel item)
public void add(int separatorGroup, javax.swing.Action action)
ActionMenuItemMerge
, to the specified group numberpublic void add(int separatorGroup, IMenuMergeModel item)
public javax.swing.JComponent install(javax.swing.JComponent menu)
IMenuMergeModel
install
in interface IMenuMergeModel
public void uninstall(javax.swing.JComponent menu)
IMenuMergeModel
uninstall
in interface IMenuMergeModel
protected abstract void addSeparator(javax.swing.JComponent menu)
public abstract javax.swing.JComponent createMenu()
public java.lang.String getMenuId()
public void setMenuId(java.lang.String moduleId)
public java.lang.String getName()
protected java.lang.Iterable<javax.swing.JComponent> iterate(javax.swing.JComponent menu)
menu
-