NatTable context menus with Eclipse menus [message #1710657] |
Thu, 08 October 2015 08:59 |
Quang Tran 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 257 times) -
Attachment: 2nd_time.png
(Size: 0.74KB, Downloaded 210 times)
[Updated on: Thu, 08 October 2015 09:02] Report message to a moderator
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03436 seconds