Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » Local toolbar in a editor
Local toolbar in a editor [message #73142] Thu, 07 February 2008 15:44 Go to next message
Emmanuel Marchal is currently offline Emmanuel MarchalFriend
Messages: 59
Registered: July 2009
Member
Hi,

I want to add a local toolbar to my editor MyEditor extends EditorPart
I've copied the following code to add such a toolbar in a view :

public void createPartControl(Composite parent) {
(...)
makeActions();
hookContextMenu();
contributeToActionBars();
}

private void contributeToActionBars() {
IActionBars bars = getViewSite().getActionBars();
fillLocalPullDown(bars.getMenuManager());
fillLocalToolBar(bars.getToolBarManager());
}

I just changed the getViewSite() to getEditorSite() because I am in a
EditorPart and not in a ViewPart.

As result of this, the toolbar buttons are added to the toolbar of my page
and not of the local folder ! How can I avoid this and get my local
toolbar at the good place ?

Thanks a lot !

Emmanuel
RE: Local toolbar in a editor [message #73196 is a reply to message #73142] Fri, 08 February 2008 09:13 Go to previous message
Eclipse UserFriend
Originally posted by: fappel.innoopract.com

Hi,

in RCP/RAP the concept of editors include that they contribute actions
to the common menu, toolbar and status bar. To do so
IEditorActionBarContributor has to be implemented. There is a
convenience class called EditorActionBarContributor that can be extended
to ease this task. If you have a look at the demo application included
in the RAP target you'll find a class called FooEditorContributor.
Change this to see how the mechanism work:

public class FooEditorContributor extends EditorActionBarContributor {

Action action = new Action() {
public String getText() {
return "Trallala";
}
public String getId() {
return "trallalaId";
}
};

public FooEditorContributor() {
}

public void contributeToToolBar( IToolBarManager toolBarManager ) {
toolBarManager.add( action );
}
}

Run the demo workbench and open an editor (click on the ninth toolbar
button). An additional toolbar entry shows up. After closing the editor
the button vanishs. Note that the EditorActionBarContributor must also
be part of the editor's extension declaration.


However if you really need a toolbar contained in the editorpart's
parent composite I'm afraid that there is no other way than to code it
by yourself using RWT widgets (Toolbar and ToolItem) - at least I'm not
aware of a more high level approach.


Ciao
Frank

-----Ursprüngliche Nachricht-----
Von: Emmanuel [mailto:emmanuel.marchal@n-side.be]
Bereitgestellt: Donnerstag, 7. Februar 2008 16:45
Bereitgestellt in: eclipse.technology.rap
Unterhaltung: Local toolbar in a editor
Betreff: Local toolbar in a editor


Hi,

I want to add a local toolbar to my editor MyEditor extends EditorPart
I've copied the following code to add such a toolbar in a view :

public void createPartControl(Composite parent) {
(...)
makeActions();
hookContextMenu();
contributeToActionBars();
}

private void contributeToActionBars() {
IActionBars bars = getViewSite().getActionBars();
fillLocalPullDown(bars.getMenuManager());
fillLocalToolBar(bars.getToolBarManager());
}

I just changed the getViewSite() to getEditorSite() because I am in a
EditorPart and not in a ViewPart.

As result of this, the toolbar buttons are added to the toolbar of my
page and not of the local folder ! How can I avoid this and get my local
toolbar at the good place ?

Thanks a lot !

Emmanuel
Previous Topic:RAP Runtime Error
Next Topic:Missing API
Goto Forum:
  


Current Time: Sat Apr 27 00:22:27 GMT 2024

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

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

Back to the top