diff options
author | Christian W. Damus | 2013-01-28 17:49:59 +0000 |
---|---|---|
committer | Christian W. Damus | 2013-01-28 21:10:28 +0000 |
commit | 246e19229f3937236e1062e712a378b292b4f7ab (patch) | |
tree | 4bef469849d61c4aece53ea9953da78a567a2b64 /plugins/org.eclipse.emf.cdo.dawn.gmf | |
parent | 89fe2240f8e4b66754832bc7b4e3df0a5c50fd2e (diff) | |
download | cdo-246e19229f3937236e1062e712a378b292b4f7ab.tar.gz cdo-246e19229f3937236e1062e712a378b292b4f7ab.tar.xz cdo-246e19229f3937236e1062e712a378b292b4f7ab.zip |
[399285] [Dawn] GMF editor support assumes that IDawnEditor is a DiagramDocumentEditor
https://bugs.eclipse.org/bugs/show_bug.cgi?id=399285
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.dawn.gmf')
3 files changed, 67 insertions, 32 deletions
diff --git a/plugins/org.eclipse.emf.cdo.dawn.gmf/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.dawn.gmf/META-INF/MANIFEST.MF index 1d82057b73..bce4e6f30d 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.gmf/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.emf.cdo.dawn.gmf/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.emf.cdo.dawn.gmf;singleton:=true -Bundle-Version: 2.0.0.qualifier +Bundle-Version: 2.1.0.qualifier Bundle-Activator: org.eclipse.emf.cdo.dawn.gmf.Activator Require-Bundle: org.eclipse.ui;bundle-version="[3.6.0,4.0.0)", org.eclipse.core.runtime;bundle-version="[3.6.0,4.0.0)", @@ -23,15 +23,15 @@ Require-Bundle: org.eclipse.ui;bundle-version="[3.6.0,4.0.0)", Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: J2SE-1.5 Bundle-Vendor: %providerName -Export-Package: org.eclipse.emf.cdo.dawn.gmf;version="2.0.0", - org.eclipse.emf.cdo.dawn.gmf.appearance;version="2.0.0", - org.eclipse.emf.cdo.dawn.gmf.appearance.impl;version="2.0.0", - org.eclipse.emf.cdo.dawn.gmf.editors.impl;version="2.0.0", - org.eclipse.emf.cdo.dawn.gmf.elementtypes;version="2.0.0", - org.eclipse.emf.cdo.dawn.gmf.notifications.impl;version="2.0.0", - org.eclipse.emf.cdo.dawn.gmf.resources;version="2.0.0", - org.eclipse.emf.cdo.dawn.gmf.stylizer;version="2.0.0", - org.eclipse.emf.cdo.dawn.gmf.synchronize;version="2.0.0", - org.eclipse.emf.cdo.dawn.gmf.util;version="2.0.0", - org.eclipse.emf.cdo.dawn.transaction;version="2.0.0" +Export-Package: org.eclipse.emf.cdo.dawn.gmf;version="2.1.0", + org.eclipse.emf.cdo.dawn.gmf.appearance;version="2.1.0", + org.eclipse.emf.cdo.dawn.gmf.appearance.impl;version="2.1.0", + org.eclipse.emf.cdo.dawn.gmf.editors.impl;version="2.1.0", + org.eclipse.emf.cdo.dawn.gmf.elementtypes;version="2.1.0", + org.eclipse.emf.cdo.dawn.gmf.notifications.impl;version="2.1.0", + org.eclipse.emf.cdo.dawn.gmf.resources;version="2.1.0", + org.eclipse.emf.cdo.dawn.gmf.stylizer;version="2.1.0", + org.eclipse.emf.cdo.dawn.gmf.synchronize;version="2.1.0", + org.eclipse.emf.cdo.dawn.gmf.util;version="2.1.0", + org.eclipse.emf.cdo.dawn.transaction;version="2.1.0" Bundle-Localization: plugin diff --git a/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/editors/impl/DawnGMFEditorSupport.java b/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/editors/impl/DawnGMFEditorSupport.java index 70dc9cee0a..461c16babc 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/editors/impl/DawnGMFEditorSupport.java +++ b/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/editors/impl/DawnGMFEditorSupport.java @@ -7,6 +7,7 @@ * * Contributors: * Martin Fluegge - initial API and implementation + * Christian W. Damus (CEA) - bug 399285 support IDawnEditor adapters */ package org.eclipse.emf.cdo.dawn.gmf.editors.impl; @@ -30,6 +31,7 @@ import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.transaction.RecordingCommand; import org.eclipse.emf.transaction.TransactionalEditingDomain; +import org.eclipse.core.runtime.IAdaptable; import org.eclipse.gef.EditPart; import org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor; import org.eclipse.gmf.runtime.notation.View; @@ -46,7 +48,7 @@ public class DawnGMFEditorSupport extends DawnAbstractEditorSupport public DawnGMFEditorSupport(IDawnEditor editor) { super(editor); - dawnGMFHandler = new DawnGMFHandler(editor); + dawnGMFHandler = createDawnGMFHandler(editor); } public void close() @@ -64,6 +66,19 @@ public class DawnGMFEditorSupport extends DawnAbstractEditorSupport return dawnGMFHandler; } + /** + * Creates a GMF-specific handler for the specified {@code editor}. + * <p> + * <strong>Note</strong> that this method is called in the constructor, so subclasses must + * be aware that {@code this} has not been fully initialized. + * + * @since 2.1 + */ + protected DawnGMFHandler createDawnGMFHandler(IDawnEditor editor) + { + return new DawnGMFHandler(editor); + } + @Override protected BasicDawnListener getLockingHandler() { @@ -83,7 +98,7 @@ public class DawnGMFEditorSupport extends DawnAbstractEditorSupport public void rollback() { super.rollback(); - final DiagramDocumentEditor diagramDocumentEditor = (DiagramDocumentEditor)getEditor(); + final DiagramDocumentEditor diagramDocumentEditor = getDiagramEditor(getEditor()); TransactionalEditingDomain editingDomain = diagramDocumentEditor.getEditingDomain(); editingDomain.getCommandStack().execute(new RecordingCommand(editingDomain) { @@ -96,9 +111,27 @@ public class DawnGMFEditorSupport extends DawnAbstractEditorSupport }); } + /** + * Obtains the GMF diagram editor from the given Dawn {@code editor}. If the + * {@code editor} is a {@link DiagramDocumentEditor}, then that is returned as + * is. Otherwise, try to get an {@code DiagramDocumentEditor} + * {@linkplain IAdaptable#getAdapter(Class) adapter} from the {@code editor}. + * + * @param editor the Dawn editor from which to get the GMF editor + * @since 2.1 + */ + public static DiagramDocumentEditor getDiagramEditor(IDawnEditor editor) + { + if (editor instanceof DiagramDocumentEditor) + { + return (DiagramDocumentEditor)editor; + } + return (DiagramDocumentEditor)editor.getAdapter(DiagramDocumentEditor.class); + } + public void refresh() { - final DiagramDocumentEditor diagramDocumentEditor = (DiagramDocumentEditor)getEditor(); + final DiagramDocumentEditor diagramDocumentEditor = getDiagramEditor(getEditor()); TransactionalEditingDomain editingDomain = diagramDocumentEditor.getEditingDomain(); editingDomain.getCommandStack().execute(new RecordingCommand(editingDomain) { @@ -177,7 +210,7 @@ public class DawnGMFEditorSupport extends DawnAbstractEditorSupport if (view != null) { // if there is no view, the semantic object is not displayed. - EditPart editPart = DawnDiagramUpdater.createOrFindEditPartIfViewExists(view, (DiagramDocumentEditor)getEditor()); + EditPart editPart = DawnDiagramUpdater.createOrFindEditPartIfViewExists(view, getDiagramEditor(getEditor())); if (object.cdoWriteLock().isLocked()) { diff --git a/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/notifications/impl/DawnGMFHandler.java b/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/notifications/impl/DawnGMFHandler.java index adbdf63480..79679a0705 100644 --- a/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/notifications/impl/DawnGMFHandler.java +++ b/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/notifications/impl/DawnGMFHandler.java @@ -7,9 +7,12 @@ * * Contributors: * Martin Fluegge - initial API and implementation + * Christian W. Damus (CEA) - bug 399285 support IDawnEditor adapters */ package org.eclipse.emf.cdo.dawn.gmf.notifications.impl; +import static org.eclipse.emf.cdo.dawn.gmf.editors.impl.DawnGMFEditorSupport.getDiagramEditor; + import org.eclipse.emf.cdo.CDOObject; import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta; import org.eclipse.emf.cdo.dawn.editors.IDawnEditor; @@ -36,7 +39,6 @@ import org.eclipse.emf.transaction.TransactionalEditingDomain; import org.eclipse.gef.EditPart; import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; -import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor; import org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor; import org.eclipse.gmf.runtime.notation.Edge; import org.eclipse.gmf.runtime.notation.View; @@ -99,7 +101,7 @@ public class DawnGMFHandler extends BasicDawnTransactionHandler if (DawnConflictHelper.isConflicted(cdoObject)) { - DawnConflictHelper.handleConflictedView(cdoObject, view, (DiagramDocumentEditor)editor); + DawnConflictHelper.handleConflictedView(cdoObject, view, getDiagramEditor(editor)); return; } } @@ -122,8 +124,8 @@ public class DawnGMFHandler extends BasicDawnTransactionHandler public void notifyChanged(Notification notification) { - DawnDiagramUpdater.refreshEditPart(((DiagramDocumentEditor)editor).getDiagramEditPart(), - (DiagramDocumentEditor)editor); + DiagramDocumentEditor diagramEditor = getDiagramEditor(editor); + DawnDiagramUpdater.refreshEditPart(diagramEditor.getDiagramEditPart(), diagramEditor); object.eAdapters().remove(this); } @@ -203,7 +205,7 @@ public class DawnGMFHandler extends BasicDawnTransactionHandler { EObject element = CDOUtil.getEObject(obj); View view = DawnDiagramUpdater.findViewByContainer(element); - DawnConflictHelper.handleConflictedView(CDOUtil.getCDOObject(element), view, (DiagramDocumentEditor)editor); + DawnConflictHelper.handleConflictedView(CDOUtil.getCDOObject(element), view, getDiagramEditor(editor)); } } @@ -223,40 +225,40 @@ public class DawnGMFHandler extends BasicDawnTransactionHandler return; } - EditPart relatedEditPart = DawnDiagramUpdater.findEditPart(view, ((DiagramEditor)editor).getDiagramEditPart() - .getViewer()); + DiagramDocumentEditor diagramEditor = getDiagramEditor(editor); + EditPart relatedEditPart = DawnDiagramUpdater.findEditPart(view, diagramEditor.getDiagramEditPart().getViewer()); if (relatedEditPart != null) { if (TRACER.isEnabled()) { TRACER.format("Updating EditPart {0} ", relatedEditPart); //$NON-NLS-1$ } - DawnDiagramUpdater.refreshEditPart(relatedEditPart.getParent(), (DiagramDocumentEditor)editor); + DawnDiagramUpdater.refreshEditPart(relatedEditPart.getParent(), diagramEditor); } else { if (TRACER.isEnabled()) { - TRACER.format("Updating DiagramEditPart {0} ", ((DiagramEditor)editor).getDiagramEditPart()); //$NON-NLS-1$ + TRACER.format("Updating DiagramEditPart {0} ", diagramEditor.getDiagramEditPart()); //$NON-NLS-1$ } - DawnDiagramUpdater.refreshEditPart(((DiagramEditor)editor).getDiagramEditPart(), (DiagramDocumentEditor)editor); + DawnDiagramUpdater.refreshEditPart(diagramEditor.getDiagramEditPart(), diagramEditor); } } protected void refresh(CDOObject object) { + DiagramDocumentEditor diagramEditor = getDiagramEditor(editor); View view = DawnDiagramUpdater.findViewByContainer(object); if (view == null) { - view = DawnDiagramUpdater.findViewForModel(object, (DiagramDocumentEditor)editor); + view = DawnDiagramUpdater.findViewForModel(object, diagramEditor); } if (view == null) { DawnDiagramUpdater.findViewFromCrossReferences(object); } - EditPart relatedEditPart = DawnDiagramUpdater.findEditPart(view, ((DiagramDocumentEditor)editor) - .getDiagramEditPart().getViewer()); + EditPart relatedEditPart = DawnDiagramUpdater.findEditPart(view, diagramEditor.getDiagramEditPart().getViewer()); if (relatedEditPart != null) { @@ -271,17 +273,17 @@ public class DawnGMFHandler extends BasicDawnTransactionHandler } else { - DawnDiagramUpdater.refreshEditPart(parent, (DiagramDocumentEditor)editor); + DawnDiagramUpdater.refreshEditPart(parent, diagramEditor); } } else { if (TRACER.isEnabled()) { - TRACER.format("Updating DiagramEditPart {0} ", ((DiagramDocumentEditor)editor).getDiagramEditPart()); //$NON-NLS-1$ + TRACER.format("Updating DiagramEditPart {0} ", getDiagramEditor(editor).getDiagramEditPart()); //$NON-NLS-1$ } - DawnDiagramUpdater.refresh(((DiagramDocumentEditor)editor).getDiagramEditPart()); + DawnDiagramUpdater.refresh(diagramEditor.getDiagramEditPart()); } } } |