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