|
|||||||||
| Home >> All >> org >> eclipse >> jface >> [ action overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.eclipse.jface.action
Class ActionContributionItem

java.lang.Objectorg.eclipse.jface.action.ContributionItem
org.eclipse.jface.action.ActionContributionItem
- All Implemented Interfaces:
- IContributionItem
- public class ActionContributionItem
- extends ContributionItem
A contribution item which delegates to an action.
This class may be instantiated; it is not intended to be subclassed.
| Nested Class Summary | |
private static class |
ActionContributionItem.ImageCache
A weakly referenced cache of image descriptors to image instances. |
| Field Summary | |
private IAction |
action
The action. |
private org.eclipse.jface.util.IPropertyChangeListener |
actionTextListener
The listener for changes to the text of the action contributed by an external source. |
private org.eclipse.swt.widgets.Listener |
buttonListener
Listener for SWT button widget events. |
private static java.lang.String |
ellipsis
a string inserted in the middle of text that has been shortened |
private static ActionContributionItem.ImageCache |
globalImageCache
|
private static int |
LOWER_GTK_ACCEL_BOUND
This is the lower bound of the continuous range of accelerator values that should be handled specially on GTK. |
private org.eclipse.swt.widgets.Listener |
menuItemListener
Listener for SWT menu item widget events. |
private int |
mode
The presentation mode. |
static int |
MODE_FORCE_TEXT
Mode bit: Show text on tool items, even if an image is present. |
private org.eclipse.jface.util.IPropertyChangeListener |
propertyListener
Listener for action property change notifications. |
private org.eclipse.swt.widgets.Listener |
toolItemListener
Listener for SWT tool item widget events. |
private static int |
UPPER_GTK_ACCEL_BOUND
This is the lower bound of the continuous range of accelerator values that should be handled specially on GTK. |
private static boolean |
USE_COLOR_ICONS
|
private org.eclipse.swt.widgets.Widget |
widget
The widget created for this item; null
before creation and after disposal. |
| Fields inherited from class org.eclipse.jface.action.ContributionItem |
|
| Constructor Summary | |
ActionContributionItem(IAction action)
Creates a new contribution item from the given action. |
|
| Method Summary | |
private void |
actionPropertyChange(org.eclipse.jface.util.PropertyChangeEvent e)
Handles a property change event on the action (forwarded by nested listener). |
boolean |
equals(java.lang.Object o)
Compares this action contribution item with another object. |
void |
fill(org.eclipse.swt.widgets.Composite parent)
The ActionContributionItem implementation of this
IContributionItem method creates an SWT Button for
the action using the action's style. |
void |
fill(org.eclipse.swt.widgets.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(org.eclipse.swt.widgets.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. |
private org.eclipse.swt.widgets.Listener |
getButtonListener()
Returns the listener for SWT button widget events. |
private static ActionContributionItem.ImageCache |
getImageCache()
Returns the image cache. |
private org.eclipse.swt.widgets.Listener |
getMenuItemListener()
Returns the listener for SWT menu item widget events. |
int |
getMode()
Returns the presentation mode, which is the bitwise-or of the MODE_* constants. |
private org.eclipse.swt.widgets.Listener |
getToolItemListener()
Returns the listener for SWT tool item widget events. |
static boolean |
getUseColorIconsInToolbars()
Returns whether color icons should be used in toolbars. |
private void |
handleWidgetDispose(org.eclipse.swt.widgets.Event e)
Handles a widget dispose event for the widget corresponding to this item. |
private void |
handleWidgetSelection(org.eclipse.swt.widgets.Event e,
boolean selection)
Handles a widget selection event. |
int |
hashCode()
Get a value that represents this Object, as uniquely as possible within the confines of an int. |
private boolean |
hasImages(IAction actionToCheck)
Returns whether the given action has any images. |
private boolean |
isCommandActive()
Returns whether the command corresponding to this action is active. |
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 java.lang.String |
shortenText(java.lang.String textValue,
org.eclipse.swt.widgets.ToolItem item)
Shorten the given text t so that its length doesn't
exceed the given width. |
void |
update()
The action item implementation of this IContributionItem
method calls update(null). |
void |
update(java.lang.String propertyName)
Synchronizes the UI with the given property. |
private boolean |
updateImages(boolean forceImage)
Updates the images for this action. |
| Methods inherited from class org.eclipse.jface.action.ContributionItem |
dispose, fill, getId, getParent, isDirty, isGroupMarker, isSeparator, saveWidgetState, setParent, setVisible, toString |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
MODE_FORCE_TEXT
public static int MODE_FORCE_TEXT
- Mode bit: Show text on tool items, even if an image is present.
If this mode bit is not set, text is only shown on tool items if there is
no image present.
LOWER_GTK_ACCEL_BOUND
private static final int LOWER_GTK_ACCEL_BOUND
- This is the lower bound of the continuous range of accelerator values
that should be handled specially on GTK. This is to circumnavigate the
special input mode in some cases.
UPPER_GTK_ACCEL_BOUND
private static final int UPPER_GTK_ACCEL_BOUND
- This is the lower bound of the continuous range of accelerator values
that should be handled specially on GTK. This is to circumnavigate the
special input mode in some cases.
ellipsis
private static final java.lang.String ellipsis
- a string inserted in the middle of text that has been shortened
- See Also:
- Constant Field Values
globalImageCache
private static ActionContributionItem.ImageCache globalImageCache
USE_COLOR_ICONS
private static boolean USE_COLOR_ICONS
mode
private int mode
- The presentation mode.
action
private IAction action
- The action.
actionTextListener
private final org.eclipse.jface.util.IPropertyChangeListener actionTextListener
- The listener for changes to the text of the action contributed by an
external source.
buttonListener
private org.eclipse.swt.widgets.Listener buttonListener
- Listener for SWT button widget events.
menuItemListener
private org.eclipse.swt.widgets.Listener menuItemListener
- Listener for SWT menu item widget events.
propertyListener
private final org.eclipse.jface.util.IPropertyChangeListener propertyListener
- Listener for action property change notifications.
toolItemListener
private org.eclipse.swt.widgets.Listener toolItemListener
- Listener for SWT tool item widget events.
widget
private org.eclipse.swt.widgets.Widget widget
- The widget created for this item;
nullbefore creation and after disposal.
| Constructor Detail |
ActionContributionItem
public ActionContributionItem(IAction action)
- Creates a new contribution item from the given action. The id of the
action is used as the id of the item.
| Method Detail |
getUseColorIconsInToolbars
public static boolean getUseColorIconsInToolbars()
- Returns whether color icons should be used in toolbars.
setUseColorIconsInToolbars
public static void setUseColorIconsInToolbars(boolean useColorIcons)
- Sets whether color icons should be used in toolbars.
actionPropertyChange
private void actionPropertyChange(org.eclipse.jface.util.PropertyChangeEvent e)
- Handles a property change event on the action (forwarded by nested listener).
equals
public boolean equals(java.lang.Object o)
- Compares this action contribution item with another object.
Two action contribution items are equal if they refer to the identical Action.
fill
public void fill(org.eclipse.swt.widgets.Composite parent)
- The
ActionContributionItemimplementation of thisIContributionItemmethod creates an SWTButtonfor 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.- Specified by:
fillin interfaceIContributionItem- Overrides:
fillin classContributionItem
fill
public void fill(org.eclipse.swt.widgets.Menu parent, int index)
- The
ActionContributionItemimplementation of thisIContributionItemmethod creates an SWTMenuItemfor 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.- Specified by:
fillin interfaceIContributionItem- Overrides:
fillin classContributionItem
fill
public void fill(org.eclipse.swt.widgets.ToolBar parent, int index)
- The
ActionContributionItemimplementation of this ,IContributionItemmethod creates an SWTToolItemfor 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.- Specified by:
fillin interfaceIContributionItem- Overrides:
fillin classContributionItem
getAction
public IAction getAction()
- Returns the action associated with this contribution item.
getButtonListener
private org.eclipse.swt.widgets.Listener getButtonListener()
- Returns the listener for SWT button widget events.
getImageCache
private static ActionContributionItem.ImageCache getImageCache()
- Returns the image cache.
The cache is global, and is shared by all action contribution items.
This has the disadvantage that once an image is allocated, it is never freed until the display
is disposed. However, it has the advantage that the same image in different contribution managers
is only ever created once.
getMenuItemListener
private org.eclipse.swt.widgets.Listener getMenuItemListener()
- Returns the listener for SWT menu item widget events.
getMode
public int getMode()
- Returns the presentation mode, which is the bitwise-or of the
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.- Since:
- 3.0
getToolItemListener
private org.eclipse.swt.widgets.Listener getToolItemListener()
- Returns the listener for SWT tool item widget events.
handleWidgetDispose
private void handleWidgetDispose(org.eclipse.swt.widgets.Event e)
- Handles a widget dispose event for the widget corresponding to this item.
handleWidgetSelection
private void handleWidgetSelection(org.eclipse.swt.widgets.Event e, boolean selection)
- Handles a widget selection event.
hashCode
public int hashCode()
- Description copied from class:
java.lang.Object - Get a value that represents this Object, as uniquely as
possible within the confines of an int.
There are some requirements on this method which subclasses must follow:
- Semantic equality implies identical hashcodes. In other
words, if
a.equals(b)is true, thena.hashCode() == b.hashCode()must be as well. However, the reverse is not necessarily true, and two objects may have the same hashcode without being equal. - It must be consistent. Whichever value o.hashCode() returns on the first invocation must be the value returned on all later invocations as long as the object exists. Notice, however, that the result of hashCode may change between separate executions of a Virtual Machine, because it is not invoked on the same object.
Notice that since
hashCodeis used in java.util.Hashtable and other hashing classes, a poor implementation will degrade the performance of hashing (so don't blindly implement it as returning a constant!). Also, if calculating the hash is time-consuming, a class may consider caching the results.The default implementation returns
System.identityHashCode(this) - Semantic equality implies identical hashcodes. In other
words, if
hasImages
private boolean hasImages(IAction actionToCheck)
- Returns whether the given action has any images.
isCommandActive
private boolean isCommandActive()
- Returns whether the command corresponding to this action
is active.
isDynamic
public boolean isDynamic()
- The action item implementation of this
IContributionItemmethod returnstruefor menu items andfalsefor everything else.- Specified by:
isDynamicin interfaceIContributionItem- Overrides:
isDynamicin classContributionItem
isEnabled
public boolean isEnabled()
- Description copied from class:
ContributionItem - The default implementation of this
IContributionItemmethod returnstrue. Subclasses may override.- Specified by:
isEnabledin interfaceIContributionItem- Overrides:
isEnabledin classContributionItem
isEnabledAllowed
protected boolean isEnabledAllowed()
- Returns
trueif this item is allowed to enable,falseotherwise.- Since:
- 2.0
isVisible
public boolean isVisible()
- The
ActionContributionItemimplementation of thisContributionItemmethod extends the super implementation by also checking whether the command corresponding to this action is active.- Specified by:
isVisiblein interfaceIContributionItem- Overrides:
isVisiblein classContributionItem
setMode
public void setMode(int mode)
- Sets the presentation mode, which is the bitwise-or of the
MODE_*constants.- Since:
- 3.0
update
public final void update()
- The action item implementation of this
IContributionItemmethod callsupdate(null).- Specified by:
updatein interfaceIContributionItem- Overrides:
updatein classContributionItem
update
public void update(java.lang.String propertyName)
- Synchronizes the UI with the given property.
- Specified by:
updatein interfaceIContributionItem- Overrides:
updatein classContributionItem
updateImages
private boolean updateImages(boolean forceImage)
- Updates the images for this action.
shortenText
protected java.lang.String shortenText(java.lang.String textValue, org.eclipse.swt.widgets.ToolItem item)
- Shorten the given text
tso that its length doesn't exceed the given width. The default implementation replaces characters in the center of the original string with an ellipsis ("..."). Override if you need a different strategy.
|
|||||||||
| Home >> All >> org >> eclipse >> jface >> [ action overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC