diff options
author | Martin Fluegge | 2010-06-06 15:00:24 +0000 |
---|---|---|
committer | Martin Fluegge | 2010-06-06 15:00:24 +0000 |
commit | e52abdb6fb99792ea153401cef4bd85bb7d8777e (patch) | |
tree | e1305665431c45ec2e9192eb185428e4e5684b66 /plugins/org.eclipse.emf.cdo.dawn | |
parent | da36bd46832db377b9f670735ec3265ec15f3410 (diff) | |
download | cdo-e52abdb6fb99792ea153401cef4bd85bb7d8777e.tar.gz cdo-e52abdb6fb99792ea153401cef4bd85bb7d8777e.tar.xz cdo-e52abdb6fb99792ea153401cef4bd85bb7d8777e.zip |
[308232] [Dawn] Develop collaborative support for GMF on CDO
https://bugs.eclipse.org/bugs/show_bug.cgi?id=308232
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.dawn')
12 files changed, 232 insertions, 12 deletions
diff --git a/plugins/org.eclipse.emf.cdo.dawn/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.dawn/META-INF/MANIFEST.MF index 41b4d395a5..6458eb7f46 100644 --- a/plugins/org.eclipse.emf.cdo.dawn/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.emf.cdo.dawn/META-INF/MANIFEST.MF @@ -29,7 +29,8 @@ Export-Package: org.eclipse.emf.cdo.dawn;version="0.2.0", org.eclipse.emf.cdo.dawn.appearance.impl;version="0.2.0", org.eclipse.emf.cdo.dawn.commands;version="0.2.0", org.eclipse.emf.cdo.dawn.conflicts;version="0.2.0", - org.eclipse.emf.cdo.dawn.diagram.part;version="0.2.0", + org.eclipse.emf.cdo.dawn.editors;version="0.2.0", + org.eclipse.emf.cdo.dawn.editors.impl;version="0.2.0", org.eclipse.emf.cdo.dawn.elementtypes;version="0.2.0", org.eclipse.emf.cdo.dawn.exceptions;version="0.2.0", org.eclipse.emf.cdo.dawn.helper;version="0.2.0", diff --git a/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/actions/HandleConflictsAction.java b/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/actions/HandleConflictsAction.java index f363239a1e..e5845a406c 100644 --- a/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/actions/HandleConflictsAction.java +++ b/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/actions/HandleConflictsAction.java @@ -10,7 +10,7 @@ */ package org.eclipse.emf.cdo.dawn.actions; -import org.eclipse.emf.cdo.dawn.diagram.part.IDawnDiagramEditor; +import org.eclipse.emf.cdo.dawn.editors.IDawnEditor; import org.eclipse.emf.cdo.dawn.helper.DawnEditorHelper; import org.eclipse.emf.cdo.dawn.synchronize.DawnConflictHelper; import org.eclipse.emf.cdo.internal.dawn.bundle.OM; @@ -52,7 +52,7 @@ public class HandleConflictsAction implements IObjectActionDelegate } IEditorPart activeEditor = DawnEditorHelper.getActiveEditor(); - if (activeEditor instanceof IDawnDiagramEditor) + if (activeEditor instanceof IDawnEditor) { MessageDialog dialog = new MessageDialog(DawnEditorHelper.getActiveShell(), "Conflict", null, "There are conflicts in your diagram. Would you like to rollback your current transaction?", diff --git a/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/diagram/part/IDawnDiagramEditor.java b/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/editors/IDawnEditor.java index ab0455ab7f..22edd2d7f8 100644 --- a/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/diagram/part/IDawnDiagramEditor.java +++ b/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/editors/IDawnEditor.java @@ -8,14 +8,14 @@ * Contributors: * Martin Fluegge - initial API and implementation ******************************************************************************/ -package org.eclipse.emf.cdo.dawn.diagram.part; +package org.eclipse.emf.cdo.dawn.editors; import org.eclipse.emf.cdo.view.CDOView; /** * @author Martin Fluegge */ -public interface IDawnDiagramEditor +public interface IDawnEditor { public String getContributorID(); diff --git a/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/editors/IDawnEditorSupport.java b/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/editors/IDawnEditorSupport.java new file mode 100644 index 0000000000..56b00c3c3e --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/editors/IDawnEditorSupport.java @@ -0,0 +1,31 @@ +/** + * Copyright (c) 2004 - 2010 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Fluegge - initial API and implementation + */ +package org.eclipse.emf.cdo.dawn.editors; + +import org.eclipse.emf.cdo.view.CDOView; + +/** + * @author Martin Fluegge + */ +public interface IDawnEditorSupport +{ + public void setDirty(boolean dirty); + + public boolean isDirty(); + + public CDOView getView(); + + public void setView(CDOView view); + + public void close(); + + public void registerListeners(); +} diff --git a/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/editors/impl/DawnAbstractEditorSupport.java b/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/editors/impl/DawnAbstractEditorSupport.java new file mode 100644 index 0000000000..afc9a66eb5 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/editors/impl/DawnAbstractEditorSupport.java @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2004 - 2010 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Fluegge - initial API and implementation + */ +package org.eclipse.emf.cdo.dawn.editors.impl; + +import org.eclipse.emf.cdo.dawn.editors.IDawnEditor; +import org.eclipse.emf.cdo.dawn.editors.IDawnEditorSupport; +import org.eclipse.emf.cdo.view.CDOView; + +/** + * @author Martin Fluegge + */ +public abstract class DawnAbstractEditorSupport implements IDawnEditorSupport +{ + private final IDawnEditor editor; + + private CDOView view; + + private boolean dirty; + + public CDOView getView() + { + return view; + } + + public void setView(CDOView view) + { + this.view = view; + } + + public DawnAbstractEditorSupport(IDawnEditor editor) + { + this.editor = editor; + } + + public void setDirty(boolean dirty) + { + this.dirty = dirty; + } + + public boolean isDirty() + { + return dirty; + } + + public IDawnEditor getEditor() + { + return editor; + } +} diff --git a/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/editors/impl/DawnGMFEditorSupport.java b/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/editors/impl/DawnGMFEditorSupport.java new file mode 100644 index 0000000000..e1691d06b0 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/editors/impl/DawnGMFEditorSupport.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2004 - 2010 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Fluegge - initial API and implementation + */ +package org.eclipse.emf.cdo.dawn.editors.impl; + +import org.eclipse.emf.cdo.dawn.editors.IDawnEditor; +import org.eclipse.emf.cdo.dawn.notifications.DawnNotificationUtil; +import org.eclipse.emf.cdo.transaction.CDOTransaction; +import org.eclipse.emf.cdo.view.CDOView; + +/** + * @author Martin Fluegge + */ +public class DawnGMFEditorSupport extends DawnAbstractEditorSupport +{ + public DawnGMFEditorSupport(IDawnEditor editor) + { + super(editor); + } + + public void close() + { + CDOView view = getView(); + if (view != null && !view.isClosed()) + { + view.close(); + } + } + + public void registerListeners() + { + // DawnNotificationUtil.registerResourceListeners(getEditingDomain().getResourceSet(), this); + DawnNotificationUtil.registerTransactionListeners((CDOTransaction)getView(), getEditor()); + DawnNotificationUtil.setChangeSubscriptionPolicy((CDOTransaction)getView()); + } +} diff --git a/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/notifications/DawnNotificationUtil.java b/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/notifications/DawnNotificationUtil.java index 991abaa2b2..fae024eb67 100644 --- a/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/notifications/DawnNotificationUtil.java +++ b/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/notifications/DawnNotificationUtil.java @@ -10,7 +10,7 @@ ******************************************************************************/ package org.eclipse.emf.cdo.dawn.notifications; -import org.eclipse.emf.cdo.dawn.diagram.part.IDawnDiagramEditor; +import org.eclipse.emf.cdo.dawn.editors.IDawnEditor; import org.eclipse.emf.cdo.internal.dawn.bundle.OM; import org.eclipse.emf.cdo.transaction.CDOTransaction; import org.eclipse.emf.cdo.view.CDOAdapterPolicy; @@ -72,7 +72,7 @@ public class DawnNotificationUtil // } } - public static void registerTransactionListeners(CDOTransaction transaction, IDawnDiagramEditor editor) + public static void registerTransactionListeners(CDOTransaction transaction, IDawnEditor editor) { BasicDawnListener transactionListener = DawnNotificationRegistry .createDawnTransactionListener((DiagramDocumentEditor)editor); diff --git a/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/notifications/DawnTransactionHandler.java b/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/notifications/DawnTransactionHandler.java index a827a6c3b3..390f7cdb74 100644 --- a/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/notifications/DawnTransactionHandler.java +++ b/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/notifications/DawnTransactionHandler.java @@ -12,7 +12,7 @@ package org.eclipse.emf.cdo.dawn.notifications; import org.eclipse.emf.cdo.CDOObject; import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta; -import org.eclipse.emf.cdo.dawn.diagram.part.IDawnDiagramEditor; +import org.eclipse.emf.cdo.dawn.editors.IDawnEditor; import org.eclipse.emf.cdo.dawn.util.DawnDiagramUpdater; import org.eclipse.emf.cdo.internal.dawn.bundle.OM; import org.eclipse.emf.cdo.transaction.CDOCommitContext; @@ -37,9 +37,9 @@ public class DawnTransactionHandler implements CDOTransactionHandler { private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, DawnElementChangeListener.class); - private final IDawnDiagramEditor editor; + private final IDawnEditor editor; - public DawnTransactionHandler(IDawnDiagramEditor editor) + public DawnTransactionHandler(IDawnEditor editor) { this.editor = editor; } diff --git a/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/resources/DawnPathmapManager.java b/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/resources/DawnPathmapManager.java new file mode 100644 index 0000000000..f898475b0e --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/resources/DawnPathmapManager.java @@ -0,0 +1,64 @@ +/** + * Copyright (c) 2004 - 2010 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Martin Fluegge - initial API and implementation + */ +package org.eclipse.emf.cdo.dawn.resources; + +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.resource.ResourceSet; + +import org.eclipse.gmf.runtime.emf.core.internal.resources.PathmapManager; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author Martin Fluegge + */ +@SuppressWarnings("restriction") +public class DawnPathmapManager extends PathmapManager +{ + // TODO remove this as soon as the PathmapManager problem is solved! + @Override + public void notifyChanged(Notification msg) + { + if (msg.getFeatureID(ResourceSet.class) == ResourceSet.RESOURCE_SET__RESOURCES) + { + switch (msg.getEventType()) + { + case Notification.REMOVE_MANY: + { + if (msg.getNewValue() instanceof int[]) + { + return; + } + break; + } + } + } + + super.notifyChanged(msg); + } + + public static void removePathMapMananger(EList<Adapter> eAdapters) + { + List<Adapter> toBeRemoved = new ArrayList<Adapter>(); + for (Adapter a : eAdapters) + { + if (a instanceof PathmapManager) + { + toBeRemoved.add(a); + } + } + eAdapters.removeAll(toBeRemoved); + } + +} diff --git a/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/synchronize/DawnConflictHelper.java b/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/synchronize/DawnConflictHelper.java index 732929c6bb..7e6c0e5dae 100644 --- a/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/synchronize/DawnConflictHelper.java +++ b/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/synchronize/DawnConflictHelper.java @@ -13,7 +13,7 @@ package org.eclipse.emf.cdo.dawn.synchronize; import org.eclipse.emf.cdo.CDOObject; import org.eclipse.emf.cdo.CDOState; import org.eclipse.emf.cdo.dawn.appearance.DawnAppearancer; -import org.eclipse.emf.cdo.dawn.diagram.part.IDawnDiagramEditor; +import org.eclipse.emf.cdo.dawn.editors.IDawnEditor; import org.eclipse.emf.cdo.dawn.util.DawnDiagramUpdater; import org.eclipse.emf.cdo.internal.dawn.bundle.OM; import org.eclipse.emf.cdo.transaction.CDOTransaction; @@ -63,7 +63,7 @@ public class DawnConflictHelper public static void rollback(final DiagramDocumentEditor editor) { - CDOView view = ((IDawnDiagramEditor)editor).getView(); + CDOView view = ((IDawnEditor)editor).getView(); if (view != null && view instanceof CDOTransaction) { diff --git a/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/transaction/DawnDiagramEditingDomainFactory.java b/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/transaction/DawnDiagramEditingDomainFactory.java index e09ff64218..cd1f8528cb 100644 --- a/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/transaction/DawnDiagramEditingDomainFactory.java +++ b/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/transaction/DawnDiagramEditingDomainFactory.java @@ -1,5 +1,6 @@ package org.eclipse.emf.cdo.dawn.transaction; +import org.eclipse.emf.cdo.dawn.resources.DawnPathmapManager; import org.eclipse.emf.cdo.internal.dawn.bundle.OM; import org.eclipse.net4j.util.om.trace.ContextTracer; @@ -16,6 +17,7 @@ import org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl; import org.eclipse.core.commands.operations.IOperationHistory; import org.eclipse.gmf.runtime.diagram.core.DiagramEditingDomainFactory; +@SuppressWarnings("restriction") public class DawnDiagramEditingDomainFactory extends DiagramEditingDomainFactory { private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, DawnDiagramEditingDomainFactory.class); @@ -86,6 +88,16 @@ public class DawnDiagramEditingDomainFactory extends DiagramEditingDomainFactory return result; } + @Override + protected void configure(final TransactionalEditingDomain domain) + { + super.configure(domain); + + final ResourceSet rset = domain.getResourceSet(); + DawnPathmapManager.removePathMapMananger(rset.eAdapters()); + rset.eAdapters().add(new DawnPathmapManager()); + } + public static WorkspaceEditingDomainFactory getInstance() { return instance; diff --git a/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/transaction/DawnGMFEditingDomainFactory.java b/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/transaction/DawnGMFEditingDomainFactory.java index dc0e9cefd2..593767adea 100644 --- a/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/transaction/DawnGMFEditingDomainFactory.java +++ b/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/transaction/DawnGMFEditingDomainFactory.java @@ -1,5 +1,6 @@ package org.eclipse.emf.cdo.dawn.transaction; +import org.eclipse.emf.cdo.dawn.resources.DawnPathmapManager; import org.eclipse.emf.cdo.internal.dawn.bundle.OM; import org.eclipse.net4j.util.om.trace.ContextTracer; @@ -13,6 +14,7 @@ import org.eclipse.emf.workspace.impl.WorkspaceCommandStackImpl; import org.eclipse.core.commands.operations.IOperationHistory; import org.eclipse.gmf.runtime.emf.core.GMFEditingDomainFactory; +@SuppressWarnings("restriction") public class DawnGMFEditingDomainFactory extends GMFEditingDomainFactory { private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, DawnGMFEditingDomainFactory.class); @@ -82,4 +84,14 @@ public class DawnGMFEditingDomainFactory extends GMFEditingDomainFactory { return instance; } + + @Override + protected void configure(final TransactionalEditingDomain domain) + { + super.configure(domain); + + final ResourceSet rset = domain.getResourceSet(); + DawnPathmapManager.removePathMapMananger(rset.eAdapters()); + rset.eAdapters().add(new DawnPathmapManager()); + } } |