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

COVERAGE SUMMARY FOR SOURCE FILE [PalladioComponentModelAllocationDiagramEditor.java]

nameclass, %method, %block, %line, %
PalladioComponentModelAllocationDiagramEditor.java0%   (0/1)0%   (0/13)0%   (0/281)0%   (0/96)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class PalladioComponentModelAllocationDiagramEditor0%   (0/1)0%   (0/13)0%   (0/281)0%   (0/96)
PalladioComponentModelAllocationDiagramEditor (): void 0%   (0/1)0%   (0/4)0%   (0/2)
createPaletteRoot (PaletteRoot): PaletteRoot 0%   (0/1)0%   (0/11)0%   (0/3)
doSaveAs (): void 0%   (0/1)0%   (0/6)0%   (0/2)
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)
getPreferencesHint (): PreferencesHint 0%   (0/1)0%   (0/2)0%   (0/1)
getShowInContext (): ShowInContext 0%   (0/1)0%   (0/9)0%   (0/2)
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)

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

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