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 19:57 Go to next message
Steve Vestal is currently offline Steve Vestal
Messages: 2
Registered: March 2013
Junior 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] Thu, 28 March 2013 20:39 Go to previous message
Steve Vestal is currently offline Steve Vestal
Messages: 2
Registered: March 2013
Junior 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 Jul 31 09:39:24 EDT 2014

Powered by FUDForum. Page generated in 0.02445 seconds