Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Fluegge2011-09-25 10:07:47 +0000
committerMartin Fluegge2011-09-25 10:07:47 +0000
commit4e7428cad8fb510b7b1dea2a6bf46105457f76cd (patch)
tree01107f8b353c9f092c711a7a95385e47834b61c1 /plugins/org.eclipse.emf.cdo.dawn.emf
parent53f0bebdc539db62a911cc27dff34cd49e135ee2 (diff)
downloadcdo-4e7428cad8fb510b7b1dea2a6bf46105457f76cd.tar.gz
cdo-4e7428cad8fb510b7b1dea2a6bf46105457f76cd.tar.xz
cdo-4e7428cad8fb510b7b1dea2a6bf46105457f76cd.zip
[319486] [Dawn] Implement locking mechanism for extended editors
https://bugs.eclipse.org/bugs/show_bug.cgi?id=319486
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.dawn.emf')
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.emf/src/org/eclipse/emf/cdo/dawn/emf/editors/impl/DawnEMFEditorSupport.java62
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.emf/src/org/eclipse/emf/cdo/dawn/emf/notifications/impl/DawnEMFHandler.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.emf/src/org/eclipse/emf/cdo/dawn/emf/notifications/impl/DawnEMFLockingHandler.java61
3 files changed, 114 insertions, 13 deletions
diff --git a/plugins/org.eclipse.emf.cdo.dawn.emf/src/org/eclipse/emf/cdo/dawn/emf/editors/impl/DawnEMFEditorSupport.java b/plugins/org.eclipse.emf.cdo.dawn.emf/src/org/eclipse/emf/cdo/dawn/emf/editors/impl/DawnEMFEditorSupport.java
index b575d1888d..1568d646ab 100644
--- a/plugins/org.eclipse.emf.cdo.dawn.emf/src/org/eclipse/emf/cdo/dawn/emf/editors/impl/DawnEMFEditorSupport.java
+++ b/plugins/org.eclipse.emf.cdo.dawn.emf/src/org/eclipse/emf/cdo/dawn/emf/editors/impl/DawnEMFEditorSupport.java
@@ -13,12 +13,14 @@ package org.eclipse.emf.cdo.dawn.emf.editors.impl;
import org.eclipse.emf.cdo.dawn.editors.IDawnEditor;
import org.eclipse.emf.cdo.dawn.editors.impl.DawnAbstractEditorSupport;
import org.eclipse.emf.cdo.dawn.emf.notifications.impl.DawnEMFHandler;
+import org.eclipse.emf.cdo.dawn.emf.notifications.impl.DawnEMFLockingHandler;
import org.eclipse.emf.cdo.dawn.notifications.BasicDawnListener;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.view.CDOAdapterPolicy;
+import org.eclipse.emf.cdo.transaction.CDOTransactionHandlerBase;
+import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.emf.cdo.view.CDOView;
import org.eclipse.emf.common.ui.viewer.IViewerProvider;
+import org.eclipse.emf.ecore.EObject;
/**
* @author Martin Fluegge
@@ -40,23 +42,61 @@ public class DawnEMFEditorSupport extends DawnAbstractEditorSupport
}
}
- public void registerListeners()
+ // public void registerListeners()
+ // {
+ // BasicDawnListener listener = new DawnEMFHandler(getEditor());
+ // CDOView view = getView();
+ // view.addListener(listener);
+ //
+ // if (view instanceof CDOTransaction)
+ // {
+ // CDOTransaction transaction = (CDOTransaction)view;
+ // transaction.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.CDO);
+ // }
+ // }
+
+ @Override
+ protected BasicDawnListener getBasicHandler()
{
- BasicDawnListener listener = new DawnEMFHandler(getEditor());
- CDOView view = getView();
- view.addListener(listener);
+ return new DawnEMFHandler(getEditor());
+ }
- if (view instanceof CDOTransaction)
- {
- CDOTransaction transaction = (CDOTransaction)view;
- transaction.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.CDO);
- }
+ @Override
+ protected BasicDawnListener getLockingHandler()
+ {
+ return new DawnEMFLockingHandler(getEditor());
+ }
+
+ @Override
+ protected CDOTransactionHandlerBase getTransactionHandler()
+ {
+ return null;
}
@Override
public void rollback()
{
super.rollback();
+ refresh();
+ }
+
+ public void refresh()
+ {
((IViewerProvider)getEditor()).getViewer().refresh();
}
+
+ public void lockObject(Object objectToBeLocked)
+ {
+ if (objectToBeLocked instanceof EObject)
+ {
+ CDOUtil.getCDOObject((EObject)objectToBeLocked).cdoWriteLock().lock();
+ }
+ refresh();
+ }
+
+ public void unlockObject(Object objectToBeUnlocked)
+ {
+ CDOUtil.getCDOObject((EObject)objectToBeUnlocked).cdoWriteLock().unlock();
+ refresh();
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.emf/src/org/eclipse/emf/cdo/dawn/emf/notifications/impl/DawnEMFHandler.java b/plugins/org.eclipse.emf.cdo.dawn.emf/src/org/eclipse/emf/cdo/dawn/emf/notifications/impl/DawnEMFHandler.java
index 6120d8506e..cfc8236565 100644
--- a/plugins/org.eclipse.emf.cdo.dawn.emf/src/org/eclipse/emf/cdo/dawn/emf/notifications/impl/DawnEMFHandler.java
+++ b/plugins/org.eclipse.emf.cdo.dawn.emf/src/org/eclipse/emf/cdo/dawn/emf/notifications/impl/DawnEMFHandler.java
@@ -11,7 +11,7 @@
package org.eclipse.emf.cdo.dawn.emf.notifications.impl;
import org.eclipse.emf.cdo.dawn.editors.IDawnEditor;
-import org.eclipse.emf.cdo.dawn.notifications.BasicDawnListener;
+import org.eclipse.emf.cdo.dawn.notifications.BasicDawnTransactionHandler;
import org.eclipse.emf.cdo.transaction.CDOTransactionConflictEvent;
import org.eclipse.emf.cdo.view.CDOViewInvalidationEvent;
@@ -20,7 +20,7 @@ import org.eclipse.emf.common.ui.viewer.IViewerProvider;
/**
* @author Martin Fluegge
*/
-public class DawnEMFHandler extends BasicDawnListener
+public class DawnEMFHandler extends BasicDawnTransactionHandler
{
/**
* @since 1.0
diff --git a/plugins/org.eclipse.emf.cdo.dawn.emf/src/org/eclipse/emf/cdo/dawn/emf/notifications/impl/DawnEMFLockingHandler.java b/plugins/org.eclipse.emf.cdo.dawn.emf/src/org/eclipse/emf/cdo/dawn/emf/notifications/impl/DawnEMFLockingHandler.java
new file mode 100644
index 0000000000..fc6f21d4d7
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.emf/src/org/eclipse/emf/cdo/dawn/emf/notifications/impl/DawnEMFLockingHandler.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2004 - 2011 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.emf.notifications.impl;
+
+import org.eclipse.emf.cdo.dawn.editors.IDawnEditor;
+import org.eclipse.emf.cdo.dawn.notifications.BasicDawnListener;
+import org.eclipse.emf.cdo.transaction.CDOTransactionConflictEvent;
+import org.eclipse.emf.cdo.view.CDOViewInvalidationEvent;
+import org.eclipse.emf.cdo.view.CDOViewLocksChangedEvent;
+
+import org.eclipse.net4j.util.event.IEvent;
+
+import org.eclipse.emf.common.ui.viewer.IViewerProvider;
+
+/**
+ * @author Martin Fluegge
+ */
+public class DawnEMFLockingHandler extends BasicDawnListener
+{
+ public DawnEMFLockingHandler(IDawnEditor editor)
+ {
+ super(editor);
+ }
+
+ public void handleViewInvalidationEvent(CDOViewInvalidationEvent event)
+ {
+ System.out.println("DawnEMFLockingHandler.handleViewInvalidationEvent()");
+ }
+
+ public void handleTransactionConflictEvent(CDOTransactionConflictEvent event)
+ {
+ System.out.println("DawnEMFLockingHandler.handleTransactionConflictEvent()");
+ }
+
+ public void handleEvent(IEvent event)
+ {
+ if (event instanceof CDOViewLocksChangedEvent)
+ {
+ refreshEditor();
+ }
+ }
+
+ private void refreshEditor()
+ {
+ editor.getSite().getShell().getDisplay().asyncExec(new Runnable()
+ {
+ public void run()
+ {
+ ((IViewerProvider)editor).getViewer().refresh();
+ }
+ });
+ }
+}

Back to the top