Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Submenu using IContextMenuEntry
Submenu using IContextMenuEntry [message #1224554] Thu, 26 December 2013 22:44 Go to next message
Mithu Deb is currently offline Mithu Deb
Messages: 8
Registered: September 2013
Junior Member
Hi,

How do i create submenu within the main menu using IContextMenuEntry for right click
context menu

Kind Regards,
Mithu Deb
Re: Submenu using IContextMenuEntry [message #1228560 is a reply to message #1224554] Tue, 07 January 2014 08:58 Go to previous message
Michael Wenz is currently offline Michael Wenz
Messages: 1527
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Hi Mithu Deb,

though it is not explained in the tutorial, the final version of the
tutorial plugin in our SDK shows that. Basically it is overriding the
getContextMenu method in the tool behavior provider with something like
this:
@Override
public IContextMenuEntry[] getContextMenu(ICustomContext context) {
// create a sub-menu for all custom features
ContextMenuEntry subMenu = new ContextMenuEntry(null, context);
subMenu.setText("Cu&stom"); //$NON-NLS-1$
subMenu.setDescription("Custom features submenu"); //$NON-NLS-1$
// display sub-menu hierarchical or flat
subMenu.setSubmenu(true);

// create a menu-entry in the sub-menu for each custom feature
ICustomFeature[] customFeatures =
getFeatureProvider().getCustomFeatures(context);
for (int i = 0; i < customFeatures.length; i++) {
ICustomFeature customFeature = customFeatures[i];
if (customFeature.isAvailable(context)) {
ContextMenuEntry menuEntry = new ContextMenuEntry(customFeature,
context);
subMenu.add(menuEntry);
}
}

IContextMenuEntry ret[] = new IContextMenuEntry[] { subMenu };
return ret;
}

Michael
Previous Topic:Routing tutorial
Next Topic:UML Class Diagram Editor based on Graphiti
Goto Forum:
  


Current Time: Fri Apr 18 10:14:18 EDT 2014

Powered by FUDForum. Page generated in 0.01675 seconds