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

COVERAGE SUMMARY FOR SOURCE FILE [UnitsEditor.java]

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

COVERAGE BREAKDOWN BY CLASS AND METHOD

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

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