org.pushingpixels.flamingo.api.ribbon
public class RibbonApplicationMenuEntryPrimary extends Object
RibbonApplicationMenu
. The primary menu entries at runtime are
represented by command menu buttons placed in the left panel of the
application menu.
There are three different types of primary entries:
ActionListener
passed to the
RibbonApplicationMenuEntryPrimary#RibbonApplicationMenuEntryPrimary(ResizableIcon, String, ActionListener, CommandButtonKind)
. 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
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
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.Modifier and Type | Class and Description |
---|---|
static interface |
RibbonApplicationMenuEntryPrimary.PrimaryRolloverCallback
Callback that allows application code to provide custom content on the
secondary panel of the
RibbonApplicationMenu . |
Modifier and Type | Field and Description |
---|---|
protected String |
actionKeyTip
Optional key tip for the action area of the command button that
represents this menu entry.
|
protected ResizableIcon |
disabledIcon
The menu icon for disabled state.
|
protected JCommandButton.CommandButtonKind |
entryKind
The kind of the command button that represents this menu entry.
|
protected List<List<RibbonApplicationMenuEntrySecondary>> |
groupEntries
List of all menu groups.
|
protected List<String> |
groupTitles
List of titles for all menu groups.
|
protected ResizableIcon |
icon
The menu icon.
|
protected boolean |
isEnabled
Enabled state of this menu.
|
protected ActionListener |
mainActionListener
The main action listener for this menu entry.
|
protected String |
popupKeyTip
Optional key tip for the popup area of the command button that represents
this menu entry.
|
protected RibbonApplicationMenuEntryPrimary.PrimaryRolloverCallback |
rolloverCallback
An optional rollover callback.
|
protected String |
text
The menu text.
|
Constructor and Description |
---|
RibbonApplicationMenuEntryPrimary(ResizableIcon icon,
String text,
ActionListener mainActionListener,
JCommandButton.CommandButtonKind entryKind)
Creates the metadata description of a
RibbonApplicationMenu
primary menu entry. |
Modifier and Type | Method and Description |
---|---|
int |
addSecondaryMenuGroup(String groupTitle,
RibbonApplicationMenuEntrySecondary... entries)
Adds a titled group of secondary menu entries.
|
String |
getActionKeyTip()
Returns the key tip for the action area of the command button that
represents this menu entry.
|
ResizableIcon |
getDisabledIcon()
Returns the disabled icon for the command button that represents this
menu entry.
|
JCommandButton.CommandButtonKind |
getEntryKind()
Returns the kind of the command button that represents this menu entry.
|
ResizableIcon |
getIcon()
Returns the icon of this application menu entry.
|
ActionListener |
getMainActionListener()
Returns the main action listener associated with this application menu
entry.
|
String |
getPopupKeyTip()
Returns the key tip for the popup area of the command button that
represents this menu entry.
|
RibbonApplicationMenuEntryPrimary.PrimaryRolloverCallback |
getRolloverCallback()
Returns the current application callback that allows placing custom
content in the secondary panel of the
RibbonApplicationMenu when
this primary menu entry is activated. |
int |
getSecondaryGroupCount()
Returns the number of secondary menu groups of this primary menu entry.
|
List<RibbonApplicationMenuEntrySecondary> |
getSecondaryGroupEntries(int groupIndex)
Returns an unmodifiable list of menu entries of the secondary menu group
at the specified index.
|
String |
getSecondaryGroupTitleAt(int groupIndex)
Returns the title of the secondary menu group at the specified index.
|
String |
getText()
Returns the text of this application menu entry.
|
boolean |
isEnabled()
Returns the enabled state of the command button that represents this menu
entry.
|
void |
setActionKeyTip(String actionKeyTip)
Sets the new value for the key tip for the action area of the command
button that represents this menu entry.
|
void |
setDisabledIcon(ResizableIcon disabledIcon)
Sets the disabled icon for the command button that represents this menu
entry.
|
void |
setEnabled(boolean isEnabled)
Sets the enabled state of the command button that represents this menu
entry.
|
void |
setPopupKeyTip(String popupKeyTip)
Sets the new value for the key tip for the popup area of the command
button that represents this menu entry.
|
void |
setRolloverCallback(RibbonApplicationMenuEntryPrimary.PrimaryRolloverCallback rolloverCallback)
Sets the rollover callback that allows the application to place custom
content in the secondary panel of the
RibbonApplicationMenu when
this primary menu entry is activated. |
void |
setSecondaryGroupTitle(int groupIndex,
String newTitle)
Changes the title of the specified group.
|
void |
setText(String text)
Sets the new text for this application menu entry.
|
protected RibbonApplicationMenuEntryPrimary.PrimaryRolloverCallback rolloverCallback
RibbonApplicationMenu
when
this primary menu entry is activated.protected List<List<RibbonApplicationMenuEntrySecondary>> groupEntries
protected ResizableIcon icon
protected ResizableIcon disabledIcon
null
.protected String text
protected ActionListener mainActionListener
protected JCommandButton.CommandButtonKind entryKind
protected boolean isEnabled
protected String actionKeyTip
protected String popupKeyTip
public RibbonApplicationMenuEntryPrimary(ResizableIcon icon, String text, ActionListener mainActionListener, JCommandButton.CommandButtonKind entryKind)
RibbonApplicationMenu
primary menu entry.icon
- The icon of this menu entry. Must be non-null
.text
- The text of this menu entry. Must be non-null
.mainActionListener
- The main action listener for this menu entry. If the entry
kind is JCommandButton.CommandButtonKind.POPUP_ONLY
, this listener
will be ignored.entryKind
- The kind of the command button that will represent this menu
entry. Must be non- null
.public int addSecondaryMenuGroup(String groupTitle, RibbonApplicationMenuEntrySecondary... entries)
groupTitle
- The title of the group.entries
- The secondary menu entries belonging to this group.getSecondaryGroupCount()
,
getSecondaryGroupTitleAt(int)
,
getSecondaryGroupEntries(int)
public int getSecondaryGroupCount()
addSecondaryMenuGroup(String,
RibbonApplicationMenuEntrySecondary...)
,
getSecondaryGroupTitleAt(int)
,
getSecondaryGroupEntries(int)
public String getSecondaryGroupTitleAt(int groupIndex)
groupIndex
- The index of a secondary menu group.addSecondaryMenuGroup(String,
RibbonApplicationMenuEntrySecondary...)
,
getSecondaryGroupCount()
,
getSecondaryGroupEntries(int)
public List<RibbonApplicationMenuEntrySecondary> getSecondaryGroupEntries(int groupIndex)
groupIndex
- The index of a secondary menu group.addSecondaryMenuGroup(String,
RibbonApplicationMenuEntrySecondary...)
,
getSecondaryGroupCount()
,
getSecondaryGroupTitleAt(int)
public void setRolloverCallback(RibbonApplicationMenuEntryPrimary.PrimaryRolloverCallback rolloverCallback)
RibbonApplicationMenu
when
this primary menu entry is activated.rolloverCallback
- The new rollover callback for populating the secondary panel
of the RibbonApplicationMenu
.getRolloverCallback()
public RibbonApplicationMenuEntryPrimary.PrimaryRolloverCallback getRolloverCallback()
RibbonApplicationMenu
when
this primary menu entry is activated.RibbonApplicationMenu
.setRolloverCallback(PrimaryRolloverCallback)
public void setSecondaryGroupTitle(int groupIndex, String newTitle)
groupIndex
- Group index.newTitle
- New title for the specified group.public ResizableIcon getIcon()
public String getText()
setText(String)
public void setText(String text)
text
- The new text for this application menu entry.getText()
public ActionListener getMainActionListener()
public JCommandButton.CommandButtonKind getEntryKind()
public void setEnabled(boolean isEnabled)
isEnabled
- If true
, the command button that represents this
menu entry will be enabled, if false
, the command
button will be disabled.isEnabled
public boolean isEnabled()
true
if the command button that represents this menu
entry is enabled, false
otherwise.public String getActionKeyTip()
setActionKeyTip(String)
,
getPopupKeyTip()
public void setActionKeyTip(String actionKeyTip)
actionKeyTip
- The new value for the key tip for the action area of the
command button that represents this menu entry.getActionKeyTip()
,
setPopupKeyTip(String)
public String getPopupKeyTip()
setPopupKeyTip(String)
,
getActionKeyTip()
public void setPopupKeyTip(String popupKeyTip)
popupKeyTip
- The new value for the key tip for the popup area of the
command button that represents this menu entry.getPopupKeyTip()
,
setActionKeyTip(String)
public ResizableIcon getDisabledIcon()
setDisabledIcon(ResizableIcon)
public void setDisabledIcon(ResizableIcon disabledIcon)
disabledIcon
- The disabled icon for the command button that represents this
menu entry.getDisabledIcon()