Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » NatTable context menus with Eclipse menus
NatTable context menus with Eclipse menus [message #1710657] Thu, 08 October 2015 08:59 Go to next message
Quang Tran is currently offline Quang TranFriend
Messages: 25
Registered: June 2012
Junior Member
Hi,
I wanted to contribute menus via the extension point org.eclipse.ui.menus, so I followed the guide written by Dirk: http://blog.vogella.com/2015/02/03/nattable-context-menus-with-eclipse-menus/

The problem is the first time I open the menu with right click my contribution is shown twice, all other consecutive tries are shown correcty.

Below my code:

public class MyContributionItem extends ContributionItem {

    @Override
    public void fill(final Menu menu, final int index) {

        final MenuItem myItem = new MenuItem( menu, SWT.CASCADE, index );
        myItem.setText( "Test" );

        final Menu myMenu = new Menu( myItem );
        myItem.setMenu( myMenu );

        final MenuItem mySubItem1 = new MenuItem( myMenu, SWT.PUSH );
        mySubItem1.setText( "Send" );
    }

    @Override
    public boolean isDynamic() {
        return true;
    }
}


// somewhere in the ViewPart, e.g. createPartControl(Composite)
MenuManager mgr = new MenuManager();
getSite().registerContextMenu("myMenu", mgr, null);


public class MyMenuConfiguration extends AbstractUiBindingConfiguration {

    private final Menu menu;

    public MyMenuConfiguration(final NatTable natTable, final MenuManager mgr) {
        menu = new PopupMenuBuilder( natTable, mgr ).build();
    }

    @Override
    public void configureUiBindings(final UiBindingRegistry uiBindingRegistry) {
        uiBindingRegistry.registerMouseDownBinding(
                MouseEventMatcher.bodyRightClick( SWT.NONE ), new PopupMenuAction( menu ) );
    }
}


// somewhere in plugin.xml
<extension
         point="org.eclipse.ui.menus">
      <menuContribution
            allPopups="false"
            locationURI="popup:myMenu">
         <dynamic
               class="com.test.ui.MyContributionItem"
               id="MyContributionItem ">
         </dynamic>
      </menuContribution>
  </extension>


I'm using NatTable 1.3.0
  • Attachment: 1st_time.png
    (Size: 1.00KB, Downloaded 86 times)
  • Attachment: 2nd_time.png
    (Size: 0.74KB, Downloaded 96 times)

[Updated on: Thu, 08 October 2015 09:02]

Report message to a moderator

Re: NatTable context menus with Eclipse menus [message #1710686 is a reply to message #1710657] Thu, 08 October 2015 11:37 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2710
Registered: July 2012
Senior Member
I haven't tested dynamic menu contributions. Might be an issue with dynamic menu contributions.

Please create a ticket. Not sure when I'm able to look at this in detail.
Re: NatTable context menus with Eclipse menus [message #1710698 is a reply to message #1710657] Thu, 08 October 2015 13:17 Go to previous messageGo to next message
Quang Tran is currently offline Quang TranFriend
Messages: 25
Registered: June 2012
Junior Member
Hi Dirk,
thanks for the reply. I've also tested it with commands, same behavior.
I will open ticker asap.
Re: NatTable context menus with Eclipse menus [message #1796882 is a reply to message #1710698] Sat, 20 October 2018 17:42 Go to previous message
Luc H is currently offline Luc HFriend
Messages: 1
Registered: October 2018
Junior Member
Invoking setRemoveAllWhenShown(true) on the MenuManager seems to make the context menu appear correctly the first time.
Previous Topic:How to read Map in Nattable
Next Topic:Release date
Goto Forum:
  


Current Time: Mon Sep 16 10:49:49 GMT 2019

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

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

Back to the top