01: package newprocess.diagram.navigator;
02:
03: import org.eclipse.emf.ecore.EObject;
04:
05: import org.eclipse.emf.ecore.resource.Resource;
06:
07: import org.eclipse.gef.EditPart;
08:
09: import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor;
10: import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditorInput;
11:
12: import org.eclipse.gmf.runtime.notation.View;
13:
14: import org.eclipse.jface.viewers.IStructuredSelection;
15: import org.eclipse.jface.viewers.StructuredSelection;
16:
17: import org.eclipse.ui.IEditorInput;
18: import org.eclipse.ui.IEditorPart;
19: import org.eclipse.ui.IWorkbenchPage;
20:
21: import org.eclipse.ui.navigator.ILinkHelper;
22:
23: /**
24: * @generated
25: */
26: public class New_processNavigatorLinkHelper implements ILinkHelper {
27:
28: /**
29: * @generated
30: */
31: public IStructuredSelection findSelection(IEditorInput anInput) {
32: return StructuredSelection.EMPTY;
33: }
34:
35: /**
36: * @generated
37: */
38: public void activateEditor(IWorkbenchPage aPage,
39: IStructuredSelection aSelection) {
40: if (aSelection == null || aSelection.isEmpty()) {
41: return;
42: }
43: if (false == aSelection.getFirstElement() instanceof New_processAbstractNavigatorItem) {
44: return;
45: }
46:
47: New_processAbstractNavigatorItem navigatorItem = (New_processAbstractNavigatorItem) aSelection
48: .getFirstElement();
49: View navigatorView = null;
50: if (navigatorItem instanceof New_processNavigatorItem) {
51: navigatorView = ((New_processNavigatorItem) navigatorItem)
52: .getView();
53: } else if (navigatorItem instanceof New_processNavigatorGroup) {
54: New_processNavigatorGroup group = (New_processNavigatorGroup) navigatorItem;
55: if (group.getParent() instanceof New_processNavigatorItem) {
56: navigatorView = ((New_processNavigatorItem) group
57: .getParent()).getView();
58: }
59: }
60: if (navigatorView == null) {
61: return;
62: }
63: DiagramEditorInput editorInput = new DiagramEditorInput(
64: navigatorView.getDiagram());
65: IEditorPart editor = aPage.findEditor(editorInput);
66: if (editor == null) {
67: return;
68: }
69: aPage.bringToTop(editor);
70: if (editor instanceof DiagramEditor) {
71: DiagramEditor diagramEditor = (DiagramEditor) editor;
72: Resource diagramResource = diagramEditor.getDiagram()
73: .eResource();
74:
75: EObject selectedView = diagramResource
76: .getEObject(navigatorView.eResource()
77: .getURIFragment(navigatorView));
78: if (selectedView == null) {
79: return;
80: }
81: EditPart selectedEditPart = (EditPart) diagramEditor
82: .getDiagramGraphicalViewer().getEditPartRegistry()
83: .get(selectedView);
84: if (selectedEditPart != null) {
85: diagramEditor.getDiagramGraphicalViewer().select(
86: selectedEditPart);
87: }
88: }
89: }
90:
91: }
|