Class AbstractMenuMerge
- All Implemented Interfaces:
IMenuMergeModel
- Direct Known Subclasses:
DockableBarMerge
,JMenuMerge
,MenuBarMerge
,ToolbarMerge
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 -
Constructor Summary
ConstructorsConstructorDescriptionAbstractMenuMerge
(String name) AbstractMenuMerge
(String name, String displayKey) AbstractMenuMerge
(String name, String displayKey, Icon icon) -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(int separatorGroup, IMenuMergeModel item) Adds a new menu merge model to the specified group numbervoid
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
Adds an action to the current implicit group.void
Increments the implicit group ID so that subsequent additions will start forming a new groupprotected abstract void
addSeparator
(JComponent menu) Subclasses must define how "separator" components get added to the parent menu item.abstract JComponent
Create the parent menu item represented by this object, that all of its children should be contained in.getName()
install
(JComponent menu) Merges this model into the menu.protected Iterable<JComponent>
iterate
(JComponent menu) Creates an Iterable<JComponent> for the menu.void
void
uninstall
(JComponent menu) Reverses the merge of this model into the given menu
-
Field Details
-
name
-
displayKey
-
icon
-
groups
-
currentImplicitGroup
protected int currentImplicitGroup -
log
protected org.apache.log4j.Logger log
-
Constructor Details
-
AbstractMenuMerge
-
AbstractMenuMerge
-
AbstractMenuMerge
-
-
Method Details
-
addSeparator
public void addSeparator()Increments the implicit group ID so that subsequent additions will start forming a new group -
add
Adds an action to the current implicit group. Wraps the action in aActionMenuItemMerge
-
add
Adds a new action, wrapped in aActionMenuItemMerge
, to the specified group number -
install
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
Description copied from interface:IMenuMergeModel
Reverses the merge of this model into the given menu- Specified by:
uninstall
in interfaceIMenuMergeModel
-
addSeparator
Subclasses must define how "separator" components get added to the parent menu item. -
createMenu
Create the parent menu item represented by this object, that all of its children should be contained in. -
getMenuId
-
setMenuId
-
getName
-
iterate
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
-