Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » popup menus not working (for me)
popup menus not working (for me) [message #503326] Fri, 11 December 2009 16:21 Go to next message
Mauro Condarelli is currently offline Mauro CondarelliFriend
Messages: 428
Registered: September 2009
Senior Member
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
Re: popup menus not working (for me) [message #503619 is a reply to message #503326] Tue, 15 December 2009 00:11 Go to previous messageGo to next message
Wim Jongman is currently offline Wim JongmanFriend
Messages: 423
Registered: July 2009
Senior Member
Hi Mauro,

Try to make the id of the locationURI also the id of your view and not the id
of the Eclipse ContentOutline view. Your view is a subclass and has its own
id.

locationURI="popup:>>>>>org.eclipse.ui.views.ContentOutline <<<<">

--

Best Regards,
Wim Jongman
-- Smash forehead on keyboard to continue.....
(Eclipse Old Skool Quote Service)
Re: popup menus not working (for me) [message #504152 is a reply to message #503326] Thu, 17 December 2009 13:30 Go to previous message
Remo Loetscher is currently offline Remo LoetscherFriend
Messages: 18
Registered: July 2009
Junior Member
Hi Mauro,

try the following locationURI:
locationURI="popup:YW5Outline.popup?after/before=..."

To find the context menu ids registered for sites you can use either the
yari toolsuite
( http://sourceforge.net/apps/trac/yari/wiki/HowToEclipse#HowT o:findthepublishedcontextmenuIDs)
or open the eclipse Plug-In Spy(ctrl+shift+f1).

hth,

Remo

Mauro Condarelli wrote:
> <menuContribution
> locationURI="popup:org.eclipse.ui.views.ContentOutline">
[...]
> getSite().registerContextMenu ("YW5Outline.popup",
> menuManager, tv);
[...]
Previous Topic:Progressbar at start
Next Topic:Common usages of views and editors in Eclipse RCP applications regarding to enterprise automation?
Goto Forum:
  


Current Time: Thu Mar 28 17:21:46 GMT 2024

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

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

Back to the top