Select an Edit Part by EObject
If you have for example an Tree Viewer that fires SelectionChanged? for the EObject that is selected. In your Diagram Editor add the following method:
@Override public void selectionChanged(IWorkbenchPart part, ISelection selection) { if (part instanceof ModelNavigatorView) { if(selection instanceof IStructuredSelection) { IStructuredSelection structuredSelection = (IStructuredSelection) selection; Object selectedObject = structuredSelection.getFirstElement(); if (selectedObject instanceof EObject) { EditPart editPartToSelect = getDiagramEditPart().findEditPart(getDiagramEditPart(), (EObject)selectedObject); editPartToSelect.getSelected(); List<EditPart> editPartsToSelect = new ArrayList<EditPart>(); editPartsToSelect.add(editPartToSelect); ExhibitionDiagramEditorUtil.selectElementsInDiagram(this, editPartsToSelect); } } } super.selectionChanged(part, selection); }
Last modified 16 years ago
Last modified on Mar 13, 2008, 1:22:05 PM