Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » are context buttons available for connections?
are context buttons available for connections? [message #1082983] Fri, 09 August 2013 05:46 Go to next message
Henrik Rentz-Reichert is currently offline Henrik Rentz-Reichert
Messages: 217
Registered: July 2009
Senior Member
Hi all,

I'm wondering whether context buttons are available for connections also?

Re: are context buttons available for connections? [message #1082994 is a reply to message #1082983] Fri, 09 August 2013 06:06 Go to previous message
Marek Jagielski is currently offline Marek Jagielski
Messages: 59
Registered: April 2012
I check if connection is selected and if the click point is close to the connection:

	public IContextMenuEntry[] getContextMenu(ICustomContext context) {
		List<IContextMenuEntry> menu = new ArrayList<IContextMenuEntry>();

		PictogramElement[] pes = context.getPictogramElements();
		List<Object> bos = new ArrayList<Object>();
		for(PictogramElement pe : pes) bos.add(getFeatureProvider().getBusinessObjectForPictogramElement(pe));
		ICustomFeature[] customFeatures = getFeatureProvider().getCustomFeatures(context);

		for(ICustomFeature customFeature : customFeatures) {
			ContextMenuEntry menuEntry = new ContextMenuEntry(customFeature, context);
			if(customFeature.isAvailable(context)) {
				if(bos.size() == 1) {
						&& bos.get(0) instanceof SimpleConnection
						&& GraphicsUtil.distanceToConnection((FreeFormConnection) pes[0], context.getX(), context.getY()) < 5) menu.add(menuEntry);					
				} else if(bos.size() > 1) {
		List<IContextMenuEntry> mes = ExtensionManager.getContextMenu(context);

		return menu.toArray(new IContextMenuEntry[menu.size()]);

Previous Topic:Connection with given point array
Next Topic:Use one create feature for different elements
Goto Forum:

Current Time: Wed Aug 27 11:08:00 EDT 2014

Powered by FUDForum. Page generated in 0.01784 seconds