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

COVERAGE SUMMARY FOR SOURCE FILE [ComputedUsageEditor.java]

nameclass, %method, %block, %line, %
ComputedUsageEditor.java0%   (0/26)0%   (0/120)0%   (0/2781)0%   (0/612)

COVERAGE BREAKDOWN BY CLASS AND METHOD

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

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