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

COVERAGE SUMMARY FOR SOURCE FILE [QMLDeclarationsEditor.java]

nameclass, %method, %block, %line, %
QMLDeclarationsEditor.java0%   (0/27)0%   (0/123)0%   (0/2778)0%   (0/619)

COVERAGE BREAKDOWN BY CLASS AND METHOD

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

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