Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Adding Action to EditorPart(Actions added to an EditorPart do not appear)
Adding Action to EditorPart [message #776699] Mon, 09 January 2012 04:55 Go to next message
parmy Missing name is currently offline parmy Missing nameFriend
Messages: 14
Registered: July 2009
Junior Member
I'm trying to add an Action to an Editor using the following code:

final IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
try {
page.bringToTop(page.openEditor(new FileStoreEditorInput(getFileStore()), getEditorId()));

Action saveAction = new Action("Save",
TerminalPlugin.getImageDescriptor("/icons/save_icon.jpg")) { //$NON-NLS-1$
@Override
public void run() {
final IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
//page.getActiveEditor().doSave(monitor);
}
};
saveAction.setToolTipText("Save");

System.out.println("PB-->" + page.getActiveEditor().getEditorSite().getActionBars().getToolBarManager().getItems().length);
page.getActiveEditor().getEditorSite().getActionBars().getToolBarManager().add(saveAction);
page.getActiveEditor().getEditorSite().getActionBars().updateActionBars();
page.getActiveEditor().getEditorSite().getActionBars().getToolBarManager().update(true);
System.out.println("PB-->" + page.getActiveEditor().getEditorSite().getActionBars().getToolBarManager().getItems().length);

} catch (PartInitException e1) {
e1.printStackTrace();
} catch (Exception e1) {
e1.printStackTrace();
}

The Editor displays fine, and I can see the number of Contribution Items for the ToolBarManager is increased, however the Action does not appear.

Any suggestions?
Re: Adding Action to EditorPart [message #776745 is a reply to message #776699] Mon, 09 January 2012 07:50 Go to previous messageGo to next message
parmy Missing name is currently offline parmy Missing nameFriend
Messages: 14
Registered: July 2009
Junior Member
An update to the above, I notice that the Action is added but it is added to the Cool bar and not the editor site (where minimum and maximum icons can be found).

I can't find a way to get a handle on the action bar manager for the actual editor, any suggestions?
Re: Adding Action to EditorPart [message #776791 is a reply to message #776745] Mon, 09 January 2012 09:27 Go to previous message
parmy Missing name is currently offline parmy Missing nameFriend
Messages: 14
Registered: July 2009
Junior Member
I've had a read through http://www.eclipse.org/articles/article.php?file=Article-action-contribution/index.html which covers all menu extensions that can be made to an existing plug-in.

It covers how to add an actions to a view's toolbar (local toolbar) but not how to add an action to a editor's toolbar. From my hunting around I'm beginning to suspect it won't be possible to update the editor's toolbar.

The other maybe to use getEditorSite.registerContextMenu() to update the sub menu. What I would like to do is extend the menu that is already there, and insert my own menu item and listen for events when my inserted menu item is selected.

Any suggestions?


Previous Topic:Editors not reflecting Appearance changes in RCP application
Next Topic:Launcher error with product executable, but not with launcher.jar
Goto Forum:
  


Current Time: Thu Mar 28 12:44:47 GMT 2024

Powered by FUDForum. Page generated in 0.02402 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top