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

COVERAGE SUMMARY FOR SOURCE FILE [QMLContractTypeEditor.java]

nameclass, %method, %block, %line, %
QMLContractTypeEditor.java0%   (0/27)0%   (0/122)0%   (0/2741)0%   (0/608)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class QMLContractTypeEditor0%   (0/1)0%   (0/47)0%   (0/1846)0%   (0/438)
QMLContractTypeEditor (): void 0%   (0/1)0%   (0/59)0%   (0/17)
access$0 (QMLContractTypeEditor): Composite 0%   (0/1)0%   (0/3)0%   (0/1)
access$1 (QMLContractTypeEditor, 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/41)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/149)0%   (0/30)
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 QMLContractTypeEditor$10%   (0/1)0%   (0/6)0%   (0/61)0%   (0/17)
QMLContractTypeEditor$1 (QMLContractTypeEditor): 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 QMLContractTypeEditor$100%   (0/1)0%   (0/3)0%   (0/20)0%   (0/6)
QMLContractTypeEditor$10 (QMLContractTypeEditor, 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 QMLContractTypeEditor$110%   (0/1)0%   (0/3)0%   (0/20)0%   (0/6)
QMLContractTypeEditor$11 (QMLContractTypeEditor, 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 QMLContractTypeEditor$120%   (0/1)0%   (0/3)0%   (0/20)0%   (0/6)
QMLContractTypeEditor$12 (QMLContractTypeEditor, 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 QMLContractTypeEditor$130%   (0/1)0%   (0/3)0%   (0/20)0%   (0/6)
QMLContractTypeEditor$13 (QMLContractTypeEditor, 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 QMLContractTypeEditor$140%   (0/1)0%   (0/2)0%   (0/11)0%   (0/4)
QMLContractTypeEditor$14 (QMLContractTypeEditor): void 0%   (0/1)0%   (0/6)0%   (0/2)
run (): void 0%   (0/1)0%   (0/5)0%   (0/2)
     
class QMLContractTypeEditor$150%   (0/1)0%   (0/2)0%   (0/22)0%   (0/8)
QMLContractTypeEditor$15 (QMLContractTypeEditor): void 0%   (0/1)0%   (0/9)0%   (0/3)
controlResized (ControlEvent): void 0%   (0/1)0%   (0/13)0%   (0/5)
     
class QMLContractTypeEditor$160%   (0/1)0%   (0/2)0%   (0/10)0%   (0/4)
QMLContractTypeEditor$16 (QMLContractTypeEditor): void 0%   (0/1)0%   (0/6)0%   (0/2)
run (): void 0%   (0/1)0%   (0/4)0%   (0/2)
     
class QMLContractTypeEditor$170%   (0/1)0%   (0/2)0%   (0/12)0%   (0/4)
QMLContractTypeEditor$17 (QMLContractTypeEditor): void 0%   (0/1)0%   (0/6)0%   (0/2)
selectionChanged (SelectionChangedEvent): void 0%   (0/1)0%   (0/6)0%   (0/2)
     
class QMLContractTypeEditor$180%   (0/1)0%   (0/3)0%   (0/25)0%   (0/8)
QMLContractTypeEditor$18 (QMLContractTypeEditor, 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 QMLContractTypeEditor$190%   (0/1)0%   (0/2)0%   (0/77)0%   (0/13)
QMLContractTypeEditor$19 (QMLContractTypeEditor, Map): void 0%   (0/1)0%   (0/9)0%   (0/2)
execute (IProgressMonitor): void 0%   (0/1)0%   (0/68)0%   (0/11)
     
class QMLContractTypeEditor$1MyContentOutlinePage0%   (0/1)0%   (0/4)0%   (0/96)0%   (0/17)
QMLContractTypeEditor$1MyContentOutlinePage (QMLContractTypeEditor): 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 QMLContractTypeEditor$20%   (0/1)0%   (0/5)0%   (0/71)0%   (0/19)
QMLContractTypeEditor$2 (QMLContractTypeEditor): void 0%   (0/1)0%   (0/6)0%   (0/2)
access$0 (QMLContractTypeEditor$2): QMLContractTypeEditor 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 QMLContractTypeEditor$2$10%   (0/1)0%   (0/2)0%   (0/11)0%   (0/4)
QMLContractTypeEditor$2$1 (QMLContractTypeEditor$2): void 0%   (0/1)0%   (0/6)0%   (0/2)
run (): void 0%   (0/1)0%   (0/5)0%   (0/2)
     
class QMLContractTypeEditor$30%   (0/1)0%   (0/3)0%   (0/56)0%   (0/14)
QMLContractTypeEditor$3 (QMLContractTypeEditor): void 0%   (0/1)0%   (0/6)0%   (0/2)
access$0 (QMLContractTypeEditor$3): QMLContractTypeEditor 0%   (0/1)0%   (0/3)0%   (0/1)
resourceChanged (IResourceChangeEvent): void 0%   (0/1)0%   (0/47)0%   (0/12)
     
class QMLContractTypeEditor$3$10%   (0/1)0%   (0/2)0%   (0/35)0%   (0/6)
QMLContractTypeEditor$3$1 (QMLContractTypeEditor$3, QMLContractTypeEditor$3$1... 0%   (0/1)0%   (0/9)0%   (0/2)
run (): void 0%   (0/1)0%   (0/26)0%   (0/4)
     
class QMLContractTypeEditor$3$1ResourceDeltaVisitor0%   (0/1)0%   (0/4)0%   (0/81)0%   (0/16)
QMLContractTypeEditor$3$1ResourceDeltaVisitor (QMLContractTypeEditor$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 QMLContractTypeEditor$3$20%   (0/1)0%   (0/2)0%   (0/33)0%   (0/6)
QMLContractTypeEditor$3$2 (QMLContractTypeEditor$3, QMLContractTypeEditor$3$1... 0%   (0/1)0%   (0/9)0%   (0/2)
run (): void 0%   (0/1)0%   (0/24)0%   (0/4)
     
class QMLContractTypeEditor$40%   (0/1)0%   (0/2)0%   (0/12)0%   (0/3)
QMLContractTypeEditor$4 (QMLContractTypeEditor, ComposedAdapterFactory$Descri... 0%   (0/1)0%   (0/7)0%   (0/2)
getRootAdapterFactory (): ComposeableAdapterFactory 0%   (0/1)0%   (0/5)0%   (0/1)
     
class QMLContractTypeEditor$50%   (0/1)0%   (0/3)0%   (0/20)0%   (0/5)
QMLContractTypeEditor$5 (QMLContractTypeEditor): void 0%   (0/1)0%   (0/6)0%   (0/2)
access$0 (QMLContractTypeEditor$5): QMLContractTypeEditor 0%   (0/1)0%   (0/3)0%   (0/1)
commandStackChanged (EventObject): void 0%   (0/1)0%   (0/11)0%   (0/3)
     
class QMLContractTypeEditor$5$10%   (0/1)0%   (0/2)0%   (0/46)0%   (0/9)
QMLContractTypeEditor$5$1 (QMLContractTypeEditor$5, EventObject): void 0%   (0/1)0%   (0/9)0%   (0/2)
run (): void 0%   (0/1)0%   (0/37)0%   (0/7)
     
class QMLContractTypeEditor$60%   (0/1)0%   (0/2)0%   (0/25)0%   (0/5)
QMLContractTypeEditor$6 (QMLContractTypeEditor, Collection): void 0%   (0/1)0%   (0/9)0%   (0/2)
run (): void 0%   (0/1)0%   (0/16)0%   (0/3)
     
class QMLContractTypeEditor$70%   (0/1)0%   (0/2)0%   (0/12)0%   (0/4)
QMLContractTypeEditor$7 (QMLContractTypeEditor): void 0%   (0/1)0%   (0/6)0%   (0/2)
selectionChanged (SelectionChangedEvent): void 0%   (0/1)0%   (0/6)0%   (0/2)
     
class QMLContractTypeEditor$80%   (0/1)0%   (0/3)0%   (0/28)0%   (0/8)
QMLContractTypeEditor$8 (QMLContractTypeEditor, 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 QMLContractTypeEditor$90%   (0/1)0%   (0/3)0%   (0/28)0%   (0/8)
QMLContractTypeEditor$9 (QMLContractTypeEditor, 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 QMLContractTypeEditor$ReverseAdapterFactoryContentProvider0%   (0/1)0%   (0/5)0%   (0/43)0%   (0/10)
QMLContractTypeEditor$ReverseAdapterFactoryContentProvider (QMLContractTypeEd... 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.dsexplore.qml.contracttype.QMLContractType.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.ComposeableAdapterFactory;
58import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
59import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory;
60import org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory;
61import org.eclipse.emf.edit.ui.action.EditingDomainActionBarContributor;
62import org.eclipse.emf.edit.ui.celleditor.AdapterFactoryTreeEditor;
63import org.eclipse.emf.edit.ui.dnd.EditingDomainViewerDropAdapter;
64import org.eclipse.emf.edit.ui.dnd.LocalTransfer;
65import org.eclipse.emf.edit.ui.dnd.ViewerDragAdapter;
66import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
67import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
68import org.eclipse.emf.edit.ui.provider.UnwrappingSelectionProvider;
69import org.eclipse.emf.edit.ui.util.EditUIMarkerHelper;
70import org.eclipse.emf.edit.ui.util.EditUIUtil;
71import org.eclipse.emf.edit.ui.view.ExtendedPropertySheetPage;
72import org.eclipse.jface.action.IMenuListener;
73import org.eclipse.jface.action.IMenuManager;
74import org.eclipse.jface.action.IStatusLineManager;
75import org.eclipse.jface.action.IToolBarManager;
76import org.eclipse.jface.action.MenuManager;
77import org.eclipse.jface.action.Separator;
78import org.eclipse.jface.dialogs.MessageDialog;
79import org.eclipse.jface.dialogs.ProgressMonitorDialog;
80import org.eclipse.jface.viewers.ColumnWeightData;
81import org.eclipse.jface.viewers.ISelection;
82import org.eclipse.jface.viewers.ISelectionChangedListener;
83import org.eclipse.jface.viewers.ISelectionProvider;
84import org.eclipse.jface.viewers.IStructuredSelection;
85import org.eclipse.jface.viewers.ListViewer;
86import org.eclipse.jface.viewers.SelectionChangedEvent;
87import org.eclipse.jface.viewers.StructuredSelection;
88import org.eclipse.jface.viewers.StructuredViewer;
89import org.eclipse.jface.viewers.TableLayout;
90import org.eclipse.jface.viewers.TableViewer;
91import org.eclipse.jface.viewers.TreeViewer;
92import org.eclipse.jface.viewers.Viewer;
93import org.eclipse.swt.SWT;
94import org.eclipse.swt.custom.CTabFolder;
95import org.eclipse.swt.dnd.DND;
96import org.eclipse.swt.dnd.Transfer;
97import org.eclipse.swt.events.ControlAdapter;
98import org.eclipse.swt.events.ControlEvent;
99import org.eclipse.swt.graphics.Point;
100import org.eclipse.swt.layout.FillLayout;
101import org.eclipse.swt.widgets.Composite;
102import org.eclipse.swt.widgets.Menu;
103import org.eclipse.swt.widgets.Table;
104import org.eclipse.swt.widgets.TableColumn;
105import org.eclipse.swt.widgets.Tree;
106import org.eclipse.swt.widgets.TreeColumn;
107import org.eclipse.ui.IActionBars;
108import org.eclipse.ui.IEditorInput;
109import org.eclipse.ui.IEditorPart;
110import org.eclipse.ui.IEditorSite;
111import org.eclipse.ui.IPartListener;
112import org.eclipse.ui.IWorkbenchPart;
113import org.eclipse.ui.PartInitException;
114import org.eclipse.ui.actions.WorkspaceModifyOperation;
115import org.eclipse.ui.dialogs.SaveAsDialog;
116import org.eclipse.ui.ide.IGotoMarker;
117import org.eclipse.ui.part.FileEditorInput;
118import org.eclipse.ui.part.MultiPageEditorPart;
119import org.eclipse.ui.views.contentoutline.ContentOutline;
120import org.eclipse.ui.views.contentoutline.ContentOutlinePage;
121import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
122import org.eclipse.ui.views.properties.IPropertySheetPage;
123import org.eclipse.ui.views.properties.PropertySheet;
124import org.eclipse.ui.views.properties.PropertySheetPage;
125 
126import de.uka.ipd.sdq.dsexplore.qml.profile.QMLProfile.presentation.QMLProfileEditorPlugin;
127import de.uka.ipd.sdq.identifier.provider.IdentifierItemProviderAdapterFactory;
128import de.uka.ipd.sdq.pcm.allocation.provider.AllocationItemProviderAdapterFactory;
129import de.uka.ipd.sdq.pcm.core.composition.provider.CompositionItemProviderAdapterFactory;
130import de.uka.ipd.sdq.pcm.core.entity.provider.EntityItemProviderAdapterFactory;
131import de.uka.ipd.sdq.pcm.core.provider.CoreItemProviderAdapterFactory;
132import de.uka.ipd.sdq.pcm.parameter.provider.ParameterItemProviderAdapterFactory;
133import de.uka.ipd.sdq.pcm.protocol.provider.ProtocolItemProviderAdapterFactory;
134import de.uka.ipd.sdq.pcm.qosannotations.provider.QosannotationsItemProviderAdapterFactory;
135import de.uka.ipd.sdq.pcm.qosannotations.qos_performance.provider.Qos_performanceItemProviderAdapterFactory;
136import de.uka.ipd.sdq.pcm.qosannotations.qos_reliability.provider.Qos_reliabilityItemProviderAdapterFactory;
137import de.uka.ipd.sdq.pcm.repository.provider.RepositoryItemProviderAdapterFactory;
138import de.uka.ipd.sdq.pcm.resourceenvironment.provider.ResourceenvironmentItemProviderAdapterFactory;
139import de.uka.ipd.sdq.pcm.resourcetype.provider.ResourcetypeItemProviderAdapterFactory;
140import de.uka.ipd.sdq.pcm.seff.provider.SeffItemProviderAdapterFactory;
141import de.uka.ipd.sdq.pcm.seff.seff_performance.provider.Seff_performanceItemProviderAdapterFactory;
142import de.uka.ipd.sdq.pcm.subsystem.provider.SubsystemItemProviderAdapterFactory;
143import de.uka.ipd.sdq.pcm.system.provider.SystemItemProviderAdapterFactory;
144import de.uka.ipd.sdq.pcm.usagemodel.provider.UsagemodelItemProviderAdapterFactory;
145import de.uka.ipd.sdq.pcmbench.propertytabs.PalladioAdapterFactoryContentProvider;
146import de.uka.ipd.sdq.pcmbench.ui.provider.PalladioItemProviderAdapterFactory;
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 QMLContractType model editor.
154 * <!-- begin-user-doc -->
155 * <!-- end-user-doc -->
156 * @generated
157 */
158public class QMLContractTypeEditor
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 not
174         */
175        protected AdapterFactory 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(QMLContractTypeEditor.this);
321 
322                                                setCurrentViewer(contentOutlineViewer);
323                                        }
324                                }
325                                else if (p instanceof PropertySheet) {
326                                        if (((PropertySheet)p).getCurrentPage() == propertySheetPage) {
327                                                getActionBarContributor().setActiveEditor(QMLContractTypeEditor.this);
328                                                handleActivate();
329                                        }
330                                }
331                                else if (p == QMLContractTypeEditor.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(QMLContractTypeEditor.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() == QMLContractTypeEditor.this) {
506                                                                                 handleActivate();
507                                                                         }
508                                                                 }
509                                                         });
510                                        }
511                                }
512                                catch (CoreException exception) {
513                                        QMLProfileEditorPlugin.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(QMLContractTypeEditor.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.dsexplore.qml.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                                        QMLProfileEditorPlugin.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                                                QMLProfileEditorPlugin.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 QMLContractTypeEditor() {
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 not
677         */
678        protected void initializeEditingDomain() {
679                // Create an adapter factory that yields item providers.
680                //
681                ComposedAdapterFactory compAdapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE) {
682                        @Override
683                        public ComposeableAdapterFactory getRootAdapterFactory() {
684                                // TODO Auto-generated method stub
685                                return (PalladioItemProviderAdapterFactory)adapterFactory;
686                        }
687                };
688 
689 
690                compAdapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory());
691                compAdapterFactory.addAdapterFactory(new CoreItemProviderAdapterFactory());
692                compAdapterFactory.addAdapterFactory(new EntityItemProviderAdapterFactory());
693                compAdapterFactory.addAdapterFactory(new CompositionItemProviderAdapterFactory());
694                compAdapterFactory.addAdapterFactory(new RepositoryItemProviderAdapterFactory());
695                compAdapterFactory.addAdapterFactory(new ProtocolItemProviderAdapterFactory());
696                compAdapterFactory.addAdapterFactory(new SubsystemItemProviderAdapterFactory());
697                compAdapterFactory.addAdapterFactory(new ParameterItemProviderAdapterFactory());
698                compAdapterFactory.addAdapterFactory(new SeffItemProviderAdapterFactory());
699                compAdapterFactory.addAdapterFactory(new Seff_performanceItemProviderAdapterFactory());
700                compAdapterFactory.addAdapterFactory(new AllocationItemProviderAdapterFactory());
701                compAdapterFactory.addAdapterFactory(new ResourceenvironmentItemProviderAdapterFactory());
702                compAdapterFactory.addAdapterFactory(new ResourcetypeItemProviderAdapterFactory());
703                compAdapterFactory.addAdapterFactory(new SystemItemProviderAdapterFactory());
704                compAdapterFactory.addAdapterFactory(new QosannotationsItemProviderAdapterFactory());
705                compAdapterFactory.addAdapterFactory(new Qos_performanceItemProviderAdapterFactory());
706                compAdapterFactory.addAdapterFactory(new Qos_reliabilityItemProviderAdapterFactory());
707                compAdapterFactory.addAdapterFactory(new UsagemodelItemProviderAdapterFactory());
708                compAdapterFactory.addAdapterFactory(new IdentifierItemProviderAdapterFactory());
709                compAdapterFactory.addAdapterFactory(new StoexItemProviderAdapterFactory());
710                compAdapterFactory.addAdapterFactory(new UnitsItemProviderAdapterFactory());
711                compAdapterFactory.addAdapterFactory(new ProbfunctionItemProviderAdapterFactory());
712                compAdapterFactory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory());
713 
714                adapterFactory = new PalladioItemProviderAdapterFactory(compAdapterFactory);
715 
716                
717                // Create the command stack that will notify this editor as commands are executed.
718                //
719                BasicCommandStack commandStack = new BasicCommandStack();
720 
721                // Add a listener to set the most recent command's affected objects to be the selection of the viewer with focus.
722                //
723                commandStack.addCommandStackListener
724                        (new CommandStackListener() {
725                                 public void commandStackChanged(final EventObject event) {
726                                         getContainer().getDisplay().asyncExec
727                                                 (new Runnable() {
728                                                          public void run() {
729                                                                  firePropertyChange(IEditorPart.PROP_DIRTY);
730 
731                                                                  // Try to select the affected objects.
732                                                                  //
733                                                                  Command mostRecentCommand = ((CommandStack)event.getSource()).getMostRecentCommand();
734                                                                  if (mostRecentCommand != null) {
735                                                                          setSelectionToViewer(mostRecentCommand.getAffectedObjects());
736                                                                  }
737                                                                  if (propertySheetPage != null && !propertySheetPage.getControl().isDisposed()) {
738                                                                          propertySheetPage.refresh();
739                                                                  }
740                                                          }
741                                                  });
742                                 }
743                         });
744 
745                // Create the editing domain with a special command stack.
746                //
747                editingDomain = new AdapterFactoryEditingDomain(adapterFactory, commandStack, new HashMap<Resource, Boolean>());
748        }
749 
750        /**
751         * This is here for the listener to be able to call it.
752         * <!-- begin-user-doc -->
753         * <!-- end-user-doc -->
754         * @generated
755         */
756                        @Override
757        protected void firePropertyChange(int action) {
758                super.firePropertyChange(action);
759        }
760 
761        /**
762         * This sets the selection into whichever viewer is active.
763         * <!-- begin-user-doc -->
764         * <!-- end-user-doc -->
765         * @generated
766         */
767        public void setSelectionToViewer(Collection<?> collection) {
768                final Collection<?> theSelection = collection;
769                // Make sure it's okay.
770                //
771                if (theSelection != null && !theSelection.isEmpty()) {
772                        Runnable runnable =
773                                new Runnable() {
774                                        public void run() {
775                                                // Try to select the items in the current content viewer of the editor.
776                                                //
777                                                if (currentViewer != null) {
778                                                        currentViewer.setSelection(new StructuredSelection(theSelection.toArray()), true);
779                                                }
780                                        }
781                                };
782                        getSite().getShell().getDisplay().asyncExec(runnable);
783                }
784        }
785 
786        /**
787         * This returns the editing domain as required by the {@link IEditingDomainProvider} interface.
788         * This is important for implementing the static methods of {@link AdapterFactoryEditingDomain}
789         * and for supporting {@link org.eclipse.emf.edit.ui.action.CommandAction}.
790         * <!-- begin-user-doc -->
791         * <!-- end-user-doc -->
792         * @generated
793         */
794        public EditingDomain getEditingDomain() {
795                return editingDomain;
796        }
797 
798        /**
799         * <!-- begin-user-doc -->
800         * <!-- end-user-doc -->
801         * @generated
802         */
803        public class ReverseAdapterFactoryContentProvider extends AdapterFactoryContentProvider {
804                /**
805                 * <!-- begin-user-doc -->
806                 * <!-- end-user-doc -->
807                 * @generated
808                 */
809                public ReverseAdapterFactoryContentProvider(AdapterFactory adapterFactory) {
810                        super(adapterFactory);
811                }
812 
813                /**
814                 * <!-- begin-user-doc -->
815                 * <!-- end-user-doc -->
816                 * @generated
817                 */
818                @Override
819                public Object [] getElements(Object object) {
820                        Object parent = super.getParent(object);
821                        return (parent == null ? Collections.EMPTY_SET : Collections.singleton(parent)).toArray();
822                }
823 
824                /**
825                 * <!-- begin-user-doc -->
826                 * <!-- end-user-doc -->
827                 * @generated
828                 */
829                @Override
830                public Object [] getChildren(Object object) {
831                        Object parent = super.getParent(object);
832                        return (parent == null ? Collections.EMPTY_SET : Collections.singleton(parent)).toArray();
833                }
834 
835                /**
836                 * <!-- begin-user-doc -->
837                 * <!-- end-user-doc -->
838                 * @generated
839                 */
840                @Override
841                public boolean hasChildren(Object object) {
842                        Object parent = super.getParent(object);
843                        return parent != null;
844                }
845 
846                /**
847                 * <!-- begin-user-doc -->
848                 * <!-- end-user-doc -->
849                 * @generated
850                 */
851                @Override
852                public Object getParent(Object object) {
853                        return null;
854                }
855        }
856 
857        /**
858         * <!-- begin-user-doc -->
859         * <!-- end-user-doc -->
860         * @generated
861         */
862        public void setCurrentViewerPane(ViewerPane viewerPane) {
863                if (currentViewerPane != viewerPane) {
864                        if (currentViewerPane != null) {
865                                currentViewerPane.showFocus(false);
866                        }
867                        currentViewerPane = viewerPane;
868                }
869                setCurrentViewer(currentViewerPane.getViewer());
870        }
871 
872        /**
873         * This makes sure that one content viewer, either for the current page or the outline view, if it has focus,
874         * is the current one.
875         * <!-- begin-user-doc -->
876         * <!-- end-user-doc -->
877         * @generated
878         */
879        public void setCurrentViewer(Viewer viewer) {
880                // If it is changing...
881                //
882                if (currentViewer != viewer) {
883                        if (selectionChangedListener == null) {
884                                // Create the listener on demand.
885                                //
886                                selectionChangedListener =
887                                        new ISelectionChangedListener() {
888                                                // This just notifies those things that are affected by the section.
889                                                //
890                                                public void selectionChanged(SelectionChangedEvent selectionChangedEvent) {
891                                                        setSelection(selectionChangedEvent.getSelection());
892                                                }
893                                        };
894                        }
895 
896                        // Stop listening to the old one.
897                        //
898                        if (currentViewer != null) {
899                                currentViewer.removeSelectionChangedListener(selectionChangedListener);
900                        }
901 
902                        // Start listening to the new one.
903                        //
904                        if (viewer != null) {
905                                viewer.addSelectionChangedListener(selectionChangedListener);
906                        }
907 
908                        // Remember it.
909                        //
910                        currentViewer = viewer;
911 
912                        // Set the editors selection based on the current viewer's selection.
913                        //
914                        setSelection(currentViewer == null ? StructuredSelection.EMPTY : currentViewer.getSelection());
915                }
916        }
917 
918        /**
919         * This returns the viewer as required by the {@link IViewerProvider} interface.
920         * <!-- begin-user-doc -->
921         * <!-- end-user-doc -->
922         * @generated
923         */
924        public Viewer getViewer() {
925                return currentViewer;
926        }
927 
928        /**
929         * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
930         * <!-- begin-user-doc -->
931         * <!-- end-user-doc -->
932         * @generated
933         */
934        protected void createContextMenuFor(StructuredViewer viewer) {
935                MenuManager contextMenu = new MenuManager("#PopUp");
936                contextMenu.add(new Separator("additions"));
937                contextMenu.setRemoveAllWhenShown(true);
938                contextMenu.addMenuListener(this);
939                Menu menu= contextMenu.createContextMenu(viewer.getControl());
940                viewer.getControl().setMenu(menu);
941                getSite().registerContextMenu(contextMenu, new UnwrappingSelectionProvider(viewer));
942 
943                int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
944                Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance() };
945                viewer.addDragSupport(dndOperations, transfers, new ViewerDragAdapter(viewer));
946                viewer.addDropSupport(dndOperations, transfers, new EditingDomainViewerDropAdapter(editingDomain, viewer));
947        }
948 
949        /**
950         * This is the method called to load a resource into the editing domain's resource set based on the editor's input.
951         * <!-- begin-user-doc -->
952         * <!-- end-user-doc -->
953         * @generated
954         */
955        public void createModel() {
956                URI resourceURI = EditUIUtil.getURI(getEditorInput());
957                Exception exception = null;
958                Resource resource = null;
959                try {
960                        // Load the resource through the editing domain.
961                        //
962                        resource = editingDomain.getResourceSet().getResource(resourceURI, true);
963                }
964                catch (Exception e) {
965                        exception = e;
966                        resource = editingDomain.getResourceSet().getResource(resourceURI, false);
967                }
968 
969                Diagnostic diagnostic = analyzeResourceProblems(resource, exception);
970                if (diagnostic.getSeverity() != Diagnostic.OK) {
971                        resourceToDiagnosticMap.put(resource,  analyzeResourceProblems(resource, exception));
972                }
973                editingDomain.getResourceSet().eAdapters().add(problemIndicationAdapter);
974        }
975 
976        /**
977         * Returns a diagnostic describing the errors and warnings listed in the resource
978         * and the specified exception (if any).
979         * <!-- begin-user-doc -->
980         * <!-- end-user-doc -->
981         * @generated
982         */
983        public Diagnostic analyzeResourceProblems(Resource resource, Exception exception) {
984                if (!resource.getErrors().isEmpty() || !resource.getWarnings().isEmpty()) {
985                        BasicDiagnostic basicDiagnostic =
986                                new BasicDiagnostic
987                                        (Diagnostic.ERROR,
988                                         "de.uka.ipd.sdq.dsexplore.qml.editor",
989                                         0,
990                                         getString("_UI_CreateModelError_message", resource.getURI()),
991                                         new Object [] { exception == null ? (Object)resource : exception });
992                        basicDiagnostic.merge(EcoreUtil.computeDiagnostic(resource, true));
993                        return basicDiagnostic;
994                }
995                else if (exception != null) {
996                        return
997                                new BasicDiagnostic
998                                        (Diagnostic.ERROR,
999                                         "de.uka.ipd.sdq.dsexplore.qml.editor",
1000                                         0,
1001                                         getString("_UI_CreateModelError_message", resource.getURI()),
1002                                         new Object[] { exception });
1003                }
1004                else {
1005                        return Diagnostic.OK_INSTANCE;
1006                }
1007        }
1008 
1009        /**
1010         * This is the method used by the framework to install your own controls.
1011         * <!-- begin-user-doc -->
1012         * <!-- end-user-doc -->
1013         * @generated
1014         */
1015        @Override
1016        public void createPages() {
1017                // Creates the model from the editor input
1018                //
1019                createModel();
1020 
1021                // Only creates the other pages if there is something that can be edited
1022                //
1023                if (!getEditingDomain().getResourceSet().getResources().isEmpty()) {
1024                        // Create a page for the selection tree view.
1025                        //
1026                        {
1027                                ViewerPane viewerPane =
1028                                        new ViewerPane(getSite().getPage(), QMLContractTypeEditor.this) {
1029                                                @Override
1030                                                public Viewer createViewer(Composite composite) {
1031                                                        Tree tree = new Tree(composite, SWT.MULTI);
1032                                                        TreeViewer newTreeViewer = new TreeViewer(tree);
1033                                                        return newTreeViewer;
1034                                                }
1035                                                @Override
1036                                                public void requestActivation() {
1037                                                        super.requestActivation();
1038                                                        setCurrentViewerPane(this);
1039                                                }
1040                                        };
1041                                viewerPane.createControl(getContainer());
1042 
1043                                selectionViewer = (TreeViewer)viewerPane.getViewer();
1044                                selectionViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
1045 
1046                                selectionViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
1047                                selectionViewer.setInput(editingDomain.getResourceSet());
1048                                selectionViewer.setSelection(new StructuredSelection(editingDomain.getResourceSet().getResources().get(0)), true);
1049                                viewerPane.setTitle(editingDomain.getResourceSet());
1050 
1051                                new AdapterFactoryTreeEditor(selectionViewer.getTree(), adapterFactory);
1052 
1053                                createContextMenuFor(selectionViewer);
1054                                int pageIndex = addPage(viewerPane.getControl());
1055                                setPageText(pageIndex, getString("_UI_SelectionPage_label"));
1056                        }
1057 
1058                        // Create a page for the parent tree view.
1059                        //
1060                        {
1061                                ViewerPane viewerPane =
1062                                        new ViewerPane(getSite().getPage(), QMLContractTypeEditor.this) {
1063                                                @Override
1064                                                public Viewer createViewer(Composite composite) {
1065                                                        Tree tree = new Tree(composite, SWT.MULTI);
1066                                                        TreeViewer newTreeViewer = new TreeViewer(tree);
1067                                                        return newTreeViewer;
1068                                                }
1069                                                @Override
1070                                                public void requestActivation() {
1071                                                        super.requestActivation();
1072                                                        setCurrentViewerPane(this);
1073                                                }
1074                                        };
1075                                viewerPane.createControl(getContainer());
1076 
1077                                parentViewer = (TreeViewer)viewerPane.getViewer();
1078                                parentViewer.setAutoExpandLevel(30);
1079                                parentViewer.setContentProvider(new ReverseAdapterFactoryContentProvider(adapterFactory));
1080                                parentViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
1081 
1082                                createContextMenuFor(parentViewer);
1083                                int pageIndex = addPage(viewerPane.getControl());
1084                                setPageText(pageIndex, getString("_UI_ParentPage_label"));
1085                        }
1086 
1087                        // This is the page for the list viewer
1088                        //
1089                        {
1090                                ViewerPane viewerPane =
1091                                        new ViewerPane(getSite().getPage(), QMLContractTypeEditor.this) {
1092                                                @Override
1093                                                public Viewer createViewer(Composite composite) {
1094                                                        return new ListViewer(composite);
1095                                                }
1096                                                @Override
1097                                                public void requestActivation() {
1098                                                        super.requestActivation();
1099                                                        setCurrentViewerPane(this);
1100                                                }
1101                                        };
1102                                viewerPane.createControl(getContainer());
1103                                listViewer = (ListViewer)viewerPane.getViewer();
1104                                listViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
1105                                listViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
1106 
1107                                createContextMenuFor(listViewer);
1108                                int pageIndex = addPage(viewerPane.getControl());
1109                                setPageText(pageIndex, getString("_UI_ListPage_label"));
1110                        }
1111 
1112                        // This is the page for the tree viewer
1113                        //
1114                        {
1115                                ViewerPane viewerPane =
1116                                        new ViewerPane(getSite().getPage(), QMLContractTypeEditor.this) {
1117                                                @Override
1118                                                public Viewer createViewer(Composite composite) {
1119                                                        return new TreeViewer(composite);
1120                                                }
1121                                                @Override
1122                                                public void requestActivation() {
1123                                                        super.requestActivation();
1124                                                        setCurrentViewerPane(this);
1125                                                }
1126                                        };
1127                                viewerPane.createControl(getContainer());
1128                                treeViewer = (TreeViewer)viewerPane.getViewer();
1129                                treeViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
1130                                treeViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
1131 
1132                                new AdapterFactoryTreeEditor(treeViewer.getTree(), adapterFactory);
1133 
1134                                createContextMenuFor(treeViewer);
1135                                int pageIndex = addPage(viewerPane.getControl());
1136                                setPageText(pageIndex, getString("_UI_TreePage_label"));
1137                        }
1138 
1139                        // This is the page for the table viewer.
1140                        //
1141                        {
1142                                ViewerPane viewerPane =
1143                                        new ViewerPane(getSite().getPage(), QMLContractTypeEditor.this) {
1144                                                @Override
1145                                                public Viewer createViewer(Composite composite) {
1146                                                        return new TableViewer(composite);
1147                                                }
1148                                                @Override
1149                                                public void requestActivation() {
1150                                                        super.requestActivation();
1151                                                        setCurrentViewerPane(this);
1152                                                }
1153                                        };
1154                                viewerPane.createControl(getContainer());
1155                                tableViewer = (TableViewer)viewerPane.getViewer();
1156 
1157                                Table table = tableViewer.getTable();
1158                                TableLayout layout = new TableLayout();
1159                                table.setLayout(layout);
1160                                table.setHeaderVisible(true);
1161                                table.setLinesVisible(true);
1162 
1163                                TableColumn objectColumn = new TableColumn(table, SWT.NONE);
1164                                layout.addColumnData(new ColumnWeightData(3, 100, true));
1165                                objectColumn.setText(getString("_UI_ObjectColumn_label"));
1166                                objectColumn.setResizable(true);
1167 
1168                                TableColumn selfColumn = new TableColumn(table, SWT.NONE);
1169                                layout.addColumnData(new ColumnWeightData(2, 100, true));
1170                                selfColumn.setText(getString("_UI_SelfColumn_label"));
1171                                selfColumn.setResizable(true);
1172 
1173                                tableViewer.setColumnProperties(new String [] {"a", "b"});
1174                                tableViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
1175                                tableViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
1176 
1177                                createContextMenuFor(tableViewer);
1178                                int pageIndex = addPage(viewerPane.getControl());
1179                                setPageText(pageIndex, getString("_UI_TablePage_label"));
1180                        }
1181 
1182                        // This is the page for the table tree viewer.
1183                        //
1184                        {
1185                                ViewerPane viewerPane =
1186                                        new ViewerPane(getSite().getPage(), QMLContractTypeEditor.this) {
1187                                                @Override
1188                                                public Viewer createViewer(Composite composite) {
1189                                                        return new TreeViewer(composite);
1190                                                }
1191                                                @Override
1192                                                public void requestActivation() {
1193                                                        super.requestActivation();
1194                                                        setCurrentViewerPane(this);
1195                                                }
1196                                        };
1197                                viewerPane.createControl(getContainer());
1198 
1199                                treeViewerWithColumns = (TreeViewer)viewerPane.getViewer();
1200 
1201                                Tree tree = treeViewerWithColumns.getTree();
1202                                tree.setLayoutData(new FillLayout());
1203                                tree.setHeaderVisible(true);
1204                                tree.setLinesVisible(true);
1205 
1206                                TreeColumn objectColumn = new TreeColumn(tree, SWT.NONE);
1207                                objectColumn.setText(getString("_UI_ObjectColumn_label"));
1208                                objectColumn.setResizable(true);
1209                                objectColumn.setWidth(250);
1210 
1211                                TreeColumn selfColumn = new TreeColumn(tree, SWT.NONE);
1212                                selfColumn.setText(getString("_UI_SelfColumn_label"));
1213                                selfColumn.setResizable(true);
1214                                selfColumn.setWidth(200);
1215 
1216                                treeViewerWithColumns.setColumnProperties(new String [] {"a", "b"});
1217                                treeViewerWithColumns.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
1218                                treeViewerWithColumns.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
1219 
1220                                createContextMenuFor(treeViewerWithColumns);
1221                                int pageIndex = addPage(viewerPane.getControl());
1222                                setPageText(pageIndex, getString("_UI_TreeWithColumnsPage_label"));
1223                        }
1224 
1225                        getSite().getShell().getDisplay().asyncExec
1226                                (new Runnable() {
1227                                         public void run() {
1228                                                 setActivePage(0);
1229                                         }
1230                                 });
1231                }
1232 
1233                // Ensures that this editor will only display the page's tab
1234                // area if there are more than one page
1235                //
1236                getContainer().addControlListener
1237                        (new ControlAdapter() {
1238                                boolean guard = false;
1239                                @Override
1240                                public void controlResized(ControlEvent event) {
1241                                        if (!guard) {
1242                                                guard = true;
1243                                                hideTabs();
1244                                                guard = false;
1245                                        }
1246                                }
1247                         });
1248 
1249                getSite().getShell().getDisplay().asyncExec
1250                        (new Runnable() {
1251                                 public void run() {
1252                                         updateProblemIndication();
1253                                 }
1254                         });
1255        }
1256 
1257        /**
1258         * If there is just one page in the multi-page editor part,
1259         * this hides the single tab at the bottom.
1260         * <!-- begin-user-doc -->
1261         * <!-- end-user-doc -->
1262         * @generated
1263         */
1264        protected void hideTabs() {
1265                if (getPageCount() <= 1) {
1266                        setPageText(0, "");
1267                        if (getContainer() instanceof CTabFolder) {
1268                                ((CTabFolder)getContainer()).setTabHeight(1);
1269                                Point point = getContainer().getSize();
1270                                getContainer().setSize(point.x, point.y + 6);
1271                        }
1272                }
1273        }
1274 
1275        /**
1276         * If there is more than one page in the multi-page editor part,
1277         * this shows the tabs at the bottom.
1278         * <!-- begin-user-doc -->
1279         * <!-- end-user-doc -->
1280         * @generated
1281         */
1282        protected void showTabs() {
1283                if (getPageCount() > 1) {
1284                        setPageText(0, getString("_UI_SelectionPage_label"));
1285                        if (getContainer() instanceof CTabFolder) {
1286                                ((CTabFolder)getContainer()).setTabHeight(SWT.DEFAULT);
1287                                Point point = getContainer().getSize();
1288                                getContainer().setSize(point.x, point.y - 6);
1289                        }
1290                }
1291        }
1292 
1293        /**
1294         * This is used to track the active viewer.
1295         * <!-- begin-user-doc -->
1296         * <!-- end-user-doc -->
1297         * @generated
1298         */
1299        @Override
1300        protected void pageChange(int pageIndex) {
1301                super.pageChange(pageIndex);
1302 
1303                if (contentOutlinePage != null) {
1304                        handleContentOutlineSelection(contentOutlinePage.getSelection());
1305                }
1306        }
1307 
1308        /**
1309         * This is how the framework determines which interfaces we implement.
1310         * <!-- begin-user-doc -->
1311         * <!-- end-user-doc -->
1312         * @generated
1313         */
1314        @SuppressWarnings("unchecked")
1315        @Override
1316        public Object getAdapter(Class key) {
1317                if (key.equals(IContentOutlinePage.class)) {
1318                        return showOutlineView() ? getContentOutlinePage() : null;
1319                }
1320                else if (key.equals(IPropertySheetPage.class)) {
1321                        return getPropertySheetPage();
1322                }
1323                else if (key.equals(IGotoMarker.class)) {
1324                        return this;
1325                }
1326                else {
1327                        return super.getAdapter(key);
1328                }
1329        }
1330 
1331        /**
1332         * This accesses a cached version of the content outliner.
1333         * <!-- begin-user-doc -->
1334         * <!-- end-user-doc -->
1335         * @generated
1336         */
1337        public IContentOutlinePage getContentOutlinePage() {
1338                if (contentOutlinePage == null) {
1339                        // The content outline is just a tree.
1340                        //
1341                        class MyContentOutlinePage extends ContentOutlinePage {
1342                                @Override
1343                                public void createControl(Composite parent) {
1344                                        super.createControl(parent);
1345                                        contentOutlineViewer = getTreeViewer();
1346                                        contentOutlineViewer.addSelectionChangedListener(this);
1347 
1348                                        // Set up the tree viewer.
1349                                        //
1350                                        contentOutlineViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
1351                                        contentOutlineViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
1352                                        contentOutlineViewer.setInput(editingDomain.getResourceSet());
1353 
1354                                        // Make sure our popups work.
1355                                        //
1356                                        createContextMenuFor(contentOutlineViewer);
1357 
1358                                        if (!editingDomain.getResourceSet().getResources().isEmpty()) {
1359                                          // Select the root object in the view.
1360                                          //
1361                                          contentOutlineViewer.setSelection(new StructuredSelection(editingDomain.getResourceSet().getResources().get(0)), true);
1362                                        }
1363                                }
1364 
1365                                @Override
1366                                public void makeContributions(IMenuManager menuManager, IToolBarManager toolBarManager, IStatusLineManager statusLineManager) {
1367                                        super.makeContributions(menuManager, toolBarManager, statusLineManager);
1368                                        contentOutlineStatusLineManager = statusLineManager;
1369                                }
1370 
1371                                @Override
1372                                public void setActionBars(IActionBars actionBars) {
1373                                        super.setActionBars(actionBars);
1374                                        getActionBarContributor().shareGlobalActions(this, actionBars);
1375                                }
1376                        }
1377 
1378                        contentOutlinePage = new MyContentOutlinePage();
1379 
1380                        // Listen to selection so that we can handle it is a special way.
1381                        //
1382                        contentOutlinePage.addSelectionChangedListener
1383                                (new ISelectionChangedListener() {
1384                                         // This ensures that we handle selections correctly.
1385                                         //
1386                                         public void selectionChanged(SelectionChangedEvent event) {
1387                                                 handleContentOutlineSelection(event.getSelection());
1388                                         }
1389                                 });
1390                }
1391 
1392                return contentOutlinePage;
1393        }
1394 
1395        /**
1396         * This accesses a cached version of the property sheet.
1397         * <!-- begin-user-doc -->
1398         * <!-- end-user-doc -->
1399         * @generated not
1400         */
1401        public IPropertySheetPage getPropertySheetPage() {
1402                if (propertySheetPage == null) {
1403                        propertySheetPage =
1404                                new ExtendedPropertySheetPage(editingDomain) {
1405                                        @Override
1406                                        public void setSelectionToViewer(List<?> selection) {
1407                                                QMLContractTypeEditor.this.setSelectionToViewer(selection);
1408                                                QMLContractTypeEditor.this.setFocus();
1409                                        }
1410 
1411                                        @Override
1412                                        public void setActionBars(IActionBars actionBars) {
1413                                                super.setActionBars(actionBars);
1414                                                getActionBarContributor().shareGlobalActions(this, actionBars);
1415                                        }
1416                                };
1417                                propertySheetPage.setPropertySourceProvider(new PalladioAdapterFactoryContentProvider(adapterFactory));
1418                }
1419 
1420                return propertySheetPage;
1421        }
1422 
1423        /**
1424         * This deals with how we want selection in the outliner to affect the other views.
1425         * <!-- begin-user-doc -->
1426         * <!-- end-user-doc -->
1427         * @generated
1428         */
1429        public void handleContentOutlineSelection(ISelection selection) {
1430                if (currentViewerPane != null && !selection.isEmpty() && selection instanceof IStructuredSelection) {
1431                        Iterator<?> selectedElements = ((IStructuredSelection)selection).iterator();
1432                        if (selectedElements.hasNext()) {
1433                                // Get the first selected element.
1434                                //
1435                                Object selectedElement = selectedElements.next();
1436 
1437                                // If it's the selection viewer, then we want it to select the same selection as this selection.
1438                                //
1439                                if (currentViewerPane.getViewer() == selectionViewer) {
1440                                        ArrayList<Object> selectionList = new ArrayList<Object>();
1441                                        selectionList.add(selectedElement);
1442                                        while (selectedElements.hasNext()) {
1443                                                selectionList.add(selectedElements.next());
1444                                        }
1445 
1446                                        // Set the selection to the widget.
1447                                        //
1448                                        selectionViewer.setSelection(new StructuredSelection(selectionList));
1449                                }
1450                                else {
1451                                        // Set the input to the widget.
1452                                        //
1453                                        if (currentViewerPane.getViewer().getInput() != selectedElement) {
1454                                                currentViewerPane.getViewer().setInput(selectedElement);
1455                                                currentViewerPane.setTitle(selectedElement);
1456                                        }
1457                                }
1458                        }
1459                }
1460        }
1461 
1462        /**
1463         * This is for implementing {@link IEditorPart} and simply tests the command stack.
1464         * <!-- begin-user-doc -->
1465         * <!-- end-user-doc -->
1466         * @generated
1467         */
1468        @Override
1469        public boolean isDirty() {
1470                return ((BasicCommandStack)editingDomain.getCommandStack()).isSaveNeeded();
1471        }
1472 
1473        /**
1474         * This is for implementing {@link IEditorPart} and simply saves the model file.
1475         * <!-- begin-user-doc -->
1476         * <!-- end-user-doc -->
1477         * @generated
1478         */
1479        @Override
1480        public void doSave(IProgressMonitor progressMonitor) {
1481                // Save only resources that have actually changed.
1482                //
1483                final Map<Object, Object> saveOptions = new HashMap<Object, Object>();
1484                saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED, Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER);
1485 
1486                // Do the work within an operation because this is a long running activity that modifies the workbench.
1487                //
1488                WorkspaceModifyOperation operation =
1489                        new WorkspaceModifyOperation() {
1490                                // This is the method that gets invoked when the operation runs.
1491                                //
1492                                @Override
1493                                public void execute(IProgressMonitor monitor) {
1494                                        // Save the resources to the file system.
1495                                        //
1496                                        boolean first = true;
1497                                        for (Resource resource : editingDomain.getResourceSet().getResources()) {
1498                                                if ((first || !resource.getContents().isEmpty() || isPersisted(resource)) && !editingDomain.isReadOnly(resource)) {
1499                                                        try {
1500                                                                long timeStamp = resource.getTimeStamp();
1501                                                                resource.save(saveOptions);
1502                                                                if (resource.getTimeStamp() != timeStamp) {
1503                                                                        savedResources.add(resource);
1504                                                                }
1505                                                        }
1506                                                        catch (Exception exception) {
1507                                                                resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception));
1508                                                        }
1509                                                        first = false;
1510                                                }
1511                                        }
1512                                }
1513                        };
1514 
1515                updateProblemIndication = false;
1516                try {
1517                        // This runs the options, and shows progress.
1518                        //
1519                        new ProgressMonitorDialog(getSite().getShell()).run(true, false, operation);
1520 
1521                        // Refresh the necessary state.
1522                        //
1523                        ((BasicCommandStack)editingDomain.getCommandStack()).saveIsDone();
1524                        firePropertyChange(IEditorPart.PROP_DIRTY);
1525                }
1526                catch (Exception exception) {
1527                        // Something went wrong that shouldn't.
1528                        //
1529                        QMLProfileEditorPlugin.INSTANCE.log(exception);
1530                }
1531                updateProblemIndication = true;
1532                updateProblemIndication();
1533        }
1534 
1535        /**
1536         * This returns whether something has been persisted to the URI of the specified resource.
1537         * The implementation uses the URI converter from the editor's resource set to try to open an input stream. 
1538         * <!-- begin-user-doc -->
1539         * <!-- end-user-doc -->
1540         * @generated
1541         */
1542        protected boolean isPersisted(Resource resource) {
1543                boolean result = false;
1544                try {
1545                        InputStream stream = editingDomain.getResourceSet().getURIConverter().createInputStream(resource.getURI());
1546                        if (stream != null) {
1547                                result = true;
1548                                stream.close();
1549                        }
1550                }
1551                catch (IOException e) {
1552                        // Ignore
1553                }
1554                return result;
1555        }
1556 
1557        /**
1558         * This always returns true because it is not currently supported.
1559         * <!-- begin-user-doc -->
1560         * <!-- end-user-doc -->
1561         * @generated
1562         */
1563        @Override
1564        public boolean isSaveAsAllowed() {
1565                return true;
1566        }
1567 
1568        /**
1569         * This also changes the editor's input.
1570         * <!-- begin-user-doc -->
1571         * <!-- end-user-doc -->
1572         * @generated
1573         */
1574        @Override
1575        public void doSaveAs() {
1576                SaveAsDialog saveAsDialog = new SaveAsDialog(getSite().getShell());
1577                saveAsDialog.open();
1578                IPath path = saveAsDialog.getResult();
1579                if (path != null) {
1580                        IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
1581                        if (file != null) {
1582                                doSaveAs(URI.createPlatformResourceURI(file.getFullPath().toString(), true), new FileEditorInput(file));
1583                        }
1584                }
1585        }
1586 
1587        /**
1588         * <!-- begin-user-doc -->
1589         * <!-- end-user-doc -->
1590         * @generated
1591         */
1592        protected void doSaveAs(URI uri, IEditorInput editorInput) {
1593                (editingDomain.getResourceSet().getResources().get(0)).setURI(uri);
1594                setInputWithNotify(editorInput);
1595                setPartName(editorInput.getName());
1596                IProgressMonitor progressMonitor =
1597                        getActionBars().getStatusLineManager() != null ?
1598                                getActionBars().getStatusLineManager().getProgressMonitor() :
1599                                new NullProgressMonitor();
1600                doSave(progressMonitor);
1601        }
1602 
1603        /**
1604         * <!-- begin-user-doc -->
1605         * <!-- end-user-doc -->
1606         * @generated
1607         */
1608        public void gotoMarker(IMarker marker) {
1609                try {
1610                        if (marker.getType().equals(EValidator.MARKER)) {
1611                                String uriAttribute = marker.getAttribute(EValidator.URI_ATTRIBUTE, null);
1612                                if (uriAttribute != null) {
1613                                        URI uri = URI.createURI(uriAttribute);
1614                                        EObject eObject = editingDomain.getResourceSet().getEObject(uri, true);
1615                                        if (eObject != null) {
1616                                          setSelectionToViewer(Collections.singleton(editingDomain.getWrapper(eObject)));
1617                                        }
1618                                }
1619                        }
1620                }
1621                catch (CoreException exception) {
1622                        QMLProfileEditorPlugin.INSTANCE.log(exception);
1623                }
1624        }
1625 
1626        /**
1627         * This is called during startup.
1628         * <!-- begin-user-doc -->
1629         * <!-- end-user-doc -->
1630         * @generated
1631         */
1632        @Override
1633        public void init(IEditorSite site, IEditorInput editorInput) {
1634                setSite(site);
1635                setInputWithNotify(editorInput);
1636                setPartName(editorInput.getName());
1637                site.setSelectionProvider(this);
1638                site.getPage().addPartListener(partListener);
1639                ResourcesPlugin.getWorkspace().addResourceChangeListener(resourceChangeListener, IResourceChangeEvent.POST_CHANGE);
1640        }
1641 
1642        /**
1643         * <!-- begin-user-doc -->
1644         * <!-- end-user-doc -->
1645         * @generated
1646         */
1647        @Override
1648        public void setFocus() {
1649                if (currentViewerPane != null) {
1650                        currentViewerPane.setFocus();
1651                }
1652                else {
1653                        getControl(getActivePage()).setFocus();
1654                }
1655        }
1656 
1657        /**
1658         * This implements {@link org.eclipse.jface.viewers.ISelectionProvider}.
1659         * <!-- begin-user-doc -->
1660         * <!-- end-user-doc -->
1661         * @generated
1662         */
1663        public void addSelectionChangedListener(ISelectionChangedListener listener) {
1664                selectionChangedListeners.add(listener);
1665        }
1666 
1667        /**
1668         * This implements {@link org.eclipse.jface.viewers.ISelectionProvider}.
1669         * <!-- begin-user-doc -->
1670         * <!-- end-user-doc -->
1671         * @generated
1672         */
1673        public void removeSelectionChangedListener(ISelectionChangedListener listener) {
1674                selectionChangedListeners.remove(listener);
1675        }
1676 
1677        /**
1678         * This implements {@link org.eclipse.jface.viewers.ISelectionProvider} to return this editor's overall selection.
1679         * <!-- begin-user-doc -->
1680         * <!-- end-user-doc -->
1681         * @generated
1682         */
1683        public ISelection getSelection() {
1684                return editorSelection;
1685        }
1686 
1687        /**
1688         * This implements {@link org.eclipse.jface.viewers.ISelectionProvider} to set this editor's overall selection.
1689         * Calling this result will notify the listeners.
1690         * <!-- begin-user-doc -->
1691         * <!-- end-user-doc -->
1692         * @generated
1693         */
1694        public void setSelection(ISelection selection) {
1695                editorSelection = selection;
1696 
1697                for (ISelectionChangedListener listener : selectionChangedListeners) {
1698                        listener.selectionChanged(new SelectionChangedEvent(this, selection));
1699                }
1700                setStatusLineManager(selection);
1701        }
1702 
1703        /**
1704         * <!-- begin-user-doc -->
1705         * <!-- end-user-doc -->
1706         * @generated
1707         */
1708        public void setStatusLineManager(ISelection selection) {
1709                IStatusLineManager statusLineManager = currentViewer != null && currentViewer == contentOutlineViewer ?
1710                        contentOutlineStatusLineManager : getActionBars().getStatusLineManager();
1711 
1712                if (statusLineManager != null) {
1713                        if (selection instanceof IStructuredSelection) {
1714                                Collection<?> collection = ((IStructuredSelection)selection).toList();
1715                                switch (collection.size()) {
1716                                        case 0: {
1717                                                statusLineManager.setMessage(getString("_UI_NoObjectSelected"));
1718                                                break;
1719                                        }
1720                                        case 1: {
1721                                                String text = new AdapterFactoryItemDelegator(adapterFactory).getText(collection.iterator().next());
1722                                                statusLineManager.setMessage(getString("_UI_SingleObjectSelected", text));
1723                                                break;
1724                                        }
1725                                        default: {
1726                                                statusLineManager.setMessage(getString("_UI_MultiObjectSelected", Integer.toString(collection.size())));
1727                                                break;
1728                                        }
1729                                }
1730                        }
1731                        else {
1732                                statusLineManager.setMessage("");
1733                        }
1734                }
1735        }
1736 
1737        /**
1738         * This looks up a string in the plugin's plugin.properties file.
1739         * <!-- begin-user-doc -->
1740         * <!-- end-user-doc -->
1741         * @generated
1742         */
1743        private static String getString(String key) {
1744                return QMLProfileEditorPlugin.INSTANCE.getString(key);
1745        }
1746 
1747        /**
1748         * This looks up a string in plugin.properties, making a substitution.
1749         * <!-- begin-user-doc -->
1750         * <!-- end-user-doc -->
1751         * @generated
1752         */
1753        private static String getString(String key, Object s1) {
1754                return QMLProfileEditorPlugin.INSTANCE.getString(key, new Object [] { s1 });
1755        }
1756 
1757        /**
1758         * This implements {@link org.eclipse.jface.action.IMenuListener} to help fill the context menus with contributions from the Edit menu.
1759         * <!-- begin-user-doc -->
1760         * <!-- end-user-doc -->
1761         * @generated
1762         */
1763        public void menuAboutToShow(IMenuManager menuManager) {
1764                ((IMenuListener)getEditorSite().getActionBarContributor()).menuAboutToShow(menuManager);
1765        }
1766 
1767        /**
1768         * <!-- begin-user-doc -->
1769         * <!-- end-user-doc -->
1770         * @generated
1771         */
1772        public EditingDomainActionBarContributor getActionBarContributor() {
1773                return (EditingDomainActionBarContributor)getEditorSite().getActionBarContributor();
1774        }
1775 
1776        /**
1777         * <!-- begin-user-doc -->
1778         * <!-- end-user-doc -->
1779         * @generated
1780         */
1781        public IActionBars getActionBars() {
1782                return getActionBarContributor().getActionBars();
1783        }
1784 
1785        /**
1786         * <!-- begin-user-doc -->
1787         * <!-- end-user-doc -->
1788         * @generated
1789         */
1790        public AdapterFactory getAdapterFactory() {
1791                return adapterFactory;
1792        }
1793 
1794        /**
1795         * <!-- begin-user-doc -->
1796         * <!-- end-user-doc -->
1797         * @generated not
1798         */
1799        @Override
1800        public void dispose() {
1801                updateProblemIndication = false;
1802 
1803                ResourcesPlugin.getWorkspace().removeResourceChangeListener(resourceChangeListener);
1804 
1805                getSite().getPage().removePartListener(partListener);
1806 
1807                ((PalladioItemProviderAdapterFactory)adapterFactory).dispose();
1808 
1809                if (getActionBarContributor().getActiveEditor() == this) {
1810                        getActionBarContributor().setActiveEditor(null);
1811                }
1812 
1813                if (propertySheetPage != null) {
1814                        propertySheetPage.dispose();
1815                }
1816 
1817                if (contentOutlinePage != null) {
1818                        contentOutlinePage.dispose();
1819                }
1820 
1821                super.dispose();
1822        }
1823 
1824        /**
1825         * Returns whether the outline view should be presented to the user.
1826         * <!-- begin-user-doc -->
1827         * <!-- end-user-doc -->
1828         * @generated
1829         */
1830        protected boolean showOutlineView() {
1831                return true;
1832        }
1833}

[all classes][de.uka.ipd.sdq.dsexplore.qml.contracttype.QMLContractType.presentation]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov