EMMA Coverage Report (generated Sun Feb 05 10:43:15 CET 2012)
[all classes][de.uka.ipd.sdq.pcm.gmf.repository.navigator]

COVERAGE SUMMARY FOR SOURCE FILE [PalladioComponentModelNavigatorLinkHelper.java]

nameclass, %method, %block, %line, %
PalladioComponentModelNavigatorLinkHelper.java0%   (0/1)0%   (0/4)0%   (0/183)0%   (0/64)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class PalladioComponentModelNavigatorLinkHelper0%   (0/1)0%   (0/4)0%   (0/183)0%   (0/64)
PalladioComponentModelNavigatorLinkHelper (): void 0%   (0/1)0%   (0/3)0%   (0/1)
activateEditor (IWorkbenchPage, IStructuredSelection): void 0%   (0/1)0%   (0/93)0%   (0/37)
findSelection (IEditorInput): IStructuredSelection 0%   (0/1)0%   (0/32)0%   (0/12)
getEditorInput (Diagram): IEditorInput 0%   (0/1)0%   (0/55)0%   (0/14)

1/*
2 *Copyright 2007, IPD, SDQ, University of Karlsruhe
3 */
4package de.uka.ipd.sdq.pcm.gmf.repository.navigator;
5 
6import java.util.Iterator;
7 
8import org.eclipse.core.resources.IFile;
9import org.eclipse.emf.common.ui.URIEditorInput;
10import org.eclipse.emf.common.util.URI;
11import org.eclipse.emf.ecore.EObject;
12import org.eclipse.emf.ecore.resource.Resource;
13import org.eclipse.emf.ecore.resource.ResourceSet;
14import org.eclipse.emf.ecore.util.EcoreUtil;
15import org.eclipse.emf.workspace.util.WorkspaceSynchronizer;
16import org.eclipse.gef.EditPart;
17import org.eclipse.gef.GraphicalViewer;
18import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor;
19import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument;
20import org.eclipse.gmf.runtime.notation.Diagram;
21import org.eclipse.gmf.runtime.notation.View;
22import org.eclipse.jface.viewers.IStructuredSelection;
23import org.eclipse.jface.viewers.StructuredSelection;
24import org.eclipse.ui.IEditorInput;
25import org.eclipse.ui.IEditorPart;
26import org.eclipse.ui.IWorkbenchPage;
27import org.eclipse.ui.navigator.ILinkHelper;
28import org.eclipse.ui.part.FileEditorInput;
29 
30import de.uka.ipd.sdq.pcm.gmf.repository.part.PalladioComponentModelRepositoryDiagramEditorPlugin;
31 
32/**
33 * @generated
34 */
35public class PalladioComponentModelNavigatorLinkHelper implements ILinkHelper {
36 
37        /**
38         * @generated
39         */
40        private static IEditorInput getEditorInput(Diagram diagram) {
41                Resource diagramResource = diagram.eResource();
42                for (Iterator it = diagramResource.getContents().iterator(); it
43                                .hasNext();) {
44                        EObject nextEObject = (EObject) it.next();
45                        if (nextEObject == diagram) {
46                                return new FileEditorInput(WorkspaceSynchronizer
47                                                .getFile(diagramResource));
48                        }
49                        if (nextEObject instanceof Diagram) {
50                                break;
51                        }
52                }
53                URI uri = EcoreUtil.getURI(diagram);
54                String editorName = uri.lastSegment()
55                                + "#" + diagram.eResource().getContents().indexOf(diagram); //$NON-NLS-1$
56                IEditorInput editorInput = new URIEditorInput(uri, editorName);
57                return editorInput;
58        }
59 
60        /**
61         * @generated
62         */
63        public IStructuredSelection findSelection(IEditorInput anInput) {
64                IDiagramDocument document = PalladioComponentModelRepositoryDiagramEditorPlugin
65                                .getInstance().getDocumentProvider()
66                                .getDiagramDocument(anInput);
67                if (document == null) {
68                        return StructuredSelection.EMPTY;
69                }
70                Diagram diagram = document.getDiagram();
71                IFile file = WorkspaceSynchronizer.getFile(diagram.eResource());
72                if (file != null) {
73                        PalladioComponentModelNavigatorItem item = new PalladioComponentModelNavigatorItem(
74                                        diagram, file, false);
75                        return new StructuredSelection(item);
76                }
77                return StructuredSelection.EMPTY;
78        }
79 
80        /**
81         * @generated
82         */
83        public void activateEditor(IWorkbenchPage aPage,
84                        IStructuredSelection aSelection) {
85                if (aSelection == null || aSelection.isEmpty()) {
86                        return;
87                }
88                if (false == aSelection.getFirstElement() instanceof PalladioComponentModelAbstractNavigatorItem) {
89                        return;
90                }
91 
92                PalladioComponentModelAbstractNavigatorItem abstractNavigatorItem = (PalladioComponentModelAbstractNavigatorItem) aSelection
93                                .getFirstElement();
94                View navigatorView = null;
95                if (abstractNavigatorItem instanceof PalladioComponentModelNavigatorItem) {
96                        navigatorView = ((PalladioComponentModelNavigatorItem) abstractNavigatorItem)
97                                        .getView();
98                } else if (abstractNavigatorItem instanceof PalladioComponentModelNavigatorGroup) {
99                        PalladioComponentModelNavigatorGroup navigatorGroup = (PalladioComponentModelNavigatorGroup) abstractNavigatorItem;
100                        if (navigatorGroup.getParent() instanceof PalladioComponentModelNavigatorItem) {
101                                navigatorView = ((PalladioComponentModelNavigatorItem) navigatorGroup
102                                                .getParent()).getView();
103                        }
104                }
105                if (navigatorView == null) {
106                        return;
107                }
108                IEditorInput editorInput = getEditorInput(navigatorView.getDiagram());
109                IEditorPart editor = aPage.findEditor(editorInput);
110                if (editor == null) {
111                        return;
112                }
113                aPage.bringToTop(editor);
114                if (editor instanceof DiagramEditor) {
115                        DiagramEditor diagramEditor = (DiagramEditor) editor;
116                        ResourceSet diagramEditorResourceSet = diagramEditor
117                                        .getEditingDomain().getResourceSet();
118                        EObject selectedView = diagramEditorResourceSet.getEObject(
119                                        EcoreUtil.getURI(navigatorView), true);
120                        if (selectedView == null) {
121                                return;
122                        }
123                        GraphicalViewer graphicalViewer = (GraphicalViewer) diagramEditor
124                                        .getAdapter(GraphicalViewer.class);
125                        EditPart selectedEditPart = (EditPart) graphicalViewer
126                                        .getEditPartRegistry().get(selectedView);
127                        if (selectedEditPart != null) {
128                                graphicalViewer.select(selectedEditPart);
129                        }
130                }
131        }
132 
133}

[all classes][de.uka.ipd.sdq.pcm.gmf.repository.navigator]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov