Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Submenu using IContextMenuEntry
Submenu using IContextMenuEntry [message #1224554] Fri, 27 December 2013 03:44 Go to next message
Mithu Deb is currently offline Mithu DebFriend
Messages: 9
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 13:58 Go to previous message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1640
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: Mon Dec 22 05:02:44 GMT 2014

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

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