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

COVERAGE SUMMARY FOR SOURCE FILE [ResourceenvironmentEditor.java]

nameclass, %method, %block, %line, %
ResourceenvironmentEditor.java0%   (0/27)0%   (0/123)0%   (0/2766)0%   (0/615)

COVERAGE BREAKDOWN BY CLASS AND METHOD

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

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