Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Duplicate popup-menu entries
Duplicate popup-menu entries [message #1819642] Mon, 20 January 2020 08:32 Go to next message
Alexander Haag is currently offline Alexander HaagFriend
Messages: 119
Registered: July 2009
Senior Member
I just switched my RCP from 3.7 to 4.12 and having trouble with duplicate popup menu entries. The RCP uses the compatibility mode - every declaration of extension points is like it was on 3.7. With 3.7, every popup entry just shows once, same code in 4.12 produces duplicates.
The View where the popup is shown, is a standard view having only a treeviewer to show the entries.

Affected plugin.xml:
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
   <extension
         point="org.eclipse.ui.menus">
      <menuContribution
            allPopups="false"
            locationURI="popup:VariableNavigationView">
         <command
               commandId="EditorialManagement.Actions.RefilterCommand"
               label="%editmanagement_refilteraction_name"
               style="push"
               tooltip="%editmanagement_refilteraction_tooltip">
            <parameter
                  name="Command.Action.Id"
                  value="EditorialManagement.Actions.RefilterAction">
            </parameter>
            <parameter
                  name="Command.Perspective.Id"
                  value="EditorialManagementPerspective">
            </parameter>
            <visibleWhen
                  checkEnabled="false">
               <with
                     variable="selection">
                  <and>
                     <count
                           value="1">
                     </count>
                      <iterate>
                             <and>
                                            <instanceof
                                       value="de.gse.editorialmgmt.client.shared.bo.EditorialTreeItemClient">
                                    </instanceof>
                         <test
                               args="VAR_BRAND_VARIABLE_BRAND"
                               forcePluginActivation="true"
                               property="de.gse.editorialmgmt.client.gui.type.isTypeOf">
                         </test>
                         </and>
                      </iterate>
                  </and>
               </with>
            </visibleWhen>
         </command>
         <command
               commandId="VariableMgmt.createNewBrandVariableCommand"
               label="%createNewBrandVariable"
               tooltip="%createNewBrandVariable_tooltip"
               style="push">
            <parameter
                  name="Command.Action.Id"
                  value="VariableManagement.Actions.CreateNewBrandVariableAction">
            </parameter>
            <parameter
                  name="Command.Perspective.Id"
                  value="EditorialManagementPerspective">
            </parameter>
            <visibleWhen
                  checkEnabled="false">
               <with
                     variable="selection">
                  <and>
                     <count
                           value="1">
                     </count>
                     <iterate>
                             <and>
                                            <instanceof
                                       value="de.gse.editorialmgmt.client.shared.bo.EditorialTreeItemClient">
                                    </instanceof>
                        <or>
                           <test
                                 args="VAR_BRAND_VARIABLE_BRAND"
                                 forcePluginActivation="true"
                                 property="de.gse.editorialmgmt.client.gui.type.isTypeOf">
                           </test>
                           <test
                                 args="VAR_BRAND_VARIABLE"
                                 forcePluginActivation="true"
                                 property="de.gse.editorialmgmt.client.gui.type.isTypeOf">
                           </test>
                        </or>
                        </and>
                     </iterate>
                  </and>
               </with>
            </visibleWhen>
         </command>
      </menuContribution>
   </extension>
</plugin>


I found https://bugs.eclipse.org/bugs/show_bug.cgi?id=485931 but i'm not sure it has anything to do with it.

As I am relying on compatibility mode, a solution without E4 model would be appreciated.
Re: Duplicate popup-menu entries [message #1819644 is a reply to message #1819642] Mon, 20 January 2020 08:57 Go to previous messageGo to next message
Rolf Theunissen is currently offline Rolf TheunissenFriend
Messages: 191
Registered: April 2012
Senior Member
- How is the VariableNavigationView popup menu created?
- Do the items duplicate the first time you open the menu? Might be bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=379426
Re: Duplicate popup-menu entries [message #1819647 is a reply to message #1819644] Mon, 20 January 2020 10:00 Go to previous messageGo to next message
Alexander Haag is currently offline Alexander HaagFriend
Messages: 119
Registered: July 2009
Senior Member
Yes, the menu entries are duplicated when the popup is opened the first time.
But they do NOT add up, so the amount of entries does not increase when the menu is opened again.

Here are the methods for menu creation.
  @Override
    protected void hookContextMenu()
    {
        MenuManager menuMgr = new MenuManager("#NavigatorViewPopup"); 
        menuMgr.setRemoveAllWhenShown(true);
        menuMgr.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
        getStackedTree().createContextMenu(menuMgr, getSite());
    }

    public void createContextMenu(MenuManager pMenuManager, IWorkbenchPartSite pSite)
    {
        Menu menu = pMenuManager.createContextMenu(fViewer.getControl());
        fViewer.getControl().setMenu(menu);
        pSite.registerContextMenu(pMenuManager, fViewer);
}


At a first glance I don't think the bug you mentioned matches our problem, but I will check it again.
Re: Duplicate popup-menu entries [message #1820532 is a reply to message #1819647] Wed, 22 January 2020 09:50 Go to previous messageGo to next message
Rolf Theunissen is currently offline Rolf TheunissenFriend
Messages: 191
Registered: April 2012
Senior Member
Must be some kind of bug you are triggering. Could you open a bug report? It would be really helpful if you could add an running example (project) that reproduces the issue.
Re: Duplicate popup-menu entries [message #1820964 is a reply to message #1820532] Mon, 03 February 2020 15:39 Go to previous message
Alexander Haag is currently offline Alexander HaagFriend
Messages: 119
Registered: July 2009
Senior Member
Hi Rolf,

while trying to generate a small example for the bug-entry, we stumbled over a 'thing' in our code. After review of the 'thing', we no longer think there is a bug in eclipse and thus will NOT open a report. But we now know that there is a change of behaviour between the versions. We think that the older version was a bit more fault-tolerant than the new version is.

For all users that are interested:
We have a navigation view with a stacklayout where two treeviewer (normal and checkbox) are positioned above each other.
Until now, we used only one "MenuManager"-instance to register the context menu for both treeviewer (see code example for menu creation) . This is where the problem occurred. While eclipse 3.7 did only process the context menu entries for the currently active stack, eclipse 4 processes the entries for both treeviewer and shows them in the popup.
We now use two instances of the MenuManager to avoid the problem.

Thanks for all help and hints
Alex
Previous Topic:How can I use TextEditor in e4?
Next Topic:Trouble Importing
Goto Forum:
  


Current Time: Sun Apr 11 05:03:24 GMT 2021

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

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

Back to the top