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 three different types of primary entries:
ActionListener
passed to the constructor of the
RibbonApplicationMenuEntryPrimary
. When this entry is armed (with
mouse rollover or via keyboard navigation), the contents of the secondary
area are cleared. The Quit
menu item is an example of such a
primary menu entry.RibbonApplicationMenuEntryPrimary.PrimaryRolloverCallback
set by the
RibbonApplicationMenuEntryPrimary.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
RibbonApplicationMenuEntryPrimary.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.RibbonApplicationMenuEntrySecondary
s added
with the
RibbonApplicationMenuEntryPrimary.addSecondaryMenuGroup(String, RibbonApplicationMenuEntrySecondary...)
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, and that description 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 addMenuEntry(RibbonApplicationMenuEntryPrimary)
and
addFooterEntry(RibbonApplicationMenuEntryFooter)
.
Constructor and Description |
---|
RibbonApplicationMenu()
Creates an empty ribbon application menu.
|
Modifier and Type | Method and Description |
---|---|
void |
addFooterEntry(RibbonApplicationMenuEntryFooter entry)
Adds the specified footer menu entry.
|
void |
addMenuEntry(RibbonApplicationMenuEntryPrimary entry)
Adds the specified primary menu entry.
|
void |
addMenuSeparator() |
RibbonApplicationMenuEntryPrimary.PrimaryRolloverCallback |
getDefaultCallback()
Returns the default callback of this ribbon application menu.
|
java.util.List<RibbonApplicationMenuEntryFooter> |
getFooterEntries()
Returns an unmodifiable list of all footer menu entries of this
application menu.
|
java.util.List<java.util.List<RibbonApplicationMenuEntryPrimary>> |
getPrimaryEntries()
Returns an unmodifiable list of all primary menu entries of this
application menu.
|
void |
setDefaultCallback(RibbonApplicationMenuEntryPrimary.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()
public void addMenuEntry(RibbonApplicationMenuEntryPrimary entry)
entry
- Primary menu entry to add.java.lang.IllegalStateException
- if this ribbon application menu has already been set on the
JRibbon
with the
JRibbon.setApplicationMenu(RibbonApplicationMenu)
.getPrimaryEntries()
,
addFooterEntry(RibbonApplicationMenuEntryFooter)
public void addMenuSeparator()
public java.util.List<java.util.List<RibbonApplicationMenuEntryPrimary>> getPrimaryEntries()
null
.addMenuEntry(RibbonApplicationMenuEntryPrimary)
,
getFooterEntries()
public void addFooterEntry(RibbonApplicationMenuEntryFooter entry)
entry
- Footer menu entry to add.java.lang.IllegalStateException
- if this ribbon application menu has already been set on the
JRibbon
with the
JRibbon.setApplicationMenu(RibbonApplicationMenu)
.getFooterEntries()
,
addMenuEntry(RibbonApplicationMenuEntryPrimary)
public java.util.List<RibbonApplicationMenuEntryFooter> getFooterEntries()
null
.addFooterEntry(RibbonApplicationMenuEntryFooter)
,
getPrimaryEntries()
public void setDefaultCallback(RibbonApplicationMenuEntryPrimary.PrimaryRolloverCallback defaultCallback)
defaultCallback
- Default callback.public RibbonApplicationMenuEntryPrimary.PrimaryRolloverCallback getDefaultCallback()
setDefaultCallback(org.pushingpixels.flamingo.api.ribbon.RibbonApplicationMenuEntryPrimary.PrimaryRolloverCallback)