implementing global action in ApplicationWorkbench [message #484309] |
Sat, 05 September 2009 23:43  |
Eclipse User |
|
|
|
hello
I have implemented the global actions in the controls of the Editors in the following way
final Action cutSelected = new Action() {
public void run() {
styledText.cut();
}
};
//
getEditorSite().getActionBars().setGlobalActionHandler(ActionFactory.CUT.getId(), cutSelected);
Now the problem is there is a control in ApplicationWorkbench. how can I implement the global actions in that control?
Thanks
|
|
|
|
|
|
|
Re: implementing global action in ApplicationWorkbench [message #485156 is a reply to message #485110] |
Thu, 10 September 2009 12:26  |
Eclipse User |
|
|
|
In an RCP app, you just need to update your ApplicationActionBarAdvisor with a CommandContributionItem instead of ActionFactory.COPY, for example (I think).
ex:
menu.add(getCopyItem());
private IContributionItem getCopyItem() {
return getItem(
ActionFactory.COPY.getId(),
ActionFactory.COPY.getCommandId(),
ISharedImages.IMG_TOOL_COPY,
ISharedImages.IMG_TOOL_COPY_DISABLED,
WorkbenchMessages.Workbench_copy,
WorkbenchMessages.Workbench_copyToolTip, null);
}
private IContributionItem getItem(String actionId, String commandId,
String image, String disabledImage, String label, String tooltip, String helpContextId) {
ISharedImages sharedImages = getWindow().getWorkbench()
.getSharedImages();
IActionCommandMappingService acms = (IActionCommandMappingService) getWindow()
.getService(IActionCommandMappingService.class);
acms.map(actionId, commandId);
CommandContributionItemParameter commandParm = new CommandContributionItemParameter(
getWindow(), actionId, commandId, null, sharedImages
.getImageDescriptor(image), sharedImages
.getImageDescriptor(disabledImage), null, label, null,
tooltip, CommandContributionItem.STYLE_PUSH, null, false);
return new CommandContributionItem(commandParm);
}
This is the code from 3.5, it might need to be tweaked for 3.4 (ActionFactory.COPY.getCommandId() doesn't exist in 3.4, for example).
PW
|
|
|
Powered by
FUDForum. Page generated in 0.26173 seconds