Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » Selection provides my business object?
Selection provides my business object? [message #1028184] Wed, 27 March 2013 23:57 Go to next message
Steve Vestal is currently offline Steve VestalFriend
Messages: 37
Registered: March 2013
Member
I have another view that is listening to selections made in a Graphiti editor. What that selection listener sees for the ISelection object is some graphiti.ui.internal.part. Is there a setting or nice coding idiom I can use so that the selection listener in the other view sees the business object as the selected object?
Re: Selection provides my business object? [message #1028950 is a reply to message #1028184] Fri, 29 March 2013 00:39 Go to previous message
Steve Vestal is currently offline Steve VestalFriend
Messages: 37
Registered: March 2013
Member
I'll answer my own question, in case anybody else ever looks for this. The trick seems to be to use GraphitiShapeEditPart rather than ShapeEditPart, which has restrictions to discourage use. It is necessary to add a dependence on org.eclipse.gef.editparts in the plugin manifeast. I also had to use a trick to get the business object from the PictogramElement, as pe.getLink seems to return a null link even when there is one.


	@Override
	public void selectionChanged(IWorkbenchPart part, ISelection selection) {
		if (part instanceof IDiagramEditor && selection instanceof IStructuredSelection) {
			Iterator<?> selectionElements = ((IStructuredSelection) selection).iterator();
			while (selectionElements.hasNext()) {
				Object se = selectionElements.next();
				if (se instanceof GraphitiShapeEditPart && !selectionElements.hasNext()) {					
					PictogramElement pe = ((GraphitiShapeEditPart) se).getPictogramElement();
					Object bo = MyFeatureProvider.getBusinessObject(pe);
					if (bo instanceof MyBusinessClass) {
						// whatever
					}
						
				}
			}
		}
	}	
Previous Topic:Add Palette entries at run-time
Next Topic:IllegalArgumentException while creating Anchor
Goto Forum:
  


Current Time: Thu Apr 25 01:26:13 GMT 2024

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

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

Back to the top