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

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