1 | /** |
2 | * <copyright> |
3 | * </copyright> |
4 | * |
5 | * $Id$ |
6 | */ |
7 | package de.uka.ipd.sdq.dsexplore.qml.profile.QMLProfile.presentation; |
8 | |
9 | |
10 | import java.io.IOException; |
11 | import java.io.InputStream; |
12 | import java.util.ArrayList; |
13 | import java.util.Collection; |
14 | import java.util.Collections; |
15 | import java.util.EventObject; |
16 | import java.util.HashMap; |
17 | import java.util.Iterator; |
18 | import java.util.LinkedHashMap; |
19 | import java.util.List; |
20 | import java.util.Map; |
21 | |
22 | import org.eclipse.core.resources.IFile; |
23 | import org.eclipse.core.resources.IMarker; |
24 | import org.eclipse.core.resources.IResource; |
25 | import org.eclipse.core.resources.IResourceChangeEvent; |
26 | import org.eclipse.core.resources.IResourceChangeListener; |
27 | import org.eclipse.core.resources.IResourceDelta; |
28 | import org.eclipse.core.resources.IResourceDeltaVisitor; |
29 | import org.eclipse.core.resources.ResourcesPlugin; |
30 | import org.eclipse.core.runtime.CoreException; |
31 | import org.eclipse.core.runtime.IPath; |
32 | import org.eclipse.core.runtime.IProgressMonitor; |
33 | import org.eclipse.core.runtime.NullProgressMonitor; |
34 | import org.eclipse.emf.common.command.BasicCommandStack; |
35 | import org.eclipse.emf.common.command.Command; |
36 | import org.eclipse.emf.common.command.CommandStack; |
37 | import org.eclipse.emf.common.command.CommandStackListener; |
38 | import org.eclipse.emf.common.notify.AdapterFactory; |
39 | import org.eclipse.emf.common.notify.Notification; |
40 | import org.eclipse.emf.common.ui.MarkerHelper; |
41 | import org.eclipse.emf.common.ui.ViewerPane; |
42 | import org.eclipse.emf.common.ui.editor.ProblemEditorPart; |
43 | import org.eclipse.emf.common.ui.viewer.IViewerProvider; |
44 | import org.eclipse.emf.common.util.BasicDiagnostic; |
45 | import org.eclipse.emf.common.util.Diagnostic; |
46 | import org.eclipse.emf.common.util.URI; |
47 | import org.eclipse.emf.ecore.EObject; |
48 | import org.eclipse.emf.ecore.EValidator; |
49 | import org.eclipse.emf.ecore.resource.Resource; |
50 | import org.eclipse.emf.ecore.resource.ResourceSet; |
51 | import org.eclipse.emf.ecore.util.EContentAdapter; |
52 | import org.eclipse.emf.ecore.util.EcoreUtil; |
53 | import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain; |
54 | import org.eclipse.emf.edit.domain.EditingDomain; |
55 | import org.eclipse.emf.edit.domain.IEditingDomainProvider; |
56 | import org.eclipse.emf.edit.provider.AdapterFactoryItemDelegator; |
57 | import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; |
58 | import org.eclipse.emf.edit.provider.ComposedAdapterFactory; |
59 | import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory; |
60 | import org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory; |
61 | import org.eclipse.emf.edit.ui.action.EditingDomainActionBarContributor; |
62 | import org.eclipse.emf.edit.ui.celleditor.AdapterFactoryTreeEditor; |
63 | import org.eclipse.emf.edit.ui.dnd.EditingDomainViewerDropAdapter; |
64 | import org.eclipse.emf.edit.ui.dnd.LocalTransfer; |
65 | import org.eclipse.emf.edit.ui.dnd.ViewerDragAdapter; |
66 | import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider; |
67 | import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider; |
68 | import org.eclipse.emf.edit.ui.provider.UnwrappingSelectionProvider; |
69 | import org.eclipse.emf.edit.ui.util.EditUIMarkerHelper; |
70 | import org.eclipse.emf.edit.ui.util.EditUIUtil; |
71 | import org.eclipse.emf.edit.ui.view.ExtendedPropertySheetPage; |
72 | import org.eclipse.jface.action.IMenuListener; |
73 | import org.eclipse.jface.action.IMenuManager; |
74 | import org.eclipse.jface.action.IStatusLineManager; |
75 | import org.eclipse.jface.action.IToolBarManager; |
76 | import org.eclipse.jface.action.MenuManager; |
77 | import org.eclipse.jface.action.Separator; |
78 | import org.eclipse.jface.dialogs.MessageDialog; |
79 | import org.eclipse.jface.dialogs.ProgressMonitorDialog; |
80 | import org.eclipse.jface.viewers.ColumnWeightData; |
81 | import org.eclipse.jface.viewers.ISelection; |
82 | import org.eclipse.jface.viewers.ISelectionChangedListener; |
83 | import org.eclipse.jface.viewers.ISelectionProvider; |
84 | import org.eclipse.jface.viewers.IStructuredSelection; |
85 | import org.eclipse.jface.viewers.ListViewer; |
86 | import org.eclipse.jface.viewers.SelectionChangedEvent; |
87 | import org.eclipse.jface.viewers.StructuredSelection; |
88 | import org.eclipse.jface.viewers.StructuredViewer; |
89 | import org.eclipse.jface.viewers.TableLayout; |
90 | import org.eclipse.jface.viewers.TableViewer; |
91 | import org.eclipse.jface.viewers.TreeViewer; |
92 | import org.eclipse.jface.viewers.Viewer; |
93 | import org.eclipse.swt.SWT; |
94 | import org.eclipse.swt.custom.CTabFolder; |
95 | import org.eclipse.swt.dnd.DND; |
96 | import org.eclipse.swt.dnd.Transfer; |
97 | import org.eclipse.swt.events.ControlAdapter; |
98 | import org.eclipse.swt.events.ControlEvent; |
99 | import org.eclipse.swt.graphics.Point; |
100 | import org.eclipse.swt.layout.FillLayout; |
101 | import org.eclipse.swt.widgets.Composite; |
102 | import org.eclipse.swt.widgets.Menu; |
103 | import org.eclipse.swt.widgets.Table; |
104 | import org.eclipse.swt.widgets.TableColumn; |
105 | import org.eclipse.swt.widgets.Tree; |
106 | import org.eclipse.swt.widgets.TreeColumn; |
107 | import org.eclipse.ui.IActionBars; |
108 | import org.eclipse.ui.IEditorInput; |
109 | import org.eclipse.ui.IEditorPart; |
110 | import org.eclipse.ui.IEditorSite; |
111 | import org.eclipse.ui.IPartListener; |
112 | import org.eclipse.ui.IWorkbenchPart; |
113 | import org.eclipse.ui.PartInitException; |
114 | import org.eclipse.ui.actions.WorkspaceModifyOperation; |
115 | import org.eclipse.ui.dialogs.SaveAsDialog; |
116 | import org.eclipse.ui.ide.IGotoMarker; |
117 | import org.eclipse.ui.part.FileEditorInput; |
118 | import org.eclipse.ui.part.MultiPageEditorPart; |
119 | import org.eclipse.ui.views.contentoutline.ContentOutline; |
120 | import org.eclipse.ui.views.contentoutline.ContentOutlinePage; |
121 | import org.eclipse.ui.views.contentoutline.IContentOutlinePage; |
122 | import org.eclipse.ui.views.properties.IPropertySheetPage; |
123 | import org.eclipse.ui.views.properties.PropertySheet; |
124 | import org.eclipse.ui.views.properties.PropertySheetPage; |
125 | |
126 | import de.uka.ipd.sdq.identifier.provider.IdentifierItemProviderAdapterFactory; |
127 | import de.uka.ipd.sdq.pcm.allocation.provider.AllocationItemProviderAdapterFactory; |
128 | import de.uka.ipd.sdq.pcm.core.composition.provider.CompositionItemProviderAdapterFactory; |
129 | import de.uka.ipd.sdq.pcm.core.entity.provider.EntityItemProviderAdapterFactory; |
130 | import de.uka.ipd.sdq.pcm.core.provider.CoreItemProviderAdapterFactory; |
131 | import de.uka.ipd.sdq.pcm.parameter.provider.ParameterItemProviderAdapterFactory; |
132 | import de.uka.ipd.sdq.pcm.protocol.provider.ProtocolItemProviderAdapterFactory; |
133 | import de.uka.ipd.sdq.pcm.qosannotations.provider.QosannotationsItemProviderAdapterFactory; |
134 | import de.uka.ipd.sdq.pcm.qosannotations.qos_performance.provider.Qos_performanceItemProviderAdapterFactory; |
135 | import de.uka.ipd.sdq.pcm.qosannotations.qos_reliability.provider.Qos_reliabilityItemProviderAdapterFactory; |
136 | import de.uka.ipd.sdq.pcm.repository.provider.RepositoryItemProviderAdapterFactory; |
137 | import de.uka.ipd.sdq.pcm.resourceenvironment.provider.ResourceenvironmentItemProviderAdapterFactory; |
138 | import de.uka.ipd.sdq.pcm.resourcetype.provider.ResourcetypeItemProviderAdapterFactory; |
139 | import de.uka.ipd.sdq.pcm.seff.provider.SeffItemProviderAdapterFactory; |
140 | import de.uka.ipd.sdq.pcm.seff.seff_performance.provider.Seff_performanceItemProviderAdapterFactory; |
141 | import de.uka.ipd.sdq.pcm.subsystem.provider.SubsystemItemProviderAdapterFactory; |
142 | import de.uka.ipd.sdq.pcm.system.provider.SystemItemProviderAdapterFactory; |
143 | import de.uka.ipd.sdq.pcm.usagemodel.provider.UsagemodelItemProviderAdapterFactory; |
144 | import de.uka.ipd.sdq.pcmbench.propertytabs.PalladioAdapterFactoryContentProvider; |
145 | import de.uka.ipd.sdq.pcmbench.ui.provider.PalladioItemProviderAdapterFactory; |
146 | import de.uka.ipd.sdq.probfunction.provider.ProbfunctionItemProviderAdapterFactory; |
147 | import de.uka.ipd.sdq.stoex.provider.StoexItemProviderAdapterFactory; |
148 | import de.uka.ipd.sdq.units.provider.UnitsItemProviderAdapterFactory; |
149 | |
150 | |
151 | /** |
152 | * This is an example of a QMLProfile model editor. |
153 | * <!-- begin-user-doc --> |
154 | * <!-- end-user-doc --> |
155 | * @generated |
156 | */ |
157 | public class QMLProfileEditor |
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 not |
173 | */ |
174 | protected AdapterFactory 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(QMLProfileEditor.this); |
320 | |
321 | setCurrentViewer(contentOutlineViewer); |
322 | } |
323 | } |
324 | else if (p instanceof PropertySheet) { |
325 | if (((PropertySheet)p).getCurrentPage() == propertySheetPage) { |
326 | getActionBarContributor().setActiveEditor(QMLProfileEditor.this); |
327 | handleActivate(); |
328 | } |
329 | } |
330 | else if (p == QMLProfileEditor.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(QMLProfileEditor.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() == QMLProfileEditor.this) { |
505 | handleActivate(); |
506 | } |
507 | } |
508 | }); |
509 | } |
510 | } |
511 | catch (CoreException exception) { |
512 | QMLProfileEditorPlugin.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(QMLProfileEditor.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.dsexplore.qml.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 | QMLProfileEditorPlugin.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 | QMLProfileEditorPlugin.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 QMLProfileEditor() { |
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 not |
676 | */ |
677 | protected void initializeEditingDomain() { |
678 | // Create an adapter factory that yields item providers. |
679 | // |
680 | ComposedAdapterFactory compAdapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE) { |
681 | @Override |
682 | public ComposeableAdapterFactory getRootAdapterFactory() { |
683 | // TODO Auto-generated method stub |
684 | return (PalladioItemProviderAdapterFactory)adapterFactory; |
685 | } |
686 | }; |
687 | |
688 | |
689 | compAdapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory()); |
690 | compAdapterFactory.addAdapterFactory(new CoreItemProviderAdapterFactory()); |
691 | compAdapterFactory.addAdapterFactory(new EntityItemProviderAdapterFactory()); |
692 | compAdapterFactory.addAdapterFactory(new CompositionItemProviderAdapterFactory()); |
693 | compAdapterFactory.addAdapterFactory(new RepositoryItemProviderAdapterFactory()); |
694 | compAdapterFactory.addAdapterFactory(new ProtocolItemProviderAdapterFactory()); |
695 | compAdapterFactory.addAdapterFactory(new SubsystemItemProviderAdapterFactory()); |
696 | compAdapterFactory.addAdapterFactory(new ParameterItemProviderAdapterFactory()); |
697 | compAdapterFactory.addAdapterFactory(new SeffItemProviderAdapterFactory()); |
698 | compAdapterFactory.addAdapterFactory(new Seff_performanceItemProviderAdapterFactory()); |
699 | compAdapterFactory.addAdapterFactory(new AllocationItemProviderAdapterFactory()); |
700 | compAdapterFactory.addAdapterFactory(new ResourceenvironmentItemProviderAdapterFactory()); |
701 | compAdapterFactory.addAdapterFactory(new ResourcetypeItemProviderAdapterFactory()); |
702 | compAdapterFactory.addAdapterFactory(new SystemItemProviderAdapterFactory()); |
703 | compAdapterFactory.addAdapterFactory(new QosannotationsItemProviderAdapterFactory()); |
704 | compAdapterFactory.addAdapterFactory(new Qos_performanceItemProviderAdapterFactory()); |
705 | compAdapterFactory.addAdapterFactory(new Qos_reliabilityItemProviderAdapterFactory()); |
706 | compAdapterFactory.addAdapterFactory(new UsagemodelItemProviderAdapterFactory()); |
707 | compAdapterFactory.addAdapterFactory(new IdentifierItemProviderAdapterFactory()); |
708 | compAdapterFactory.addAdapterFactory(new StoexItemProviderAdapterFactory()); |
709 | compAdapterFactory.addAdapterFactory(new UnitsItemProviderAdapterFactory()); |
710 | compAdapterFactory.addAdapterFactory(new ProbfunctionItemProviderAdapterFactory()); |
711 | compAdapterFactory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory()); |
712 | |
713 | adapterFactory = new PalladioItemProviderAdapterFactory(compAdapterFactory); |
714 | |
715 | |
716 | // Create the command stack that will notify this editor as commands are executed. |
717 | // |
718 | BasicCommandStack commandStack = new BasicCommandStack(); |
719 | |
720 | // Add a listener to set the most recent command's affected objects to be the selection of the viewer with focus. |
721 | // |
722 | commandStack.addCommandStackListener |
723 | (new CommandStackListener() { |
724 | public void commandStackChanged(final EventObject event) { |
725 | getContainer().getDisplay().asyncExec |
726 | (new Runnable() { |
727 | public void run() { |
728 | firePropertyChange(IEditorPart.PROP_DIRTY); |
729 | |
730 | // Try to select the affected objects. |
731 | // |
732 | Command mostRecentCommand = ((CommandStack)event.getSource()).getMostRecentCommand(); |
733 | if (mostRecentCommand != null) { |
734 | setSelectionToViewer(mostRecentCommand.getAffectedObjects()); |
735 | } |
736 | if (propertySheetPage != null && !propertySheetPage.getControl().isDisposed()) { |
737 | propertySheetPage.refresh(); |
738 | } |
739 | } |
740 | }); |
741 | } |
742 | }); |
743 | |
744 | // Create the editing domain with a special command stack. |
745 | // |
746 | editingDomain = new AdapterFactoryEditingDomain(adapterFactory, commandStack, new HashMap<Resource, Boolean>()); |
747 | } |
748 | |
749 | /** |
750 | * This is here for the listener to be able to call it. |
751 | * <!-- begin-user-doc --> |
752 | * <!-- end-user-doc --> |
753 | * @generated |
754 | */ |
755 | @Override |
756 | protected void firePropertyChange(int action) { |
757 | super.firePropertyChange(action); |
758 | } |
759 | |
760 | /** |
761 | * This sets the selection into whichever viewer is active. |
762 | * <!-- begin-user-doc --> |
763 | * <!-- end-user-doc --> |
764 | * @generated |
765 | */ |
766 | public void setSelectionToViewer(Collection<?> collection) { |
767 | final Collection<?> theSelection = collection; |
768 | // Make sure it's okay. |
769 | // |
770 | if (theSelection != null && !theSelection.isEmpty()) { |
771 | Runnable runnable = |
772 | new Runnable() { |
773 | public void run() { |
774 | // Try to select the items in the current content viewer of the editor. |
775 | // |
776 | if (currentViewer != null) { |
777 | currentViewer.setSelection(new StructuredSelection(theSelection.toArray()), true); |
778 | } |
779 | } |
780 | }; |
781 | getSite().getShell().getDisplay().asyncExec(runnable); |
782 | } |
783 | } |
784 | |
785 | /** |
786 | * This returns the editing domain as required by the {@link IEditingDomainProvider} interface. |
787 | * This is important for implementing the static methods of {@link AdapterFactoryEditingDomain} |
788 | * and for supporting {@link org.eclipse.emf.edit.ui.action.CommandAction}. |
789 | * <!-- begin-user-doc --> |
790 | * <!-- end-user-doc --> |
791 | * @generated |
792 | */ |
793 | public EditingDomain getEditingDomain() { |
794 | return editingDomain; |
795 | } |
796 | |
797 | /** |
798 | * <!-- begin-user-doc --> |
799 | * <!-- end-user-doc --> |
800 | * @generated |
801 | */ |
802 | public class ReverseAdapterFactoryContentProvider extends AdapterFactoryContentProvider { |
803 | /** |
804 | * <!-- begin-user-doc --> |
805 | * <!-- end-user-doc --> |
806 | * @generated |
807 | */ |
808 | public ReverseAdapterFactoryContentProvider(AdapterFactory adapterFactory) { |
809 | super(adapterFactory); |
810 | } |
811 | |
812 | /** |
813 | * <!-- begin-user-doc --> |
814 | * <!-- end-user-doc --> |
815 | * @generated |
816 | */ |
817 | @Override |
818 | public Object [] getElements(Object object) { |
819 | Object parent = super.getParent(object); |
820 | return (parent == null ? Collections.EMPTY_SET : Collections.singleton(parent)).toArray(); |
821 | } |
822 | |
823 | /** |
824 | * <!-- begin-user-doc --> |
825 | * <!-- end-user-doc --> |
826 | * @generated |
827 | */ |
828 | @Override |
829 | public Object [] getChildren(Object object) { |
830 | Object parent = super.getParent(object); |
831 | return (parent == null ? Collections.EMPTY_SET : Collections.singleton(parent)).toArray(); |
832 | } |
833 | |
834 | /** |
835 | * <!-- begin-user-doc --> |
836 | * <!-- end-user-doc --> |
837 | * @generated |
838 | */ |
839 | @Override |
840 | public boolean hasChildren(Object object) { |
841 | Object parent = super.getParent(object); |
842 | return parent != null; |
843 | } |
844 | |
845 | /** |
846 | * <!-- begin-user-doc --> |
847 | * <!-- end-user-doc --> |
848 | * @generated |
849 | */ |
850 | @Override |
851 | public Object getParent(Object object) { |
852 | return null; |
853 | } |
854 | } |
855 | |
856 | /** |
857 | * <!-- begin-user-doc --> |
858 | * <!-- end-user-doc --> |
859 | * @generated |
860 | */ |
861 | public void setCurrentViewerPane(ViewerPane viewerPane) { |
862 | if (currentViewerPane != viewerPane) { |
863 | if (currentViewerPane != null) { |
864 | currentViewerPane.showFocus(false); |
865 | } |
866 | currentViewerPane = viewerPane; |
867 | } |
868 | setCurrentViewer(currentViewerPane.getViewer()); |
869 | } |
870 | |
871 | /** |
872 | * This makes sure that one content viewer, either for the current page or the outline view, if it has focus, |
873 | * is the current one. |
874 | * <!-- begin-user-doc --> |
875 | * <!-- end-user-doc --> |
876 | * @generated |
877 | */ |
878 | public void setCurrentViewer(Viewer viewer) { |
879 | // If it is changing... |
880 | // |
881 | if (currentViewer != viewer) { |
882 | if (selectionChangedListener == null) { |
883 | // Create the listener on demand. |
884 | // |
885 | selectionChangedListener = |
886 | new ISelectionChangedListener() { |
887 | // This just notifies those things that are affected by the section. |
888 | // |
889 | public void selectionChanged(SelectionChangedEvent selectionChangedEvent) { |
890 | setSelection(selectionChangedEvent.getSelection()); |
891 | } |
892 | }; |
893 | } |
894 | |
895 | // Stop listening to the old one. |
896 | // |
897 | if (currentViewer != null) { |
898 | currentViewer.removeSelectionChangedListener(selectionChangedListener); |
899 | } |
900 | |
901 | // Start listening to the new one. |
902 | // |
903 | if (viewer != null) { |
904 | viewer.addSelectionChangedListener(selectionChangedListener); |
905 | } |
906 | |
907 | // Remember it. |
908 | // |
909 | currentViewer = viewer; |
910 | |
911 | // Set the editors selection based on the current viewer's selection. |
912 | // |
913 | setSelection(currentViewer == null ? StructuredSelection.EMPTY : currentViewer.getSelection()); |
914 | } |
915 | } |
916 | |
917 | /** |
918 | * This returns the viewer as required by the {@link IViewerProvider} interface. |
919 | * <!-- begin-user-doc --> |
920 | * <!-- end-user-doc --> |
921 | * @generated |
922 | */ |
923 | public Viewer getViewer() { |
924 | return currentViewer; |
925 | } |
926 | |
927 | /** |
928 | * This creates a context menu for the viewer and adds a listener as well registering the menu for extension. |
929 | * <!-- begin-user-doc --> |
930 | * <!-- end-user-doc --> |
931 | * @generated |
932 | */ |
933 | protected void createContextMenuFor(StructuredViewer viewer) { |
934 | MenuManager contextMenu = new MenuManager("#PopUp"); |
935 | contextMenu.add(new Separator("additions")); |
936 | contextMenu.setRemoveAllWhenShown(true); |
937 | contextMenu.addMenuListener(this); |
938 | Menu menu= contextMenu.createContextMenu(viewer.getControl()); |
939 | viewer.getControl().setMenu(menu); |
940 | getSite().registerContextMenu(contextMenu, new UnwrappingSelectionProvider(viewer)); |
941 | |
942 | int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK; |
943 | Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance() }; |
944 | viewer.addDragSupport(dndOperations, transfers, new ViewerDragAdapter(viewer)); |
945 | viewer.addDropSupport(dndOperations, transfers, new EditingDomainViewerDropAdapter(editingDomain, viewer)); |
946 | } |
947 | |
948 | /** |
949 | * This is the method called to load a resource into the editing domain's resource set based on the editor's input. |
950 | * <!-- begin-user-doc --> |
951 | * <!-- end-user-doc --> |
952 | * @generated |
953 | */ |
954 | public void createModel() { |
955 | URI resourceURI = EditUIUtil.getURI(getEditorInput()); |
956 | Exception exception = null; |
957 | Resource resource = null; |
958 | try { |
959 | // Load the resource through the editing domain. |
960 | // |
961 | resource = editingDomain.getResourceSet().getResource(resourceURI, true); |
962 | } |
963 | catch (Exception e) { |
964 | exception = e; |
965 | resource = editingDomain.getResourceSet().getResource(resourceURI, false); |
966 | } |
967 | |
968 | Diagnostic diagnostic = analyzeResourceProblems(resource, exception); |
969 | if (diagnostic.getSeverity() != Diagnostic.OK) { |
970 | resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception)); |
971 | } |
972 | editingDomain.getResourceSet().eAdapters().add(problemIndicationAdapter); |
973 | } |
974 | |
975 | /** |
976 | * Returns a diagnostic describing the errors and warnings listed in the resource |
977 | * and the specified exception (if any). |
978 | * <!-- begin-user-doc --> |
979 | * <!-- end-user-doc --> |
980 | * @generated |
981 | */ |
982 | public Diagnostic analyzeResourceProblems(Resource resource, Exception exception) { |
983 | if (!resource.getErrors().isEmpty() || !resource.getWarnings().isEmpty()) { |
984 | BasicDiagnostic basicDiagnostic = |
985 | new BasicDiagnostic |
986 | (Diagnostic.ERROR, |
987 | "de.uka.ipd.sdq.dsexplore.qml.editor", |
988 | 0, |
989 | getString("_UI_CreateModelError_message", resource.getURI()), |
990 | new Object [] { exception == null ? (Object)resource : exception }); |
991 | basicDiagnostic.merge(EcoreUtil.computeDiagnostic(resource, true)); |
992 | return basicDiagnostic; |
993 | } |
994 | else if (exception != null) { |
995 | return |
996 | new BasicDiagnostic |
997 | (Diagnostic.ERROR, |
998 | "de.uka.ipd.sdq.dsexplore.qml.editor", |
999 | 0, |
1000 | getString("_UI_CreateModelError_message", resource.getURI()), |
1001 | new Object[] { exception }); |
1002 | } |
1003 | else { |
1004 | return Diagnostic.OK_INSTANCE; |
1005 | } |
1006 | } |
1007 | |
1008 | /** |
1009 | * This is the method used by the framework to install your own controls. |
1010 | * <!-- begin-user-doc --> |
1011 | * <!-- end-user-doc --> |
1012 | * @generated |
1013 | */ |
1014 | @Override |
1015 | public void createPages() { |
1016 | // Creates the model from the editor input |
1017 | // |
1018 | createModel(); |
1019 | |
1020 | // Only creates the other pages if there is something that can be edited |
1021 | // |
1022 | if (!getEditingDomain().getResourceSet().getResources().isEmpty()) { |
1023 | // Create a page for the selection tree view. |
1024 | // |
1025 | { |
1026 | ViewerPane viewerPane = |
1027 | new ViewerPane(getSite().getPage(), QMLProfileEditor.this) { |
1028 | @Override |
1029 | public Viewer createViewer(Composite composite) { |
1030 | Tree tree = new Tree(composite, SWT.MULTI); |
1031 | TreeViewer newTreeViewer = new TreeViewer(tree); |
1032 | return newTreeViewer; |
1033 | } |
1034 | @Override |
1035 | public void requestActivation() { |
1036 | super.requestActivation(); |
1037 | setCurrentViewerPane(this); |
1038 | } |
1039 | }; |
1040 | viewerPane.createControl(getContainer()); |
1041 | |
1042 | selectionViewer = (TreeViewer)viewerPane.getViewer(); |
1043 | selectionViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); |
1044 | |
1045 | selectionViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); |
1046 | selectionViewer.setInput(editingDomain.getResourceSet()); |
1047 | selectionViewer.setSelection(new StructuredSelection(editingDomain.getResourceSet().getResources().get(0)), true); |
1048 | viewerPane.setTitle(editingDomain.getResourceSet()); |
1049 | |
1050 | new AdapterFactoryTreeEditor(selectionViewer.getTree(), adapterFactory); |
1051 | |
1052 | createContextMenuFor(selectionViewer); |
1053 | int pageIndex = addPage(viewerPane.getControl()); |
1054 | setPageText(pageIndex, getString("_UI_SelectionPage_label")); |
1055 | } |
1056 | |
1057 | // Create a page for the parent tree view. |
1058 | // |
1059 | { |
1060 | ViewerPane viewerPane = |
1061 | new ViewerPane(getSite().getPage(), QMLProfileEditor.this) { |
1062 | @Override |
1063 | public Viewer createViewer(Composite composite) { |
1064 | Tree tree = new Tree(composite, SWT.MULTI); |
1065 | TreeViewer newTreeViewer = new TreeViewer(tree); |
1066 | return newTreeViewer; |
1067 | } |
1068 | @Override |
1069 | public void requestActivation() { |
1070 | super.requestActivation(); |
1071 | setCurrentViewerPane(this); |
1072 | } |
1073 | }; |
1074 | viewerPane.createControl(getContainer()); |
1075 | |
1076 | parentViewer = (TreeViewer)viewerPane.getViewer(); |
1077 | parentViewer.setAutoExpandLevel(30); |
1078 | parentViewer.setContentProvider(new ReverseAdapterFactoryContentProvider(adapterFactory)); |
1079 | parentViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); |
1080 | |
1081 | createContextMenuFor(parentViewer); |
1082 | int pageIndex = addPage(viewerPane.getControl()); |
1083 | setPageText(pageIndex, getString("_UI_ParentPage_label")); |
1084 | } |
1085 | |
1086 | // This is the page for the list viewer |
1087 | // |
1088 | { |
1089 | ViewerPane viewerPane = |
1090 | new ViewerPane(getSite().getPage(), QMLProfileEditor.this) { |
1091 | @Override |
1092 | public Viewer createViewer(Composite composite) { |
1093 | return new ListViewer(composite); |
1094 | } |
1095 | @Override |
1096 | public void requestActivation() { |
1097 | super.requestActivation(); |
1098 | setCurrentViewerPane(this); |
1099 | } |
1100 | }; |
1101 | viewerPane.createControl(getContainer()); |
1102 | listViewer = (ListViewer)viewerPane.getViewer(); |
1103 | listViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); |
1104 | listViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); |
1105 | |
1106 | createContextMenuFor(listViewer); |
1107 | int pageIndex = addPage(viewerPane.getControl()); |
1108 | setPageText(pageIndex, getString("_UI_ListPage_label")); |
1109 | } |
1110 | |
1111 | // This is the page for the tree viewer |
1112 | // |
1113 | { |
1114 | ViewerPane viewerPane = |
1115 | new ViewerPane(getSite().getPage(), QMLProfileEditor.this) { |
1116 | @Override |
1117 | public Viewer createViewer(Composite composite) { |
1118 | return new TreeViewer(composite); |
1119 | } |
1120 | @Override |
1121 | public void requestActivation() { |
1122 | super.requestActivation(); |
1123 | setCurrentViewerPane(this); |
1124 | } |
1125 | }; |
1126 | viewerPane.createControl(getContainer()); |
1127 | treeViewer = (TreeViewer)viewerPane.getViewer(); |
1128 | treeViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); |
1129 | treeViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); |
1130 | |
1131 | new AdapterFactoryTreeEditor(treeViewer.getTree(), adapterFactory); |
1132 | |
1133 | createContextMenuFor(treeViewer); |
1134 | int pageIndex = addPage(viewerPane.getControl()); |
1135 | setPageText(pageIndex, getString("_UI_TreePage_label")); |
1136 | } |
1137 | |
1138 | // This is the page for the table viewer. |
1139 | // |
1140 | { |
1141 | ViewerPane viewerPane = |
1142 | new ViewerPane(getSite().getPage(), QMLProfileEditor.this) { |
1143 | @Override |
1144 | public Viewer createViewer(Composite composite) { |
1145 | return new TableViewer(composite); |
1146 | } |
1147 | @Override |
1148 | public void requestActivation() { |
1149 | super.requestActivation(); |
1150 | setCurrentViewerPane(this); |
1151 | } |
1152 | }; |
1153 | viewerPane.createControl(getContainer()); |
1154 | tableViewer = (TableViewer)viewerPane.getViewer(); |
1155 | |
1156 | Table table = tableViewer.getTable(); |
1157 | TableLayout layout = new TableLayout(); |
1158 | table.setLayout(layout); |
1159 | table.setHeaderVisible(true); |
1160 | table.setLinesVisible(true); |
1161 | |
1162 | TableColumn objectColumn = new TableColumn(table, SWT.NONE); |
1163 | layout.addColumnData(new ColumnWeightData(3, 100, true)); |
1164 | objectColumn.setText(getString("_UI_ObjectColumn_label")); |
1165 | objectColumn.setResizable(true); |
1166 | |
1167 | TableColumn selfColumn = new TableColumn(table, SWT.NONE); |
1168 | layout.addColumnData(new ColumnWeightData(2, 100, true)); |
1169 | selfColumn.setText(getString("_UI_SelfColumn_label")); |
1170 | selfColumn.setResizable(true); |
1171 | |
1172 | tableViewer.setColumnProperties(new String [] {"a", "b"}); |
1173 | tableViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); |
1174 | tableViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); |
1175 | |
1176 | createContextMenuFor(tableViewer); |
1177 | int pageIndex = addPage(viewerPane.getControl()); |
1178 | setPageText(pageIndex, getString("_UI_TablePage_label")); |
1179 | } |
1180 | |
1181 | // This is the page for the table tree viewer. |
1182 | // |
1183 | { |
1184 | ViewerPane viewerPane = |
1185 | new ViewerPane(getSite().getPage(), QMLProfileEditor.this) { |
1186 | @Override |
1187 | public Viewer createViewer(Composite composite) { |
1188 | return new TreeViewer(composite); |
1189 | } |
1190 | @Override |
1191 | public void requestActivation() { |
1192 | super.requestActivation(); |
1193 | setCurrentViewerPane(this); |
1194 | } |
1195 | }; |
1196 | viewerPane.createControl(getContainer()); |
1197 | |
1198 | treeViewerWithColumns = (TreeViewer)viewerPane.getViewer(); |
1199 | |
1200 | Tree tree = treeViewerWithColumns.getTree(); |
1201 | tree.setLayoutData(new FillLayout()); |
1202 | tree.setHeaderVisible(true); |
1203 | tree.setLinesVisible(true); |
1204 | |
1205 | TreeColumn objectColumn = new TreeColumn(tree, SWT.NONE); |
1206 | objectColumn.setText(getString("_UI_ObjectColumn_label")); |
1207 | objectColumn.setResizable(true); |
1208 | objectColumn.setWidth(250); |
1209 | |
1210 | TreeColumn selfColumn = new TreeColumn(tree, SWT.NONE); |
1211 | selfColumn.setText(getString("_UI_SelfColumn_label")); |
1212 | selfColumn.setResizable(true); |
1213 | selfColumn.setWidth(200); |
1214 | |
1215 | treeViewerWithColumns.setColumnProperties(new String [] {"a", "b"}); |
1216 | treeViewerWithColumns.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); |
1217 | treeViewerWithColumns.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); |
1218 | |
1219 | createContextMenuFor(treeViewerWithColumns); |
1220 | int pageIndex = addPage(viewerPane.getControl()); |
1221 | setPageText(pageIndex, getString("_UI_TreeWithColumnsPage_label")); |
1222 | } |
1223 | |
1224 | getSite().getShell().getDisplay().asyncExec |
1225 | (new Runnable() { |
1226 | public void run() { |
1227 | setActivePage(0); |
1228 | } |
1229 | }); |
1230 | } |
1231 | |
1232 | // Ensures that this editor will only display the page's tab |
1233 | // area if there are more than one page |
1234 | // |
1235 | getContainer().addControlListener |
1236 | (new ControlAdapter() { |
1237 | boolean guard = false; |
1238 | @Override |
1239 | public void controlResized(ControlEvent event) { |
1240 | if (!guard) { |
1241 | guard = true; |
1242 | hideTabs(); |
1243 | guard = false; |
1244 | } |
1245 | } |
1246 | }); |
1247 | |
1248 | getSite().getShell().getDisplay().asyncExec |
1249 | (new Runnable() { |
1250 | public void run() { |
1251 | updateProblemIndication(); |
1252 | } |
1253 | }); |
1254 | } |
1255 | |
1256 | /** |
1257 | * If there is just one page in the multi-page editor part, |
1258 | * this hides the single tab at the bottom. |
1259 | * <!-- begin-user-doc --> |
1260 | * <!-- end-user-doc --> |
1261 | * @generated |
1262 | */ |
1263 | protected void hideTabs() { |
1264 | if (getPageCount() <= 1) { |
1265 | setPageText(0, ""); |
1266 | if (getContainer() instanceof CTabFolder) { |
1267 | ((CTabFolder)getContainer()).setTabHeight(1); |
1268 | Point point = getContainer().getSize(); |
1269 | getContainer().setSize(point.x, point.y + 6); |
1270 | } |
1271 | } |
1272 | } |
1273 | |
1274 | /** |
1275 | * If there is more than one page in the multi-page editor part, |
1276 | * this shows the tabs at the bottom. |
1277 | * <!-- begin-user-doc --> |
1278 | * <!-- end-user-doc --> |
1279 | * @generated |
1280 | */ |
1281 | protected void showTabs() { |
1282 | if (getPageCount() > 1) { |
1283 | setPageText(0, getString("_UI_SelectionPage_label")); |
1284 | if (getContainer() instanceof CTabFolder) { |
1285 | ((CTabFolder)getContainer()).setTabHeight(SWT.DEFAULT); |
1286 | Point point = getContainer().getSize(); |
1287 | getContainer().setSize(point.x, point.y - 6); |
1288 | } |
1289 | } |
1290 | } |
1291 | |
1292 | /** |
1293 | * This is used to track the active viewer. |
1294 | * <!-- begin-user-doc --> |
1295 | * <!-- end-user-doc --> |
1296 | * @generated |
1297 | */ |
1298 | @Override |
1299 | protected void pageChange(int pageIndex) { |
1300 | super.pageChange(pageIndex); |
1301 | |
1302 | if (contentOutlinePage != null) { |
1303 | handleContentOutlineSelection(contentOutlinePage.getSelection()); |
1304 | } |
1305 | } |
1306 | |
1307 | /** |
1308 | * This is how the framework determines which interfaces we implement. |
1309 | * <!-- begin-user-doc --> |
1310 | * <!-- end-user-doc --> |
1311 | * @generated |
1312 | */ |
1313 | @SuppressWarnings("unchecked") |
1314 | @Override |
1315 | public Object getAdapter(Class key) { |
1316 | if (key.equals(IContentOutlinePage.class)) { |
1317 | return showOutlineView() ? getContentOutlinePage() : null; |
1318 | } |
1319 | else if (key.equals(IPropertySheetPage.class)) { |
1320 | return getPropertySheetPage(); |
1321 | } |
1322 | else if (key.equals(IGotoMarker.class)) { |
1323 | return this; |
1324 | } |
1325 | else { |
1326 | return super.getAdapter(key); |
1327 | } |
1328 | } |
1329 | |
1330 | /** |
1331 | * This accesses a cached version of the content outliner. |
1332 | * <!-- begin-user-doc --> |
1333 | * <!-- end-user-doc --> |
1334 | * @generated |
1335 | */ |
1336 | public IContentOutlinePage getContentOutlinePage() { |
1337 | if (contentOutlinePage == null) { |
1338 | // The content outline is just a tree. |
1339 | // |
1340 | class MyContentOutlinePage extends ContentOutlinePage { |
1341 | @Override |
1342 | public void createControl(Composite parent) { |
1343 | super.createControl(parent); |
1344 | contentOutlineViewer = getTreeViewer(); |
1345 | contentOutlineViewer.addSelectionChangedListener(this); |
1346 | |
1347 | // Set up the tree viewer. |
1348 | // |
1349 | contentOutlineViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); |
1350 | contentOutlineViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); |
1351 | contentOutlineViewer.setInput(editingDomain.getResourceSet()); |
1352 | |
1353 | // Make sure our popups work. |
1354 | // |
1355 | createContextMenuFor(contentOutlineViewer); |
1356 | |
1357 | if (!editingDomain.getResourceSet().getResources().isEmpty()) { |
1358 | // Select the root object in the view. |
1359 | // |
1360 | contentOutlineViewer.setSelection(new StructuredSelection(editingDomain.getResourceSet().getResources().get(0)), true); |
1361 | } |
1362 | } |
1363 | |
1364 | @Override |
1365 | public void makeContributions(IMenuManager menuManager, IToolBarManager toolBarManager, IStatusLineManager statusLineManager) { |
1366 | super.makeContributions(menuManager, toolBarManager, statusLineManager); |
1367 | contentOutlineStatusLineManager = statusLineManager; |
1368 | } |
1369 | |
1370 | @Override |
1371 | public void setActionBars(IActionBars actionBars) { |
1372 | super.setActionBars(actionBars); |
1373 | getActionBarContributor().shareGlobalActions(this, actionBars); |
1374 | } |
1375 | } |
1376 | |
1377 | contentOutlinePage = new MyContentOutlinePage(); |
1378 | |
1379 | // Listen to selection so that we can handle it is a special way. |
1380 | // |
1381 | contentOutlinePage.addSelectionChangedListener |
1382 | (new ISelectionChangedListener() { |
1383 | // This ensures that we handle selections correctly. |
1384 | // |
1385 | public void selectionChanged(SelectionChangedEvent event) { |
1386 | handleContentOutlineSelection(event.getSelection()); |
1387 | } |
1388 | }); |
1389 | } |
1390 | |
1391 | return contentOutlinePage; |
1392 | } |
1393 | |
1394 | /** |
1395 | * This accesses a cached version of the property sheet. |
1396 | * <!-- begin-user-doc --> |
1397 | * <!-- end-user-doc --> |
1398 | * @generated not |
1399 | */ |
1400 | public IPropertySheetPage getPropertySheetPage() { |
1401 | if (propertySheetPage == null) { |
1402 | propertySheetPage = |
1403 | new ExtendedPropertySheetPage(editingDomain) { |
1404 | @Override |
1405 | public void setSelectionToViewer(List<?> selection) { |
1406 | QMLProfileEditor.this.setSelectionToViewer(selection); |
1407 | QMLProfileEditor.this.setFocus(); |
1408 | } |
1409 | |
1410 | @Override |
1411 | public void setActionBars(IActionBars actionBars) { |
1412 | super.setActionBars(actionBars); |
1413 | getActionBarContributor().shareGlobalActions(this, actionBars); |
1414 | } |
1415 | }; |
1416 | propertySheetPage.setPropertySourceProvider(new PalladioAdapterFactoryContentProvider(adapterFactory)); |
1417 | } |
1418 | |
1419 | return propertySheetPage; |
1420 | } |
1421 | |
1422 | /** |
1423 | * This deals with how we want selection in the outliner to affect the other views. |
1424 | * <!-- begin-user-doc --> |
1425 | * <!-- end-user-doc --> |
1426 | * @generated |
1427 | */ |
1428 | public void handleContentOutlineSelection(ISelection selection) { |
1429 | if (currentViewerPane != null && !selection.isEmpty() && selection instanceof IStructuredSelection) { |
1430 | Iterator<?> selectedElements = ((IStructuredSelection)selection).iterator(); |
1431 | if (selectedElements.hasNext()) { |
1432 | // Get the first selected element. |
1433 | // |
1434 | Object selectedElement = selectedElements.next(); |
1435 | |
1436 | // If it's the selection viewer, then we want it to select the same selection as this selection. |
1437 | // |
1438 | if (currentViewerPane.getViewer() == selectionViewer) { |
1439 | ArrayList<Object> selectionList = new ArrayList<Object>(); |
1440 | selectionList.add(selectedElement); |
1441 | while (selectedElements.hasNext()) { |
1442 | selectionList.add(selectedElements.next()); |
1443 | } |
1444 | |
1445 | // Set the selection to the widget. |
1446 | // |
1447 | selectionViewer.setSelection(new StructuredSelection(selectionList)); |
1448 | } |
1449 | else { |
1450 | // Set the input to the widget. |
1451 | // |
1452 | if (currentViewerPane.getViewer().getInput() != selectedElement) { |
1453 | currentViewerPane.getViewer().setInput(selectedElement); |
1454 | currentViewerPane.setTitle(selectedElement); |
1455 | } |
1456 | } |
1457 | } |
1458 | } |
1459 | } |
1460 | |
1461 | /** |
1462 | * This is for implementing {@link IEditorPart} and simply tests the command stack. |
1463 | * <!-- begin-user-doc --> |
1464 | * <!-- end-user-doc --> |
1465 | * @generated |
1466 | */ |
1467 | @Override |
1468 | public boolean isDirty() { |
1469 | return ((BasicCommandStack)editingDomain.getCommandStack()).isSaveNeeded(); |
1470 | } |
1471 | |
1472 | /** |
1473 | * This is for implementing {@link IEditorPart} and simply saves the model file. |
1474 | * <!-- begin-user-doc --> |
1475 | * <!-- end-user-doc --> |
1476 | * @generated |
1477 | */ |
1478 | @Override |
1479 | public void doSave(IProgressMonitor progressMonitor) { |
1480 | // Save only resources that have actually changed. |
1481 | // |
1482 | final Map<Object, Object> saveOptions = new HashMap<Object, Object>(); |
1483 | saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED, Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER); |
1484 | |
1485 | // Do the work within an operation because this is a long running activity that modifies the workbench. |
1486 | // |
1487 | WorkspaceModifyOperation operation = |
1488 | new WorkspaceModifyOperation() { |
1489 | // This is the method that gets invoked when the operation runs. |
1490 | // |
1491 | @Override |
1492 | public void execute(IProgressMonitor monitor) { |
1493 | // Save the resources to the file system. |
1494 | // |
1495 | boolean first = true; |
1496 | for (Resource resource : editingDomain.getResourceSet().getResources()) { |
1497 | if ((first || !resource.getContents().isEmpty() || isPersisted(resource)) && !editingDomain.isReadOnly(resource)) { |
1498 | try { |
1499 | long timeStamp = resource.getTimeStamp(); |
1500 | resource.save(saveOptions); |
1501 | if (resource.getTimeStamp() != timeStamp) { |
1502 | savedResources.add(resource); |
1503 | } |
1504 | } |
1505 | catch (Exception exception) { |
1506 | resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception)); |
1507 | } |
1508 | first = false; |
1509 | } |
1510 | } |
1511 | } |
1512 | }; |
1513 | |
1514 | updateProblemIndication = false; |
1515 | try { |
1516 | // This runs the options, and shows progress. |
1517 | // |
1518 | new ProgressMonitorDialog(getSite().getShell()).run(true, false, operation); |
1519 | |
1520 | // Refresh the necessary state. |
1521 | // |
1522 | ((BasicCommandStack)editingDomain.getCommandStack()).saveIsDone(); |
1523 | firePropertyChange(IEditorPart.PROP_DIRTY); |
1524 | } |
1525 | catch (Exception exception) { |
1526 | // Something went wrong that shouldn't. |
1527 | // |
1528 | QMLProfileEditorPlugin.INSTANCE.log(exception); |
1529 | } |
1530 | updateProblemIndication = true; |
1531 | updateProblemIndication(); |
1532 | } |
1533 | |
1534 | /** |
1535 | * This returns whether something has been persisted to the URI of the specified resource. |
1536 | * The implementation uses the URI converter from the editor's resource set to try to open an input stream. |
1537 | * <!-- begin-user-doc --> |
1538 | * <!-- end-user-doc --> |
1539 | * @generated |
1540 | */ |
1541 | protected boolean isPersisted(Resource resource) { |
1542 | boolean result = false; |
1543 | try { |
1544 | InputStream stream = editingDomain.getResourceSet().getURIConverter().createInputStream(resource.getURI()); |
1545 | if (stream != null) { |
1546 | result = true; |
1547 | stream.close(); |
1548 | } |
1549 | } |
1550 | catch (IOException e) { |
1551 | // Ignore |
1552 | } |
1553 | return result; |
1554 | } |
1555 | |
1556 | /** |
1557 | * This always returns true because it is not currently supported. |
1558 | * <!-- begin-user-doc --> |
1559 | * <!-- end-user-doc --> |
1560 | * @generated |
1561 | */ |
1562 | @Override |
1563 | public boolean isSaveAsAllowed() { |
1564 | return true; |
1565 | } |
1566 | |
1567 | /** |
1568 | * This also changes the editor's input. |
1569 | * <!-- begin-user-doc --> |
1570 | * <!-- end-user-doc --> |
1571 | * @generated |
1572 | */ |
1573 | @Override |
1574 | public void doSaveAs() { |
1575 | SaveAsDialog saveAsDialog = new SaveAsDialog(getSite().getShell()); |
1576 | saveAsDialog.open(); |
1577 | IPath path = saveAsDialog.getResult(); |
1578 | if (path != null) { |
1579 | IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path); |
1580 | if (file != null) { |
1581 | doSaveAs(URI.createPlatformResourceURI(file.getFullPath().toString(), true), new FileEditorInput(file)); |
1582 | } |
1583 | } |
1584 | } |
1585 | |
1586 | /** |
1587 | * <!-- begin-user-doc --> |
1588 | * <!-- end-user-doc --> |
1589 | * @generated |
1590 | */ |
1591 | protected void doSaveAs(URI uri, IEditorInput editorInput) { |
1592 | (editingDomain.getResourceSet().getResources().get(0)).setURI(uri); |
1593 | setInputWithNotify(editorInput); |
1594 | setPartName(editorInput.getName()); |
1595 | IProgressMonitor progressMonitor = |
1596 | getActionBars().getStatusLineManager() != null ? |
1597 | getActionBars().getStatusLineManager().getProgressMonitor() : |
1598 | new NullProgressMonitor(); |
1599 | doSave(progressMonitor); |
1600 | } |
1601 | |
1602 | /** |
1603 | * <!-- begin-user-doc --> |
1604 | * <!-- end-user-doc --> |
1605 | * @generated |
1606 | */ |
1607 | public void gotoMarker(IMarker marker) { |
1608 | try { |
1609 | if (marker.getType().equals(EValidator.MARKER)) { |
1610 | String uriAttribute = marker.getAttribute(EValidator.URI_ATTRIBUTE, null); |
1611 | if (uriAttribute != null) { |
1612 | URI uri = URI.createURI(uriAttribute); |
1613 | EObject eObject = editingDomain.getResourceSet().getEObject(uri, true); |
1614 | if (eObject != null) { |
1615 | setSelectionToViewer(Collections.singleton(editingDomain.getWrapper(eObject))); |
1616 | } |
1617 | } |
1618 | } |
1619 | } |
1620 | catch (CoreException exception) { |
1621 | QMLProfileEditorPlugin.INSTANCE.log(exception); |
1622 | } |
1623 | } |
1624 | |
1625 | /** |
1626 | * This is called during startup. |
1627 | * <!-- begin-user-doc --> |
1628 | * <!-- end-user-doc --> |
1629 | * @generated |
1630 | */ |
1631 | @Override |
1632 | public void init(IEditorSite site, IEditorInput editorInput) { |
1633 | setSite(site); |
1634 | setInputWithNotify(editorInput); |
1635 | setPartName(editorInput.getName()); |
1636 | site.setSelectionProvider(this); |
1637 | site.getPage().addPartListener(partListener); |
1638 | ResourcesPlugin.getWorkspace().addResourceChangeListener(resourceChangeListener, IResourceChangeEvent.POST_CHANGE); |
1639 | } |
1640 | |
1641 | /** |
1642 | * <!-- begin-user-doc --> |
1643 | * <!-- end-user-doc --> |
1644 | * @generated |
1645 | */ |
1646 | @Override |
1647 | public void setFocus() { |
1648 | if (currentViewerPane != null) { |
1649 | currentViewerPane.setFocus(); |
1650 | } |
1651 | else { |
1652 | getControl(getActivePage()).setFocus(); |
1653 | } |
1654 | } |
1655 | |
1656 | /** |
1657 | * This implements {@link org.eclipse.jface.viewers.ISelectionProvider}. |
1658 | * <!-- begin-user-doc --> |
1659 | * <!-- end-user-doc --> |
1660 | * @generated |
1661 | */ |
1662 | public void addSelectionChangedListener(ISelectionChangedListener listener) { |
1663 | selectionChangedListeners.add(listener); |
1664 | } |
1665 | |
1666 | /** |
1667 | * This implements {@link org.eclipse.jface.viewers.ISelectionProvider}. |
1668 | * <!-- begin-user-doc --> |
1669 | * <!-- end-user-doc --> |
1670 | * @generated |
1671 | */ |
1672 | public void removeSelectionChangedListener(ISelectionChangedListener listener) { |
1673 | selectionChangedListeners.remove(listener); |
1674 | } |
1675 | |
1676 | /** |
1677 | * This implements {@link org.eclipse.jface.viewers.ISelectionProvider} to return this editor's overall selection. |
1678 | * <!-- begin-user-doc --> |
1679 | * <!-- end-user-doc --> |
1680 | * @generated |
1681 | */ |
1682 | public ISelection getSelection() { |
1683 | return editorSelection; |
1684 | } |
1685 | |
1686 | /** |
1687 | * This implements {@link org.eclipse.jface.viewers.ISelectionProvider} to set this editor's overall selection. |
1688 | * Calling this result will notify the listeners. |
1689 | * <!-- begin-user-doc --> |
1690 | * <!-- end-user-doc --> |
1691 | * @generated |
1692 | */ |
1693 | public void setSelection(ISelection selection) { |
1694 | editorSelection = selection; |
1695 | |
1696 | for (ISelectionChangedListener listener : selectionChangedListeners) { |
1697 | listener.selectionChanged(new SelectionChangedEvent(this, selection)); |
1698 | } |
1699 | setStatusLineManager(selection); |
1700 | } |
1701 | |
1702 | /** |
1703 | * <!-- begin-user-doc --> |
1704 | * <!-- end-user-doc --> |
1705 | * @generated |
1706 | */ |
1707 | public void setStatusLineManager(ISelection selection) { |
1708 | IStatusLineManager statusLineManager = currentViewer != null && currentViewer == contentOutlineViewer ? |
1709 | contentOutlineStatusLineManager : getActionBars().getStatusLineManager(); |
1710 | |
1711 | if (statusLineManager != null) { |
1712 | if (selection instanceof IStructuredSelection) { |
1713 | Collection<?> collection = ((IStructuredSelection)selection).toList(); |
1714 | switch (collection.size()) { |
1715 | case 0: { |
1716 | statusLineManager.setMessage(getString("_UI_NoObjectSelected")); |
1717 | break; |
1718 | } |
1719 | case 1: { |
1720 | String text = new AdapterFactoryItemDelegator(adapterFactory).getText(collection.iterator().next()); |
1721 | statusLineManager.setMessage(getString("_UI_SingleObjectSelected", text)); |
1722 | break; |
1723 | } |
1724 | default: { |
1725 | statusLineManager.setMessage(getString("_UI_MultiObjectSelected", Integer.toString(collection.size()))); |
1726 | break; |
1727 | } |
1728 | } |
1729 | } |
1730 | else { |
1731 | statusLineManager.setMessage(""); |
1732 | } |
1733 | } |
1734 | } |
1735 | |
1736 | /** |
1737 | * This looks up a string in the plugin's plugin.properties file. |
1738 | * <!-- begin-user-doc --> |
1739 | * <!-- end-user-doc --> |
1740 | * @generated |
1741 | */ |
1742 | private static String getString(String key) { |
1743 | return QMLProfileEditorPlugin.INSTANCE.getString(key); |
1744 | } |
1745 | |
1746 | /** |
1747 | * This looks up a string in plugin.properties, making a substitution. |
1748 | * <!-- begin-user-doc --> |
1749 | * <!-- end-user-doc --> |
1750 | * @generated |
1751 | */ |
1752 | private static String getString(String key, Object s1) { |
1753 | return QMLProfileEditorPlugin.INSTANCE.getString(key, new Object [] { s1 }); |
1754 | } |
1755 | |
1756 | /** |
1757 | * This implements {@link org.eclipse.jface.action.IMenuListener} to help fill the context menus with contributions from the Edit menu. |
1758 | * <!-- begin-user-doc --> |
1759 | * <!-- end-user-doc --> |
1760 | * @generated |
1761 | */ |
1762 | public void menuAboutToShow(IMenuManager menuManager) { |
1763 | ((IMenuListener)getEditorSite().getActionBarContributor()).menuAboutToShow(menuManager); |
1764 | } |
1765 | |
1766 | /** |
1767 | * <!-- begin-user-doc --> |
1768 | * <!-- end-user-doc --> |
1769 | * @generated |
1770 | */ |
1771 | public EditingDomainActionBarContributor getActionBarContributor() { |
1772 | return (EditingDomainActionBarContributor)getEditorSite().getActionBarContributor(); |
1773 | } |
1774 | |
1775 | /** |
1776 | * <!-- begin-user-doc --> |
1777 | * <!-- end-user-doc --> |
1778 | * @generated |
1779 | */ |
1780 | public IActionBars getActionBars() { |
1781 | return getActionBarContributor().getActionBars(); |
1782 | } |
1783 | |
1784 | /** |
1785 | * <!-- begin-user-doc --> |
1786 | * <!-- end-user-doc --> |
1787 | * @generated |
1788 | */ |
1789 | public AdapterFactory getAdapterFactory() { |
1790 | return adapterFactory; |
1791 | } |
1792 | |
1793 | /** |
1794 | * <!-- begin-user-doc --> |
1795 | * <!-- end-user-doc --> |
1796 | * @generated not |
1797 | */ |
1798 | @Override |
1799 | public void dispose() { |
1800 | updateProblemIndication = false; |
1801 | |
1802 | ResourcesPlugin.getWorkspace().removeResourceChangeListener(resourceChangeListener); |
1803 | |
1804 | getSite().getPage().removePartListener(partListener); |
1805 | |
1806 | ((PalladioItemProviderAdapterFactory)adapterFactory).dispose(); |
1807 | |
1808 | if (getActionBarContributor().getActiveEditor() == this) { |
1809 | getActionBarContributor().setActiveEditor(null); |
1810 | } |
1811 | |
1812 | if (propertySheetPage != null) { |
1813 | propertySheetPage.dispose(); |
1814 | } |
1815 | |
1816 | if (contentOutlinePage != null) { |
1817 | contentOutlinePage.dispose(); |
1818 | } |
1819 | |
1820 | super.dispose(); |
1821 | } |
1822 | |
1823 | /** |
1824 | * Returns whether the outline view should be presented to the user. |
1825 | * <!-- begin-user-doc --> |
1826 | * <!-- end-user-doc --> |
1827 | * @generated |
1828 | */ |
1829 | protected boolean showOutlineView() { |
1830 | return true; |
1831 | } |
1832 | } |