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: 211
Registered: July 2009
Senior Member
Hi all,

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

Thanks,
Henrik
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: 43
Registered: April 2012
Member
Hi,
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);
			menuEntry.setText(customFeature.getName());
			if(customFeature.isAvailable(context)) {
				if(bos.size() == 1) {
					if(customFeature.getName().equals(CreateSimpleConnectionPointFeature.NAME) 
						&& 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);
		menu.addAll(mes);

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


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


Current Time: Thu Apr 17 11:45:42 EDT 2014

Powered by FUDForum. Page generated in 0.08093 seconds