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

COVERAGE SUMMARY FOR SOURCE FILE [RepositorydecoratorEditor.java]

nameclass, %method, %block, %line, %
RepositorydecoratorEditor.java0%   (0/26)0%   (0/120)0%   (0/2769)0%   (0/610)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class RepositorydecoratorEditor0%   (0/1)0%   (0/47)0%   (0/1886)0%   (0/441)
RepositorydecoratorEditor (): void 0%   (0/1)0%   (0/59)0%   (0/17)
access$0 (RepositorydecoratorEditor): Composite 0%   (0/1)0%   (0/3)0%   (0/1)
access$1 (RepositorydecoratorEditor, 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/190)0%   (0/33)
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 RepositorydecoratorEditor$10%   (0/1)0%   (0/6)0%   (0/61)0%   (0/17)
RepositorydecoratorEditor$1 (RepositorydecoratorEditor): 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 RepositorydecoratorEditor$100%   (0/1)0%   (0/3)0%   (0/20)0%   (0/6)
RepositorydecoratorEditor$10 (RepositorydecoratorEditor, IWorkbenchPage, IWor... 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 RepositorydecoratorEditor$110%   (0/1)0%   (0/3)0%   (0/20)0%   (0/6)
RepositorydecoratorEditor$11 (RepositorydecoratorEditor, IWorkbenchPage, IWor... 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 RepositorydecoratorEditor$120%   (0/1)0%   (0/3)0%   (0/20)0%   (0/6)
RepositorydecoratorEditor$12 (RepositorydecoratorEditor, IWorkbenchPage, IWor... 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 RepositorydecoratorEditor$130%   (0/1)0%   (0/2)0%   (0/11)0%   (0/4)
RepositorydecoratorEditor$13 (RepositorydecoratorEditor): void 0%   (0/1)0%   (0/6)0%   (0/2)
run (): void 0%   (0/1)0%   (0/5)0%   (0/2)
     
class RepositorydecoratorEditor$140%   (0/1)0%   (0/2)0%   (0/22)0%   (0/8)
RepositorydecoratorEditor$14 (RepositorydecoratorEditor): void 0%   (0/1)0%   (0/9)0%   (0/3)
controlResized (ControlEvent): void 0%   (0/1)0%   (0/13)0%   (0/5)
     
class RepositorydecoratorEditor$150%   (0/1)0%   (0/2)0%   (0/10)0%   (0/4)
RepositorydecoratorEditor$15 (RepositorydecoratorEditor): void 0%   (0/1)0%   (0/6)0%   (0/2)
run (): void 0%   (0/1)0%   (0/4)0%   (0/2)
     
class RepositorydecoratorEditor$160%   (0/1)0%   (0/2)0%   (0/12)0%   (0/4)
RepositorydecoratorEditor$16 (RepositorydecoratorEditor): void 0%   (0/1)0%   (0/6)0%   (0/2)
selectionChanged (SelectionChangedEvent): void 0%   (0/1)0%   (0/6)0%   (0/2)
     
class RepositorydecoratorEditor$170%   (0/1)0%   (0/3)0%   (0/25)0%   (0/8)
RepositorydecoratorEditor$17 (RepositorydecoratorEditor, AdapterFactoryEditin... 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 RepositorydecoratorEditor$180%   (0/1)0%   (0/2)0%   (0/77)0%   (0/13)
RepositorydecoratorEditor$18 (RepositorydecoratorEditor, Map): void 0%   (0/1)0%   (0/9)0%   (0/2)
execute (IProgressMonitor): void 0%   (0/1)0%   (0/68)0%   (0/11)
     
class RepositorydecoratorEditor$1MyContentOutlinePage0%   (0/1)0%   (0/4)0%   (0/96)0%   (0/17)
RepositorydecoratorEditor$1MyContentOutlinePage (RepositorydecoratorEditor): ... 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 RepositorydecoratorEditor$20%   (0/1)0%   (0/5)0%   (0/71)0%   (0/19)
RepositorydecoratorEditor$2 (RepositorydecoratorEditor): void 0%   (0/1)0%   (0/6)0%   (0/2)
access$0 (RepositorydecoratorEditor$2): RepositorydecoratorEditor 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 RepositorydecoratorEditor$2$10%   (0/1)0%   (0/2)0%   (0/11)0%   (0/4)
RepositorydecoratorEditor$2$1 (RepositorydecoratorEditor$2): void 0%   (0/1)0%   (0/6)0%   (0/2)
run (): void 0%   (0/1)0%   (0/5)0%   (0/2)
     
class RepositorydecoratorEditor$30%   (0/1)0%   (0/3)0%   (0/56)0%   (0/14)
RepositorydecoratorEditor$3 (RepositorydecoratorEditor): void 0%   (0/1)0%   (0/6)0%   (0/2)
access$0 (RepositorydecoratorEditor$3): RepositorydecoratorEditor 0%   (0/1)0%   (0/3)0%   (0/1)
resourceChanged (IResourceChangeEvent): void 0%   (0/1)0%   (0/47)0%   (0/12)
     
class RepositorydecoratorEditor$3$10%   (0/1)0%   (0/2)0%   (0/35)0%   (0/6)
RepositorydecoratorEditor$3$1 (RepositorydecoratorEditor$3, Repositorydecorat... 0%   (0/1)0%   (0/9)0%   (0/2)
run (): void 0%   (0/1)0%   (0/26)0%   (0/4)
     
class RepositorydecoratorEditor$3$1ResourceDeltaVisitor0%   (0/1)0%   (0/4)0%   (0/81)0%   (0/16)
RepositorydecoratorEditor$3$1ResourceDeltaVisitor (RepositorydecoratorEditor$... 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 RepositorydecoratorEditor$3$20%   (0/1)0%   (0/2)0%   (0/33)0%   (0/6)
RepositorydecoratorEditor$3$2 (RepositorydecoratorEditor$3, Repositorydecorat... 0%   (0/1)0%   (0/9)0%   (0/2)
run (): void 0%   (0/1)0%   (0/24)0%   (0/4)
     
class RepositorydecoratorEditor$40%   (0/1)0%   (0/3)0%   (0/20)0%   (0/5)
RepositorydecoratorEditor$4 (RepositorydecoratorEditor): void 0%   (0/1)0%   (0/6)0%   (0/2)
access$0 (RepositorydecoratorEditor$4): RepositorydecoratorEditor 0%   (0/1)0%   (0/3)0%   (0/1)
commandStackChanged (EventObject): void 0%   (0/1)0%   (0/11)0%   (0/3)
     
class RepositorydecoratorEditor$4$10%   (0/1)0%   (0/2)0%   (0/46)0%   (0/9)
RepositorydecoratorEditor$4$1 (RepositorydecoratorEditor$4, EventObject): void 0%   (0/1)0%   (0/9)0%   (0/2)
run (): void 0%   (0/1)0%   (0/37)0%   (0/7)
     
class RepositorydecoratorEditor$50%   (0/1)0%   (0/2)0%   (0/25)0%   (0/5)
RepositorydecoratorEditor$5 (RepositorydecoratorEditor, Collection): void 0%   (0/1)0%   (0/9)0%   (0/2)
run (): void 0%   (0/1)0%   (0/16)0%   (0/3)
     
class RepositorydecoratorEditor$60%   (0/1)0%   (0/2)0%   (0/12)0%   (0/4)
RepositorydecoratorEditor$6 (RepositorydecoratorEditor): void 0%   (0/1)0%   (0/6)0%   (0/2)
selectionChanged (SelectionChangedEvent): void 0%   (0/1)0%   (0/6)0%   (0/2)
     
class RepositorydecoratorEditor$70%   (0/1)0%   (0/3)0%   (0/28)0%   (0/8)
RepositorydecoratorEditor$7 (RepositorydecoratorEditor, IWorkbenchPage, IWork... 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 RepositorydecoratorEditor$80%   (0/1)0%   (0/3)0%   (0/28)0%   (0/8)
RepositorydecoratorEditor$8 (RepositorydecoratorEditor, IWorkbenchPage, IWork... 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 RepositorydecoratorEditor$90%   (0/1)0%   (0/3)0%   (0/20)0%   (0/6)
RepositorydecoratorEditor$9 (RepositorydecoratorEditor, IWorkbenchPage, IWork... 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 RepositorydecoratorEditor$ReverseAdapterFactoryContentProvider0%   (0/1)0%   (0/5)0%   (0/43)0%   (0/10)
RepositorydecoratorEditor$ReverseAdapterFactoryContentProvider (Repositorydec... 0%   (0/1)0%   (0/7)0%   (0/3)
getChildren (Object): Object [] 0%   (0/1)0%   (0/12)0%   (0/2)
getElements (Object): Object [] 0%   (0/1)0%   (0/12)0%   (0/2)
getParent (Object): Object 0%   (0/1)0%   (0/2)0%   (0/1)
hasChildren (Object): boolean 0%   (0/1)0%   (0/10)0%   (0/2)

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

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