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

COVERAGE SUMMARY FOR SOURCE FILE [CompletionsEditor.java]

nameclass, %method, %block, %line, %
CompletionsEditor.java0%   (0/26)0%   (0/120)0%   (0/2769)0%   (0/610)

COVERAGE BREAKDOWN BY CLASS AND METHOD

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

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