public class ActionContributionItem extends ContributionItem
This class may be instantiated; it is not intended to be subclassed.
Modifier and Type | Field and Description |
---|---|
static int |
MODE_FORCE_TEXT
Mode bit: Show text on tool items or buttons, even if an image is
present.
|
Constructor and Description |
---|
ActionContributionItem(IAction action)
Creates a new contribution item from the given action.
|
Modifier and Type | Method and Description |
---|---|
void |
dispose()
The default implementation of this
IContributionItem
method does nothing. |
boolean |
equals(Object o)
Compares this action contribution item with another object.
|
void |
fill(Composite parent)
The
ActionContributionItem implementation of this
IContributionItem method creates an SWT
Button for the action using the action's style. |
void |
fill(Menu parent,
int index)
The
ActionContributionItem implementation of this
IContributionItem method creates an SWT
MenuItem for the action using the action's style. |
void |
fill(ToolBar parent,
int index)
The
ActionContributionItem implementation of this ,
IContributionItem method creates an SWT
ToolItem for the action using the action's style. |
IAction |
getAction()
Returns the action associated with this contribution item.
|
int |
getMode()
Returns the presentation mode, which is the bitwise-or of the
MODE_* constants. |
static boolean |
getUseColorIconsInToolbars()
Returns whether color icons should be used in toolbars.
|
Widget |
getWidget()
Return the widget associated with this contribution item.
|
int |
hashCode() |
boolean |
isDynamic()
The action item implementation of this
IContributionItem
method returns true for menu items and false
for everything else. |
boolean |
isEnabled()
The default implementation of this
IContributionItem
method returns true . |
protected boolean |
isEnabledAllowed()
Returns
true if this item is allowed to enable,
false otherwise. |
boolean |
isVisible()
The
ActionContributionItem implementation of this
ContributionItem method extends the super implementation
by also checking whether the command corresponding to this action is
active. |
void |
setMode(int mode)
Sets the presentation mode, which is the bitwise-or of the
MODE_* constants. |
static void |
setUseColorIconsInToolbars(boolean useColorIcons)
Sets whether color icons should be used in toolbars.
|
protected String |
shortenText(String textValue,
ToolItem item)
Shorten the given text
t so that its length doesn't exceed
the width of the given ToolItem.The default implementation replaces
characters in the center of the original string with an ellipsis ("..."). |
void |
update()
The action item implementation of this
IContributionItem
method calls update(null) . |
void |
update(String propertyName)
Synchronizes the UI with the given property.
|
fill, getId, getParent, isDirty, isGroupMarker, isSeparator, saveWidgetState, setId, setParent, setVisible, toString
public static int MODE_FORCE_TEXT
public ActionContributionItem(IAction action)
action
- the actionpublic static boolean getUseColorIconsInToolbars()
true
if color icons should be used in toolbars,
false
otherwisepublic static void setUseColorIconsInToolbars(boolean useColorIcons)
useColorIcons
- true
if color icons should be used in toolbars,
false
otherwisepublic boolean equals(Object o)
public void fill(Composite parent)
ActionContributionItem
implementation of this
IContributionItem
method creates an SWT
Button
for the action using the action's style. If the
action's checked property has been set, the button is created and primed
to the value of the checked property.fill
in interface IContributionItem
fill
in class ContributionItem
parent
- the parent controlpublic void fill(Menu parent, int index)
ActionContributionItem
implementation of this
IContributionItem
method creates an SWT
MenuItem
for the action using the action's style. If the
action's checked property has been set, a button is created and primed to
the value of the checked property. If the action's menu creator property
has been set, a cascading submenu is created.fill
in interface IContributionItem
fill
in class ContributionItem
parent
- the parent menuindex
- the index where the controls are inserted,
or -1
to insert at the endpublic void fill(ToolBar parent, int index)
ActionContributionItem
implementation of this ,
IContributionItem
method creates an SWT
ToolItem
for the action using the action's style. If the
action's checked property has been set, a button is created and primed to
the value of the checked property. If the action's menu creator property
has been set, a drop-down tool item is created.fill
in interface IContributionItem
fill
in class ContributionItem
parent
- the parent tool barindex
- the index where the controls are inserted,
or -1
to insert at the endpublic IAction getAction()
public int getMode()
MODE_*
constants. The default mode setting is 0, meaning
that for menu items, both text and image are shown (if present), but for
tool items, the text is shown only if there is no image.public boolean isDynamic()
IContributionItem
method returns true
for menu items and false
for everything else.isDynamic
in interface IContributionItem
isDynamic
in class ContributionItem
true
if this item is dynamic, and
false
for normal itemspublic boolean isEnabled()
ContributionItem
IContributionItem
method returns true
. Subclasses may override.isEnabled
in interface IContributionItem
isEnabled
in class ContributionItem
true
if this item is enabledprotected boolean isEnabledAllowed()
true
if this item is allowed to enable,
false
otherwise.public boolean isVisible()
ActionContributionItem
implementation of this
ContributionItem
method extends the super implementation
by also checking whether the command corresponding to this action is
active.isVisible
in interface IContributionItem
isVisible
in class ContributionItem
true
if this item is visible, and
false
otherwisepublic void setMode(int mode)
MODE_*
constants.mode
- the presentation mode settingspublic final void update()
IContributionItem
method calls update(null)
.update
in interface IContributionItem
update
in class ContributionItem
public void update(String propertyName)
update
in interface IContributionItem
update
in class ContributionItem
propertyName
- the name of the property, or null
meaning all
applicable propertiesprotected String shortenText(String textValue, ToolItem item)
t
so that its length doesn't exceed
the width of the given ToolItem.The default implementation replaces
characters in the center of the original string with an ellipsis ("...").
Override if you need a different strategy.textValue
- the text to shortenitem
- the tool item the text belongs topublic void dispose()
ContributionItem
IContributionItem
method does nothing. Subclasses may override.dispose
in interface IContributionItem
dispose
in class ContributionItem
public Widget getWidget()
This can be used to set layout data on the widget if appropriate. The actual type of the widget can be any valid control for this ContributionItem's current ContributionManager.
null
depending on the lifecycle.
Copyright (c) 2000, 2014 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.