Home » Eclipse Projects » Rich Client Platform (RCP) » implementing global action in ApplicationWorkbench
| | | | |
Re: implementing global action in ApplicationWorkbench [message #485156 is a reply to message #485110] |
Thu, 10 September 2009 16:26 |
|
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
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Menu_Contributions
|
|
|
Goto Forum:
Current Time: Wed Feb 05 19:05:54 GMT 2025
Powered by FUDForum. Page generated in 0.03630 seconds
|