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