KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > dods > editor > Doml > presentation > DomlEditor


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

7 package org.enhydra.dods.editor.Doml.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 org.enhydra.dods.editor.Doml.provider.DomlItemProviderAdapterFactory;
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 import org.enhydra.dods.editor.Doml.provider.DomlEditPlugin;
151
152
153 /**
154  * This is an example of a Doml model editor.
155  * <!-- begin-user-doc -->
156  * <!-- end-user-doc -->
157  * @generated
158  */

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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