Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Custom Feature location Context Menu
Custom Feature location Context Menu [message #1619056] Mon, 16 February 2015 09:58 Go to next message
Abhishek Chakraborty is currently offline Abhishek ChakrabortyFriend
Messages: 82
Registered: July 2009
Location: Cologne, Germany
Member

In Graphiti, when i add a custom feature it automatically added under "custom" of the context menu. Can I add it at the top level next to Delete /remove?

Regards,
Abhishek Chakraborty
Re: Custom Feature location Context Menu [message #1620787 is a reply to message #1619056] Tue, 17 February 2015 12:34 Go to previous messageGo to next message
Simon Sperl is currently offline Simon SperlFriend
Messages: 21
Registered: May 2014
Junior Member
Override:

org.eclipse.graphiti.ui.editor.DiagramEditorContextMenuProvider.buildContextMenu(IMenuManager)
andor addDefaultMenuGroupRest()

(maybe it can also be done with MenuContributions of the plugin.xml)

[Updated on: Tue, 17 February 2015 12:35]

Report message to a moderator

Re: Custom Feature location Context Menu [message #1622275 is a reply to message #1619056] Wed, 18 February 2015 11:34 Go to previous message
Michael Wenz is currently offline Michael WenzFriend
Messages: 1931
Registered: July 2009
Location: Walldorf, Germany
Senior Member
Hi,

the default implementation in DefaultToolsBehaviorProvider should add custom
features to the main context menu:
public IContextMenuEntry[] getContextMenu(ICustomContext context) {
final String SIGNATURE = "getContextMenu(IContext)"; //$NON-NLS-1$
boolean info = T.racer().info();
if (info) {
T.racer().entering(DefaultToolBehaviorProvider.class, SIGNATURE, new
Object[] { context });
}
IContextMenuEntry[] ret = NO_CONTEXT_MENU_ENTRIES;
List<IContextMenuEntry> retList = new ArrayList<IContextMenuEntry>();

ICustomFeature[] customFeatures =
getFeatureProvider().getCustomFeatures(context);
for (int i = 0; i < customFeatures.length; i++) {
ICustomFeature customFeature = customFeatures[i];
retList.add(new ContextMenuEntry(customFeature, context));
}

ret = retList.toArray(NO_CONTEXT_MENU_ENTRIES);
if (info) {
T.racer().exiting(DefaultToolBehaviorProvider.class, SIGNATURE,
ret);
}
return ret;
}


Maybe you have based your tool on the tutorial, there in the
TutorialToolBehaviorProvider we have:
@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;
}

which will cause the submenu.

Michael

"Abhishek Chakraborty" schrieb im Newsbeitrag
news:mbsf0q$sqm$1@xxxxxxxxe.org...

In Graphiti, when i add a custom feature it automatically added under
"custom" of the context menu. Can I add it at the top level next to Delete
/remove?
--
Regards,
Abhishek Chakraborty
Previous Topic:Disabling reveal behavior in diagram editor
Next Topic:Serialization betwenn Xtext und Graphiti
Goto Forum:
  


Current Time: Tue Mar 19 03:21:39 GMT 2024

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

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

Back to the top