Package org.eclipse.ui.menus
Class CommandContributionItem
- java.lang.Object
-
- org.eclipse.jface.action.ContributionItem
-
- org.eclipse.ui.menus.CommandContributionItem
-
- All Implemented Interfaces:
IContributionItem
public class CommandContributionItem extends ContributionItem
A contribution item which delegates to a command. It can be used inAbstractContributionFactory.createContributionItems(IServiceLocator, IContributionRoot)
.It currently supports placement in menus and toolbars.
This class may be instantiated; it is not intended to be subclassed.
- Since:
- 3.3
- Restriction:
- This class is not intended to be subclassed by clients.
-
-
Field Summary
Fields Modifier and Type Field Description static int
MODE_FORCE_TEXT
Mode bit: Show text on tool items or buttons, even if an image is present.static int
STYLE_CHECK
A checked tool item or menu item.static int
STYLE_PULLDOWN
A ToolBar pulldown item.static int
STYLE_PUSH
A push button tool item or menu item.static int
STYLE_RADIO
A radio-button style menu item.
-
Constructor Summary
Constructors Constructor Description CommandContributionItem(CommandContributionItemParameter contributionParameters)
Create a CommandContributionItem to place in a ContributionManager.CommandContributionItem(IServiceLocator serviceLocator, String id, String commandId, Map parameters, ImageDescriptor icon, ImageDescriptor disabledIcon, ImageDescriptor hoverIcon, String label, String mnemonic, String tooltip, int style)
Deprecated.create theCommandContributionItemParameter
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
dispose()
The default implementation of thisIContributionItem
method does nothing.void
fill(Composite parent)
The default implementation of thisIContributionItem
method does nothing.void
fill(Menu parent, int index)
The default implementation of thisIContributionItem
method does nothing.void
fill(ToolBar parent, int index)
The default implementation of thisIContributionItem
method does nothing.ParameterizedCommand
getCommand()
Returns the ParameterizedCommand for this contribution.CommandContributionItemParameter
getData()
Provide info on the rendering data contained in this item.boolean
isEnabled()
The default implementation of thisIContributionItem
method returnstrue
.boolean
isVisible()
The default implementation of thisIContributionItem
method returns the value recorded in an internal state variable, which istrue
by default.void
setParent(IContributionManager parent)
Sets the parent manager of this itemvoid
update()
The default implementation of thisIContributionItem
method does nothing.void
update(String id)
TheContributionItem
implementation of this method declared onIContributionItem
does nothing.-
Methods inherited from class org.eclipse.jface.action.ContributionItem
fill, getId, getParent, isDirty, isDynamic, isGroupMarker, isSeparator, saveWidgetState, setId, setVisible, toString
-
-
-
-
Field Detail
-
STYLE_PUSH
public static final int STYLE_PUSH
A push button tool item or menu item.- See Also:
- Constant Field Values
-
STYLE_CHECK
public static final int STYLE_CHECK
A checked tool item or menu item.- See Also:
- Constant Field Values
-
STYLE_RADIO
public static final int STYLE_RADIO
A radio-button style menu item.- See Also:
- Constant Field Values
-
STYLE_PULLDOWN
public static final int STYLE_PULLDOWN
A ToolBar pulldown item.- See Also:
- Constant Field Values
-
MODE_FORCE_TEXT
public static int MODE_FORCE_TEXT
Mode bit: Show text on tool items or buttons, 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.- Since:
- 3.4
-
-
Constructor Detail
-
CommandContributionItem
public CommandContributionItem(CommandContributionItemParameter contributionParameters)
Create a CommandContributionItem to place in a ContributionManager.- Parameters:
contributionParameters
- parameters necessary to render this contribution item.- Since:
- 3.4
-
CommandContributionItem
@Deprecated public CommandContributionItem(IServiceLocator serviceLocator, String id, String commandId, Map parameters, ImageDescriptor icon, ImageDescriptor disabledIcon, ImageDescriptor hoverIcon, String label, String mnemonic, String tooltip, int style)
Deprecated.create theCommandContributionItemParameter
Create a CommandContributionItem to place in a ContributionManager.- Parameters:
serviceLocator
- a service locator that is most appropriate for this contribution. Typically the localIWorkbenchWindow
orIWorkbenchPartSite
will be sufficient.id
- The id for this item. May benull
. Items without an id cannot be referenced later.commandId
- A command id for a defined command. Must not benull
.parameters
- A map of strings to strings which represent parameter names to values. The parameter names must match those in the command definition.icon
- An icon for this item. May benull
.disabledIcon
- A disabled icon for this item. May benull
.hoverIcon
- A hover icon for this item. May benull
.label
- A label for this item. May benull
.mnemonic
- A mnemonic for this item to be applied to the label. May benull
.tooltip
- A tooltip for this item. May benull
. Tooltips are currently only valid for toolbar contributions.style
- The style of this menu contribution. See the STYLE_* contants.
-
-
Method Detail
-
getCommand
public ParameterizedCommand getCommand()
Returns the ParameterizedCommand for this contribution.NOTE: The returned object should be treated as 'read-only', do not execute this instance or attempt to modify its state.
- Returns:
- The parameterized command for this contribution.
- Since:
- 3.5
-
fill
public void fill(Menu parent, int index)
Description copied from class:ContributionItem
The default implementation of thisIContributionItem
method does nothing. Subclasses may override.- Specified by:
fill
in interfaceIContributionItem
- Overrides:
fill
in classContributionItem
- Parameters:
parent
- the parent menuindex
- the index where the controls are inserted, or-1
to insert at the end
-
fill
public void fill(Composite parent)
Description copied from class:ContributionItem
The default implementation of thisIContributionItem
method does nothing. Subclasses may override.- Specified by:
fill
in interfaceIContributionItem
- Overrides:
fill
in classContributionItem
- Parameters:
parent
- the parent control
-
fill
public void fill(ToolBar parent, int index)
Description copied from class:ContributionItem
The default implementation of thisIContributionItem
method does nothing. Subclasses may override.- Specified by:
fill
in interfaceIContributionItem
- Overrides:
fill
in classContributionItem
- Parameters:
parent
- the parent tool barindex
- the index where the controls are inserted, or-1
to insert at the end
-
update
public void update()
Description copied from class:ContributionItem
The default implementation of thisIContributionItem
method does nothing. Subclasses may override.- Specified by:
update
in interfaceIContributionItem
- Overrides:
update
in classContributionItem
-
update
public void update(String id)
Description copied from class:ContributionItem
TheContributionItem
implementation of this method declared onIContributionItem
does nothing. Subclasses should override to update their state.- Specified by:
update
in interfaceIContributionItem
- Overrides:
update
in classContributionItem
- Parameters:
id
- the id of the changed property
-
setParent
public void setParent(IContributionManager parent)
Description copied from interface:IContributionItem
Sets the parent manager of this item- Specified by:
setParent
in interfaceIContributionItem
- Overrides:
setParent
in classContributionItem
- Parameters:
parent
- the parent contribution manager
-
dispose
public void dispose()
Description copied from class:ContributionItem
The default implementation of thisIContributionItem
method does nothing. Subclasses may override.- Specified by:
dispose
in interfaceIContributionItem
- Overrides:
dispose
in classContributionItem
-
isEnabled
public boolean isEnabled()
Description copied from class:ContributionItem
The default implementation of thisIContributionItem
method returnstrue
. Subclasses may override.- Specified by:
isEnabled
in interfaceIContributionItem
- Overrides:
isEnabled
in classContributionItem
- Returns:
true
if this item is enabled
-
isVisible
public boolean isVisible()
Description copied from class:ContributionItem
The default implementation of thisIContributionItem
method returns the value recorded in an internal state variable, which istrue
by default.setVisible
should be used to change this setting.- Specified by:
isVisible
in interfaceIContributionItem
- Overrides:
isVisible
in classContributionItem
- Returns:
true
if this item is visible, andfalse
otherwise- Since:
- 3.4
-
getData
public CommandContributionItemParameter getData()
Provide info on the rendering data contained in this item.- Returns:
- a
CommandContributionItemParameter
. Valid fields are serviceLocator, id, style, icon, disabledIcon, hoverIcon, label, helpContextId, mnemonic, tooltip. The Object will never benull
, although any of the fields may benull
. - Since:
- 3.100
-
-