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

COVERAGE SUMMARY FOR SOURCE FILE [SubsystemEditor.java]

nameclass, %method, %block, %line, %
SubsystemEditor.java0%   (0/27)0%   (0/122)0%   (0/2741)0%   (0/608)

COVERAGE BREAKDOWN BY CLASS AND METHOD

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

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