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

COVERAGE SUMMARY FOR SOURCE FILE [SeffDiagramEditor.java]

nameclass, %method, %block, %line, %
SeffDiagramEditor.java0%   (0/2)0%   (0/18)0%   (0/356)0%   (0/114)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class SeffDiagramEditor0%   (0/1)0%   (0/16)0%   (0/343)0%   (0/112)
SeffDiagramEditor (): 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/62)
setDocumentProvider (IEditorInput): void 0%   (0/1)0%   (0/15)0%   (0/6)
     
class SeffDiagramEditor$10%   (0/1)0%   (0/2)0%   (0/13)0%   (0/3)
SeffDiagramEditor$1 (SeffDiagramEditor): void 0%   (0/1)0%   (0/6)0%   (0/2)
getShowInTargetIds (): String [] 0%   (0/1)0%   (0/7)0%   (0/1)

1/*
2 *Copyright 2006 SDQ Research Group, University of Karlsruhe (TH)
3 */
4package de.uka.ipd.sdq.pcm.gmf.seff.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.seff.navigator.PalladioComponentModelNavigatorItem;
48 
49/**
50 * @generated
51 */
52public class SeffDiagramEditor extends DiagramDocumentEditor implements
53                IGotoMarker {
54 
55        /**
56         * @generated
57         */
58        public static final String ID = "de.uka.ipd.sdq.pcm.gmf.seff.part.SeffDiagramEditorID"; //$NON-NLS-1$
59 
60        /**
61         * @generated
62         */
63        public static final String CONTEXT_ID = "de.uka.ipd.sdq.pcm.gmf.seff.ui.diagramContext"; //$NON-NLS-1$
64 
65        /**
66         * @generated
67         */
68        public SeffDiagramEditor() {
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 PalladioComponentModelSeffDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT;
93        }
94 
95        /**
96         * @generated
97         */
98        public String getContributorId() {
99                return PalladioComponentModelSeffDiagramEditorPlugin.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 PalladioComponentModelSeffDiagramEditorPlugin.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(PalladioComponentModelSeffDiagramEditorPlugin
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.bind(
195                                        Messages.SeffDiagramEditor_SavingDeletedFile, original
196                                                        .getName());
197                        dialog.setErrorMessage(null);
198                        dialog.setMessage(message, IMessageProvider.WARNING);
199                }
200                if (dialog.open() == Window.CANCEL) {
201                        if (progressMonitor != null) {
202                                progressMonitor.setCanceled(true);
203                        }
204                        return;
205                }
206                IPath filePath = dialog.getResult();
207                if (filePath == null) {
208                        if (progressMonitor != null) {
209                                progressMonitor.setCanceled(true);
210                        }
211                        return;
212                }
213                IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
214                IFile file = workspaceRoot.getFile(filePath);
215                final IEditorInput newInput = new FileEditorInput(file);
216                // Check if the editor is already open
217                IEditorMatchingStrategy matchingStrategy = getEditorDescriptor()
218                                .getEditorMatchingStrategy();
219                IEditorReference[] editorRefs = PlatformUI.getWorkbench()
220                                .getActiveWorkbenchWindow().getActivePage()
221                                .getEditorReferences();
222                for (int i = 0; i < editorRefs.length; i++) {
223                        if (matchingStrategy.matches(editorRefs[i], newInput)) {
224                                MessageDialog.openWarning(shell,
225                                                Messages.SeffDiagramEditor_SaveAsErrorTitle,
226                                                Messages.SeffDiagramEditor_SaveAsErrorMessage);
227                                return;
228                        }
229                }
230                boolean success = false;
231                try {
232                        provider.aboutToChange(newInput);
233                        getDocumentProvider(newInput).saveDocument(progressMonitor,
234                                        newInput,
235                                        getDocumentProvider().getDocument(getEditorInput()), true);
236                        success = true;
237                } catch (CoreException x) {
238                        IStatus status = x.getStatus();
239                        if (status == null || status.getSeverity() != IStatus.CANCEL) {
240                                ErrorDialog.openError(shell,
241                                                Messages.SeffDiagramEditor_SaveErrorTitle,
242                                                Messages.SeffDiagramEditor_SaveErrorMessage, x
243                                                                .getStatus());
244                        }
245                } finally {
246                        provider.changed(newInput);
247                        if (success) {
248                                setInput(newInput);
249                        }
250                }
251                if (progressMonitor != null) {
252                        progressMonitor.setCanceled(!success);
253                }
254        }
255 
256        /**
257         * @generated
258         */
259        public ShowInContext getShowInContext() {
260                return new ShowInContext(getEditorInput(), getNavigatorSelection());
261        }
262 
263        /**
264         * @generated
265         */
266        private ISelection getNavigatorSelection() {
267                IDiagramDocument document = getDiagramDocument();
268                if (document == null) {
269                        return StructuredSelection.EMPTY;
270                }
271                Diagram diagram = document.getDiagram();
272                IFile file = WorkspaceSynchronizer.getFile(diagram.eResource());
273                if (file != null) {
274                        PalladioComponentModelNavigatorItem item = new PalladioComponentModelNavigatorItem(
275                                        diagram, file, false);
276                        return new StructuredSelection(item);
277                }
278                return StructuredSelection.EMPTY;
279        }
280 
281        /**
282         * @generated
283         */
284        protected void configureGraphicalViewer() {
285                super.configureGraphicalViewer();
286                DiagramEditorContextMenuProvider provider = new DiagramEditorContextMenuProvider(
287                                this, getDiagramGraphicalViewer());
288                getDiagramGraphicalViewer().setContextMenu(provider);
289                getSite().registerContextMenu(ActionIds.DIAGRAM_EDITOR_CONTEXT_MENU,
290                                provider, getDiagramGraphicalViewer());
291        }
292 
293}

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