popup menus not working (for me) [message #503326] |
Fri, 11 December 2009 11:21  |
Eclipse User |
|
|
|
Hi,
I'm trying to complete my RCP App.
Now I'm fighting (and losing) my battle with context menus.
I have a couple of Editors and one handful of Views, including a standard ContentOutline.
I want to add a context (popup) menu to the Outline to perform Commands on the selected line.
I tried several things without success.
Current status is:
Commands: <extension
point="org.eclipse.ui.commands">
...
<command
defaultHandler="it.condarelli.rcp.yw.commands.AddSceneHandler"
description="add scene after current one"
id="it.condarelli.rcp.yw.commands.addSceneHandler"
name="add Scene">
</command>
<command
defaultHandler="it.condarelli.rcp.yw.commands.EditRTF"
id="it.condarelli.rcp.yw.commands.EditRTF"
name="Edit RTF">
</command>
</extension>
Menus: <extension
point="org.eclipse.ui.menus">
...
<menuContribution
locationURI="popup:org.eclipse.ui.views.ContentOutline">
<command
commandId="it.condarelli.rcp.yw.commands.EditRTF"
icon="icons/16x16/EditPages [16x16].png"
label="Edit RTF file"
style="push">
</command>
<command
commandId="it.condarelli.rcp.yw.commands.addSceneHandler"
icon="icons/16x16/NewPage [16x16].png"
label="Add new Scene"
style="push">
</command>
</menuContribution>
</extension>
ContentOutlinePart:public class YW5Outline extends ContentOutlinePage {
public static final String ID = "it.condarelli.rcp.yw.views.YW5Outline";
@Override
public void createControl(Composite parent) {
super.createControl(parent);
for (IEditorReference er : getSite().getPage().getEditorReferences()) {
IWorkbenchPart ep = er.getPart(true);
if (ep instanceof YW5EditorPart) {
YW5EditorPart yw5 = (YW5EditorPart) ep;
final YW5file model = yw5.getModel();
final TreeViewer tv = getTreeViewer();
tv.setLabelProvider(model);
tv.setContentProvider(model);
tv.setInput(model.getTree());
MenuManager menuManager = new MenuManager("Outline popup", "YW5Outline.popup");
Menu menu = menuManager.createContextMenu(tv.getControl());
tv.getControl().setMenu(menu);
getSite().registerContextMenu ("YW5Outline.popup", menuManager, tv);
...
This code does not produce any errors, but it does not produce Menu either!
I did many tries, including defining separators and all other things I found on the Internet.
In particular notice I had to modify what I found in the very official Eclipse_RCP_How-to because registerContextMenu() now has one more parameter.
I seem unable to understand how to link the context menus. "normal" (menu:org.eclipse.ui.main.menu) menus seem ok.
...almost: someone is contributing a couple of menus ("Run" and "Search") and I cannot divine just who is.
Can someone send me in the right direction, plase?
Thanks in Advance
Mauro
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03720 seconds