Reputation: 119
Now I want to call an actionset which is defined in another plugin,I already have the actionId,But I don't know how to call it.
Here is the actionset:
<action
class="com.src.action1"
icon="action1.png"
id="com.src.action1"
label="action1"
style="push"
toolbarPath="new.ext">
</action>
I know that I can call command by commandId like this :
IHandlerService handlerService =
PlatformUI.getWorkbench().getService(IHandlerService.class);
handlerService.executeCommand(COMMANDID, null);
So I want to know if the toolbar button is defined by actionSet,can I call it like command by actionId?
Upvotes: 1
Views: 288
Reputation: 111216
Actions are only connected to a command if they have a definitionId
parameter. For example this action from the JDT plugin:
<action
allowLabelUpdate="true"
style="toggle"
toolbarPath="org.eclipse.ui.edit.text.actionSet.presentation/Presentation"
id="org.eclipse.jdt.ui.edit.text.java.toggleMarkOccurrences"
definitionId="org.eclipse.jdt.ui.edit.text.java.toggleMarkOccurrences"
disabledIcon="$nl$/icons/full/dtool16/mark_occurrences.png"
icon="$nl$/icons/full/etool16/mark_occurrences.png"
helpContextId="org.eclipse.jdt.ui.toggle_mark_occurrences_action_context"
label="%toggleMarkOccurrences.label"
retarget="true"
tooltip="%toggleMarkOccurrences.tooltip">
</action>
In this example the command id is org.eclipse.jdt.ui.edit.text.java.toggleMarkOccurrences
. So you would execute it using:
handlerService.executeCommand("org.eclipse.jdt.ui.edit.text.java.toggleMarkOccurrences", null);
If there is no definitionId
parameter the action is not associated with a command and you cannot call it through the handler service.
Upvotes: 1