| 1 | = Select an Edit Part by EObject = |
| 2 | |
| 3 | [wiki:gmf:gmf <back] |
| 4 | |
| 5 | 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: |
| 6 | |
| 7 | {{{ |
| 8 | |
| 9 | @Override |
| 10 | public void selectionChanged(IWorkbenchPart part, ISelection selection) { |
| 11 | |
| 12 | if (part instanceof ModelNavigatorView) |
| 13 | { |
| 14 | if(selection instanceof IStructuredSelection) |
| 15 | { |
| 16 | IStructuredSelection structuredSelection = (IStructuredSelection) selection; |
| 17 | Object selectedObject = structuredSelection.getFirstElement(); |
| 18 | if (selectedObject instanceof EObject) |
| 19 | { |
| 20 | EditPart editPartToSelect = getDiagramEditPart().findEditPart(getDiagramEditPart(), |
| 21 | (EObject)selectedObject); |
| 22 | editPartToSelect.getSelected(); |
| 23 | List<EditPart> editPartsToSelect = new ArrayList<EditPart>(); |
| 24 | editPartsToSelect.add(editPartToSelect); |
| 25 | ExhibitionDiagramEditorUtil.selectElementsInDiagram(this, editPartsToSelect); |
| 26 | } |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | super.selectionChanged(part, selection); |
| 31 | } |
| 32 | |
| 33 | }}} |