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

COVERAGE SUMMARY FOR SOURCE FILE [PalladioComponentModelDiagramEditor.java]

nameclass, %method, %block, %line, %
PalladioComponentModelDiagramEditor.java0%   (0/2)0%   (0/18)0%   (0/356)0%   (0/117)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class PalladioComponentModelDiagramEditor0%   (0/1)0%   (0/16)0%   (0/343)0%   (0/115)
PalladioComponentModelDiagramEditor (): void 0%   (0/1)0%   (0/4)0%   (0/2)
configureGraphicalViewer (): void 0%   (0/1)0%   (0/21)0%   (0/7)
createPaletteRoot (PaletteRoot): PaletteRoot 0%   (0/1)0%   (0/11)0%   (0/3)
doSaveAs (): void 0%   (0/1)0%   (0/6)0%   (0/2)
getAdapter (Class): Object 0%   (0/1)0%   (0/12)0%   (0/3)
getContextID (): String 0%   (0/1)0%   (0/2)0%   (0/1)
getContributorId (): String 0%   (0/1)0%   (0/2)0%   (0/1)
getDocumentProvider (IEditorInput): IDocumentProvider 0%   (0/1)0%   (0/13)0%   (0/5)
getEditingDomain (): TransactionalEditingDomain 0%   (0/1)0%   (0/21)0%   (0/5)
getNavigatorSelection (): ISelection 0%   (0/1)0%   (0/30)0%   (0/10)
getPreferencesHint (): PreferencesHint 0%   (0/1)0%   (0/2)0%   (0/1)
getShowInContext (): ShowInContext 0%   (0/1)0%   (0/8)0%   (0/1)
gotoMarker (IMarker): void 0%   (0/1)0%   (0/5)0%   (0/2)
isSaveAsAllowed (): boolean 0%   (0/1)0%   (0/2)0%   (0/1)
performSaveAs (IProgressMonitor): void 0%   (0/1)0%   (0/189)0%   (0/65)
setDocumentProvider (IEditorInput): void 0%   (0/1)0%   (0/15)0%   (0/6)
     
class PalladioComponentModelDiagramEditor$10%   (0/1)0%   (0/2)0%   (0/13)0%   (0/3)
PalladioComponentModelDiagramEditor$1 (PalladioComponentModelDiagramEditor): ... 0%   (0/1)0%   (0/6)0%   (0/2)
getShowInTargetIds (): String [] 0%   (0/1)0%   (0/7)0%   (0/1)

1/*
2 *Copyright 2007, SDQ, IPD, Uni Karlsruhe (TH)
3 */
4package de.uka.ipd.sdq.pcm.gmf.composite.part;
5 
6import org.eclipse.gef.palette.PaletteRoot;
7import org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor;
8import org.eclipse.gmf.runtime.notation.Diagram;
9import org.eclipse.emf.transaction.TransactionalEditingDomain;
10import org.eclipse.emf.workspace.util.WorkspaceSynchronizer;
11import org.eclipse.core.resources.IFile;
12import org.eclipse.core.resources.IMarker;
13import org.eclipse.core.resources.IWorkspaceRoot;
14import org.eclipse.core.resources.ResourcesPlugin;
15 
16import org.eclipse.core.runtime.CoreException;
17import org.eclipse.core.runtime.IPath;
18import org.eclipse.core.runtime.IProgressMonitor;
19import org.eclipse.core.runtime.IStatus;
20import org.eclipse.core.runtime.NullProgressMonitor;
21 
22import org.eclipse.emf.common.ui.URIEditorInput;
23 
24import org.eclipse.gmf.runtime.common.ui.services.marker.MarkerNavigationService;
25 
26import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint;
27 
28import org.eclipse.gmf.runtime.diagram.ui.actions.ActionIds;
29import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDiagramDocument;
30import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocument;
31import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocumentProvider;
32 
33import org.eclipse.jface.dialogs.ErrorDialog;
34import org.eclipse.jface.dialogs.IMessageProvider;
35import org.eclipse.jface.dialogs.MessageDialog;
36 
37import org.eclipse.jface.viewers.ISelection;
38import org.eclipse.jface.viewers.StructuredSelection;
39import org.eclipse.jface.window.Window;
40 
41import org.eclipse.osgi.util.NLS;
42 
43import org.eclipse.swt.widgets.Shell;
44 
45import org.eclipse.ui.IEditorInput;
46import org.eclipse.ui.IEditorMatchingStrategy;
47import org.eclipse.ui.IEditorReference;
48import org.eclipse.ui.IFileEditorInput;
49import org.eclipse.ui.PlatformUI;
50 
51import org.eclipse.ui.dialogs.SaveAsDialog;
52 
53import org.eclipse.ui.ide.IGotoMarker;
54 
55import org.eclipse.ui.navigator.resources.ProjectExplorer;
56import org.eclipse.ui.part.FileEditorInput;
57import org.eclipse.ui.part.IShowInTargetList;
58import org.eclipse.ui.part.ShowInContext;
59import de.uka.ipd.sdq.pcm.gmf.composite.navigator.PalladioComponentModelNavigatorItem;
60 
61/**
62 * @generated
63 */
64public class PalladioComponentModelDiagramEditor extends DiagramDocumentEditor
65                implements IGotoMarker {
66 
67        /**
68         * @generated
69         */
70        public static final String ID = "de.uka.ipd.sdq.pcm.gmf.composite.part.PalladioComponentModelDiagramEditorID"; //$NON-NLS-1$
71 
72        /**
73         * @generated
74         */
75        public static final String CONTEXT_ID = "de.uka.ipd.sdq.pcm.gmf.composite.ui.diagramContext"; //$NON-NLS-1$
76 
77        /**
78         * @generated
79         */
80        public PalladioComponentModelDiagramEditor() {
81                super(true);
82        }
83 
84        /**
85         * @generated
86         */
87        protected String getContextID() {
88                return CONTEXT_ID;
89        }
90 
91        /**
92         * @generated
93         */
94        protected PaletteRoot createPaletteRoot(PaletteRoot existingPaletteRoot) {
95                PaletteRoot root = super.createPaletteRoot(existingPaletteRoot);
96                new PalladioComponentModelPaletteFactory().fillPalette(root);
97                return root;
98        }
99 
100        /**
101         * @generated
102         */
103        protected PreferencesHint getPreferencesHint() {
104                return PalladioComponentModelComposedStructureDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT;
105        }
106 
107        /**
108         * @generated
109         */
110        public String getContributorId() {
111                return PalladioComponentModelComposedStructureDiagramEditorPlugin.ID;
112        }
113 
114        /**
115         * @generated
116         */
117        public Object getAdapter(Class type) {
118                if (type == IShowInTargetList.class) {
119                        return new IShowInTargetList() {
120                                public String[] getShowInTargetIds() {
121                                        return new String[] { ProjectExplorer.VIEW_ID };
122                                }
123                        };
124                }
125                return super.getAdapter(type);
126        }
127 
128        /**
129         * @generated
130         */
131        protected IDocumentProvider getDocumentProvider(IEditorInput input) {
132                if (input instanceof IFileEditorInput
133                                || input instanceof URIEditorInput) {
134                        return PalladioComponentModelComposedStructureDiagramEditorPlugin
135                                        .getInstance().getDocumentProvider();
136                }
137                return super.getDocumentProvider(input);
138        }
139 
140        /**
141         * @generated
142         */
143        public TransactionalEditingDomain getEditingDomain() {
144                IDocument document = getEditorInput() != null ? getDocumentProvider()
145                                .getDocument(getEditorInput()) : null;
146                if (document instanceof IDiagramDocument) {
147                        return ((IDiagramDocument) document).getEditingDomain();
148                }
149                return super.getEditingDomain();
150        }
151 
152        /**
153         * @generated
154         */
155        protected void setDocumentProvider(IEditorInput input) {
156                if (input instanceof IFileEditorInput
157                                || input instanceof URIEditorInput) {
158                        setDocumentProvider(PalladioComponentModelComposedStructureDiagramEditorPlugin
159                                        .getInstance().getDocumentProvider());
160                } else {
161                        super.setDocumentProvider(input);
162                }
163        }
164 
165        /**
166         * @generated
167         */
168        public void gotoMarker(IMarker marker) {
169                MarkerNavigationService.getInstance().gotoMarker(this, marker);
170        }
171 
172        /**
173         * @generated
174         */
175        public boolean isSaveAsAllowed() {
176                return true;
177        }
178 
179        /**
180         * @generated
181         */
182        public void doSaveAs() {
183                performSaveAs(new NullProgressMonitor());
184        }
185 
186        /**
187         * @generated
188         */
189        protected void performSaveAs(IProgressMonitor progressMonitor) {
190                Shell shell = getSite().getShell();
191                IEditorInput input = getEditorInput();
192                SaveAsDialog dialog = new SaveAsDialog(shell);
193                IFile original = input instanceof IFileEditorInput ? ((IFileEditorInput) input)
194                                .getFile()
195                                : null;
196                if (original != null) {
197                        dialog.setOriginalFile(original);
198                }
199                dialog.create();
200                IDocumentProvider provider = getDocumentProvider();
201                if (provider == null) {
202                        // editor has been programmatically closed while the dialog was open
203                        return;
204                }
205                if (provider.isDeleted(input) && original != null) {
206                        String message = NLS
207                                        .bind(
208                                                        Messages.PalladioComponentModelDiagramEditor_SavingDeletedFile,
209                                                        original.getName());
210                        dialog.setErrorMessage(null);
211                        dialog.setMessage(message, IMessageProvider.WARNING);
212                }
213                if (dialog.open() == Window.CANCEL) {
214                        if (progressMonitor != null) {
215                                progressMonitor.setCanceled(true);
216                        }
217                        return;
218                }
219                IPath filePath = dialog.getResult();
220                if (filePath == null) {
221                        if (progressMonitor != null) {
222                                progressMonitor.setCanceled(true);
223                        }
224                        return;
225                }
226                IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
227                IFile file = workspaceRoot.getFile(filePath);
228                final IEditorInput newInput = new FileEditorInput(file);
229                // Check if the editor is already open
230                IEditorMatchingStrategy matchingStrategy = getEditorDescriptor()
231                                .getEditorMatchingStrategy();
232                IEditorReference[] editorRefs = PlatformUI.getWorkbench()
233                                .getActiveWorkbenchWindow().getActivePage()
234                                .getEditorReferences();
235                for (int i = 0; i < editorRefs.length; i++) {
236                        if (matchingStrategy.matches(editorRefs[i], newInput)) {
237                                MessageDialog
238                                                .openWarning(
239                                                                shell,
240                                                                Messages.PalladioComponentModelDiagramEditor_SaveAsErrorTitle,
241                                                                Messages.PalladioComponentModelDiagramEditor_SaveAsErrorMessage);
242                                return;
243                        }
244                }
245                boolean success = false;
246                try {
247                        provider.aboutToChange(newInput);
248                        getDocumentProvider(newInput).saveDocument(progressMonitor,
249                                        newInput,
250                                        getDocumentProvider().getDocument(getEditorInput()), true);
251                        success = true;
252                } catch (CoreException x) {
253                        IStatus status = x.getStatus();
254                        if (status == null || status.getSeverity() != IStatus.CANCEL) {
255                                ErrorDialog
256                                                .openError(
257                                                                shell,
258                                                                Messages.PalladioComponentModelDiagramEditor_SaveErrorTitle,
259                                                                Messages.PalladioComponentModelDiagramEditor_SaveErrorMessage,
260                                                                x.getStatus());
261                        }
262                } finally {
263                        provider.changed(newInput);
264                        if (success) {
265                                setInput(newInput);
266                        }
267                }
268                if (progressMonitor != null) {
269                        progressMonitor.setCanceled(!success);
270                }
271        }
272 
273        /**
274         * @generated
275         */
276        public ShowInContext getShowInContext() {
277                return new ShowInContext(getEditorInput(), getNavigatorSelection());
278        }
279 
280        /**
281         * @generated
282         */
283        private ISelection getNavigatorSelection() {
284                IDiagramDocument document = getDiagramDocument();
285                if (document == null) {
286                        return StructuredSelection.EMPTY;
287                }
288                Diagram diagram = document.getDiagram();
289                IFile file = WorkspaceSynchronizer.getFile(diagram.eResource());
290                if (file != null) {
291                        PalladioComponentModelNavigatorItem item = new PalladioComponentModelNavigatorItem(
292                                        diagram, file, false);
293                        return new StructuredSelection(item);
294                }
295                return StructuredSelection.EMPTY;
296        }
297 
298        /**
299         * @generated
300         */
301        protected void configureGraphicalViewer() {
302                super.configureGraphicalViewer();
303                DiagramEditorContextMenuProvider provider = new DiagramEditorContextMenuProvider(
304                                this, getDiagramGraphicalViewer());
305                getDiagramGraphicalViewer().setContextMenu(provider);
306                getSite().registerContextMenu(ActionIds.DIAGRAM_EDITOR_CONTEXT_MENU,
307                                provider, getDiagramGraphicalViewer());
308        }
309 
310}

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