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