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

COVERAGE SUMMARY FOR SOURCE FILE [CoreEditor.java]

nameclass, %method, %block, %line, %
CoreEditor.java0%   (0/26)0%   (0/120)0%   (0/2763)0%   (0/609)

COVERAGE BREAKDOWN BY CLASS AND METHOD

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

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