Skip to main content


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 09:46 Go to next message
Henrik Rentz-Reichert is currently offline Henrik Rentz-ReichertFriend
Messages: 261
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 10:06 Go to previous message
Marek Jagielski is currently offline Marek JagielskiFriend
Messages: 97
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: Fri Apr 26 13:02:03 GMT 2024

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

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

Back to the top