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

COVERAGE SUMMARY FOR SOURCE FILE [RepositoryEditor.java]

nameclass, %method, %block, %line, %
RepositoryEditor.java0%   (0/27)0%   (0/123)0%   (0/2773)0%   (0/616)

COVERAGE BREAKDOWN BY CLASS AND METHOD

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

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