1 | /** |
2 | * Copyright 2007 by SDQ, IPD, University of Karlsruhe, Germany |
3 | * |
4 | * $Id$ |
5 | */ |
6 | package de.uka.ipd.sdq.pcm.resourcetype.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.ui.provider.PalladioItemProviderAdapterFactory; |
149 | import de.uka.ipd.sdq.probfunction.provider.ProbfunctionItemProviderAdapterFactory; |
150 | import de.uka.ipd.sdq.stoex.provider.StoexItemProviderAdapterFactory; |
151 | import de.uka.ipd.sdq.units.provider.UnitsItemProviderAdapterFactory; |
152 | |
153 | |
154 | /** |
155 | * This is an example of a Resourcetype model editor. |
156 | * <!-- begin-user-doc --> |
157 | * <!-- end-user-doc --> |
158 | * @generated |
159 | */ |
160 | public class ResourcetypeEditor |
161 | extends MultiPageEditorPart |
162 | implements IEditingDomainProvider, ISelectionProvider, IMenuListener, IViewerProvider, IGotoMarker { |
163 | /** |
164 | * <!-- begin-user-doc --> |
165 | * <!-- end-user-doc --> |
166 | * @generated |
167 | */ |
168 | public static final String copyright = "Copyright 2005-2009 by SDQ, IPD, University of Karlsruhe, Germany"; |
169 | |
170 | /** |
171 | * This keeps track of the editing domain that is used to track all changes to the model. |
172 | * <!-- begin-user-doc --> |
173 | * <!-- end-user-doc --> |
174 | * @generated |
175 | */ |
176 | protected AdapterFactoryEditingDomain editingDomain; |
177 | |
178 | /** |
179 | * This is the one adapter factory used for providing views of the model. |
180 | * <!-- begin-user-doc --> |
181 | * <!-- end-user-doc --> |
182 | * @generated not |
183 | */ |
184 | protected AdapterFactory adapterFactory; |
185 | |
186 | /** |
187 | * This is the content outline page. |
188 | * <!-- begin-user-doc --> |
189 | * <!-- end-user-doc --> |
190 | * @generated |
191 | */ |
192 | protected IContentOutlinePage contentOutlinePage; |
193 | |
194 | /** |
195 | * This is a kludge... |
196 | * <!-- begin-user-doc --> |
197 | * <!-- end-user-doc --> |
198 | * @generated |
199 | */ |
200 | protected IStatusLineManager contentOutlineStatusLineManager; |
201 | |
202 | /** |
203 | * This is the content outline page's viewer. |
204 | * <!-- begin-user-doc --> |
205 | * <!-- end-user-doc --> |
206 | * @generated |
207 | */ |
208 | protected TreeViewer contentOutlineViewer; |
209 | |
210 | /** |
211 | * This is the property sheet page. |
212 | * <!-- begin-user-doc --> |
213 | * <!-- end-user-doc --> |
214 | * @generated |
215 | */ |
216 | protected PropertySheetPage propertySheetPage; |
217 | |
218 | /** |
219 | * This is the viewer that shadows the selection in the content outline. |
220 | * The parent relation must be correctly defined for this to work. |
221 | * <!-- begin-user-doc --> |
222 | * <!-- end-user-doc --> |
223 | * @generated |
224 | */ |
225 | protected TreeViewer selectionViewer; |
226 | |
227 | /** |
228 | * This inverts the roll of parent and child in the content provider and show parents as a tree. |
229 | * <!-- begin-user-doc --> |
230 | * <!-- end-user-doc --> |
231 | * @generated |
232 | */ |
233 | protected TreeViewer parentViewer; |
234 | |
235 | /** |
236 | * This shows how a tree view works. |
237 | * <!-- begin-user-doc --> |
238 | * <!-- end-user-doc --> |
239 | * @generated |
240 | */ |
241 | protected TreeViewer treeViewer; |
242 | |
243 | /** |
244 | * This shows how a list view works. |
245 | * A list viewer doesn't support icons. |
246 | * <!-- begin-user-doc --> |
247 | * <!-- end-user-doc --> |
248 | * @generated |
249 | */ |
250 | protected ListViewer listViewer; |
251 | |
252 | /** |
253 | * This shows how a table view works. |
254 | * A table can be used as a list with icons. |
255 | * <!-- begin-user-doc --> |
256 | * <!-- end-user-doc --> |
257 | * @generated |
258 | */ |
259 | protected TableViewer tableViewer; |
260 | |
261 | /** |
262 | * This shows how a tree view with columns works. |
263 | * <!-- begin-user-doc --> |
264 | * <!-- end-user-doc --> |
265 | * @generated |
266 | */ |
267 | protected TreeViewer treeViewerWithColumns; |
268 | |
269 | /** |
270 | * This keeps track of the active viewer pane, in the book. |
271 | * <!-- begin-user-doc --> |
272 | * <!-- end-user-doc --> |
273 | * @generated |
274 | */ |
275 | protected ViewerPane currentViewerPane; |
276 | |
277 | /** |
278 | * This keeps track of the active content viewer, which may be either one of the viewers in the pages or the content outline viewer. |
279 | * <!-- begin-user-doc --> |
280 | * <!-- end-user-doc --> |
281 | * @generated |
282 | */ |
283 | protected Viewer currentViewer; |
284 | |
285 | /** |
286 | * This listens to which ever viewer is active. |
287 | * <!-- begin-user-doc --> |
288 | * <!-- end-user-doc --> |
289 | * @generated |
290 | */ |
291 | protected ISelectionChangedListener selectionChangedListener; |
292 | |
293 | /** |
294 | * This keeps track of all the {@link org.eclipse.jface.viewers.ISelectionChangedListener}s that are listening to this editor. |
295 | * <!-- begin-user-doc --> |
296 | * <!-- end-user-doc --> |
297 | * @generated |
298 | */ |
299 | protected Collection<ISelectionChangedListener> selectionChangedListeners = new ArrayList<ISelectionChangedListener>(); |
300 | |
301 | /** |
302 | * This keeps track of the selection of the editor as a whole. |
303 | * <!-- begin-user-doc --> |
304 | * <!-- end-user-doc --> |
305 | * @generated |
306 | */ |
307 | protected ISelection editorSelection = StructuredSelection.EMPTY; |
308 | |
309 | /** |
310 | * The MarkerHelper is responsible for creating workspace resource markers presented |
311 | * in Eclipse's Problems View. |
312 | * <!-- begin-user-doc --> |
313 | * <!-- end-user-doc --> |
314 | * @generated |
315 | */ |
316 | protected MarkerHelper markerHelper = new EditUIMarkerHelper(); |
317 | |
318 | /** |
319 | * This listens for when the outline becomes active |
320 | * <!-- begin-user-doc --> |
321 | * <!-- end-user-doc --> |
322 | * @generated |
323 | */ |
324 | protected IPartListener partListener = |
325 | new IPartListener() { |
326 | public void partActivated(IWorkbenchPart p) { |
327 | if (p instanceof ContentOutline) { |
328 | if (((ContentOutline)p).getCurrentPage() == contentOutlinePage) { |
329 | getActionBarContributor().setActiveEditor(ResourcetypeEditor.this); |
330 | |
331 | setCurrentViewer(contentOutlineViewer); |
332 | } |
333 | } |
334 | else if (p instanceof PropertySheet) { |
335 | if (((PropertySheet)p).getCurrentPage() == propertySheetPage) { |
336 | getActionBarContributor().setActiveEditor(ResourcetypeEditor.this); |
337 | handleActivate(); |
338 | } |
339 | } |
340 | else if (p == ResourcetypeEditor.this) { |
341 | handleActivate(); |
342 | } |
343 | } |
344 | public void partBroughtToTop(IWorkbenchPart p) { |
345 | // Ignore. |
346 | } |
347 | public void partClosed(IWorkbenchPart p) { |
348 | // Ignore. |
349 | } |
350 | public void partDeactivated(IWorkbenchPart p) { |
351 | // Ignore. |
352 | } |
353 | public void partOpened(IWorkbenchPart p) { |
354 | // Ignore. |
355 | } |
356 | }; |
357 | |
358 | /** |
359 | * Resources that have been removed since last activation. |
360 | * <!-- begin-user-doc --> |
361 | * <!-- end-user-doc --> |
362 | * @generated |
363 | */ |
364 | protected Collection<Resource> removedResources = new ArrayList<Resource>(); |
365 | |
366 | /** |
367 | * Resources that have been changed since last activation. |
368 | * <!-- begin-user-doc --> |
369 | * <!-- end-user-doc --> |
370 | * @generated |
371 | */ |
372 | protected Collection<Resource> changedResources = new ArrayList<Resource>(); |
373 | |
374 | /** |
375 | * Resources that have been saved. |
376 | * <!-- begin-user-doc --> |
377 | * <!-- end-user-doc --> |
378 | * @generated |
379 | */ |
380 | protected Collection<Resource> savedResources = new ArrayList<Resource>(); |
381 | |
382 | /** |
383 | * Map to store the diagnostic associated with a resource. |
384 | * <!-- begin-user-doc --> |
385 | * <!-- end-user-doc --> |
386 | * @generated |
387 | */ |
388 | protected Map<Resource, Diagnostic> resourceToDiagnosticMap = new LinkedHashMap<Resource, Diagnostic>(); |
389 | |
390 | /** |
391 | * Controls whether the problem indication should be updated. |
392 | * <!-- begin-user-doc --> |
393 | * <!-- end-user-doc --> |
394 | * @generated |
395 | */ |
396 | protected boolean updateProblemIndication = true; |
397 | |
398 | /** |
399 | * Adapter used to update the problem indication when resources are demanded loaded. |
400 | * <!-- begin-user-doc --> |
401 | * <!-- end-user-doc --> |
402 | * @generated |
403 | */ |
404 | protected EContentAdapter problemIndicationAdapter = |
405 | new EContentAdapter() { |
406 | @Override |
407 | public void notifyChanged(Notification notification) { |
408 | if (notification.getNotifier() instanceof Resource) { |
409 | switch (notification.getFeatureID(Resource.class)) { |
410 | case Resource.RESOURCE__IS_LOADED: |
411 | case Resource.RESOURCE__ERRORS: |
412 | case Resource.RESOURCE__WARNINGS: { |
413 | Resource resource = (Resource)notification.getNotifier(); |
414 | Diagnostic diagnostic = analyzeResourceProblems(resource, null); |
415 | if (diagnostic.getSeverity() != Diagnostic.OK) { |
416 | resourceToDiagnosticMap.put(resource, diagnostic); |
417 | } |
418 | else { |
419 | resourceToDiagnosticMap.remove(resource); |
420 | } |
421 | |
422 | if (updateProblemIndication) { |
423 | getSite().getShell().getDisplay().asyncExec |
424 | (new Runnable() { |
425 | public void run() { |
426 | updateProblemIndication(); |
427 | } |
428 | }); |
429 | } |
430 | break; |
431 | } |
432 | } |
433 | } |
434 | else { |
435 | super.notifyChanged(notification); |
436 | } |
437 | } |
438 | |
439 | @Override |
440 | protected void setTarget(Resource target) { |
441 | basicSetTarget(target); |
442 | } |
443 | |
444 | @Override |
445 | protected void unsetTarget(Resource target) { |
446 | basicUnsetTarget(target); |
447 | } |
448 | }; |
449 | |
450 | /** |
451 | * This listens for workspace changes. |
452 | * <!-- begin-user-doc --> |
453 | * <!-- end-user-doc --> |
454 | * @generated |
455 | */ |
456 | protected IResourceChangeListener resourceChangeListener = |
457 | new IResourceChangeListener() { |
458 | public void resourceChanged(IResourceChangeEvent event) { |
459 | IResourceDelta delta = event.getDelta(); |
460 | try { |
461 | class ResourceDeltaVisitor implements IResourceDeltaVisitor { |
462 | protected ResourceSet resourceSet = editingDomain.getResourceSet(); |
463 | protected Collection<Resource> changedResources = new ArrayList<Resource>(); |
464 | protected Collection<Resource> removedResources = new ArrayList<Resource>(); |
465 | |
466 | public boolean visit(IResourceDelta delta) { |
467 | if (delta.getResource().getType() == IResource.FILE) { |
468 | if (delta.getKind() == IResourceDelta.REMOVED || |
469 | delta.getKind() == IResourceDelta.CHANGED && delta.getFlags() != IResourceDelta.MARKERS) { |
470 | Resource resource = resourceSet.getResource(URI.createPlatformResourceURI(delta.getFullPath().toString(), true), false); |
471 | if (resource != null) { |
472 | if (delta.getKind() == IResourceDelta.REMOVED) { |
473 | removedResources.add(resource); |
474 | } |
475 | else if (!savedResources.remove(resource)) { |
476 | changedResources.add(resource); |
477 | } |
478 | } |
479 | } |
480 | } |
481 | |
482 | return true; |
483 | } |
484 | |
485 | public Collection<Resource> getChangedResources() { |
486 | return changedResources; |
487 | } |
488 | |
489 | public Collection<Resource> getRemovedResources() { |
490 | return removedResources; |
491 | } |
492 | } |
493 | |
494 | final ResourceDeltaVisitor visitor = new ResourceDeltaVisitor(); |
495 | delta.accept(visitor); |
496 | |
497 | if (!visitor.getRemovedResources().isEmpty()) { |
498 | getSite().getShell().getDisplay().asyncExec |
499 | (new Runnable() { |
500 | public void run() { |
501 | removedResources.addAll(visitor.getRemovedResources()); |
502 | if (!isDirty()) { |
503 | getSite().getPage().closeEditor(ResourcetypeEditor.this, false); |
504 | } |
505 | } |
506 | }); |
507 | } |
508 | |
509 | if (!visitor.getChangedResources().isEmpty()) { |
510 | getSite().getShell().getDisplay().asyncExec |
511 | (new Runnable() { |
512 | public void run() { |
513 | changedResources.addAll(visitor.getChangedResources()); |
514 | if (getSite().getPage().getActiveEditor() == ResourcetypeEditor.this) { |
515 | handleActivate(); |
516 | } |
517 | } |
518 | }); |
519 | } |
520 | } |
521 | catch (CoreException exception) { |
522 | PalladioComponentModelEditorPlugin.INSTANCE.log(exception); |
523 | } |
524 | } |
525 | }; |
526 | |
527 | /** |
528 | * Handles activation of the editor or it's associated views. |
529 | * <!-- begin-user-doc --> |
530 | * <!-- end-user-doc --> |
531 | * @generated |
532 | */ |
533 | protected void handleActivate() { |
534 | // Recompute the read only state. |
535 | // |
536 | if (editingDomain.getResourceToReadOnlyMap() != null) { |
537 | editingDomain.getResourceToReadOnlyMap().clear(); |
538 | |
539 | // Refresh any actions that may become enabled or disabled. |
540 | // |
541 | setSelection(getSelection()); |
542 | } |
543 | |
544 | if (!removedResources.isEmpty()) { |
545 | if (handleDirtyConflict()) { |
546 | getSite().getPage().closeEditor(ResourcetypeEditor.this, false); |
547 | } |
548 | else { |
549 | removedResources.clear(); |
550 | changedResources.clear(); |
551 | savedResources.clear(); |
552 | } |
553 | } |
554 | else if (!changedResources.isEmpty()) { |
555 | changedResources.removeAll(savedResources); |
556 | handleChangedResources(); |
557 | changedResources.clear(); |
558 | savedResources.clear(); |
559 | } |
560 | } |
561 | |
562 | /** |
563 | * Handles what to do with changed resources on activation. |
564 | * <!-- begin-user-doc --> |
565 | * <!-- end-user-doc --> |
566 | * @generated |
567 | */ |
568 | protected void handleChangedResources() { |
569 | if (!changedResources.isEmpty() && (!isDirty() || handleDirtyConflict())) { |
570 | if (isDirty()) { |
571 | changedResources.addAll(editingDomain.getResourceSet().getResources()); |
572 | } |
573 | editingDomain.getCommandStack().flush(); |
574 | |
575 | updateProblemIndication = false; |
576 | for (Resource resource : changedResources) { |
577 | if (resource.isLoaded()) { |
578 | resource.unload(); |
579 | try { |
580 | resource.load(Collections.EMPTY_MAP); |
581 | } |
582 | catch (IOException exception) { |
583 | if (!resourceToDiagnosticMap.containsKey(resource)) { |
584 | resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception)); |
585 | } |
586 | } |
587 | } |
588 | } |
589 | |
590 | if (AdapterFactoryEditingDomain.isStale(editorSelection)) { |
591 | setSelection(StructuredSelection.EMPTY); |
592 | } |
593 | |
594 | updateProblemIndication = true; |
595 | updateProblemIndication(); |
596 | } |
597 | } |
598 | |
599 | /** |
600 | * Updates the problems indication with the information described in the specified diagnostic. |
601 | * <!-- begin-user-doc --> |
602 | * <!-- end-user-doc --> |
603 | * @generated |
604 | */ |
605 | protected void updateProblemIndication() { |
606 | if (updateProblemIndication) { |
607 | BasicDiagnostic diagnostic = |
608 | new BasicDiagnostic |
609 | (Diagnostic.OK, |
610 | "de.uka.ipd.sdq.pcm.editor", |
611 | 0, |
612 | null, |
613 | new Object [] { editingDomain.getResourceSet() }); |
614 | for (Diagnostic childDiagnostic : resourceToDiagnosticMap.values()) { |
615 | if (childDiagnostic.getSeverity() != Diagnostic.OK) { |
616 | diagnostic.add(childDiagnostic); |
617 | } |
618 | } |
619 | |
620 | int lastEditorPage = getPageCount() - 1; |
621 | if (lastEditorPage >= 0 && getEditor(lastEditorPage) instanceof ProblemEditorPart) { |
622 | ((ProblemEditorPart)getEditor(lastEditorPage)).setDiagnostic(diagnostic); |
623 | if (diagnostic.getSeverity() != Diagnostic.OK) { |
624 | setActivePage(lastEditorPage); |
625 | } |
626 | } |
627 | else if (diagnostic.getSeverity() != Diagnostic.OK) { |
628 | ProblemEditorPart problemEditorPart = new ProblemEditorPart(); |
629 | problemEditorPart.setDiagnostic(diagnostic); |
630 | problemEditorPart.setMarkerHelper(markerHelper); |
631 | try { |
632 | addPage(++lastEditorPage, problemEditorPart, getEditorInput()); |
633 | setPageText(lastEditorPage, problemEditorPart.getPartName()); |
634 | setActivePage(lastEditorPage); |
635 | showTabs(); |
636 | } |
637 | catch (PartInitException exception) { |
638 | PalladioComponentModelEditorPlugin.INSTANCE.log(exception); |
639 | } |
640 | } |
641 | |
642 | if (markerHelper.hasMarkers(editingDomain.getResourceSet())) { |
643 | markerHelper.deleteMarkers(editingDomain.getResourceSet()); |
644 | if (diagnostic.getSeverity() != Diagnostic.OK) { |
645 | try { |
646 | markerHelper.createMarkers(diagnostic); |
647 | } |
648 | catch (CoreException exception) { |
649 | PalladioComponentModelEditorPlugin.INSTANCE.log(exception); |
650 | } |
651 | } |
652 | } |
653 | } |
654 | } |
655 | |
656 | /** |
657 | * Shows a dialog that asks if conflicting changes should be discarded. |
658 | * <!-- begin-user-doc --> |
659 | * <!-- end-user-doc --> |
660 | * @generated |
661 | */ |
662 | protected boolean handleDirtyConflict() { |
663 | return |
664 | MessageDialog.openQuestion |
665 | (getSite().getShell(), |
666 | getString("_UI_FileConflict_label"), |
667 | getString("_WARN_FileConflict")); |
668 | } |
669 | |
670 | /** |
671 | * This creates a model editor. |
672 | * <!-- begin-user-doc --> |
673 | * <!-- end-user-doc --> |
674 | * @generated |
675 | */ |
676 | public ResourcetypeEditor() { |
677 | super(); |
678 | initializeEditingDomain(); |
679 | } |
680 | |
681 | /** |
682 | * This sets up the editing domain for the model editor. |
683 | * <!-- begin-user-doc --> |
684 | * <!-- end-user-doc --> |
685 | * @generated not |
686 | */ |
687 | protected void initializeEditingDomain() { |
688 | // Create an adapter factory that yields item providers. |
689 | // |
690 | ComposedAdapterFactory compAdapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE) { |
691 | @Override |
692 | public ComposeableAdapterFactory getRootAdapterFactory() { |
693 | // TODO Auto-generated method stub |
694 | return (PalladioItemProviderAdapterFactory)adapterFactory; |
695 | } |
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(), ResourcetypeEditor.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(), ResourcetypeEditor.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(), ResourcetypeEditor.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(), ResourcetypeEditor.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(), ResourcetypeEditor.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(), ResourcetypeEditor.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 |
1410 | */ |
1411 | public IPropertySheetPage getPropertySheetPage() { |
1412 | if (propertySheetPage == null) { |
1413 | propertySheetPage = |
1414 | new ExtendedPropertySheetPage(editingDomain) { |
1415 | @Override |
1416 | public void setSelectionToViewer(List<?> selection) { |
1417 | ResourcetypeEditor.this.setSelectionToViewer(selection); |
1418 | ResourcetypeEditor.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 AdapterFactoryContentProvider(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 | } |