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

COVERAGE SUMMARY FOR SOURCE FILE [costEditor.java]

nameclass, %method, %block, %line, %
costEditor.java0%   (0/27)0%   (0/122)0%   (0/2751)0%   (0/610)

COVERAGE BREAKDOWN BY CLASS AND METHOD

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

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