public class RibbonApplicationMenu
extends java.lang.Object
JRibbon component. The ribbon
application menu has three parts:
+-------------------------------------+ | | | | | | | primary | secondary | | area | area | | | | | | | |-------------------------------------| | footer area | +-------------------------------------+
The entries in the primary area are always visible. The secondary area entries are shown based on the currently active element in the primary area. There are two different types of primary entries:
RibbonApplicationMenuPrimaryCommand.PrimaryRolloverCallback configured by the
RibbonApplicationMenuPrimaryCommand.RibbonApplicationMenuPrimaryCommandBuilder.setRolloverCallback(PrimaryRolloverCallback)
. When this entry is armed (with mouse rollover or via keyboard navigation), the contents of the
secondary area are populated by the application callback implementation of
RibbonApplicationMenuPrimaryCommand.PrimaryRolloverCallback.menuEntryActivated(javax.swing.JPanel). The Open
menu item is an example of such a primary menu entry, showing a list of recently opened files.
For a primary entry that is action-only, pass RibbonApplicationMenuPrimaryCommand.PrimaryClearRolloverCallback as the primary
rollover callback to clear the secondary area.FlamingoCommands added with the
RibbonApplicationMenuPrimaryCommand.RibbonApplicationMenuPrimaryCommandBuilder.addSecondaryMenuGroup(String, FlamingoCommand...)
API. When this entry is armed (with mouse rollover or via keyboard navigation), the secondary
area shows menu buttons for the registered secondary menu entries. The Save As menu
item is an example of such a primary menu item, showing a list of default save formats.
At runtime, the application menu entries are implemented as JCommandMenuButton, but the
application code does not operate on that level. Instead, the application code creates
metadata-driven description of the ribbon application menu with
RibbonApplicationMenuPrimaryCommand.RibbonApplicationMenuPrimaryCommandBuilder and FlamingoCommand.FlamingoCommandBuilder, and those
commands is used to create and populate the "real" controls of the application menu popup.
Note that once a RibbonApplicationMenu is set on the JRibbon with the
JRibbon.setApplicationMenu(RibbonApplicationMenu), its contents cannot be changed. An
IllegalStateException will be thrown from
addMenuCommand(RibbonApplicationMenuPrimaryCommand) and
addFooterCommand(FlamingoCommand).
| Constructor | Description |
|---|---|
RibbonApplicationMenu(java.lang.String title) |
Creates an empty ribbon application menu.
|
| Modifier and Type | Method | Description |
|---|---|---|
void |
addFooterCommand(FlamingoCommand entry) |
Adds the specified footer command.
|
void |
addMenuCommand(RibbonApplicationMenuPrimaryCommand command) |
Adds the specified primary menu command.
|
void |
addMenuSeparator() |
|
RibbonApplicationMenuPrimaryCommand.PrimaryRolloverCallback |
getDefaultCallback() |
Returns the default callback of this ribbon application menu.
|
java.util.List<FlamingoCommand> |
getFooterCommands() |
Returns an unmodifiable list of all footer commands of this application menu.
|
java.util.List<java.util.List<RibbonApplicationMenuPrimaryCommand>> |
getPrimaryCommands() |
Returns an unmodifiable list of all primary menu commands of this application menu.
|
java.lang.String |
getTitle() |
|
void |
setDefaultCallback(RibbonApplicationMenuPrimaryCommand.PrimaryRolloverCallback defaultCallback) |
Sets the default callback to be called when:
The ribbon application menu is first shown.
The currently active (rollover) primary application menu entry has no secondary menu
entries and no associated rollover callback.
|
public RibbonApplicationMenu(java.lang.String title)
public java.lang.String getTitle()
public void addMenuCommand(RibbonApplicationMenuPrimaryCommand command)
command - Primary menu command to add.java.lang.IllegalStateException - if this ribbon application menu has already been set on the JRibbon with
the JRibbon.setApplicationMenu(RibbonApplicationMenu).getPrimaryCommands(),
addFooterCommand(FlamingoCommand)public void addMenuSeparator()
public java.util.List<java.util.List<RibbonApplicationMenuPrimaryCommand>> getPrimaryCommands()
null.addMenuCommand(RibbonApplicationMenuPrimaryCommand),
getFooterCommands()public void addFooterCommand(FlamingoCommand entry)
entry - Footer command to add.java.lang.IllegalStateException - if this ribbon application menu has already been set on the JRibbon with
the JRibbon.setApplicationMenu(RibbonApplicationMenu).getFooterCommands(),
addMenuCommand(RibbonApplicationMenuPrimaryCommand)public java.util.List<FlamingoCommand> getFooterCommands()
null.addFooterCommand(FlamingoCommand),
getPrimaryCommands()public void setDefaultCallback(RibbonApplicationMenuPrimaryCommand.PrimaryRolloverCallback defaultCallback)
defaultCallback - Default callback.public RibbonApplicationMenuPrimaryCommand.PrimaryRolloverCallback getDefaultCallback()
setDefaultCallback(PrimaryRolloverCallback)