public class CommandContributionItem extends ContributionItem
AbstractContributionFactory.createContributionItems(IServiceLocator, IContributionRoot)
.
It currently supports placement in menus and toolbars.
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.
|
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 and Description |
---|
CommandContributionItem(CommandContributionItemParameter contributionParameters)
Create a CommandContributionItem to place in a ContributionManager.
|
CommandContributionItem(IServiceLocator serviceLocator,
java.lang.String id,
java.lang.String commandId,
java.util.Map parameters,
ImageDescriptor icon,
ImageDescriptor disabledIcon,
ImageDescriptor hoverIcon,
java.lang.String label,
java.lang.String mnemonic,
java.lang.String tooltip,
int style)
Deprecated.
create the
CommandContributionItemParameter |
Modifier and Type | Method and Description |
---|---|
void |
dispose() |
void |
fill(Composite parent) |
void |
fill(Menu parent,
int index) |
void |
fill(ToolBar parent,
int index) |
ParameterizedCommand |
getCommand()
Returns the ParameterizedCommand for this contribution.
|
CommandContributionItemParameter |
getData()
Provide info on the rendering data contained in this item.
|
boolean |
isEnabled() |
boolean |
isVisible() |
void |
setIcon(ImageDescriptor desc) |
void |
setLabel(java.lang.String label) |
void |
setParent(IContributionManager parent) |
void |
update() |
void |
update(java.lang.String id) |
fill, getId, getParent, isDirty, isDynamic, isGroupMarker, isSeparator, saveWidgetState, setId, setVisible, toString
public static final int STYLE_PUSH
public static final int STYLE_CHECK
public static final int STYLE_RADIO
public static final int STYLE_PULLDOWN
public static int MODE_FORCE_TEXT
public CommandContributionItem(CommandContributionItemParameter contributionParameters)
contributionParameters
- parameters necessary to render this contribution item.@Deprecated public CommandContributionItem(IServiceLocator serviceLocator, java.lang.String id, java.lang.String commandId, java.util.Map parameters, ImageDescriptor icon, ImageDescriptor disabledIcon, ImageDescriptor hoverIcon, java.lang.String label, java.lang.String mnemonic, java.lang.String tooltip, int style)
CommandContributionItemParameter
serviceLocator
- a service locator that is most appropriate for this contribution. Typically the local IWorkbenchWindow
or IWorkbenchPartSite
will be sufficient.id
- The id for this item. May be null
. Items without an id cannot be referenced later.commandId
- A command id for a defined command. Must not be null
.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 be null
.disabledIcon
- A disabled icon for this item. May be null
.hoverIcon
- A hover icon for this item. May be null
.label
- A label for this item. May be null
.mnemonic
- A mnemonic for this item to be applied to the label. May be null
.tooltip
- A tooltip for this item. May be null
. Tooltips are currently only valid for toolbar contributions.style
- The style of this menu contribution. See the STYLE_* constants.public ParameterizedCommand getCommand()
NOTE: The returned object should be treated as 'read-only', do not execute this instance or attempt to modify its state.
public void fill(Menu parent, int index)
fill
in interface IContributionItem
fill
in class ContributionItem
public void fill(Composite parent)
fill
in interface IContributionItem
fill
in class ContributionItem
public void fill(ToolBar parent, int index)
fill
in interface IContributionItem
fill
in class ContributionItem
public void update()
update
in interface IContributionItem
update
in class ContributionItem
public void update(java.lang.String id)
update
in interface IContributionItem
update
in class ContributionItem
public void setParent(IContributionManager parent)
setParent
in interface IContributionItem
setParent
in class ContributionItem
public void dispose()
dispose
in interface IContributionItem
dispose
in class ContributionItem
public void setIcon(ImageDescriptor desc)
public boolean isEnabled()
isEnabled
in interface IContributionItem
isEnabled
in class ContributionItem
public boolean isVisible()
isVisible
in interface IContributionItem
isVisible
in class ContributionItem
public CommandContributionItemParameter getData()
CommandContributionItemParameter
. Valid fields are serviceLocator, id, style, icon, disabledIcon, hoverIcon, label, helpContextId,
mnemonic, tooltip. The Object will never be null
, although any of the fields may be null
.public void setLabel(java.lang.String label)