[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.platform.rcp] Re: implementing global action in ApplicationWorkbench
|
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