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

COVERAGE SUMMARY FOR SOURCE FILE [ResultdecoratorEditor.java]

nameclass, %method, %block, %line, %
ResultdecoratorEditor.java0%   (0/26)0%   (0/120)0%   (0/2769)0%   (0/610)

COVERAGE BREAKDOWN BY CLASS AND METHOD

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

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