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

COVERAGE SUMMARY FOR SOURCE FILE [QualityAnnotationEditor.java]

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

COVERAGE BREAKDOWN BY CLASS AND METHOD

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

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