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