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

COVERAGE SUMMARY FOR SOURCE FILE [MarkovEditor.java]

nameclass, %method, %block, %line, %
MarkovEditor.java0%   (0/26)0%   (0/120)0%   (0/2625)0%   (0/586)

COVERAGE BREAKDOWN BY CLASS AND METHOD

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

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