KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > Olj > presentation > OljEditor


1 /**
2  * <copyright>
3  * </copyright>
4  *
5  * $Id$
6  */

7 package Olj.presentation;
8
9
10 import org.eclipse.emf.common.command.BasicCommandStack;
11 import org.eclipse.emf.common.command.Command;
12 import org.eclipse.emf.common.command.CommandStack;
13 import org.eclipse.emf.common.command.CommandStackListener;
14
15 import org.eclipse.emf.common.notify.AdapterFactory;
16
17 import org.eclipse.emf.common.ui.ViewerPane;
18
19 import org.eclipse.emf.common.ui.viewer.IViewerProvider;
20
21 import org.eclipse.emf.common.util.URI;
22
23 import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
24 import org.eclipse.emf.edit.domain.EditingDomain;
25 import org.eclipse.emf.edit.domain.IEditingDomainProvider;
26
27 import org.eclipse.emf.edit.provider.AdapterFactoryItemDelegator;
28 import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
29 import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory;
30
31 import org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory;
32
33 import org.eclipse.emf.edit.ui.action.EditingDomainActionBarContributor;
34
35 import org.eclipse.emf.edit.ui.celleditor.AdapterFactoryTreeEditor;
36
37 import org.eclipse.emf.edit.ui.dnd.EditingDomainViewerDropAdapter;
38 import org.eclipse.emf.edit.ui.dnd.LocalTransfer;
39 import org.eclipse.emf.edit.ui.dnd.ViewerDragAdapter;
40
41 import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
42 import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
43
44 import org.eclipse.emf.ecore.EObject;
45 import org.eclipse.emf.ecore.EValidator;
46
47 import org.eclipse.emf.ecore.resource.Resource;
48 import org.eclipse.emf.ecore.resource.ResourceSet;
49
50 import java.io.IOException JavaDoc;
51
52 import java.util.ArrayList JavaDoc;
53 import java.util.Collection JavaDoc;
54 import java.util.Collections JavaDoc;
55 import java.util.EventObject JavaDoc;
56 import java.util.Iterator JavaDoc;
57 import java.util.List JavaDoc;
58
59 import org.eclipse.core.resources.IFile;
60 import org.eclipse.core.resources.IMarker;
61 import org.eclipse.core.resources.IResource;
62 import org.eclipse.core.resources.IResourceChangeListener;
63 import org.eclipse.core.resources.IResourceChangeEvent;
64 import org.eclipse.core.resources.IResourceDelta;
65 import org.eclipse.core.resources.IResourceDeltaVisitor;
66 import org.eclipse.core.resources.ResourcesPlugin;
67
68 import org.eclipse.core.runtime.CoreException;
69 import org.eclipse.core.runtime.IPath;
70 import org.eclipse.core.runtime.IProgressMonitor;
71
72 import org.eclipse.jface.action.IMenuListener;
73 import org.eclipse.jface.action.IMenuManager;
74 import org.eclipse.jface.action.IStatusLineManager;
75 import org.eclipse.jface.action.IToolBarManager;
76 import org.eclipse.jface.action.MenuManager;
77 import org.eclipse.jface.action.Separator;
78
79 import org.eclipse.jface.dialogs.MessageDialog;
80 import org.eclipse.jface.dialogs.ProgressMonitorDialog;
81
82 import org.eclipse.jface.viewers.ColumnWeightData;
83 import org.eclipse.jface.viewers.ISelection;
84 import org.eclipse.jface.viewers.ISelectionChangedListener;
85 import org.eclipse.jface.viewers.ISelectionProvider;
86 import org.eclipse.jface.viewers.IStructuredSelection;
87 import org.eclipse.jface.viewers.ListViewer;
88 import org.eclipse.jface.viewers.SelectionChangedEvent;
89 import org.eclipse.jface.viewers.StructuredSelection;
90 import org.eclipse.jface.viewers.StructuredViewer;
91 import org.eclipse.jface.viewers.TableLayout;
92 import org.eclipse.jface.viewers.TableTreeViewer;
93 import org.eclipse.jface.viewers.TableViewer;
94 import org.eclipse.jface.viewers.TreeViewer;
95 import org.eclipse.jface.viewers.Viewer;
96
97 import org.eclipse.swt.SWT;
98
99 import org.eclipse.swt.custom.TableTree;
100 import org.eclipse.swt.custom.CTabFolder;
101
102 import org.eclipse.swt.dnd.DND;
103 import org.eclipse.swt.dnd.Transfer;
104
105 import org.eclipse.swt.events.ControlAdapter;
106 import org.eclipse.swt.events.ControlEvent;
107
108 import org.eclipse.swt.graphics.Point;
109
110 import org.eclipse.swt.widgets.Composite;
111 import org.eclipse.swt.widgets.Control;
112 import org.eclipse.swt.widgets.Menu;
113 import org.eclipse.swt.widgets.Table;
114 import org.eclipse.swt.widgets.TableColumn;
115 import org.eclipse.swt.widgets.Tree;
116
117 import org.eclipse.ui.IActionBars;
118 import org.eclipse.ui.IEditorInput;
119 import org.eclipse.ui.IEditorPart;
120 import org.eclipse.ui.IEditorSite;
121 import org.eclipse.ui.IFileEditorInput;
122 import org.eclipse.ui.IPartListener;
123 import org.eclipse.ui.IWorkbenchPart;
124 import org.eclipse.ui.PartInitException;
125
126 import org.eclipse.ui.dialogs.SaveAsDialog;
127
128 import org.eclipse.ui.ide.IGotoMarker;
129
130 import org.eclipse.ui.part.FileEditorInput;
131 import org.eclipse.ui.part.MultiPageEditorPart;
132
133 import org.eclipse.ui.views.contentoutline.ContentOutline;
134 import org.eclipse.ui.views.contentoutline.ContentOutlinePage;
135 import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
136
137 import org.eclipse.ui.views.properties.IPropertySheetPage;
138 import org.eclipse.ui.views.properties.PropertySheet;
139 import org.eclipse.ui.views.properties.PropertySheetPage;
140
141 import Olj.provider.OljItemProviderAdapterFactory;
142
143
144 import java.util.HashMap JavaDoc;
145
146 import org.eclipse.core.runtime.NullProgressMonitor;
147
148 import org.eclipse.ui.actions.WorkspaceModifyOperation;
149
150
151 /**
152  * This is an example of a Olj model editor.
153  * <!-- begin-user-doc -->
154  * <!-- end-user-doc -->
155  * @generated
156  */

157 public class OljEditor
158     extends MultiPageEditorPart
159     implements IEditingDomainProvider, ISelectionProvider, IMenuListener, IViewerProvider, IGotoMarker {
160     /**
161      * This keeps track of the editing domain that is used to track all changes to the model.
162      * <!-- begin-user-doc -->
163      * <!-- end-user-doc -->
164      * @generated
165      */

166     protected AdapterFactoryEditingDomain editingDomain;
167
168     /**
169      * This is the one adapter factory used for providing views of the model.
170      * <!-- begin-user-doc -->
171      * <!-- end-user-doc -->
172      * @generated
173      */

174     protected ComposedAdapterFactory adapterFactory;
175
176     /**
177      * This is the content outline page.
178      * <!-- begin-user-doc -->
179      * <!-- end-user-doc -->
180      * @generated
181      */

182     protected IContentOutlinePage contentOutlinePage;
183
184     /**
185      * This is a kludge...
186      * <!-- begin-user-doc -->
187      * <!-- end-user-doc -->
188      * @generated
189      */

190     protected IStatusLineManager contentOutlineStatusLineManager;
191
192     /**
193      * This is the content outline page's viewer.
194      * <!-- begin-user-doc -->
195      * <!-- end-user-doc -->
196      * @generated
197      */

198     protected TreeViewer contentOutlineViewer;
199
200     /**
201      * This is the property sheet page.
202      * <!-- begin-user-doc -->
203      * <!-- end-user-doc -->
204      * @generated
205      */

206     protected PropertySheetPage propertySheetPage;
207
208     /**
209      * This is the viewer that shadows the selection in the content outline.
210      * The parent relation must be correctly defined for this to work.
211      * <!-- begin-user-doc -->
212      * <!-- end-user-doc -->
213      * @generated
214      */

215     protected TreeViewer selectionViewer;
216
217     /**
218      * This inverts the roll of parent and child in the content provider and show parents as a tree.
219      * <!-- begin-user-doc -->
220      * <!-- end-user-doc -->
221      * @generated
222      */

223     protected TreeViewer parentViewer;
224
225     /**
226      * This shows how a tree view works.
227      * <!-- begin-user-doc -->
228      * <!-- end-user-doc -->
229      * @generated
230      */

231     protected TreeViewer treeViewer;
232
233     /**
234      * This shows how a list view works.
235      * A list viewer doesn't support icons.
236      * <!-- begin-user-doc -->
237      * <!-- end-user-doc -->
238      * @generated
239      */

240     protected ListViewer listViewer;
241
242     /**
243      * This shows how a table view works.
244      * A table can be used as a list with icons.
245      * <!-- begin-user-doc -->
246      * <!-- end-user-doc -->
247      * @generated
248      */

249     protected TableViewer tableViewer;
250
251     /**
252      * This shows how a table view works.
253      * A table can be used as a list with icons.
254      * <!-- begin-user-doc -->
255      * <!-- end-user-doc -->
256      * @generated
257      */

258     protected TableTreeViewer tableTreeViewer;
259
260     /**
261      * This keeps track of the active viewer pane, in the book.
262      * <!-- begin-user-doc -->
263      * <!-- end-user-doc -->
264      * @generated
265      */

266     protected ViewerPane currentViewerPane;
267
268     /**
269      * This keeps track of the active content viewer, which may be either one of the viewers in the pages or the content outline viewer.
270      * <!-- begin-user-doc -->
271      * <!-- end-user-doc -->
272      * @generated
273      */

274     protected Viewer currentViewer;
275
276     /**
277      * This listens to which ever viewer is active.
278      * <!-- begin-user-doc -->
279      * <!-- end-user-doc -->
280      * @generated
281      */

282     protected ISelectionChangedListener selectionChangedListener;
283
284     /**
285      * This keeps track of all the {@link org.eclipse.jface.viewers.ISelectionChangedListener}s that are listening to this editor.
286      * <!-- begin-user-doc -->
287      * <!-- end-user-doc -->
288      * @generated
289      */

290     protected Collection JavaDoc selectionChangedListeners = new ArrayList JavaDoc();
291
292     /**
293      * This keeps track of the selection of the editor as a whole.
294      * <!-- begin-user-doc -->
295      * <!-- end-user-doc -->
296      * @generated
297      */

298     protected ISelection editorSelection = StructuredSelection.EMPTY;
299
300     /**
301      * This listens for when the outline becomes active
302      * <!-- begin-user-doc -->
303      * <!-- end-user-doc -->
304      * @generated
305      */

306     protected IPartListener partListener =
307         new IPartListener() {
308             public void partActivated(IWorkbenchPart p) {
309                 if (p instanceof ContentOutline) {
310                     if (((ContentOutline)p).getCurrentPage() == contentOutlinePage) {
311                         getActionBarContributor().setActiveEditor(OljEditor.this);
312
313                         setCurrentViewer(contentOutlineViewer);
314                     }
315                 }
316                 else if (p instanceof PropertySheet) {
317                     if (((PropertySheet)p).getCurrentPage() == propertySheetPage) {
318                         getActionBarContributor().setActiveEditor(OljEditor.this);
319                         handleActivate();
320                     }
321                 }
322                 else if (p == OljEditor.this) {
323                     handleActivate();
324                 }
325             }
326             public void partBroughtToTop(IWorkbenchPart p) {
327             }
328             public void partClosed(IWorkbenchPart p) {
329             }
330             public void partDeactivated(IWorkbenchPart p) {
331             }
332             public void partOpened(IWorkbenchPart p) {
333             }
334         };
335
336     /**
337      * Resources that have been removed since last activation.
338      * @generated
339      */

340     Collection JavaDoc removedResources = new ArrayList JavaDoc();
341
342     /**
343      * Resources that have been changed since last activation.
344      * @generated
345      */

346     Collection JavaDoc changedResources = new ArrayList JavaDoc();
347
348     /**
349      * Resources that have been saved.
350      * @generated
351      */

352     Collection JavaDoc savedResources = new ArrayList JavaDoc();
353
354     /**
355      * This listens for workspace changes.
356      * <!-- begin-user-doc -->
357      * <!-- end-user-doc -->
358      * @generated
359      */

360     protected IResourceChangeListener resourceChangeListener =
361         new IResourceChangeListener() {
362             public void resourceChanged(IResourceChangeEvent event) {
363                 ResourceSet resourceSet = editingDomain.getResourceSet();
364                 // Only listening to these.
365
// if (event.getType() == IResourceDelta.POST_CHANGE)
366
{
367                     IResourceDelta delta = event.getDelta();
368                     try {
369                         class ResourceDeltaVisitor implements IResourceDeltaVisitor {
370                             protected ResourceSet resourceSet = editingDomain.getResourceSet();
371                             protected Collection JavaDoc changedResources = new ArrayList JavaDoc();
372                             protected Collection JavaDoc removedResources = new ArrayList JavaDoc();
373
374                             public boolean visit(IResourceDelta delta) {
375                                 if (delta.getFlags() != IResourceDelta.MARKERS &&
376                                       delta.getResource().getType() == IResource.FILE) {
377                                     if ((delta.getKind() & (IResourceDelta.CHANGED | IResourceDelta.REMOVED)) != 0) {
378                                         Resource resource = resourceSet.getResource(URI.createURI(delta.getFullPath().toString()), false);
379                                         if (resource != null) {
380                                             if ((delta.getKind() & IResourceDelta.REMOVED) != 0) {
381                                                 removedResources.add(resource);
382                                             }
383                                             else {
384                                                 changedResources.add(resource);
385                                             }
386                                         }
387                                     }
388                                 }
389
390                                 return true;
391                             }
392
393                             public Collection JavaDoc getChangedResources() {
394                                 return changedResources;
395                             }
396
397                             public Collection JavaDoc getRemovedResources() {
398                                 return removedResources;
399                             }
400                         }
401
402                         ResourceDeltaVisitor visitor = new ResourceDeltaVisitor();
403                         delta.accept(visitor);
404
405                         removedResources.addAll(visitor.getRemovedResources());
406                         if (!visitor.getRemovedResources().isEmpty() && !isDirty()) {
407                             getSite().getShell().getDisplay().asyncExec
408                                 (new Runnable JavaDoc() {
409                                     public void run() {
410                                         getSite().getPage().closeEditor(OljEditor.this, false);
411                                         OljEditor.this.dispose();
412                                     }
413                                  });
414                         }
415
416                         changedResources.addAll(visitor.getChangedResources());
417                     }
418                     catch (CoreException exception) {
419                         OljEditorPlugin.INSTANCE.log(exception);
420                     }
421                 }
422             }
423         };
424
425     /**
426      * Handles activation of the editor or it's associated views.
427      * @generated
428      */

429     protected void handleActivate() {
430         // Recompute the read only state.
431
//
432
if (editingDomain.getResourceToReadOnlyMap() != null) {
433           editingDomain.getResourceToReadOnlyMap().clear();
434
435           // Refresh any actions that may become enabled or disabled.
436
//
437
setSelection(getSelection());
438         }
439
440         if (!removedResources.isEmpty()) {
441             if (handleDirtyConflict()) {
442                 getSite().getPage().closeEditor(OljEditor.this, false);
443                 OljEditor.this.dispose();
444             }
445             else {
446                 removedResources.clear();
447                 changedResources.clear();
448                 savedResources.clear();
449             }
450         }
451         else if (!changedResources.isEmpty()) {
452             changedResources.removeAll(savedResources);
453             handleChangedResources();
454             changedResources.clear();
455             savedResources.clear();
456         }
457     }
458
459
460     /**
461      * Handles what to do with changed resources on activation.
462      * @generated
463      */

464     protected void handleChangedResources() {
465         if (!changedResources.isEmpty() && (!isDirty() || handleDirtyConflict())) {
466           editingDomain.getCommandStack().flush();
467
468             for (Iterator JavaDoc i = changedResources.iterator(); i.hasNext(); ) {
469                 Resource resource = (Resource)i.next();
470                 if (resource.isLoaded()) {
471                     resource.unload();
472                     try {
473                         resource.load(Collections.EMPTY_MAP);
474                     }
475                     catch (IOException JavaDoc exception) {
476                         OljEditorPlugin.INSTANCE.log(exception);
477                     }
478                 }
479             }
480         }
481     }
482
483     /**
484      * Shows a dialog that asks if conflicting changes should be discarded.
485      * @generated
486      */

487     protected boolean handleDirtyConflict() {
488         return
489             MessageDialog.openQuestion
490                 (getSite().getShell(),
491                  getString("_UI_FileConflict_label"),
492                  getString("_WARN_FileConflict"));
493     }
494
495     /**
496      * This creates a model editor.
497      * <!-- begin-user-doc -->
498      * <!-- end-user-doc -->
499      * @generated
500      */

501     public OljEditor() {
502         super();
503
504         // Create an adapter factory that yields item providers.
505
//
506
List JavaDoc factories = new ArrayList JavaDoc();
507         factories.add(new ResourceItemProviderAdapterFactory());
508         factories.add(new OljItemProviderAdapterFactory());
509         factories.add(new ReflectiveItemProviderAdapterFactory());
510
511         adapterFactory = new ComposedAdapterFactory(factories);
512
513         // Create the command stack that will notify this editor as commands are executed.
514
//
515
BasicCommandStack commandStack = new BasicCommandStack();
516
517         // Add a listener to set the most recent command's affected objects to be the selection of the viewer with focus.
518
//
519
commandStack.addCommandStackListener
520             (new CommandStackListener() {
521                  public void commandStackChanged(final EventObject JavaDoc event) {
522                      getContainer().getDisplay().asyncExec
523                          (new Runnable JavaDoc() {
524                               public void run() {
525                                   firePropertyChange(IEditorPart.PROP_DIRTY);
526
527                                   // Try to select the affected objects.
528
//
529
Command mostRecentCommand = ((CommandStack)event.getSource()).getMostRecentCommand();
530                                   if (mostRecentCommand != null) {
531                                       setSelectionToViewer(mostRecentCommand.getAffectedObjects());
532                                   }
533                                   if (propertySheetPage != null) {
534                                       propertySheetPage.refresh();
535                                   }
536                               }
537                           });
538                  }
539              });
540
541         // Create the editing domain with a special command stack.
542
//
543
editingDomain = new AdapterFactoryEditingDomain(adapterFactory, commandStack, new HashMap JavaDoc());
544     }
545
546     /**
547      * This is here for the listener to be able to call it.
548      * <!-- begin-user-doc -->
549      * <!-- end-user-doc -->
550      * @generated
551      */

552     protected void firePropertyChange(int action) {
553         super.firePropertyChange(action);
554     }
555
556     /**
557      * This sets the selection into whichever viewer is active.
558      * <!-- begin-user-doc -->
559      * <!-- end-user-doc -->
560      * @generated
561      */

562     public void setSelectionToViewer(Collection JavaDoc collection) {
563         final Collection JavaDoc theSelection = collection;
564         // Make sure it's okay.
565
//
566
if (theSelection != null && !theSelection.isEmpty()) {
567             // I don't know if this should be run this deferred
568
// because we might have to give the editor a chance to process the viewer update events
569
// and hence to update the views first.
570
//
571
//
572
Runnable JavaDoc runnable =
573                 new Runnable JavaDoc() {
574                     public void run() {
575                         // Try to select the items in the current content viewer of the editor.
576
//
577
if (currentViewer != null) {
578                             currentViewer.setSelection(new StructuredSelection(theSelection.toArray()), true);
579                         }
580                     }
581                 };
582             runnable.run();
583         }
584     }
585
586     /**
587      * This returns the editing domain as required by the {@link IEditingDomainProvider} interface.
588      * This is important for implementing the static methods of {@link AdapterFactoryEditingDomain}
589      * and for supporting {@link org.eclipse.emf.edit.ui.action.CommandAction}.
590      * <!-- begin-user-doc -->
591      * <!-- end-user-doc -->
592      * @generated
593      */

594     public EditingDomain getEditingDomain() {
595         return editingDomain;
596     }
597
598     /**
599      * <!-- begin-user-doc -->
600      * <!-- end-user-doc -->
601      * @generated
602      */

603     public class ReverseAdapterFactoryContentProvider extends AdapterFactoryContentProvider {
604         public ReverseAdapterFactoryContentProvider(AdapterFactory adapterFactory) {
605             super(adapterFactory);
606         }
607
608         public Object JavaDoc [] getElements(Object JavaDoc object) {
609             Object JavaDoc parent = super.getParent(object);
610             return (parent == null ? Collections.EMPTY_SET : Collections.singleton(parent)).toArray();
611         }
612
613         public Object JavaDoc [] getChildren(Object JavaDoc object) {
614             Object JavaDoc parent = super.getParent(object);
615             return (parent == null ? Collections.EMPTY_SET : Collections.singleton(parent)).toArray();
616         }
617
618         public boolean hasChildren(Object JavaDoc object) {
619             Object JavaDoc parent = super.getParent(object);
620             return parent != null;
621         }
622
623         public Object JavaDoc getParent(Object JavaDoc object) {
624             return null;
625         }
626     }
627
628     /**
629      * <!-- begin-user-doc -->
630      * <!-- end-user-doc -->
631      * @generated
632      */

633     public void setCurrentViewerPane(ViewerPane viewerPane) {
634         if (currentViewerPane != viewerPane) {
635             if (currentViewerPane != null) {
636                 currentViewerPane.showFocus(false);
637             }
638             currentViewerPane = viewerPane;
639         }
640         setCurrentViewer(currentViewerPane.getViewer());
641     }
642
643     /**
644      * This makes sure that one content viewer, either for the current page or the outline view, if it has focus,
645      * is the current one.
646      * <!-- begin-user-doc -->
647      * <!-- end-user-doc -->
648      * @generated
649      */

650     public void setCurrentViewer(Viewer viewer) {
651         // If it is changing...
652
//
653
if (currentViewer != viewer) {
654             if (selectionChangedListener == null) {
655                 // Create the listener on demand.
656
//
657
selectionChangedListener =
658                     new ISelectionChangedListener() {
659                         // This just notifies those things that are affected by the section.
660
//
661
public void selectionChanged(SelectionChangedEvent selectionChangedEvent) {
662                             setSelection(selectionChangedEvent.getSelection());
663                         }
664                     };
665             }
666
667             // Stop listening to the old one.
668
//
669
if (currentViewer != null) {
670                 currentViewer.removeSelectionChangedListener(selectionChangedListener);
671             }
672
673             // Start listening to the new one.
674
//
675
if (viewer != null) {
676                 viewer.addSelectionChangedListener(selectionChangedListener);
677             }
678
679             // Remember it.
680
//
681
currentViewer = viewer;
682
683             // Set the editors selection based on the current viewer's selection.
684
//
685
setSelection(currentViewer == null ? StructuredSelection.EMPTY : currentViewer.getSelection());
686         }
687     }
688
689     /**
690      * This returns the viewer as required by the {@link IViewerProvider} interface.
691      * <!-- begin-user-doc -->
692      * <!-- end-user-doc -->
693      * @generated
694      */

695     public Viewer getViewer() {
696         return currentViewer;
697     }
698
699     /**
700      * This creates a context menu for the viewer and adds a listener as well registering the menu for extension.
701      * <!-- begin-user-doc -->
702      * <!-- end-user-doc -->
703      * @generated
704      */

705     protected void createContextMenuFor(StructuredViewer viewer) {
706         MenuManager contextMenu = new MenuManager("#PopUp");
707         contextMenu.add(new Separator("additions"));
708         contextMenu.setRemoveAllWhenShown(true);
709         contextMenu.addMenuListener(this);
710         Menu menu= contextMenu.createContextMenu(viewer.getControl());
711         viewer.getControl().setMenu(menu);
712         getSite().registerContextMenu(contextMenu, viewer);
713
714         int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
715         Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance() };
716         viewer.addDragSupport(dndOperations, transfers, new ViewerDragAdapter(viewer));
717         viewer.addDropSupport(dndOperations, transfers, new EditingDomainViewerDropAdapter(editingDomain, viewer));
718     }
719
720     /**
721      * This is the method called to load a resource into the editing domain's resource set based on the editor's input.
722      * <!-- begin-user-doc -->
723      * <!-- end-user-doc -->
724      * @generated
725      */

726     public void createModel() {
727         // I assume that the input is a file object.
728
//
729
IFileEditorInput modelFile = (IFileEditorInput)getEditorInput();
730
731         try {
732             // Load the resource through the editing domain.
733
//
734
Resource resource =
735                 editingDomain.loadResource
736                     (URI.createPlatformResourceURI(modelFile.getFile().getFullPath().toString()).toString());
737         }
738         catch (Exception JavaDoc exception) {
739             OljEditorPlugin.INSTANCE.log(exception);
740         }
741     }
742
743     /**
744      * This is the method used by the framework to install your own controls.
745      * <!-- begin-user-doc -->
746      * <!-- end-user-doc -->
747      * @generated
748      */

749     public void createPages() {
750         // Creates the model from the editor input
751
//
752
createModel();
753
754         // Create a page for the selection tree view.
755
//
756
{
757             ViewerPane viewerPane =
758                 new ViewerPane(getSite().getPage(), OljEditor.this) {
759                     public Viewer createViewer(Composite composite) {
760                         Tree tree = new Tree(composite, SWT.MULTI);
761                         TreeViewer newTreeViewer = new TreeViewer(tree);
762                         return newTreeViewer;
763                     }
764                     public void requestActivation() {
765                         super.requestActivation();
766                         setCurrentViewerPane(this);
767                     }
768                 };
769             viewerPane.createControl(getContainer());
770
771             selectionViewer = (TreeViewer)viewerPane.getViewer();
772             selectionViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
773
774             selectionViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
775             selectionViewer.setInput(editingDomain.getResourceSet());
776             viewerPane.setTitle(editingDomain.getResourceSet());
777
778             new AdapterFactoryTreeEditor(selectionViewer.getTree(), adapterFactory);
779
780             createContextMenuFor(selectionViewer);
781             int pageIndex = addPage(viewerPane.getControl());
782             setPageText(pageIndex, getString("_UI_SelectionPage_label"));
783         }
784
785         // Create a page for the parent tree view.
786
//
787
{
788             ViewerPane viewerPane =
789                 new ViewerPane(getSite().getPage(), OljEditor.this) {
790                     public Viewer createViewer(Composite composite) {
791                         Tree tree = new Tree(composite, SWT.MULTI);
792                         TreeViewer newTreeViewer = new TreeViewer(tree);
793                         return newTreeViewer;
794                     }
795                     public void requestActivation() {
796                         super.requestActivation();
797                         setCurrentViewerPane(this);
798                     }
799                 };
800             viewerPane.createControl(getContainer());
801
802             parentViewer = (TreeViewer)viewerPane.getViewer();
803             parentViewer.setAutoExpandLevel(30);
804             parentViewer.setContentProvider(new ReverseAdapterFactoryContentProvider(adapterFactory));
805             parentViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
806
807             createContextMenuFor(parentViewer);
808             int pageIndex = addPage(viewerPane.getControl());
809             setPageText(pageIndex, getString("_UI_ParentPage_label"));
810         }
811
812         // This is the page for the list viewer
813
//
814
{
815             ViewerPane viewerPane =
816                 new ViewerPane(getSite().getPage(), OljEditor.this) {
817                     public Viewer createViewer(Composite composite) {
818                         return new ListViewer(composite);
819                     }
820                     public void requestActivation() {
821                         super.requestActivation();
822                         setCurrentViewerPane(this);
823                     }
824                 };
825             viewerPane.createControl(getContainer());
826             listViewer = (ListViewer)viewerPane.getViewer();
827             listViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
828             listViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
829
830             createContextMenuFor(listViewer);
831             int pageIndex = addPage(viewerPane.getControl());
832             setPageText(pageIndex, getString("_UI_ListPage_label"));
833         }
834
835         // This is the page for the tree viewer
836
//
837
{
838             ViewerPane viewerPane =
839                 new ViewerPane(getSite().getPage(), OljEditor.this) {
840                     public Viewer createViewer(Composite composite) {
841                         return new TreeViewer(composite);
842                     }
843                     public void requestActivation() {
844                         super.requestActivation();
845                         setCurrentViewerPane(this);
846                     }
847                 };
848             viewerPane.createControl(getContainer());
849             treeViewer = (TreeViewer)viewerPane.getViewer();
850             treeViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
851             treeViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
852
853             new AdapterFactoryTreeEditor(treeViewer.getTree(), adapterFactory);
854
855             createContextMenuFor(treeViewer);
856             int pageIndex = addPage(viewerPane.getControl());
857             setPageText(pageIndex, getString("_UI_TreePage_label"));
858         }
859
860         // This is the page for the table viewer.
861
//
862
{
863             ViewerPane viewerPane =
864                 new ViewerPane(getSite().getPage(), OljEditor.this) {
865                     public Viewer createViewer(Composite composite) {
866                         return new TableViewer(composite);
867                     }
868                     public void requestActivation() {
869                         super.requestActivation();
870                         setCurrentViewerPane(this);
871                     }
872                 };
873             viewerPane.createControl(getContainer());
874             tableViewer = (TableViewer)viewerPane.getViewer();
875
876             Table table = tableViewer.getTable();
877             TableLayout layout = new TableLayout();
878             table.setLayout(layout);
879             table.setHeaderVisible(true);
880             table.setLinesVisible(true);
881
882             TableColumn objectColumn = new TableColumn(table, SWT.NONE);
883             layout.addColumnData(new ColumnWeightData(3, 100, true));
884             objectColumn.setText(getString("_UI_ObjectColumn_label"));
885             objectColumn.setResizable(true);
886
887             TableColumn selfColumn = new TableColumn(table, SWT.NONE);
888             layout.addColumnData(new ColumnWeightData(2, 100, true));
889             selfColumn.setText(getString("_UI_SelfColumn_label"));
890             selfColumn.setResizable(true);
891
892             tableViewer.setColumnProperties(new String JavaDoc [] {"a", "b"});
893             tableViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
894             tableViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
895
896             createContextMenuFor(tableViewer);
897             int pageIndex = addPage(viewerPane.getControl());
898             setPageText(pageIndex, getString("_UI_TablePage_label"));
899         }
900
901         // This is the page for the table tree viewer.
902
//
903
{
904             ViewerPane viewerPane =
905                 new ViewerPane(getSite().getPage(), OljEditor.this) {
906                     public Viewer createViewer(Composite composite) {
907                         return new TableTreeViewer(composite);
908                     }
909                     public void requestActivation() {
910                         super.requestActivation();
911                         setCurrentViewerPane(this);
912                     }
913                 };
914             viewerPane.createControl(getContainer());
915
916             tableTreeViewer = (TableTreeViewer)viewerPane.getViewer();
917
918             TableTree tableTree = tableTreeViewer.getTableTree();
919             TableLayout layout = new TableLayout();
920             tableTree.getTable().setLayout(layout);
921             tableTree.getTable().setHeaderVisible(true);
922             tableTree.getTable().setLinesVisible(true);
923
924             TableColumn objectColumn = new TableColumn(tableTree.getTable(), SWT.NONE);
925             layout.addColumnData(new ColumnWeightData(3, 100, true));
926             objectColumn.setText(getString("_UI_ObjectColumn_label"));
927             objectColumn.setResizable(true);
928
929             TableColumn selfColumn = new TableColumn(tableTree.getTable(), SWT.NONE);
930             layout.addColumnData(new ColumnWeightData(2, 100, true));
931             selfColumn.setText(getString("_UI_SelfColumn_label"));
932             selfColumn.setResizable(true);
933
934             tableTreeViewer.setColumnProperties(new String JavaDoc [] {"a", "b"});
935             tableTreeViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
936             tableTreeViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
937
938             createContextMenuFor(tableTreeViewer);
939             int pageIndex = addPage(viewerPane.getControl());
940             setPageText(pageIndex, getString("_UI_TableTreePage_label"));
941         }
942
943         setActivePage(0);
944
945         getContainer().addControlListener
946             (new ControlAdapter() {
947                 boolean guard = false;
948                 public void controlResized(ControlEvent event) {
949                     if (!guard) {
950                         guard = true;
951                         hideTabs();
952                         guard = false;
953                     }
954                 }
955              });
956     }
957
958     /**
959      * If there is just one page in the multi-page editor part, this hides
960      * the single tab at the bottom.
961      * <!-- begin-user-doc -->
962      * <!-- end-user-doc -->
963      * @generated
964      */

965     protected void hideTabs() {
966         if (getPageCount() <= 1) {
967             setPageText(0, "");
968             if (getContainer() instanceof CTabFolder) {
969                 ((CTabFolder)getContainer()).setTabHeight(1);
970                 Point point = getContainer().getSize();
971                 getContainer().setSize(point.x, point.y + 6);
972             }
973         }
974     }
975
976     /**
977      * This is used to track the active viewer.
978      * <!-- begin-user-doc -->
979      * <!-- end-user-doc -->
980      * @generated
981      */

982     protected void pageChange(int pageIndex) {
983         super.pageChange(pageIndex);
984
985         // This is a temporary workaround... EATM
986
//
987
Control control = getControl(pageIndex);
988         if (control != null) {
989             control.setVisible(true);
990             control.setFocus();
991         }
992
993         if (contentOutlinePage != null) {
994             handleContentOutlineSelection(contentOutlinePage.getSelection());
995         }
996     }
997
998     /**
999      * This is how the framework determines which interfaces we implement.
1000     * <!-- begin-user-doc -->
1001     * <!-- end-user-doc -->
1002     * @generated
1003     */

1004    public Object JavaDoc getAdapter(Class JavaDoc key) {
1005        if (key.equals(IContentOutlinePage.class)) {
1006            return getContentOutlinePage();
1007        }
1008        else if (key.equals(IPropertySheetPage.class)) {
1009            return getPropertySheetPage();
1010        }
1011        else if (key.equals(IGotoMarker.class)) {
1012            return this;
1013        }
1014        else {
1015            return super.getAdapter(key);
1016        }
1017    }
1018
1019    /**
1020     * This accesses a cached version of the content outliner.
1021     * <!-- begin-user-doc -->
1022     * <!-- end-user-doc -->
1023     * @generated
1024     */

1025    public IContentOutlinePage getContentOutlinePage() {
1026        if (contentOutlinePage == null) {
1027            // The content outline is just a tree.
1028
//
1029
class MyContentOutlinePage extends ContentOutlinePage {
1030                public void createControl(Composite parent) {
1031                    super.createControl(parent);
1032                    contentOutlineViewer = getTreeViewer();
1033                    contentOutlineViewer.addSelectionChangedListener(this);
1034
1035                    // Set up the tree viewer.
1036
//
1037
contentOutlineViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
1038                    contentOutlineViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
1039                    contentOutlineViewer.setInput(editingDomain.getResourceSet());
1040
1041                    // Make sure our popups work.
1042
//
1043
createContextMenuFor(contentOutlineViewer);
1044
1045                    if (!editingDomain.getResourceSet().getResources().isEmpty()) {
1046                      // Select the root object in the view.
1047
//
1048
ArrayList JavaDoc selection = new ArrayList JavaDoc();
1049                      selection.add(editingDomain.getResourceSet().getResources().get(0));
1050                      contentOutlineViewer.setSelection(new StructuredSelection(selection), true);
1051                    }
1052                }
1053
1054                public void makeContributions(IMenuManager menuManager, IToolBarManager toolBarManager, IStatusLineManager statusLineManager) {
1055                    super.makeContributions(menuManager, toolBarManager, statusLineManager);
1056                    contentOutlineStatusLineManager = statusLineManager;
1057                }
1058
1059                public void setActionBars(IActionBars actionBars) {
1060                    super.setActionBars(actionBars);
1061                    getActionBarContributor().shareGlobalActions(this, actionBars);
1062                }
1063            }
1064
1065            contentOutlinePage = new MyContentOutlinePage();
1066
1067            // Listen to selection so that we can handle it is a special way.
1068
//
1069
contentOutlinePage.addSelectionChangedListener
1070                (new ISelectionChangedListener() {
1071                     // This ensures that we handle selections correctly.
1072
//
1073
public void selectionChanged(SelectionChangedEvent event) {
1074                         handleContentOutlineSelection(event.getSelection());
1075                     }
1076                 });
1077        }
1078
1079        return contentOutlinePage;
1080    }
1081
1082    /**
1083     * This accesses a cached version of the property sheet.
1084     * <!-- begin-user-doc -->
1085     * <!-- end-user-doc -->
1086     * @generated
1087     */

1088    public IPropertySheetPage getPropertySheetPage() {
1089        if (propertySheetPage == null) {
1090            propertySheetPage =
1091                new PropertySheetPage() {
1092                    public void makeContributions(IMenuManager menuManager, IToolBarManager toolBarManager, IStatusLineManager statusLineManager) {
1093                        super.makeContributions(menuManager, toolBarManager, statusLineManager);
1094                    }
1095
1096                    public void setActionBars(IActionBars actionBars) {
1097                        super.setActionBars(actionBars);
1098                        getActionBarContributor().shareGlobalActions(this, actionBars);
1099                    }
1100                };
1101            propertySheetPage.setPropertySourceProvider(new AdapterFactoryContentProvider(adapterFactory));
1102        }
1103
1104        return propertySheetPage;
1105    }
1106
1107    /**
1108     * This deals with how we want selection in the outliner to affect the other views.
1109     * <!-- begin-user-doc -->
1110     * <!-- end-user-doc -->
1111     * @generated
1112     */

1113    public void handleContentOutlineSelection(ISelection selection) {
1114        if (currentViewerPane != null && !selection.isEmpty() && selection instanceof IStructuredSelection) {
1115            Iterator JavaDoc selectedElements = ((IStructuredSelection)selection).iterator();
1116            if (selectedElements.hasNext()) {
1117                // Get the first selected element.
1118
//
1119
Object JavaDoc selectedElement = selectedElements.next();
1120
1121                // If it's the selection viewer, then we want it to select the same selection as this selection.
1122
//
1123
if (currentViewerPane.getViewer() == selectionViewer) {
1124                    ArrayList JavaDoc selectionList = new ArrayList JavaDoc();
1125                    selectionList.add(selectedElement);
1126                    while (selectedElements.hasNext()) {
1127                        selectionList.add(selectedElements.next());
1128                    }
1129
1130                    // Set the selection to the widget.
1131
//
1132
selectionViewer.setSelection(new StructuredSelection(selectionList));
1133                }
1134                else {
1135                    // Set the input to the widget.
1136
//
1137
if (currentViewerPane.getViewer().getInput() != selectedElement) {
1138                        currentViewerPane.getViewer().setInput(selectedElement);
1139                        currentViewerPane.setTitle(selectedElement);
1140                    }
1141                }
1142            }
1143        }
1144    }
1145
1146    /**
1147     * This is for implementing {@link IEditorPart} and simply tests the command stack.
1148     * <!-- begin-user-doc -->
1149     * <!-- end-user-doc -->
1150     * @generated
1151     */

1152    public boolean isDirty() {
1153        return ((BasicCommandStack)editingDomain.getCommandStack()).isSaveNeeded();
1154    }
1155
1156    /**
1157     * This is for implementing {@link IEditorPart} and simply saves the model file.
1158     * <!-- begin-user-doc -->
1159     * <!-- end-user-doc -->
1160     * @generated
1161     */

1162    public void doSave(IProgressMonitor progressMonitor) {
1163        // Do the work within an operation because this is a long running activity that modifies the workbench.
1164
//
1165
WorkspaceModifyOperation operation =
1166            new WorkspaceModifyOperation() {
1167                // This is the method that gets invoked when the operation runs.
1168
//
1169
public void execute(IProgressMonitor monitor) {
1170                    try {
1171                        // Save the resource to the file system.
1172
//
1173
Resource savedResource = (Resource)editingDomain.getResourceSet().getResources().get(0);
1174                        savedResources.add(savedResource);
1175                        savedResource.save(Collections.EMPTY_MAP);
1176                    }
1177                    catch (Exception JavaDoc exception) {
1178                        OljEditorPlugin.INSTANCE.log(exception);
1179                    }
1180                }
1181            };
1182
1183        try {
1184            // This runs the options, and shows progress.
1185
//
1186
new ProgressMonitorDialog(getSite().getShell()).run(true, false, operation);
1187
1188            // Refresh the necessary state.
1189
//
1190
((BasicCommandStack)editingDomain.getCommandStack()).saveIsDone();
1191            firePropertyChange(IEditorPart.PROP_DIRTY);
1192        }
1193        catch (Exception JavaDoc exception) {
1194            // Something went wrong that shouldn't.
1195
//
1196
OljEditorPlugin.INSTANCE.log(exception);
1197        }
1198    }
1199
1200    /**
1201     * This always returns true because it is not currently supported.
1202     * <!-- begin-user-doc -->
1203     * <!-- end-user-doc -->
1204     * @generated
1205     */

1206    public boolean isSaveAsAllowed() {
1207        return true;
1208    }
1209
1210    /**
1211     * This also changes the editor's input.
1212     * <!-- begin-user-doc -->
1213     * <!-- end-user-doc -->
1214     * @generated
1215     */

1216    public void doSaveAs() {
1217        SaveAsDialog saveAsDialog= new SaveAsDialog(getSite().getShell());
1218        saveAsDialog.open();
1219        IPath path= saveAsDialog.getResult();
1220        if (path != null) {
1221            IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
1222            if (file != null) {
1223                doSaveAs(URI.createPlatformResourceURI(file.getFullPath().toString()), new FileEditorInput(file));
1224            }
1225        }
1226    }
1227    
1228    /**
1229     * <!-- begin-user-doc -->
1230     * <!-- end-user-doc -->
1231     * @generated
1232     */

1233    protected void doSaveAs(URI uri, IEditorInput editorInput) {
1234        ((Resource)editingDomain.getResourceSet().getResources().get(0)).setURI(uri);
1235        setInput(editorInput);
1236        setPartName(editorInput.getName());
1237        IProgressMonitor progressMonitor =
1238            getActionBars().getStatusLineManager() != null ?
1239                getActionBars().getStatusLineManager().getProgressMonitor() :
1240                new NullProgressMonitor();
1241        doSave(progressMonitor);
1242    }
1243
1244    /**
1245     * <!-- begin-user-doc -->
1246     * <!-- end-user-doc -->
1247     * @generated
1248     */

1249    public void gotoMarker(IMarker marker) {
1250        try {
1251            if (marker.getType().equals(EValidator.MARKER)) {
1252                String JavaDoc uriAttribute = marker.getAttribute(EValidator.URI_ATTRIBUTE, null);
1253                if (uriAttribute != null) {
1254                    URI uri = URI.createURI(uriAttribute);
1255                    EObject eObject = editingDomain.getResourceSet().getEObject(uri, true);
1256                    if (eObject != null) {
1257                      setSelectionToViewer(Collections.singleton(editingDomain.getWrapper(eObject)));
1258                    }
1259                }
1260            }
1261        }
1262        catch (CoreException exception) {
1263            OljEditorPlugin.INSTANCE.log(exception);
1264        }
1265    }
1266
1267    /**
1268     * This is called during startup.
1269     * <!-- begin-user-doc -->
1270     * <!-- end-user-doc -->
1271     * @generated
1272     */

1273    public void init(IEditorSite site, IEditorInput editorInput) throws PartInitException {
1274        setSite(site);
1275        setInput(editorInput);
1276        setPartName(editorInput.getName());
1277        site.setSelectionProvider(this);
1278        site.getPage().addPartListener(partListener);
1279        ResourcesPlugin.getWorkspace().addResourceChangeListener(resourceChangeListener, IResourceChangeEvent.POST_CHANGE);
1280    }
1281
1282    /**
1283     * <!-- begin-user-doc -->
1284     * <!-- end-user-doc -->
1285     * @generated
1286     */

1287    public void setFocus() {
1288        getControl(getActivePage()).setFocus();
1289    }
1290
1291    /**
1292     * This implements {@link org.eclipse.jface.viewers.ISelectionProvider}.
1293     * <!-- begin-user-doc -->
1294     * <!-- end-user-doc -->
1295     * @generated
1296     */

1297    public void addSelectionChangedListener(ISelectionChangedListener listener) {
1298        selectionChangedListeners.add(listener);
1299    }
1300
1301    /**
1302     * This implements {@link org.eclipse.jface.viewers.ISelectionProvider}.
1303     * <!-- begin-user-doc -->
1304     * <!-- end-user-doc -->
1305     * @generated
1306     */

1307    public void removeSelectionChangedListener(ISelectionChangedListener listener) {
1308        selectionChangedListeners.remove(listener);
1309    }
1310
1311    /**
1312     * This implements {@link org.eclipse.jface.viewers.ISelectionProvider} to return this editor's overall selection.
1313     * <!-- begin-user-doc -->
1314     * <!-- end-user-doc -->
1315     * @generated
1316     */

1317    public ISelection getSelection() {
1318        return editorSelection;
1319    }
1320
1321    /**
1322     * This implements {@link org.eclipse.jface.viewers.ISelectionProvider} to set this editor's overall selection.
1323     * Calling this result will notify the listeners.
1324     * <!-- begin-user-doc -->
1325     * <!-- end-user-doc -->
1326     * @generated
1327     */

1328    public void setSelection(ISelection selection) {
1329        editorSelection = selection;
1330
1331        for (Iterator JavaDoc listeners = selectionChangedListeners.iterator(); listeners.hasNext(); ) {
1332            ISelectionChangedListener listener = (ISelectionChangedListener)listeners.next();
1333            listener.selectionChanged(new SelectionChangedEvent(this, selection));
1334        }
1335        setStatusLineManager(selection);
1336    }
1337
1338    /**
1339     * <!-- begin-user-doc -->
1340     * <!-- end-user-doc -->
1341     * @generated
1342     */

1343    public void setStatusLineManager(ISelection selection) {
1344        IStatusLineManager statusLineManager = currentViewer != null && currentViewer == contentOutlineViewer ?
1345            contentOutlineStatusLineManager : getActionBars().getStatusLineManager();
1346    
1347        if (statusLineManager != null) {
1348            if (selection instanceof IStructuredSelection) {
1349                Collection JavaDoc collection = ((IStructuredSelection)selection).toList();
1350                switch (collection.size()) {
1351                    case 0: {
1352                        statusLineManager.setMessage(getString("_UI_NoObjectSelected"));
1353                        break;
1354                    }
1355                    case 1: {
1356                        String JavaDoc text = new AdapterFactoryItemDelegator(adapterFactory).getText(collection.iterator().next());
1357                        statusLineManager.setMessage(getString("_UI_SingleObjectSelected", text));
1358                        break;
1359                    }
1360                    default: {
1361                        statusLineManager.setMessage(getString("_UI_MultiObjectSelected", Integer.toString(collection.size())));
1362                        break;
1363                    }
1364                }
1365            }
1366            else {
1367                statusLineManager.setMessage("");
1368            }
1369        }
1370    }
1371
1372    /**
1373     * This looks up a string in the plugin's plugin.properties file.
1374     * <!-- begin-user-doc -->
1375     * <!-- end-user-doc -->
1376     * @generated
1377     */

1378    private static String JavaDoc getString(String JavaDoc key) {
1379        return OljEditorPlugin.INSTANCE.getString(key);
1380    }
1381
1382    /**
1383     * This looks up a string in plugin.properties, making a substitution.
1384     * <!-- begin-user-doc -->
1385     * <!-- end-user-doc -->
1386     * @generated
1387     */

1388    private static String JavaDoc getString(String JavaDoc key, Object JavaDoc s1) {
1389        return OljEditorPlugin.INSTANCE.getString(key, new Object JavaDoc [] { s1 });
1390    }
1391
1392    /**
1393     * This implements {@link org.eclipse.jface.action.IMenuListener} to help fill the context menus with contributions from the Edit menu.
1394     * <!-- begin-user-doc -->
1395     * <!-- end-user-doc -->
1396     * @generated
1397     */

1398    public void menuAboutToShow(IMenuManager menuManager) {
1399        ((IMenuListener)getEditorSite().getActionBarContributor()).menuAboutToShow(menuManager);
1400    }
1401
1402    /**
1403     * <!-- begin-user-doc -->
1404     * <!-- end-user-doc -->
1405     * @generated
1406     */

1407    public EditingDomainActionBarContributor getActionBarContributor() {
1408        return (EditingDomainActionBarContributor)getEditorSite().getActionBarContributor();
1409    }
1410
1411    /**
1412     * <!-- begin-user-doc -->
1413     * <!-- end-user-doc -->
1414     * @generated
1415     */

1416    public IActionBars getActionBars() {
1417        return getActionBarContributor().getActionBars();
1418    }
1419
1420    /**
1421     * <!-- begin-user-doc -->
1422     * <!-- end-user-doc -->
1423     * @generated
1424     */

1425    public AdapterFactory getAdapterFactory() {
1426        return adapterFactory;
1427    }
1428
1429    /**
1430     * <!-- begin-user-doc -->
1431     * <!-- end-user-doc -->
1432     * @generated
1433     */

1434    public void dispose() {
1435        ResourcesPlugin.getWorkspace().removeResourceChangeListener(resourceChangeListener);
1436
1437        getSite().getPage().removePartListener(partListener);
1438
1439        adapterFactory.dispose();
1440
1441        if (getActionBarContributor().getActiveEditor() == this) {
1442            getActionBarContributor().setActiveEditor(null);
1443        }
1444
1445        if (propertySheetPage != null) {
1446            propertySheetPage.dispose();
1447        }
1448
1449        if (contentOutlinePage != null) {
1450            contentOutlinePage.dispose();
1451        }
1452
1453        super.dispose();
1454    }
1455
1456}
1457
Popular Tags