EMMA Coverage Report (generated Sun Feb 05 10:43:15 CET 2012)
[all classes][de.fzi.se.quality.presentation]

COVERAGE SUMMARY FOR SOURCE FILE [QualityEditor.java]

nameclass, %method, %block, %line, %
QualityEditor.java0%   (0/26)0%   (0/120)0%   (0/2772)0%   (0/609)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class QualityEditor0%   (0/1)0%   (0/47)0%   (0/1897)0%   (0/442)
QualityEditor (): void 0%   (0/1)0%   (0/59)0%   (0/17)
access$0 (QualityEditor): Composite 0%   (0/1)0%   (0/3)0%   (0/1)
access$1 (QualityEditor, int): void 0%   (0/1)0%   (0/4)0%   (0/1)
addSelectionChangedListener (ISelectionChangedListener): void 0%   (0/1)0%   (0/6)0%   (0/2)
analyzeResourceProblems (Resource, Exception): Diagnostic 0%   (0/1)0%   (0/57)0%   (0/19)
createContextMenuFor (StructuredViewer): void 0%   (0/1)0%   (0/62)0%   (0/12)
createModel (): void 0%   (0/1)0%   (0/52)0%   (0/12)
createPages (): void 0%   (0/1)0%   (0/497)0%   (0/96)
dispose (): void 0%   (0/1)0%   (0/40)0%   (0/12)
doSave (IProgressMonitor): void 0%   (0/1)0%   (0/47)0%   (0/13)
doSaveAs (): void 0%   (0/1)0%   (0/34)0%   (0/8)
doSaveAs (URI, IEditorInput): void 0%   (0/1)0%   (0/33)0%   (0/9)
firePropertyChange (int): void 0%   (0/1)0%   (0/4)0%   (0/2)
getActionBarContributor (): EditingDomainActionBarContributor 0%   (0/1)0%   (0/5)0%   (0/1)
getActionBars (): IActionBars 0%   (0/1)0%   (0/4)0%   (0/1)
getAdapter (Class): Object 0%   (0/1)0%   (0/29)0%   (0/7)
getAdapterFactory (): AdapterFactory 0%   (0/1)0%   (0/3)0%   (0/1)
getContentOutlinePage (): IContentOutlinePage 0%   (0/1)0%   (0/19)0%   (0/5)
getEditingDomain (): EditingDomain 0%   (0/1)0%   (0/3)0%   (0/1)
getPropertySheetPage (): IPropertySheetPage 0%   (0/1)0%   (0/22)0%   (0/5)
getSelection (): ISelection 0%   (0/1)0%   (0/3)0%   (0/1)
getString (String): String 0%   (0/1)0%   (0/4)0%   (0/1)
getString (String, Object): String 0%   (0/1)0%   (0/10)0%   (0/1)
getViewer (): Viewer 0%   (0/1)0%   (0/3)0%   (0/1)
gotoMarker (IMarker): void 0%   (0/1)0%   (0/37)0%   (0/10)
handleActivate (): void 0%   (0/1)0%   (0/56)0%   (0/15)
handleChangedResources (): void 0%   (0/1)0%   (0/70)0%   (0/15)
handleContentOutlineSelection (ISelection): void 0%   (0/1)0%   (0/66)0%   (0/14)
handleDirtyConflict (): boolean 0%   (0/1)0%   (0/9)0%   (0/5)
hideTabs (): void 0%   (0/1)0%   (0/31)0%   (0/7)
init (IEditorSite, IEditorInput): void 0%   (0/1)0%   (0/24)0%   (0/7)
initializeEditingDomain (): void 0%   (0/1)0%   (0/208)0%   (0/36)
isDirty (): boolean 0%   (0/1)0%   (0/6)0%   (0/1)
isPersisted (Resource): boolean 0%   (0/1)0%   (0/20)0%   (0/7)
isSaveAsAllowed (): boolean 0%   (0/1)0%   (0/2)0%   (0/1)
menuAboutToShow (IMenuManager): void 0%   (0/1)0%   (0/7)0%   (0/2)
pageChange (int): void 0%   (0/1)0%   (0/12)0%   (0/4)
removeSelectionChangedListener (ISelectionChangedListener): void 0%   (0/1)0%   (0/6)0%   (0/2)
setCurrentViewer (Viewer): void 0%   (0/1)0%   (0/41)0%   (0/11)
setCurrentViewerPane (ViewerPane): void 0%   (0/1)0%   (0/20)0%   (0/6)
setFocus (): void 0%   (0/1)0%   (0/14)0%   (0/4)
setSelection (ISelection): void 0%   (0/1)0%   (0/26)0%   (0/5)
setSelectionToViewer (Collection): void 0%   (0/1)0%   (0/20)0%   (0/6)
setStatusLineManager (ISelection): void 0%   (0/1)0%   (0/60)0%   (0/15)
showOutlineView (): boolean 0%   (0/1)0%   (0/2)0%   (0/1)
showTabs (): void 0%   (0/1)0%   (0/32)0%   (0/7)
updateProblemIndication (): void 0%   (0/1)0%   (0/125)0%   (0/33)
     
class QualityEditor$10%   (0/1)0%   (0/6)0%   (0/61)0%   (0/17)
QualityEditor$1 (QualityEditor): void 0%   (0/1)0%   (0/6)0%   (0/2)
partActivated (IWorkbenchPart): void 0%   (0/1)0%   (0/51)0%   (0/11)
partBroughtToTop (IWorkbenchPart): void 0%   (0/1)0%   (0/1)0%   (0/1)
partClosed (IWorkbenchPart): void 0%   (0/1)0%   (0/1)0%   (0/1)
partDeactivated (IWorkbenchPart): void 0%   (0/1)0%   (0/1)0%   (0/1)
partOpened (IWorkbenchPart): void 0%   (0/1)0%   (0/1)0%   (0/1)
     
class QualityEditor$100%   (0/1)0%   (0/3)0%   (0/20)0%   (0/6)
QualityEditor$10 (QualityEditor, IWorkbenchPage, IWorkbenchPart): void 0%   (0/1)0%   (0/8)0%   (0/2)
createViewer (Composite): Viewer 0%   (0/1)0%   (0/5)0%   (0/1)
requestActivation (): void 0%   (0/1)0%   (0/7)0%   (0/3)
     
class QualityEditor$110%   (0/1)0%   (0/3)0%   (0/20)0%   (0/6)
QualityEditor$11 (QualityEditor, IWorkbenchPage, IWorkbenchPart): void 0%   (0/1)0%   (0/8)0%   (0/2)
createViewer (Composite): Viewer 0%   (0/1)0%   (0/5)0%   (0/1)
requestActivation (): void 0%   (0/1)0%   (0/7)0%   (0/3)
     
class QualityEditor$120%   (0/1)0%   (0/3)0%   (0/20)0%   (0/6)
QualityEditor$12 (QualityEditor, IWorkbenchPage, IWorkbenchPart): void 0%   (0/1)0%   (0/8)0%   (0/2)
createViewer (Composite): Viewer 0%   (0/1)0%   (0/5)0%   (0/1)
requestActivation (): void 0%   (0/1)0%   (0/7)0%   (0/3)
     
class QualityEditor$130%   (0/1)0%   (0/2)0%   (0/11)0%   (0/4)
QualityEditor$13 (QualityEditor): void 0%   (0/1)0%   (0/6)0%   (0/2)
run (): void 0%   (0/1)0%   (0/5)0%   (0/2)
     
class QualityEditor$140%   (0/1)0%   (0/2)0%   (0/22)0%   (0/8)
QualityEditor$14 (QualityEditor): void 0%   (0/1)0%   (0/9)0%   (0/3)
controlResized (ControlEvent): void 0%   (0/1)0%   (0/13)0%   (0/5)
     
class QualityEditor$150%   (0/1)0%   (0/2)0%   (0/10)0%   (0/4)
QualityEditor$15 (QualityEditor): void 0%   (0/1)0%   (0/6)0%   (0/2)
run (): void 0%   (0/1)0%   (0/4)0%   (0/2)
     
class QualityEditor$160%   (0/1)0%   (0/2)0%   (0/12)0%   (0/4)
QualityEditor$16 (QualityEditor): void 0%   (0/1)0%   (0/6)0%   (0/2)
selectionChanged (SelectionChangedEvent): void 0%   (0/1)0%   (0/6)0%   (0/2)
     
class QualityEditor$170%   (0/1)0%   (0/3)0%   (0/25)0%   (0/8)
QualityEditor$17 (QualityEditor, AdapterFactoryEditingDomain): void 0%   (0/1)0%   (0/7)0%   (0/2)
setActionBars (IActionBars): void 0%   (0/1)0%   (0/10)0%   (0/3)
setSelectionToViewer (List): void 0%   (0/1)0%   (0/8)0%   (0/3)
     
class QualityEditor$180%   (0/1)0%   (0/2)0%   (0/69)0%   (0/11)
QualityEditor$18 (QualityEditor, Map): void 0%   (0/1)0%   (0/9)0%   (0/2)
execute (IProgressMonitor): void 0%   (0/1)0%   (0/60)0%   (0/9)
     
class QualityEditor$1MyContentOutlinePage0%   (0/1)0%   (0/4)0%   (0/96)0%   (0/17)
QualityEditor$1MyContentOutlinePage (QualityEditor): void 0%   (0/1)0%   (0/6)0%   (0/1)
createControl (Composite): void 0%   (0/1)0%   (0/70)0%   (0/10)
makeContributions (IMenuManager, IToolBarManager, IStatusLineManager): void 0%   (0/1)0%   (0/10)0%   (0/3)
setActionBars (IActionBars): void 0%   (0/1)0%   (0/10)0%   (0/3)
     
class QualityEditor$20%   (0/1)0%   (0/5)0%   (0/71)0%   (0/19)
QualityEditor$2 (QualityEditor): void 0%   (0/1)0%   (0/6)0%   (0/2)
access$0 (QualityEditor$2): QualityEditor 0%   (0/1)0%   (0/3)0%   (0/1)
notifyChanged (Notification): void 0%   (0/1)0%   (0/54)0%   (0/13)
setTarget (Resource): void 0%   (0/1)0%   (0/4)0%   (0/2)
unsetTarget (Resource): void 0%   (0/1)0%   (0/4)0%   (0/2)
     
class QualityEditor$2$10%   (0/1)0%   (0/2)0%   (0/11)0%   (0/4)
QualityEditor$2$1 (QualityEditor$2): void 0%   (0/1)0%   (0/6)0%   (0/2)
run (): void 0%   (0/1)0%   (0/5)0%   (0/2)
     
class QualityEditor$30%   (0/1)0%   (0/3)0%   (0/56)0%   (0/14)
QualityEditor$3 (QualityEditor): void 0%   (0/1)0%   (0/6)0%   (0/2)
access$0 (QualityEditor$3): QualityEditor 0%   (0/1)0%   (0/3)0%   (0/1)
resourceChanged (IResourceChangeEvent): void 0%   (0/1)0%   (0/47)0%   (0/12)
     
class QualityEditor$3$10%   (0/1)0%   (0/2)0%   (0/35)0%   (0/6)
QualityEditor$3$1 (QualityEditor$3, QualityEditor$3$1ResourceDeltaVisitor): void 0%   (0/1)0%   (0/9)0%   (0/2)
run (): void 0%   (0/1)0%   (0/26)0%   (0/4)
     
class QualityEditor$3$1ResourceDeltaVisitor0%   (0/1)0%   (0/4)0%   (0/81)0%   (0/16)
QualityEditor$3$1ResourceDeltaVisitor (QualityEditor$3): void 0%   (0/1)0%   (0/22)0%   (0/4)
getChangedResources (): Collection 0%   (0/1)0%   (0/3)0%   (0/1)
getRemovedResources (): Collection 0%   (0/1)0%   (0/3)0%   (0/1)
visit (IResourceDelta): boolean 0%   (0/1)0%   (0/53)0%   (0/10)
     
class QualityEditor$3$20%   (0/1)0%   (0/2)0%   (0/33)0%   (0/6)
QualityEditor$3$2 (QualityEditor$3, QualityEditor$3$1ResourceDeltaVisitor): void 0%   (0/1)0%   (0/9)0%   (0/2)
run (): void 0%   (0/1)0%   (0/24)0%   (0/4)
     
class QualityEditor$40%   (0/1)0%   (0/3)0%   (0/20)0%   (0/5)
QualityEditor$4 (QualityEditor): void 0%   (0/1)0%   (0/6)0%   (0/2)
access$0 (QualityEditor$4): QualityEditor 0%   (0/1)0%   (0/3)0%   (0/1)
commandStackChanged (EventObject): void 0%   (0/1)0%   (0/11)0%   (0/3)
     
class QualityEditor$4$10%   (0/1)0%   (0/2)0%   (0/46)0%   (0/9)
QualityEditor$4$1 (QualityEditor$4, EventObject): void 0%   (0/1)0%   (0/9)0%   (0/2)
run (): void 0%   (0/1)0%   (0/37)0%   (0/7)
     
class QualityEditor$50%   (0/1)0%   (0/2)0%   (0/25)0%   (0/5)
QualityEditor$5 (QualityEditor, Collection): void 0%   (0/1)0%   (0/9)0%   (0/2)
run (): void 0%   (0/1)0%   (0/16)0%   (0/3)
     
class QualityEditor$60%   (0/1)0%   (0/2)0%   (0/12)0%   (0/4)
QualityEditor$6 (QualityEditor): void 0%   (0/1)0%   (0/6)0%   (0/2)
selectionChanged (SelectionChangedEvent): void 0%   (0/1)0%   (0/6)0%   (0/2)
     
class QualityEditor$70%   (0/1)0%   (0/3)0%   (0/28)0%   (0/8)
QualityEditor$7 (QualityEditor, IWorkbenchPage, IWorkbenchPart): void 0%   (0/1)0%   (0/8)0%   (0/2)
createViewer (Composite): Viewer 0%   (0/1)0%   (0/13)0%   (0/3)
requestActivation (): void 0%   (0/1)0%   (0/7)0%   (0/3)
     
class QualityEditor$80%   (0/1)0%   (0/3)0%   (0/28)0%   (0/8)
QualityEditor$8 (QualityEditor, IWorkbenchPage, IWorkbenchPart): void 0%   (0/1)0%   (0/8)0%   (0/2)
createViewer (Composite): Viewer 0%   (0/1)0%   (0/13)0%   (0/3)
requestActivation (): void 0%   (0/1)0%   (0/7)0%   (0/3)
     
class QualityEditor$90%   (0/1)0%   (0/3)0%   (0/20)0%   (0/6)
QualityEditor$9 (QualityEditor, IWorkbenchPage, IWorkbenchPart): void 0%   (0/1)0%   (0/8)0%   (0/2)
createViewer (Composite): Viewer 0%   (0/1)0%   (0/5)0%   (0/1)
requestActivation (): void 0%   (0/1)0%   (0/7)0%   (0/3)
     
class QualityEditor$ReverseAdapterFactoryContentProvider0%   (0/1)0%   (0/5)0%   (0/43)0%   (0/10)
QualityEditor$ReverseAdapterFactoryContentProvider (QualityEditor, AdapterFac... 0%   (0/1)0%   (0/7)0%   (0/3)
getChildren (Object): Object [] 0%   (0/1)0%   (0/12)0%   (0/2)
getElements (Object): Object [] 0%   (0/1)0%   (0/12)0%   (0/2)
getParent (Object): Object 0%   (0/1)0%   (0/2)0%   (0/1)
hasChildren (Object): boolean 0%   (0/1)0%   (0/10)0%   (0/2)

1/**
2 * <copyright>
3 * </copyright>
4 *
5 * $Id$
6 */
7package de.fzi.se.quality.presentation;
8 
9 
10import java.io.IOException;
11import java.io.InputStream;
12 
13import java.util.ArrayList;
14import java.util.Collection;
15import java.util.Collections;
16import java.util.EventObject;
17import java.util.HashMap;
18import java.util.Iterator;
19import java.util.LinkedHashMap;
20import java.util.List;
21import java.util.Map;
22 
23import org.eclipse.core.resources.IFile;
24import org.eclipse.core.resources.IMarker;
25import org.eclipse.core.resources.IResource;
26import org.eclipse.core.resources.IResourceChangeEvent;
27import org.eclipse.core.resources.IResourceChangeListener;
28import org.eclipse.core.resources.IResourceDelta;
29import org.eclipse.core.resources.IResourceDeltaVisitor;
30import org.eclipse.core.resources.ResourcesPlugin;
31 
32import org.eclipse.core.runtime.CoreException;
33import org.eclipse.core.runtime.IPath;
34import org.eclipse.core.runtime.IProgressMonitor;
35import org.eclipse.core.runtime.NullProgressMonitor;
36 
37import org.eclipse.jface.action.IMenuListener;
38import org.eclipse.jface.action.IMenuManager;
39import org.eclipse.jface.action.IStatusLineManager;
40import org.eclipse.jface.action.IToolBarManager;
41import org.eclipse.jface.action.MenuManager;
42import org.eclipse.jface.action.Separator;
43 
44import org.eclipse.jface.dialogs.MessageDialog;
45import org.eclipse.jface.dialogs.ProgressMonitorDialog;
46 
47import org.eclipse.jface.viewers.ColumnWeightData;
48import org.eclipse.jface.viewers.ISelection;
49import org.eclipse.jface.viewers.ISelectionChangedListener;
50import org.eclipse.jface.viewers.ISelectionProvider;
51import org.eclipse.jface.viewers.IStructuredSelection;
52import org.eclipse.jface.viewers.ListViewer;
53import org.eclipse.jface.viewers.SelectionChangedEvent;
54import org.eclipse.jface.viewers.StructuredSelection;
55import org.eclipse.jface.viewers.StructuredViewer;
56import org.eclipse.jface.viewers.TableLayout;
57import org.eclipse.jface.viewers.TableViewer;
58import org.eclipse.jface.viewers.TreeViewer;
59import org.eclipse.jface.viewers.Viewer;
60 
61import org.eclipse.swt.SWT;
62 
63import org.eclipse.swt.custom.CTabFolder;
64 
65import org.eclipse.swt.dnd.DND;
66import org.eclipse.swt.dnd.Transfer;
67 
68import org.eclipse.swt.events.ControlAdapter;
69import org.eclipse.swt.events.ControlEvent;
70 
71import org.eclipse.swt.graphics.Point;
72 
73import org.eclipse.swt.layout.FillLayout;
74 
75import org.eclipse.swt.widgets.Composite;
76import org.eclipse.swt.widgets.Menu;
77import org.eclipse.swt.widgets.Table;
78import org.eclipse.swt.widgets.TableColumn;
79import org.eclipse.swt.widgets.Tree;
80import org.eclipse.swt.widgets.TreeColumn;
81 
82import org.eclipse.ui.IActionBars;
83import org.eclipse.ui.IEditorInput;
84import org.eclipse.ui.IEditorPart;
85import org.eclipse.ui.IEditorSite;
86import org.eclipse.ui.IPartListener;
87import org.eclipse.ui.IWorkbenchPart;
88import org.eclipse.ui.PartInitException;
89 
90import org.eclipse.ui.dialogs.SaveAsDialog;
91 
92import org.eclipse.ui.ide.IGotoMarker;
93 
94import org.eclipse.ui.part.FileEditorInput;
95import org.eclipse.ui.part.MultiPageEditorPart;
96 
97import org.eclipse.ui.views.contentoutline.ContentOutline;
98import org.eclipse.ui.views.contentoutline.ContentOutlinePage;
99import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
100 
101import org.eclipse.ui.views.properties.IPropertySheetPage;
102import org.eclipse.ui.views.properties.PropertySheet;
103import org.eclipse.ui.views.properties.PropertySheetPage;
104 
105import org.eclipse.emf.common.command.BasicCommandStack;
106import org.eclipse.emf.common.command.Command;
107import org.eclipse.emf.common.command.CommandStack;
108import org.eclipse.emf.common.command.CommandStackListener;
109 
110import org.eclipse.emf.common.notify.AdapterFactory;
111import org.eclipse.emf.common.notify.Notification;
112 
113import org.eclipse.emf.common.ui.MarkerHelper;
114import org.eclipse.emf.common.ui.ViewerPane;
115 
116import org.eclipse.emf.common.ui.editor.ProblemEditorPart;
117 
118import org.eclipse.emf.common.ui.viewer.IViewerProvider;
119 
120import org.eclipse.emf.common.util.BasicDiagnostic;
121import org.eclipse.emf.common.util.Diagnostic;
122import org.eclipse.emf.common.util.URI;
123 
124import org.eclipse.emf.ecore.EObject;
125import org.eclipse.emf.ecore.EValidator;
126 
127import org.eclipse.emf.ecore.resource.Resource;
128import org.eclipse.emf.ecore.resource.ResourceSet;
129 
130import org.eclipse.emf.ecore.util.EContentAdapter;
131import org.eclipse.emf.ecore.util.EcoreUtil;
132 
133import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
134import org.eclipse.emf.edit.domain.EditingDomain;
135import org.eclipse.emf.edit.domain.IEditingDomainProvider;
136 
137import org.eclipse.emf.edit.provider.AdapterFactoryItemDelegator;
138import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
139import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory;
140 
141import org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory;
142 
143import org.eclipse.emf.edit.ui.action.EditingDomainActionBarContributor;
144 
145import org.eclipse.emf.edit.ui.celleditor.AdapterFactoryTreeEditor;
146 
147import org.eclipse.emf.edit.ui.dnd.EditingDomainViewerDropAdapter;
148import org.eclipse.emf.edit.ui.dnd.LocalTransfer;
149import org.eclipse.emf.edit.ui.dnd.ViewerDragAdapter;
150 
151import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
152import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
153import org.eclipse.emf.edit.ui.provider.UnwrappingSelectionProvider;
154 
155import org.eclipse.emf.edit.ui.util.EditUIMarkerHelper;
156import org.eclipse.emf.edit.ui.util.EditUIUtil;
157 
158import org.eclipse.emf.edit.ui.view.ExtendedPropertySheetPage;
159 
160import de.fzi.se.quality.provider.QualityItemProviderAdapterFactory;
161 
162import de.fzi.se.quality.parameters.pcm.provider.PCMItemProviderAdapterFactory;
163 
164import de.fzi.se.quality.parameters.provider.ParametersItemProviderAdapterFactory;
165 
166import de.fzi.se.quality.qualityannotation.provider.QualityAnnotationItemProviderAdapterFactory;
167 
168import de.uka.ipd.sdq.identifier.provider.IdentifierItemProviderAdapterFactory;
169 
170import de.uka.ipd.sdq.pcm.allocation.provider.AllocationItemProviderAdapterFactory;
171 
172import de.uka.ipd.sdq.pcm.core.composition.provider.CompositionItemProviderAdapterFactory;
173 
174import de.uka.ipd.sdq.pcm.core.entity.provider.EntityItemProviderAdapterFactory;
175 
176import de.uka.ipd.sdq.pcm.core.provider.CoreItemProviderAdapterFactory;
177 
178import de.uka.ipd.sdq.pcm.parameter.provider.ParameterItemProviderAdapterFactory;
179 
180import de.uka.ipd.sdq.pcm.protocol.provider.ProtocolItemProviderAdapterFactory;
181 
182import de.uka.ipd.sdq.pcm.provider.PcmItemProviderAdapterFactory;
183 
184import de.uka.ipd.sdq.pcm.qosannotations.provider.QosannotationsItemProviderAdapterFactory;
185 
186import de.uka.ipd.sdq.pcm.qosannotations.qos_performance.provider.Qos_performanceItemProviderAdapterFactory;
187 
188import de.uka.ipd.sdq.pcm.qosannotations.qos_reliability.provider.Qos_reliabilityItemProviderAdapterFactory;
189 
190import de.uka.ipd.sdq.pcm.reliability.provider.ReliabilityItemProviderAdapterFactory;
191 
192import de.uka.ipd.sdq.pcm.repository.provider.RepositoryItemProviderAdapterFactory;
193 
194import de.uka.ipd.sdq.pcm.resourceenvironment.provider.ResourceenvironmentItemProviderAdapterFactory;
195 
196import de.uka.ipd.sdq.pcm.resourcetype.provider.ResourcetypeItemProviderAdapterFactory;
197 
198import de.uka.ipd.sdq.pcm.seff.provider.SeffItemProviderAdapterFactory;
199 
200import de.uka.ipd.sdq.pcm.seff.seff_performance.provider.Seff_performanceItemProviderAdapterFactory;
201 
202import de.uka.ipd.sdq.pcm.seff.seff_reliability.provider.Seff_reliabilityItemProviderAdapterFactory;
203 
204import de.uka.ipd.sdq.pcm.subsystem.provider.SubsystemItemProviderAdapterFactory;
205 
206import de.uka.ipd.sdq.pcm.system.provider.SystemItemProviderAdapterFactory;
207 
208import de.uka.ipd.sdq.pcm.usagemodel.provider.UsagemodelItemProviderAdapterFactory;
209 
210import de.uka.ipd.sdq.probfunction.provider.ProbfunctionItemProviderAdapterFactory;
211 
212import de.uka.ipd.sdq.stoex.provider.StoexItemProviderAdapterFactory;
213 
214import de.uka.ipd.sdq.units.provider.UnitsItemProviderAdapterFactory;
215 
216import org.eclipse.ui.actions.WorkspaceModifyOperation;
217 
218 
219/**
220 * This is an example of a Quality model editor.
221 * <!-- begin-user-doc -->
222 * <!-- end-user-doc -->
223 * @generated
224 */
225public class QualityEditor
226        extends MultiPageEditorPart
227        implements IEditingDomainProvider, ISelectionProvider, IMenuListener, IViewerProvider, IGotoMarker {
228        /**
229         * This keeps track of the editing domain that is used to track all changes to the model.
230         * <!-- begin-user-doc -->
231         * <!-- end-user-doc -->
232         * @generated
233         */
234        protected AdapterFactoryEditingDomain editingDomain;
235 
236        /**
237         * This is the one adapter factory used for providing views of the model.
238         * <!-- begin-user-doc -->
239         * <!-- end-user-doc -->
240         * @generated
241         */
242        protected ComposedAdapterFactory adapterFactory;
243 
244        /**
245         * This is the content outline page.
246         * <!-- begin-user-doc -->
247         * <!-- end-user-doc -->
248         * @generated
249         */
250        protected IContentOutlinePage contentOutlinePage;
251 
252        /**
253         * This is a kludge...
254         * <!-- begin-user-doc -->
255         * <!-- end-user-doc -->
256         * @generated
257         */
258        protected IStatusLineManager contentOutlineStatusLineManager;
259 
260        /**
261         * This is the content outline page's viewer.
262         * <!-- begin-user-doc -->
263         * <!-- end-user-doc -->
264         * @generated
265         */
266        protected TreeViewer contentOutlineViewer;
267 
268        /**
269         * This is the property sheet page.
270         * <!-- begin-user-doc -->
271         * <!-- end-user-doc -->
272         * @generated
273         */
274        protected PropertySheetPage propertySheetPage;
275 
276        /**
277         * This is the viewer that shadows the selection in the content outline.
278         * The parent relation must be correctly defined for this to work.
279         * <!-- begin-user-doc -->
280         * <!-- end-user-doc -->
281         * @generated
282         */
283        protected TreeViewer selectionViewer;
284 
285        /**
286         * This inverts the roll of parent and child in the content provider and show parents as a tree.
287         * <!-- begin-user-doc -->
288         * <!-- end-user-doc -->
289         * @generated
290         */
291        protected TreeViewer parentViewer;
292 
293        /**
294         * This shows how a tree view works.
295         * <!-- begin-user-doc -->
296         * <!-- end-user-doc -->
297         * @generated
298         */
299        protected TreeViewer treeViewer;
300 
301        /**
302         * This shows how a list view works.
303         * A list viewer doesn't support icons.
304         * <!-- begin-user-doc -->
305         * <!-- end-user-doc -->
306         * @generated
307         */
308        protected ListViewer listViewer;
309 
310        /**
311         * This shows how a table view works.
312         * A table can be used as a list with icons.
313         * <!-- begin-user-doc -->
314         * <!-- end-user-doc -->
315         * @generated
316         */
317        protected TableViewer tableViewer;
318 
319        /**
320         * This shows how a tree view with columns works.
321         * <!-- begin-user-doc -->
322         * <!-- end-user-doc -->
323         * @generated
324         */
325        protected TreeViewer treeViewerWithColumns;
326 
327        /**
328         * This keeps track of the active viewer pane, in the book.
329         * <!-- begin-user-doc -->
330         * <!-- end-user-doc -->
331         * @generated
332         */
333        protected ViewerPane currentViewerPane;
334 
335        /**
336         * This keeps track of the active content viewer, which may be either one of the viewers in the pages or the content outline viewer.
337         * <!-- begin-user-doc -->
338         * <!-- end-user-doc -->
339         * @generated
340         */
341        protected Viewer currentViewer;
342 
343        /**
344         * This listens to which ever viewer is active.
345         * <!-- begin-user-doc -->
346         * <!-- end-user-doc -->
347         * @generated
348         */
349        protected ISelectionChangedListener selectionChangedListener;
350 
351        /**
352         * This keeps track of all the {@link org.eclipse.jface.viewers.ISelectionChangedListener}s that are listening to this editor.
353         * <!-- begin-user-doc -->
354         * <!-- end-user-doc -->
355         * @generated
356         */
357        protected Collection<ISelectionChangedListener> selectionChangedListeners = new ArrayList<ISelectionChangedListener>();
358 
359        /**
360         * This keeps track of the selection of the editor as a whole.
361         * <!-- begin-user-doc -->
362         * <!-- end-user-doc -->
363         * @generated
364         */
365        protected ISelection editorSelection = StructuredSelection.EMPTY;
366 
367        /**
368         * The MarkerHelper is responsible for creating workspace resource markers presented
369         * in Eclipse's Problems View.
370         * <!-- begin-user-doc -->
371         * <!-- end-user-doc -->
372         * @generated
373         */
374        protected MarkerHelper markerHelper = new EditUIMarkerHelper();
375 
376        /**
377         * This listens for when the outline becomes active
378         * <!-- begin-user-doc -->
379         * <!-- end-user-doc -->
380         * @generated
381         */
382        protected IPartListener partListener =
383                new IPartListener() {
384                        public void partActivated(IWorkbenchPart p) {
385                                if (p instanceof ContentOutline) {
386                                        if (((ContentOutline)p).getCurrentPage() == contentOutlinePage) {
387                                                getActionBarContributor().setActiveEditor(QualityEditor.this);
388 
389                                                setCurrentViewer(contentOutlineViewer);
390                                        }
391                                }
392                                else if (p instanceof PropertySheet) {
393                                        if (((PropertySheet)p).getCurrentPage() == propertySheetPage) {
394                                                getActionBarContributor().setActiveEditor(QualityEditor.this);
395                                                handleActivate();
396                                        }
397                                }
398                                else if (p == QualityEditor.this) {
399                                        handleActivate();
400                                }
401                        }
402                        public void partBroughtToTop(IWorkbenchPart p) {
403                                // Ignore.
404                        }
405                        public void partClosed(IWorkbenchPart p) {
406                                // Ignore.
407                        }
408                        public void partDeactivated(IWorkbenchPart p) {
409                                // Ignore.
410                        }
411                        public void partOpened(IWorkbenchPart p) {
412                                // Ignore.
413                        }
414                };
415 
416        /**
417         * Resources that have been removed since last activation.
418         * <!-- begin-user-doc -->
419         * <!-- end-user-doc -->
420         * @generated
421         */
422        protected Collection<Resource> removedResources = new ArrayList<Resource>();
423 
424        /**
425         * Resources that have been changed since last activation.
426         * <!-- begin-user-doc -->
427         * <!-- end-user-doc -->
428         * @generated
429         */
430        protected Collection<Resource> changedResources = new ArrayList<Resource>();
431 
432        /**
433         * Resources that have been saved.
434         * <!-- begin-user-doc -->
435         * <!-- end-user-doc -->
436         * @generated
437         */
438        protected Collection<Resource> savedResources = new ArrayList<Resource>();
439 
440        /**
441         * Map to store the diagnostic associated with a resource.
442         * <!-- begin-user-doc -->
443         * <!-- end-user-doc -->
444         * @generated
445         */
446        protected Map<Resource, Diagnostic> resourceToDiagnosticMap = new LinkedHashMap<Resource, Diagnostic>();
447 
448        /**
449         * Controls whether the problem indication should be updated.
450         * <!-- begin-user-doc -->
451         * <!-- end-user-doc -->
452         * @generated
453         */
454        protected boolean updateProblemIndication = true;
455 
456        /**
457         * Adapter used to update the problem indication when resources are demanded loaded.
458         * <!-- begin-user-doc -->
459         * <!-- end-user-doc -->
460         * @generated
461         */
462        protected EContentAdapter problemIndicationAdapter = 
463                new EContentAdapter() {
464                        @Override
465                        public void notifyChanged(Notification notification) {
466                                if (notification.getNotifier() instanceof Resource) {
467                                        switch (notification.getFeatureID(Resource.class)) {
468                                                case Resource.RESOURCE__IS_LOADED:
469                                                case Resource.RESOURCE__ERRORS:
470                                                case Resource.RESOURCE__WARNINGS: {
471                                                        Resource resource = (Resource)notification.getNotifier();
472                                                        Diagnostic diagnostic = analyzeResourceProblems(resource, null);
473                                                        if (diagnostic.getSeverity() != Diagnostic.OK) {
474                                                                resourceToDiagnosticMap.put(resource, diagnostic);
475                                                        }
476                                                        else {
477                                                                resourceToDiagnosticMap.remove(resource);
478                                                        }
479 
480                                                        if (updateProblemIndication) {
481                                                                getSite().getShell().getDisplay().asyncExec
482                                                                        (new Runnable() {
483                                                                                 public void run() {
484                                                                                         updateProblemIndication();
485                                                                                 }
486                                                                         });
487                                                        }
488                                                        break;
489                                                }
490                                        }
491                                }
492                                else {
493                                        super.notifyChanged(notification);
494                                }
495                        }
496 
497                        @Override
498                        protected void setTarget(Resource target) {
499                                basicSetTarget(target);
500                        }
501 
502                        @Override
503                        protected void unsetTarget(Resource target) {
504                                basicUnsetTarget(target);
505                        }
506                };
507 
508        /**
509         * This listens for workspace changes.
510         * <!-- begin-user-doc -->
511         * <!-- end-user-doc -->
512         * @generated
513         */
514        protected IResourceChangeListener resourceChangeListener =
515                new IResourceChangeListener() {
516                        public void resourceChanged(IResourceChangeEvent event) {
517                                IResourceDelta delta = event.getDelta();
518                                try {
519                                        class ResourceDeltaVisitor implements IResourceDeltaVisitor {
520                                                protected ResourceSet resourceSet = editingDomain.getResourceSet();
521                                                protected Collection<Resource> changedResources = new ArrayList<Resource>();
522                                                protected Collection<Resource> removedResources = new ArrayList<Resource>();
523 
524                                                public boolean visit(IResourceDelta delta) {
525                                                        if (delta.getResource().getType() == IResource.FILE) {
526                                                                if (delta.getKind() == IResourceDelta.REMOVED ||
527                                                                    delta.getKind() == IResourceDelta.CHANGED && delta.getFlags() != IResourceDelta.MARKERS) {
528                                                                        Resource resource = resourceSet.getResource(URI.createPlatformResourceURI(delta.getFullPath().toString(), true), false);
529                                                                        if (resource != null) {
530                                                                                if (delta.getKind() == IResourceDelta.REMOVED) {
531                                                                                        removedResources.add(resource);
532                                                                                }
533                                                                                else if (!savedResources.remove(resource)) {
534                                                                                        changedResources.add(resource);
535                                                                                }
536                                                                        }
537                                                                }
538                                                        }
539 
540                                                        return true;
541                                                }
542 
543                                                public Collection<Resource> getChangedResources() {
544                                                        return changedResources;
545                                                }
546 
547                                                public Collection<Resource> getRemovedResources() {
548                                                        return removedResources;
549                                                }
550                                        }
551 
552                                        final ResourceDeltaVisitor visitor = new ResourceDeltaVisitor();
553                                        delta.accept(visitor);
554 
555                                        if (!visitor.getRemovedResources().isEmpty()) {
556                                                getSite().getShell().getDisplay().asyncExec
557                                                        (new Runnable() {
558                                                                 public void run() {
559                                                                         removedResources.addAll(visitor.getRemovedResources());
560                                                                         if (!isDirty()) {
561                                                                                 getSite().getPage().closeEditor(QualityEditor.this, false);
562                                                                         }
563                                                                 }
564                                                         });
565                                        }
566 
567                                        if (!visitor.getChangedResources().isEmpty()) {
568                                                getSite().getShell().getDisplay().asyncExec
569                                                        (new Runnable() {
570                                                                 public void run() {
571                                                                         changedResources.addAll(visitor.getChangedResources());
572                                                                         if (getSite().getPage().getActiveEditor() == QualityEditor.this) {
573                                                                                 handleActivate();
574                                                                         }
575                                                                 }
576                                                         });
577                                        }
578                                }
579                                catch (CoreException exception) {
580                                        QualityEditorPlugin.INSTANCE.log(exception);
581                                }
582                        }
583                };
584 
585        /**
586         * Handles activation of the editor or it's associated views.
587         * <!-- begin-user-doc -->
588         * <!-- end-user-doc -->
589         * @generated
590         */
591        protected void handleActivate() {
592                // Recompute the read only state.
593                //
594                if (editingDomain.getResourceToReadOnlyMap() != null) {
595                  editingDomain.getResourceToReadOnlyMap().clear();
596 
597                  // Refresh any actions that may become enabled or disabled.
598                  //
599                  setSelection(getSelection());
600                }
601 
602                if (!removedResources.isEmpty()) {
603                        if (handleDirtyConflict()) {
604                                getSite().getPage().closeEditor(QualityEditor.this, false);
605                        }
606                        else {
607                                removedResources.clear();
608                                changedResources.clear();
609                                savedResources.clear();
610                        }
611                }
612                else if (!changedResources.isEmpty()) {
613                        changedResources.removeAll(savedResources);
614                        handleChangedResources();
615                        changedResources.clear();
616                        savedResources.clear();
617                }
618        }
619 
620        /**
621         * Handles what to do with changed resources on activation.
622         * <!-- begin-user-doc -->
623         * <!-- end-user-doc -->
624         * @generated
625         */
626        protected void handleChangedResources() {
627                if (!changedResources.isEmpty() && (!isDirty() || handleDirtyConflict())) {
628                        if (isDirty()) {
629                                changedResources.addAll(editingDomain.getResourceSet().getResources());
630                        }
631                        editingDomain.getCommandStack().flush();
632 
633                        updateProblemIndication = false;
634                        for (Resource resource : changedResources) {
635                                if (resource.isLoaded()) {
636                                        resource.unload();
637                                        try {
638                                                resource.load(Collections.EMPTY_MAP);
639                                        }
640                                        catch (IOException exception) {
641                                                if (!resourceToDiagnosticMap.containsKey(resource)) {
642                                                        resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception));
643                                                }
644                                        }
645                                }
646                        }
647 
648 
649                        updateProblemIndication = true;
650                        updateProblemIndication();
651                }
652        }
653  
654        /**
655         * Updates the problems indication with the information described in the specified diagnostic.
656         * <!-- begin-user-doc -->
657         * <!-- end-user-doc -->
658         * @generated
659         */
660        protected void updateProblemIndication() {
661                if (updateProblemIndication) {
662                        BasicDiagnostic diagnostic =
663                                new BasicDiagnostic
664                                        (Diagnostic.OK,
665                                         "de.fzi.se.quality.editor",
666                                         0,
667                                         null,
668                                         new Object [] { editingDomain.getResourceSet() });
669                        for (Diagnostic childDiagnostic : resourceToDiagnosticMap.values()) {
670                                if (childDiagnostic.getSeverity() != Diagnostic.OK) {
671                                        diagnostic.add(childDiagnostic);
672                                }
673                        }
674 
675                        int lastEditorPage = getPageCount() - 1;
676                        if (lastEditorPage >= 0 && getEditor(lastEditorPage) instanceof ProblemEditorPart) {
677                                ((ProblemEditorPart)getEditor(lastEditorPage)).setDiagnostic(diagnostic);
678                                if (diagnostic.getSeverity() != Diagnostic.OK) {
679                                        setActivePage(lastEditorPage);
680                                }
681                        }
682                        else if (diagnostic.getSeverity() != Diagnostic.OK) {
683                                ProblemEditorPart problemEditorPart = new ProblemEditorPart();
684                                problemEditorPart.setDiagnostic(diagnostic);
685                                problemEditorPart.setMarkerHelper(markerHelper);
686                                try {
687                                        addPage(++lastEditorPage, problemEditorPart, getEditorInput());
688                                        setPageText(lastEditorPage, problemEditorPart.getPartName());
689                                        setActivePage(lastEditorPage);
690                                        showTabs();
691                                }
692                                catch (PartInitException exception) {
693                                        QualityEditorPlugin.INSTANCE.log(exception);
694                                }
695                        }
696 
697                        if (markerHelper.hasMarkers(editingDomain.getResourceSet())) {
698                                markerHelper.deleteMarkers(editingDomain.getResourceSet());
699                                if (diagnostic.getSeverity() != Diagnostic.OK) {
700                                        try {
701                                                markerHelper.createMarkers(diagnostic);
702                                        }
703                                        catch (CoreException exception) {
704                                                QualityEditorPlugin.INSTANCE.log(exception);
705                                        }
706                                }
707                        }
708                }
709        }
710 
711        /**
712         * Shows a dialog that asks if conflicting changes should be discarded.
713         * <!-- begin-user-doc -->
714         * <!-- end-user-doc -->
715         * @generated
716         */
717        protected boolean handleDirtyConflict() {
718                return
719                        MessageDialog.openQuestion
720                                (getSite().getShell(),
721                                 getString("_UI_FileConflict_label"),
722                                 getString("_WARN_FileConflict"));
723        }
724 
725        /**
726         * This creates a model editor.
727         * <!-- begin-user-doc -->
728         * <!-- end-user-doc -->
729         * @generated
730         */
731        public QualityEditor() {
732                super();
733                initializeEditingDomain();
734        }
735 
736        /**
737         * This sets up the editing domain for the model editor.
738         * <!-- begin-user-doc -->
739         * <!-- end-user-doc -->
740         * @generated
741         */
742        protected void initializeEditingDomain() {
743                // Create an adapter factory that yields item providers.
744                //
745                adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
746 
747                adapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory());
748                adapterFactory.addAdapterFactory(new QualityItemProviderAdapterFactory());
749                adapterFactory.addAdapterFactory(new QualityAnnotationItemProviderAdapterFactory());
750                adapterFactory.addAdapterFactory(new ParametersItemProviderAdapterFactory());
751                adapterFactory.addAdapterFactory(new PCMItemProviderAdapterFactory());
752                adapterFactory.addAdapterFactory(new IdentifierItemProviderAdapterFactory());
753                adapterFactory.addAdapterFactory(new PcmItemProviderAdapterFactory());
754                adapterFactory.addAdapterFactory(new CoreItemProviderAdapterFactory());
755                adapterFactory.addAdapterFactory(new EntityItemProviderAdapterFactory());
756                adapterFactory.addAdapterFactory(new CompositionItemProviderAdapterFactory());
757                adapterFactory.addAdapterFactory(new UsagemodelItemProviderAdapterFactory());
758                adapterFactory.addAdapterFactory(new RepositoryItemProviderAdapterFactory());
759                adapterFactory.addAdapterFactory(new ResourcetypeItemProviderAdapterFactory());
760                adapterFactory.addAdapterFactory(new ProtocolItemProviderAdapterFactory());
761                adapterFactory.addAdapterFactory(new ParameterItemProviderAdapterFactory());
762                adapterFactory.addAdapterFactory(new ReliabilityItemProviderAdapterFactory());
763                adapterFactory.addAdapterFactory(new SeffItemProviderAdapterFactory());
764                adapterFactory.addAdapterFactory(new Seff_performanceItemProviderAdapterFactory());
765                adapterFactory.addAdapterFactory(new Seff_reliabilityItemProviderAdapterFactory());
766                adapterFactory.addAdapterFactory(new QosannotationsItemProviderAdapterFactory());
767                adapterFactory.addAdapterFactory(new Qos_performanceItemProviderAdapterFactory());
768                adapterFactory.addAdapterFactory(new Qos_reliabilityItemProviderAdapterFactory());
769                adapterFactory.addAdapterFactory(new SystemItemProviderAdapterFactory());
770                adapterFactory.addAdapterFactory(new ResourceenvironmentItemProviderAdapterFactory());
771                adapterFactory.addAdapterFactory(new AllocationItemProviderAdapterFactory());
772                adapterFactory.addAdapterFactory(new SubsystemItemProviderAdapterFactory());
773                adapterFactory.addAdapterFactory(new ProbfunctionItemProviderAdapterFactory());
774                adapterFactory.addAdapterFactory(new StoexItemProviderAdapterFactory());
775                adapterFactory.addAdapterFactory(new UnitsItemProviderAdapterFactory());
776                adapterFactory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory());
777 
778                // Create the command stack that will notify this editor as commands are executed.
779                //
780                BasicCommandStack commandStack = new BasicCommandStack();
781 
782                // Add a listener to set the most recent command's affected objects to be the selection of the viewer with focus.
783                //
784                commandStack.addCommandStackListener
785                        (new CommandStackListener() {
786                                 public void commandStackChanged(final EventObject event) {
787                                         getContainer().getDisplay().asyncExec
788                                                 (new Runnable() {
789                                                          public void run() {
790                                                                  firePropertyChange(IEditorPart.PROP_DIRTY);
791 
792                                                                  // Try to select the affected objects.
793                                                                  //
794                                                                  Command mostRecentCommand = ((CommandStack)event.getSource()).getMostRecentCommand();
795                                                                  if (mostRecentCommand != null) {
796                                                                          setSelectionToViewer(mostRecentCommand.getAffectedObjects());
797                                                                  }
798                                                                  if (propertySheetPage != null && !propertySheetPage.getControl().isDisposed()) {
799                                                                          propertySheetPage.refresh();
800                                                                  }
801                                                          }
802                                                  });
803                                 }
804                         });
805 
806                // Create the editing domain with a special command stack.
807                //
808                editingDomain = new AdapterFactoryEditingDomain(adapterFactory, commandStack, new HashMap<Resource, Boolean>());
809        }
810 
811        /**
812         * This is here for the listener to be able to call it.
813         * <!-- begin-user-doc -->
814         * <!-- end-user-doc -->
815         * @generated
816         */
817                        @Override
818        protected void firePropertyChange(int action) {
819                super.firePropertyChange(action);
820        }
821 
822        /**
823         * This sets the selection into whichever viewer is active.
824         * <!-- begin-user-doc -->
825         * <!-- end-user-doc -->
826         * @generated
827         */
828        public void setSelectionToViewer(Collection<?> collection) {
829                final Collection<?> theSelection = collection;
830                // Make sure it's okay.
831                //
832                if (theSelection != null && !theSelection.isEmpty()) {
833                        Runnable runnable =
834                                new Runnable() {
835                                        public void run() {
836                                                // Try to select the items in the current content viewer of the editor.
837                                                //
838                                                if (currentViewer != null) {
839                                                        currentViewer.setSelection(new StructuredSelection(theSelection.toArray()), true);
840                                                }
841                                        }
842                                };
843                        getSite().getShell().getDisplay().asyncExec(runnable);
844                }
845        }
846 
847        /**
848         * This returns the editing domain as required by the {@link IEditingDomainProvider} interface.
849         * This is important for implementing the static methods of {@link AdapterFactoryEditingDomain}
850         * and for supporting {@link org.eclipse.emf.edit.ui.action.CommandAction}.
851         * <!-- begin-user-doc -->
852         * <!-- end-user-doc -->
853         * @generated
854         */
855        public EditingDomain getEditingDomain() {
856                return editingDomain;
857        }
858 
859        /**
860         * <!-- begin-user-doc -->
861         * <!-- end-user-doc -->
862         * @generated
863         */
864        public class ReverseAdapterFactoryContentProvider extends AdapterFactoryContentProvider {
865                /**
866                 * <!-- begin-user-doc -->
867                 * <!-- end-user-doc -->
868                 * @generated
869                 */
870                public ReverseAdapterFactoryContentProvider(AdapterFactory adapterFactory) {
871                        super(adapterFactory);
872                }
873 
874                /**
875                 * <!-- begin-user-doc -->
876                 * <!-- end-user-doc -->
877                 * @generated
878                 */
879                @Override
880                public Object [] getElements(Object object) {
881                        Object parent = super.getParent(object);
882                        return (parent == null ? Collections.EMPTY_SET : Collections.singleton(parent)).toArray();
883                }
884 
885                /**
886                 * <!-- begin-user-doc -->
887                 * <!-- end-user-doc -->
888                 * @generated
889                 */
890                @Override
891                public Object [] getChildren(Object object) {
892                        Object parent = super.getParent(object);
893                        return (parent == null ? Collections.EMPTY_SET : Collections.singleton(parent)).toArray();
894                }
895 
896                /**
897                 * <!-- begin-user-doc -->
898                 * <!-- end-user-doc -->
899                 * @generated
900                 */
901                @Override
902                public boolean hasChildren(Object object) {
903                        Object parent = super.getParent(object);
904                        return parent != null;
905                }
906 
907                /**
908                 * <!-- begin-user-doc -->
909                 * <!-- end-user-doc -->
910                 * @generated
911                 */
912                @Override
913                public Object getParent(Object object) {
914                        return null;
915                }
916        }
917 
918        /**
919         * <!-- begin-user-doc -->
920         * <!-- end-user-doc -->
921         * @generated
922         */
923        public void setCurrentViewerPane(ViewerPane viewerPane) {
924                if (currentViewerPane != viewerPane) {
925                        if (currentViewerPane != null) {
926                                currentViewerPane.showFocus(false);
927                        }
928                        currentViewerPane = viewerPane;
929                }
930                setCurrentViewer(currentViewerPane.getViewer());
931        }
932 
933        /**
934         * This makes sure that one content viewer, either for the current page or the outline view, if it has focus,
935         * is the current one.
936         * <!-- begin-user-doc -->
937         * <!-- end-user-doc -->
938         * @generated
939         */
940        public void setCurrentViewer(Viewer viewer) {
941                // If it is changing...
942                //
943                if (currentViewer != viewer) {
944                        if (selectionChangedListener == null) {
945                                // Create the listener on demand.
946                                //
947                                selectionChangedListener =
948                                        new ISelectionChangedListener() {
949                                                // This just notifies those things that are affected by the section.
950                                                //
951                                                public void selectionChanged(SelectionChangedEvent selectionChangedEvent) {
952                                                        setSelection(selectionChangedEvent.getSelection());
953                                                }
954                                        };
955                        }
956 
957                        // Stop listening to the old one.
958                        //
959                        if (currentViewer != null) {
960                                currentViewer.removeSelectionChangedListener(selectionChangedListener);
961                        }
962 
963                        // Start listening to the new one.
964                        //
965                        if (viewer != null) {
966                                viewer.addSelectionChangedListener(selectionChangedListener);
967                        }
968 
969                        // Remember it.
970                        //
971                        currentViewer = viewer;
972 
973                        // Set the editors selection based on the current viewer's selection.
974                        //
975                        setSelection(currentViewer == null ? StructuredSelection.EMPTY : currentViewer.getSelection());
976                }
977        }
978 
979        /**
980         * This returns the viewer as required by the {@link IViewerProvider} interface.
981         * <!-- begin-user-doc -->
982         * <!-- end-user-doc -->
983         * @generated
984         */
985        public Viewer getViewer() {
986                return currentViewer;
987        }
988 
989        /**
990         * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
991         * <!-- begin-user-doc -->
992         * <!-- end-user-doc -->
993         * @generated
994         */
995        protected void createContextMenuFor(StructuredViewer viewer) {
996                MenuManager contextMenu = new MenuManager("#PopUp");
997                contextMenu.add(new Separator("additions"));
998                contextMenu.setRemoveAllWhenShown(true);
999                contextMenu.addMenuListener(this);
1000                Menu menu= contextMenu.createContextMenu(viewer.getControl());
1001                viewer.getControl().setMenu(menu);
1002                getSite().registerContextMenu(contextMenu, new UnwrappingSelectionProvider(viewer));
1003 
1004                int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
1005                Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance() };
1006                viewer.addDragSupport(dndOperations, transfers, new ViewerDragAdapter(viewer));
1007                viewer.addDropSupport(dndOperations, transfers, new EditingDomainViewerDropAdapter(editingDomain, viewer));
1008        }
1009 
1010        /**
1011         * This is the method called to load a resource into the editing domain's resource set based on the editor's input.
1012         * <!-- begin-user-doc -->
1013         * <!-- end-user-doc -->
1014         * @generated
1015         */
1016        public void createModel() {
1017                URI resourceURI = EditUIUtil.getURI(getEditorInput());
1018                Exception exception = null;
1019                Resource resource = null;
1020                try {
1021                        // Load the resource through the editing domain.
1022                        //
1023                        resource = editingDomain.getResourceSet().getResource(resourceURI, true);
1024                }
1025                catch (Exception e) {
1026                        exception = e;
1027                        resource = editingDomain.getResourceSet().getResource(resourceURI, false);
1028                }
1029 
1030                Diagnostic diagnostic = analyzeResourceProblems(resource, exception);
1031                if (diagnostic.getSeverity() != Diagnostic.OK) {
1032                        resourceToDiagnosticMap.put(resource,  analyzeResourceProblems(resource, exception));
1033                }
1034                editingDomain.getResourceSet().eAdapters().add(problemIndicationAdapter);
1035        }
1036 
1037        /**
1038         * Returns a diagnostic describing the errors and warnings listed in the resource
1039         * and the specified exception (if any).
1040         * <!-- begin-user-doc -->
1041         * <!-- end-user-doc -->
1042         * @generated
1043         */
1044        public Diagnostic analyzeResourceProblems(Resource resource, Exception exception) {
1045                if (!resource.getErrors().isEmpty() || !resource.getWarnings().isEmpty()) {
1046                        BasicDiagnostic basicDiagnostic =
1047                                new BasicDiagnostic
1048                                        (Diagnostic.ERROR,
1049                                         "de.fzi.se.quality.editor",
1050                                         0,
1051                                         getString("_UI_CreateModelError_message", resource.getURI()),
1052                                         new Object [] { exception == null ? (Object)resource : exception });
1053                        basicDiagnostic.merge(EcoreUtil.computeDiagnostic(resource, true));
1054                        return basicDiagnostic;
1055                }
1056                else if (exception != null) {
1057                        return
1058                                new BasicDiagnostic
1059                                        (Diagnostic.ERROR,
1060                                         "de.fzi.se.quality.editor",
1061                                         0,
1062                                         getString("_UI_CreateModelError_message", resource.getURI()),
1063                                         new Object[] { exception });
1064                }
1065                else {
1066                        return Diagnostic.OK_INSTANCE;
1067                }
1068        }
1069 
1070        /**
1071         * This is the method used by the framework to install your own controls.
1072         * <!-- begin-user-doc -->
1073         * <!-- end-user-doc -->
1074         * @generated
1075         */
1076        @Override
1077        public void createPages() {
1078                // Creates the model from the editor input
1079                //
1080                createModel();
1081 
1082                // Only creates the other pages if there is something that can be edited
1083                //
1084                if (!getEditingDomain().getResourceSet().getResources().isEmpty()) {
1085                        // Create a page for the selection tree view.
1086                        //
1087                        {
1088                                ViewerPane viewerPane =
1089                                        new ViewerPane(getSite().getPage(), QualityEditor.this) {
1090                                                @Override
1091                                                public Viewer createViewer(Composite composite) {
1092                                                        Tree tree = new Tree(composite, SWT.MULTI);
1093                                                        TreeViewer newTreeViewer = new TreeViewer(tree);
1094                                                        return newTreeViewer;
1095                                                }
1096                                                @Override
1097                                                public void requestActivation() {
1098                                                        super.requestActivation();
1099                                                        setCurrentViewerPane(this);
1100                                                }
1101                                        };
1102                                viewerPane.createControl(getContainer());
1103 
1104                                selectionViewer = (TreeViewer)viewerPane.getViewer();
1105                                selectionViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
1106 
1107                                selectionViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
1108                                selectionViewer.setInput(editingDomain.getResourceSet());
1109                                selectionViewer.setSelection(new StructuredSelection(editingDomain.getResourceSet().getResources().get(0)), true);
1110                                viewerPane.setTitle(editingDomain.getResourceSet());
1111 
1112                                new AdapterFactoryTreeEditor(selectionViewer.getTree(), adapterFactory);
1113 
1114                                createContextMenuFor(selectionViewer);
1115                                int pageIndex = addPage(viewerPane.getControl());
1116                                setPageText(pageIndex, getString("_UI_SelectionPage_label"));
1117                        }
1118 
1119                        // Create a page for the parent tree view.
1120                        //
1121                        {
1122                                ViewerPane viewerPane =
1123                                        new ViewerPane(getSite().getPage(), QualityEditor.this) {
1124                                                @Override
1125                                                public Viewer createViewer(Composite composite) {
1126                                                        Tree tree = new Tree(composite, SWT.MULTI);
1127                                                        TreeViewer newTreeViewer = new TreeViewer(tree);
1128                                                        return newTreeViewer;
1129                                                }
1130                                                @Override
1131                                                public void requestActivation() {
1132                                                        super.requestActivation();
1133                                                        setCurrentViewerPane(this);
1134                                                }
1135                                        };
1136                                viewerPane.createControl(getContainer());
1137 
1138                                parentViewer = (TreeViewer)viewerPane.getViewer();
1139                                parentViewer.setAutoExpandLevel(30);
1140                                parentViewer.setContentProvider(new ReverseAdapterFactoryContentProvider(adapterFactory));
1141                                parentViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
1142 
1143                                createContextMenuFor(parentViewer);
1144                                int pageIndex = addPage(viewerPane.getControl());
1145                                setPageText(pageIndex, getString("_UI_ParentPage_label"));
1146                        }
1147 
1148                        // This is the page for the list viewer
1149                        //
1150                        {
1151                                ViewerPane viewerPane =
1152                                        new ViewerPane(getSite().getPage(), QualityEditor.this) {
1153                                                @Override
1154                                                public Viewer createViewer(Composite composite) {
1155                                                        return new ListViewer(composite);
1156                                                }
1157                                                @Override
1158                                                public void requestActivation() {
1159                                                        super.requestActivation();
1160                                                        setCurrentViewerPane(this);
1161                                                }
1162                                        };
1163                                viewerPane.createControl(getContainer());
1164                                listViewer = (ListViewer)viewerPane.getViewer();
1165                                listViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
1166                                listViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
1167 
1168                                createContextMenuFor(listViewer);
1169                                int pageIndex = addPage(viewerPane.getControl());
1170                                setPageText(pageIndex, getString("_UI_ListPage_label"));
1171                        }
1172 
1173                        // This is the page for the tree viewer
1174                        //
1175                        {
1176                                ViewerPane viewerPane =
1177                                        new ViewerPane(getSite().getPage(), QualityEditor.this) {
1178                                                @Override
1179                                                public Viewer createViewer(Composite composite) {
1180                                                        return new TreeViewer(composite);
1181                                                }
1182                                                @Override
1183                                                public void requestActivation() {
1184                                                        super.requestActivation();
1185                                                        setCurrentViewerPane(this);
1186                                                }
1187                                        };
1188                                viewerPane.createControl(getContainer());
1189                                treeViewer = (TreeViewer)viewerPane.getViewer();
1190                                treeViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
1191                                treeViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
1192 
1193                                new AdapterFactoryTreeEditor(treeViewer.getTree(), adapterFactory);
1194 
1195                                createContextMenuFor(treeViewer);
1196                                int pageIndex = addPage(viewerPane.getControl());
1197                                setPageText(pageIndex, getString("_UI_TreePage_label"));
1198                        }
1199 
1200                        // This is the page for the table viewer.
1201                        //
1202                        {
1203                                ViewerPane viewerPane =
1204                                        new ViewerPane(getSite().getPage(), QualityEditor.this) {
1205                                                @Override
1206                                                public Viewer createViewer(Composite composite) {
1207                                                        return new TableViewer(composite);
1208                                                }
1209                                                @Override
1210                                                public void requestActivation() {
1211                                                        super.requestActivation();
1212                                                        setCurrentViewerPane(this);
1213                                                }
1214                                        };
1215                                viewerPane.createControl(getContainer());
1216                                tableViewer = (TableViewer)viewerPane.getViewer();
1217 
1218                                Table table = tableViewer.getTable();
1219                                TableLayout layout = new TableLayout();
1220                                table.setLayout(layout);
1221                                table.setHeaderVisible(true);
1222                                table.setLinesVisible(true);
1223 
1224                                TableColumn objectColumn = new TableColumn(table, SWT.NONE);
1225                                layout.addColumnData(new ColumnWeightData(3, 100, true));
1226                                objectColumn.setText(getString("_UI_ObjectColumn_label"));
1227                                objectColumn.setResizable(true);
1228 
1229                                TableColumn selfColumn = new TableColumn(table, SWT.NONE);
1230                                layout.addColumnData(new ColumnWeightData(2, 100, true));
1231                                selfColumn.setText(getString("_UI_SelfColumn_label"));
1232                                selfColumn.setResizable(true);
1233 
1234                                tableViewer.setColumnProperties(new String [] {"a", "b"});
1235                                tableViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
1236                                tableViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
1237 
1238                                createContextMenuFor(tableViewer);
1239                                int pageIndex = addPage(viewerPane.getControl());
1240                                setPageText(pageIndex, getString("_UI_TablePage_label"));
1241                        }
1242 
1243                        // This is the page for the table tree viewer.
1244                        //
1245                        {
1246                                ViewerPane viewerPane =
1247                                        new ViewerPane(getSite().getPage(), QualityEditor.this) {
1248                                                @Override
1249                                                public Viewer createViewer(Composite composite) {
1250                                                        return new TreeViewer(composite);
1251                                                }
1252                                                @Override
1253                                                public void requestActivation() {
1254                                                        super.requestActivation();
1255                                                        setCurrentViewerPane(this);
1256                                                }
1257                                        };
1258                                viewerPane.createControl(getContainer());
1259 
1260                                treeViewerWithColumns = (TreeViewer)viewerPane.getViewer();
1261 
1262                                Tree tree = treeViewerWithColumns.getTree();
1263                                tree.setLayoutData(new FillLayout());
1264                                tree.setHeaderVisible(true);
1265                                tree.setLinesVisible(true);
1266 
1267                                TreeColumn objectColumn = new TreeColumn(tree, SWT.NONE);
1268                                objectColumn.setText(getString("_UI_ObjectColumn_label"));
1269                                objectColumn.setResizable(true);
1270                                objectColumn.setWidth(250);
1271 
1272                                TreeColumn selfColumn = new TreeColumn(tree, SWT.NONE);
1273                                selfColumn.setText(getString("_UI_SelfColumn_label"));
1274                                selfColumn.setResizable(true);
1275                                selfColumn.setWidth(200);
1276 
1277                                treeViewerWithColumns.setColumnProperties(new String [] {"a", "b"});
1278                                treeViewerWithColumns.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
1279                                treeViewerWithColumns.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
1280 
1281                                createContextMenuFor(treeViewerWithColumns);
1282                                int pageIndex = addPage(viewerPane.getControl());
1283                                setPageText(pageIndex, getString("_UI_TreeWithColumnsPage_label"));
1284                        }
1285 
1286                        getSite().getShell().getDisplay().asyncExec
1287                                (new Runnable() {
1288                                         public void run() {
1289                                                 setActivePage(0);
1290                                         }
1291                                 });
1292                }
1293 
1294                // Ensures that this editor will only display the page's tab
1295                // area if there are more than one page
1296                //
1297                getContainer().addControlListener
1298                        (new ControlAdapter() {
1299                                boolean guard = false;
1300                                @Override
1301                                public void controlResized(ControlEvent event) {
1302                                        if (!guard) {
1303                                                guard = true;
1304                                                hideTabs();
1305                                                guard = false;
1306                                        }
1307                                }
1308                         });
1309 
1310                getSite().getShell().getDisplay().asyncExec
1311                        (new Runnable() {
1312                                 public void run() {
1313                                         updateProblemIndication();
1314                                 }
1315                         });
1316        }
1317 
1318        /**
1319         * If there is just one page in the multi-page editor part,
1320         * this hides the single tab at the bottom.
1321         * <!-- begin-user-doc -->
1322         * <!-- end-user-doc -->
1323         * @generated
1324         */
1325        protected void hideTabs() {
1326                if (getPageCount() <= 1) {
1327                        setPageText(0, "");
1328                        if (getContainer() instanceof CTabFolder) {
1329                                ((CTabFolder)getContainer()).setTabHeight(1);
1330                                Point point = getContainer().getSize();
1331                                getContainer().setSize(point.x, point.y + 6);
1332                        }
1333                }
1334        }
1335 
1336        /**
1337         * If there is more than one page in the multi-page editor part,
1338         * this shows the tabs at the bottom.
1339         * <!-- begin-user-doc -->
1340         * <!-- end-user-doc -->
1341         * @generated
1342         */
1343        protected void showTabs() {
1344                if (getPageCount() > 1) {
1345                        setPageText(0, getString("_UI_SelectionPage_label"));
1346                        if (getContainer() instanceof CTabFolder) {
1347                                ((CTabFolder)getContainer()).setTabHeight(SWT.DEFAULT);
1348                                Point point = getContainer().getSize();
1349                                getContainer().setSize(point.x, point.y - 6);
1350                        }
1351                }
1352        }
1353 
1354        /**
1355         * This is used to track the active viewer.
1356         * <!-- begin-user-doc -->
1357         * <!-- end-user-doc -->
1358         * @generated
1359         */
1360        @Override
1361        protected void pageChange(int pageIndex) {
1362                super.pageChange(pageIndex);
1363 
1364                if (contentOutlinePage != null) {
1365                        handleContentOutlineSelection(contentOutlinePage.getSelection());
1366                }
1367        }
1368 
1369        /**
1370         * This is how the framework determines which interfaces we implement.
1371         * <!-- begin-user-doc -->
1372         * <!-- end-user-doc -->
1373         * @generated
1374         */
1375        @SuppressWarnings("unchecked")
1376        @Override
1377        public Object getAdapter(Class key) {
1378                if (key.equals(IContentOutlinePage.class)) {
1379                        return showOutlineView() ? getContentOutlinePage() : null;
1380                }
1381                else if (key.equals(IPropertySheetPage.class)) {
1382                        return getPropertySheetPage();
1383                }
1384                else if (key.equals(IGotoMarker.class)) {
1385                        return this;
1386                }
1387                else {
1388                        return super.getAdapter(key);
1389                }
1390        }
1391 
1392        /**
1393         * This accesses a cached version of the content outliner.
1394         * <!-- begin-user-doc -->
1395         * <!-- end-user-doc -->
1396         * @generated
1397         */
1398        public IContentOutlinePage getContentOutlinePage() {
1399                if (contentOutlinePage == null) {
1400                        // The content outline is just a tree.
1401                        //
1402                        class MyContentOutlinePage extends ContentOutlinePage {
1403                                @Override
1404                                public void createControl(Composite parent) {
1405                                        super.createControl(parent);
1406                                        contentOutlineViewer = getTreeViewer();
1407                                        contentOutlineViewer.addSelectionChangedListener(this);
1408 
1409                                        // Set up the tree viewer.
1410                                        //
1411                                        contentOutlineViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
1412                                        contentOutlineViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
1413                                        contentOutlineViewer.setInput(editingDomain.getResourceSet());
1414 
1415                                        // Make sure our popups work.
1416                                        //
1417                                        createContextMenuFor(contentOutlineViewer);
1418 
1419                                        if (!editingDomain.getResourceSet().getResources().isEmpty()) {
1420                                          // Select the root object in the view.
1421                                          //
1422                                          contentOutlineViewer.setSelection(new StructuredSelection(editingDomain.getResourceSet().getResources().get(0)), true);
1423                                        }
1424                                }
1425 
1426                                @Override
1427                                public void makeContributions(IMenuManager menuManager, IToolBarManager toolBarManager, IStatusLineManager statusLineManager) {
1428                                        super.makeContributions(menuManager, toolBarManager, statusLineManager);
1429                                        contentOutlineStatusLineManager = statusLineManager;
1430                                }
1431 
1432                                @Override
1433                                public void setActionBars(IActionBars actionBars) {
1434                                        super.setActionBars(actionBars);
1435                                        getActionBarContributor().shareGlobalActions(this, actionBars);
1436                                }
1437                        }
1438 
1439                        contentOutlinePage = new MyContentOutlinePage();
1440 
1441                        // Listen to selection so that we can handle it is a special way.
1442                        //
1443                        contentOutlinePage.addSelectionChangedListener
1444                                (new ISelectionChangedListener() {
1445                                         // This ensures that we handle selections correctly.
1446                                         //
1447                                         public void selectionChanged(SelectionChangedEvent event) {
1448                                                 handleContentOutlineSelection(event.getSelection());
1449                                         }
1450                                 });
1451                }
1452 
1453                return contentOutlinePage;
1454        }
1455 
1456        /**
1457         * This accesses a cached version of the property sheet.
1458         * <!-- begin-user-doc -->
1459         * <!-- end-user-doc -->
1460         * @generated
1461         */
1462        public IPropertySheetPage getPropertySheetPage() {
1463                if (propertySheetPage == null) {
1464                        propertySheetPage =
1465                                new ExtendedPropertySheetPage(editingDomain) {
1466                                        @Override
1467                                        public void setSelectionToViewer(List<?> selection) {
1468                                                QualityEditor.this.setSelectionToViewer(selection);
1469                                                QualityEditor.this.setFocus();
1470                                        }
1471 
1472                                        @Override
1473                                        public void setActionBars(IActionBars actionBars) {
1474                                                super.setActionBars(actionBars);
1475                                                getActionBarContributor().shareGlobalActions(this, actionBars);
1476                                        }
1477                                };
1478                        propertySheetPage.setPropertySourceProvider(new AdapterFactoryContentProvider(adapterFactory));
1479                }
1480 
1481                return propertySheetPage;
1482        }
1483 
1484        /**
1485         * This deals with how we want selection in the outliner to affect the other views.
1486         * <!-- begin-user-doc -->
1487         * <!-- end-user-doc -->
1488         * @generated
1489         */
1490        public void handleContentOutlineSelection(ISelection selection) {
1491                if (currentViewerPane != null && !selection.isEmpty() && selection instanceof IStructuredSelection) {
1492                        Iterator<?> selectedElements = ((IStructuredSelection)selection).iterator();
1493                        if (selectedElements.hasNext()) {
1494                                // Get the first selected element.
1495                                //
1496                                Object selectedElement = selectedElements.next();
1497 
1498                                // If it's the selection viewer, then we want it to select the same selection as this selection.
1499                                //
1500                                if (currentViewerPane.getViewer() == selectionViewer) {
1501                                        ArrayList<Object> selectionList = new ArrayList<Object>();
1502                                        selectionList.add(selectedElement);
1503                                        while (selectedElements.hasNext()) {
1504                                                selectionList.add(selectedElements.next());
1505                                        }
1506 
1507                                        // Set the selection to the widget.
1508                                        //
1509                                        selectionViewer.setSelection(new StructuredSelection(selectionList));
1510                                }
1511                                else {
1512                                        // Set the input to the widget.
1513                                        //
1514                                        if (currentViewerPane.getViewer().getInput() != selectedElement) {
1515                                                currentViewerPane.getViewer().setInput(selectedElement);
1516                                                currentViewerPane.setTitle(selectedElement);
1517                                        }
1518                                }
1519                        }
1520                }
1521        }
1522 
1523        /**
1524         * This is for implementing {@link IEditorPart} and simply tests the command stack.
1525         * <!-- begin-user-doc -->
1526         * <!-- end-user-doc -->
1527         * @generated
1528         */
1529        @Override
1530        public boolean isDirty() {
1531                return ((BasicCommandStack)editingDomain.getCommandStack()).isSaveNeeded();
1532        }
1533 
1534        /**
1535         * This is for implementing {@link IEditorPart} and simply saves the model file.
1536         * <!-- begin-user-doc -->
1537         * <!-- end-user-doc -->
1538         * @generated
1539         */
1540        @Override
1541        public void doSave(IProgressMonitor progressMonitor) {
1542                // Save only resources that have actually changed.
1543                //
1544                final Map<Object, Object> saveOptions = new HashMap<Object, Object>();
1545                saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED, Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER);
1546 
1547                // Do the work within an operation because this is a long running activity that modifies the workbench.
1548                //
1549                WorkspaceModifyOperation operation =
1550                        new WorkspaceModifyOperation() {
1551                                // This is the method that gets invoked when the operation runs.
1552                                //
1553                                @Override
1554                                public void execute(IProgressMonitor monitor) {
1555                                        // Save the resources to the file system.
1556                                        //
1557                                        boolean first = true;
1558                                        for (Resource resource : editingDomain.getResourceSet().getResources()) {
1559                                                if ((first || !resource.getContents().isEmpty() || isPersisted(resource)) && !editingDomain.isReadOnly(resource)) {
1560                                                        try {
1561                                                                resource.save(saveOptions);
1562                                                                savedResources.add(resource);
1563                                                        }
1564                                                        catch (Exception exception) {
1565                                                                resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception));
1566                                                        }
1567                                                        first = false;
1568                                                }
1569                                        }
1570                                }
1571                        };
1572 
1573                updateProblemIndication = false;
1574                try {
1575                        // This runs the options, and shows progress.
1576                        //
1577                        new ProgressMonitorDialog(getSite().getShell()).run(true, false, operation);
1578 
1579                        // Refresh the necessary state.
1580                        //
1581                        ((BasicCommandStack)editingDomain.getCommandStack()).saveIsDone();
1582                        firePropertyChange(IEditorPart.PROP_DIRTY);
1583                }
1584                catch (Exception exception) {
1585                        // Something went wrong that shouldn't.
1586                        //
1587                        QualityEditorPlugin.INSTANCE.log(exception);
1588                }
1589                updateProblemIndication = true;
1590                updateProblemIndication();
1591        }
1592 
1593        /**
1594         * This returns whether something has been persisted to the URI of the specified resource.
1595         * The implementation uses the URI converter from the editor's resource set to try to open an input stream. 
1596         * <!-- begin-user-doc -->
1597         * <!-- end-user-doc -->
1598         * @generated
1599         */
1600        protected boolean isPersisted(Resource resource) {
1601                boolean result = false;
1602                try {
1603                        InputStream stream = editingDomain.getResourceSet().getURIConverter().createInputStream(resource.getURI());
1604                        if (stream != null) {
1605                                result = true;
1606                                stream.close();
1607                        }
1608                }
1609                catch (IOException e) {
1610                        // Ignore
1611                }
1612                return result;
1613        }
1614 
1615        /**
1616         * This always returns true because it is not currently supported.
1617         * <!-- begin-user-doc -->
1618         * <!-- end-user-doc -->
1619         * @generated
1620         */
1621        @Override
1622        public boolean isSaveAsAllowed() {
1623                return true;
1624        }
1625 
1626        /**
1627         * This also changes the editor's input.
1628         * <!-- begin-user-doc -->
1629         * <!-- end-user-doc -->
1630         * @generated
1631         */
1632        @Override
1633        public void doSaveAs() {
1634                SaveAsDialog saveAsDialog = new SaveAsDialog(getSite().getShell());
1635                saveAsDialog.open();
1636                IPath path = saveAsDialog.getResult();
1637                if (path != null) {
1638                        IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
1639                        if (file != null) {
1640                                doSaveAs(URI.createPlatformResourceURI(file.getFullPath().toString(), true), new FileEditorInput(file));
1641                        }
1642                }
1643        }
1644 
1645        /**
1646         * <!-- begin-user-doc -->
1647         * <!-- end-user-doc -->
1648         * @generated
1649         */
1650        protected void doSaveAs(URI uri, IEditorInput editorInput) {
1651                (editingDomain.getResourceSet().getResources().get(0)).setURI(uri);
1652                setInputWithNotify(editorInput);
1653                setPartName(editorInput.getName());
1654                IProgressMonitor progressMonitor =
1655                        getActionBars().getStatusLineManager() != null ?
1656                                getActionBars().getStatusLineManager().getProgressMonitor() :
1657                                new NullProgressMonitor();
1658                doSave(progressMonitor);
1659        }
1660 
1661        /**
1662         * <!-- begin-user-doc -->
1663         * <!-- end-user-doc -->
1664         * @generated
1665         */
1666        public void gotoMarker(IMarker marker) {
1667                try {
1668                        if (marker.getType().equals(EValidator.MARKER)) {
1669                                String uriAttribute = marker.getAttribute(EValidator.URI_ATTRIBUTE, null);
1670                                if (uriAttribute != null) {
1671                                        URI uri = URI.createURI(uriAttribute);
1672                                        EObject eObject = editingDomain.getResourceSet().getEObject(uri, true);
1673                                        if (eObject != null) {
1674                                          setSelectionToViewer(Collections.singleton(editingDomain.getWrapper(eObject)));
1675                                        }
1676                                }
1677                        }
1678                }
1679                catch (CoreException exception) {
1680                        QualityEditorPlugin.INSTANCE.log(exception);
1681                }
1682        }
1683 
1684        /**
1685         * This is called during startup.
1686         * <!-- begin-user-doc -->
1687         * <!-- end-user-doc -->
1688         * @generated
1689         */
1690        @Override
1691        public void init(IEditorSite site, IEditorInput editorInput) {
1692                setSite(site);
1693                setInputWithNotify(editorInput);
1694                setPartName(editorInput.getName());
1695                site.setSelectionProvider(this);
1696                site.getPage().addPartListener(partListener);
1697                ResourcesPlugin.getWorkspace().addResourceChangeListener(resourceChangeListener, IResourceChangeEvent.POST_CHANGE);
1698        }
1699 
1700        /**
1701         * <!-- begin-user-doc -->
1702         * <!-- end-user-doc -->
1703         * @generated
1704         */
1705        @Override
1706        public void setFocus() {
1707                if (currentViewerPane != null) {
1708                        currentViewerPane.setFocus();
1709                }
1710                else {
1711                        getControl(getActivePage()).setFocus();
1712                }
1713        }
1714 
1715        /**
1716         * This implements {@link org.eclipse.jface.viewers.ISelectionProvider}.
1717         * <!-- begin-user-doc -->
1718         * <!-- end-user-doc -->
1719         * @generated
1720         */
1721        public void addSelectionChangedListener(ISelectionChangedListener listener) {
1722                selectionChangedListeners.add(listener);
1723        }
1724 
1725        /**
1726         * This implements {@link org.eclipse.jface.viewers.ISelectionProvider}.
1727         * <!-- begin-user-doc -->
1728         * <!-- end-user-doc -->
1729         * @generated
1730         */
1731        public void removeSelectionChangedListener(ISelectionChangedListener listener) {
1732                selectionChangedListeners.remove(listener);
1733        }
1734 
1735        /**
1736         * This implements {@link org.eclipse.jface.viewers.ISelectionProvider} to return this editor's overall selection.
1737         * <!-- begin-user-doc -->
1738         * <!-- end-user-doc -->
1739         * @generated
1740         */
1741        public ISelection getSelection() {
1742                return editorSelection;
1743        }
1744 
1745        /**
1746         * This implements {@link org.eclipse.jface.viewers.ISelectionProvider} to set this editor's overall selection.
1747         * Calling this result will notify the listeners.
1748         * <!-- begin-user-doc -->
1749         * <!-- end-user-doc -->
1750         * @generated
1751         */
1752        public void setSelection(ISelection selection) {
1753                editorSelection = selection;
1754 
1755                for (ISelectionChangedListener listener : selectionChangedListeners) {
1756                        listener.selectionChanged(new SelectionChangedEvent(this, selection));
1757                }
1758                setStatusLineManager(selection);
1759        }
1760 
1761        /**
1762         * <!-- begin-user-doc -->
1763         * <!-- end-user-doc -->
1764         * @generated
1765         */
1766        public void setStatusLineManager(ISelection selection) {
1767                IStatusLineManager statusLineManager = currentViewer != null && currentViewer == contentOutlineViewer ?
1768                        contentOutlineStatusLineManager : getActionBars().getStatusLineManager();
1769 
1770                if (statusLineManager != null) {
1771                        if (selection instanceof IStructuredSelection) {
1772                                Collection<?> collection = ((IStructuredSelection)selection).toList();
1773                                switch (collection.size()) {
1774                                        case 0: {
1775                                                statusLineManager.setMessage(getString("_UI_NoObjectSelected"));
1776                                                break;
1777                                        }
1778                                        case 1: {
1779                                                String text = new AdapterFactoryItemDelegator(adapterFactory).getText(collection.iterator().next());
1780                                                statusLineManager.setMessage(getString("_UI_SingleObjectSelected", text));
1781                                                break;
1782                                        }
1783                                        default: {
1784                                                statusLineManager.setMessage(getString("_UI_MultiObjectSelected", Integer.toString(collection.size())));
1785                                                break;
1786                                        }
1787                                }
1788                        }
1789                        else {
1790                                statusLineManager.setMessage("");
1791                        }
1792                }
1793        }
1794 
1795        /**
1796         * This looks up a string in the plugin's plugin.properties file.
1797         * <!-- begin-user-doc -->
1798         * <!-- end-user-doc -->
1799         * @generated
1800         */
1801        private static String getString(String key) {
1802                return QualityEditorPlugin.INSTANCE.getString(key);
1803        }
1804 
1805        /**
1806         * This looks up a string in plugin.properties, making a substitution.
1807         * <!-- begin-user-doc -->
1808         * <!-- end-user-doc -->
1809         * @generated
1810         */
1811        private static String getString(String key, Object s1) {
1812                return QualityEditorPlugin.INSTANCE.getString(key, new Object [] { s1 });
1813        }
1814 
1815        /**
1816         * This implements {@link org.eclipse.jface.action.IMenuListener} to help fill the context menus with contributions from the Edit menu.
1817         * <!-- begin-user-doc -->
1818         * <!-- end-user-doc -->
1819         * @generated
1820         */
1821        public void menuAboutToShow(IMenuManager menuManager) {
1822                ((IMenuListener)getEditorSite().getActionBarContributor()).menuAboutToShow(menuManager);
1823        }
1824 
1825        /**
1826         * <!-- begin-user-doc -->
1827         * <!-- end-user-doc -->
1828         * @generated
1829         */
1830        public EditingDomainActionBarContributor getActionBarContributor() {
1831                return (EditingDomainActionBarContributor)getEditorSite().getActionBarContributor();
1832        }
1833 
1834        /**
1835         * <!-- begin-user-doc -->
1836         * <!-- end-user-doc -->
1837         * @generated
1838         */
1839        public IActionBars getActionBars() {
1840                return getActionBarContributor().getActionBars();
1841        }
1842 
1843        /**
1844         * <!-- begin-user-doc -->
1845         * <!-- end-user-doc -->
1846         * @generated
1847         */
1848        public AdapterFactory getAdapterFactory() {
1849                return adapterFactory;
1850        }
1851 
1852        /**
1853         * <!-- begin-user-doc -->
1854         * <!-- end-user-doc -->
1855         * @generated
1856         */
1857        @Override
1858        public void dispose() {
1859                updateProblemIndication = false;
1860 
1861                ResourcesPlugin.getWorkspace().removeResourceChangeListener(resourceChangeListener);
1862 
1863                getSite().getPage().removePartListener(partListener);
1864 
1865                adapterFactory.dispose();
1866 
1867                if (getActionBarContributor().getActiveEditor() == this) {
1868                        getActionBarContributor().setActiveEditor(null);
1869                }
1870 
1871                if (propertySheetPage != null) {
1872                        propertySheetPage.dispose();
1873                }
1874 
1875                if (contentOutlinePage != null) {
1876                        contentOutlinePage.dispose();
1877                }
1878 
1879                super.dispose();
1880        }
1881 
1882        /**
1883         * Returns whether the outline view should be presented to the user.
1884         * <!-- begin-user-doc -->
1885         * <!-- end-user-doc -->
1886         * @generated
1887         */
1888        protected boolean showOutlineView() {
1889                return true;
1890        }
1891}

[all classes][de.fzi.se.quality.presentation]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov