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
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
-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
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram.dawn/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/part/DawnAcoreDocumentProvider.java1
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.gmf/META-INF/MANIFEST.MF3
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/DawnAppearancer.java18
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/impl/DawnBasicConnectionEditPartStylizerImpl.java9
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/impl/DawnBasicGraphicalEditPartStylizerImpl.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/impl/DawnBasicNodeEditPartStylizerImpl.java19
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/impl/DawnBasicTextAwareEditPartStylizerImpl.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/impl/DawnBlinkingNodeEditPartStylizerImpl.java9
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/editors/impl/DawnGMFEditorSupport.java116
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/notifications/impl/DawnGMFHandler.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/notifications/impl/DawnGMFLockingHandler.java117
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/AllTestsDawnUISWTBot.java22
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/emf/EMFEditorRollbackTest.java42
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/emf/EMFLockingTest.java105
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/gmf/GMFLockingTest.java128
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/util/DawnAcoreTestUtil.java31
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/util/DawnEcoreTestUtil.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/util/DawnSWTBotEMFEditor.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.ui/META-INF/MANIFEST.MF4
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.ui/plugin.xml80
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/DawnColorConstants.java33
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/DawnLabelProvider.java20
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/handlers/LockObjectsHandler.java32
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/handlers/SelectionHandler.java45
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/handlers/SolveConflictHandler.java (renamed from plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/handlers/SolveConflictHandler.java)4
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/handlers/UnLockObjectsHandler.java32
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn/META-INF/MANIFEST.MF2
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn/plugin.xml38
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/editors/IDawnEditor.java13
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/editors/IDawnEditorSupport.java19
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/editors/impl/DawnAbstractEditorSupport.java93
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/notifications/BasicDawnListener.java75
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/notifications/BasicDawnTransactionHandler.java84
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/notifications/IDawnListener.java9
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/notifications/IDawnTransactionHandler.java21
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/spi/IDawnEditingSupport.java99
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/spi/IDawnUIElement.java27
40 files changed, 1279 insertions, 220 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();
+ }
+ });
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram.dawn/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/part/DawnAcoreDocumentProvider.java b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram.dawn/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/part/DawnAcoreDocumentProvider.java
index 0dcf8e6313..08580c21c1 100644
--- a/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram.dawn/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/part/DawnAcoreDocumentProvider.java
+++ b/plugins/org.eclipse.emf.cdo.dawn.examples.acore.diagram.dawn/src/org/eclipse/emf/cdo/dawn/examples/acore/diagram/part/DawnAcoreDocumentProvider.java
@@ -51,7 +51,6 @@ import java.util.Map;
@SuppressWarnings("restriction")
public class DawnAcoreDocumentProvider extends AcoreDocumentProvider
{
-
public DawnAcoreDocumentProvider()
{
super();
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 424e81b382..5a4d01f9f2 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
@@ -18,7 +18,8 @@ Require-Bundle: org.eclipse.ui;bundle-version="[3.6.0,4.0.0)",
org.eclipse.gmf.runtime.notation.providers;bundle-version="[1.3.0,2.0.0)",
org.eclipse.gmf.runtime.diagram.ui.resources.editor;bundle-version="[1.3.0,2.0.0)",
org.eclipse.gmf.runtime.diagram.ui.resources.editor.ide;bundle-version="[1.2.0,2.0.0)",
- org.eclipse.emf.cdo.dawn.util;bundle-version="[2.0.0,3.0.0)"
+ org.eclipse.emf.cdo.dawn.util;bundle-version="[2.0.0,3.0.0)",
+ org.eclipse.emf.cdo.dawn.ui;bundle-version="[2.0.0,3.0.0)"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Vendor: %providerName
diff --git a/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/DawnAppearancer.java b/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/DawnAppearancer.java
index 3dbce67abb..c8e26c81d3 100644
--- a/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/DawnAppearancer.java
+++ b/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/DawnAppearancer.java
@@ -10,11 +10,9 @@
*/
package org.eclipse.emf.cdo.dawn.gmf.appearance;
-import org.eclipse.draw2d.ColorConstants;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.GraphicalEditPart;
import org.eclipse.gef.util.EditPartUtilities;
-import org.eclipse.swt.graphics.Color;
/**
* @author Martin Fluegge
@@ -26,18 +24,6 @@ public class DawnAppearancer
public static final int DEFAULT_LINE_THICKNESS = 3;
- public static final Color COLOR_NO_BORDER = new Color(null, 255, 255, 255);
-
- public static final Color COLOR_LOCKED_REMOTELY = ColorConstants.yellow;
-
- public static final Color COLOR_LOCKED_LOCALLY = ColorConstants.green;
-
- public static final Color COLOR_DELETE_CONFLICT = new Color(null, 255, 0, 0);
-
- public static final Color COLOR_CHANGE_CONFLICT = new Color(null, 0, 0, 255);
-
- public static final Color COLOR_NO_CONFLICT = new Color(null, 255, 255, 255);
-
public static final int TYPE_CONFLICT_NONE = -1;
public static final int TYPE_CONFLICT_LOCALLY_DELETED = 0;
@@ -90,12 +76,12 @@ public class DawnAppearancer
/**
* @since 2.0
*/
- protected static void setEditPartLocked(EditPart editPart, int type)
+ public static void setEditPartLocked(EditPart editPart, int type)
{
DawnEditPartStylizer stylizer = DawnEditPartStylizerRegistry.instance.getStylizer(editPart);
if (stylizer != null)
{
- stylizer.setDefault(editPart);
+ stylizer.setLocked(editPart, type);
}
}
}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/impl/DawnBasicConnectionEditPartStylizerImpl.java b/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/impl/DawnBasicConnectionEditPartStylizerImpl.java
index 40b658fe3d..d741d8c4fc 100644
--- a/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/impl/DawnBasicConnectionEditPartStylizerImpl.java
+++ b/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/impl/DawnBasicConnectionEditPartStylizerImpl.java
@@ -12,6 +12,7 @@ package org.eclipse.emf.cdo.dawn.gmf.appearance.impl;
import org.eclipse.emf.cdo.dawn.gmf.appearance.DawnAppearancer;
import org.eclipse.emf.cdo.dawn.gmf.appearance.DawnEditPartStylizer;
+import org.eclipse.emf.cdo.dawn.ui.DawnColorConstants;
import org.eclipse.emf.workspace.AbstractEMFOperation;
@@ -43,7 +44,7 @@ public class DawnBasicConnectionEditPartStylizerImpl implements DawnEditPartStyl
*/
public void setDefault(EditPart editPart)
{
- setEdge(editPart, DawnAppearancer.COLOR_NO_CONFLICT);
+ setEdge(editPart, DawnColorConstants.COLOR_NO_CONFLICT);
}
/**
@@ -51,7 +52,7 @@ public class DawnBasicConnectionEditPartStylizerImpl implements DawnEditPartStyl
*/
public void setConflicted(EditPart editPart, int type)
{
- Color color = DawnAppearancer.COLOR_DELETE_CONFLICT;
+ Color color = DawnColorConstants.COLOR_DELETE_CONFLICT;
setEdge(editPart, color);
}
@@ -97,12 +98,12 @@ public class DawnBasicConnectionEditPartStylizerImpl implements DawnEditPartStyl
{
case DawnAppearancer.TYPE_LOCKED_LOCALLY:
{
- color = DawnAppearancer.COLOR_LOCKED_REMOTELY;
+ color = DawnColorConstants.COLOR_LOCKED_REMOTELY;
break;
}
case DawnAppearancer.TYPE_LOCKED_GLOBALLY:
{
- color = DawnAppearancer.COLOR_LOCKED_LOCALLY;
+ color = DawnColorConstants.COLOR_LOCKED_LOCALLY;
break;
}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/impl/DawnBasicGraphicalEditPartStylizerImpl.java b/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/impl/DawnBasicGraphicalEditPartStylizerImpl.java
index 79462d1c42..878c359e21 100644
--- a/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/impl/DawnBasicGraphicalEditPartStylizerImpl.java
+++ b/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/impl/DawnBasicGraphicalEditPartStylizerImpl.java
@@ -12,6 +12,7 @@ package org.eclipse.emf.cdo.dawn.gmf.appearance.impl;
import org.eclipse.emf.cdo.dawn.gmf.appearance.DawnAppearancer;
import org.eclipse.emf.cdo.dawn.gmf.appearance.DawnEditPartStylizer;
+import org.eclipse.emf.cdo.dawn.ui.DawnColorConstants;
import org.eclipse.draw2d.Border;
import org.eclipse.draw2d.IFigure;
@@ -40,7 +41,7 @@ public class DawnBasicGraphicalEditPartStylizerImpl implements DawnEditPartStyli
*/
public void setConflicted(EditPart editPart, int type)
{
- setBorder(editPart, DawnAppearancer.COLOR_DELETE_CONFLICT, DawnAppearancer.DEFAULT_BORDER_THICKNESS);
+ setBorder(editPart, DawnColorConstants.COLOR_DELETE_CONFLICT, DawnAppearancer.DEFAULT_BORDER_THICKNESS);
}
/**
@@ -48,7 +49,7 @@ public class DawnBasicGraphicalEditPartStylizerImpl implements DawnEditPartStyli
*/
public void setLocked(EditPart editPart, int type)
{
- setBorder(editPart, DawnAppearancer.COLOR_LOCKED_REMOTELY, DawnAppearancer.DEFAULT_BORDER_THICKNESS);
+ setBorder(editPart, DawnColorConstants.COLOR_LOCKED_REMOTELY, DawnAppearancer.DEFAULT_BORDER_THICKNESS);
}
/**
diff --git a/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/impl/DawnBasicNodeEditPartStylizerImpl.java b/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/impl/DawnBasicNodeEditPartStylizerImpl.java
index b8c76131c3..f89c5c0370 100644
--- a/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/impl/DawnBasicNodeEditPartStylizerImpl.java
+++ b/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/impl/DawnBasicNodeEditPartStylizerImpl.java
@@ -11,6 +11,7 @@
package org.eclipse.emf.cdo.dawn.gmf.appearance.impl;
import org.eclipse.emf.cdo.dawn.gmf.appearance.DawnAppearancer;
+import org.eclipse.emf.cdo.dawn.ui.DawnColorConstants;
import org.eclipse.gef.EditPart;
@@ -23,18 +24,30 @@ public class DawnBasicNodeEditPartStylizerImpl extends DawnBasicGraphicalEditPar
@Override
public void setDefault(EditPart editPart)
{
- setBorder(editPart, DawnAppearancer.COLOR_NO_CONFLICT, 0);
+ setBorder(editPart, DawnColorConstants.COLOR_NO_CONFLICT, 0);
}
@Override
public void setConflicted(EditPart editPart, int type)
{
- setBorder(editPart, DawnAppearancer.COLOR_DELETE_CONFLICT, DawnAppearancer.DEFAULT_BORDER_THICKNESS);
+ setBorder(editPart, DawnColorConstants.COLOR_DELETE_CONFLICT, DawnAppearancer.DEFAULT_BORDER_THICKNESS);
}
@Override
public void setLocked(EditPart editPart, int type)
{
- setBorder(editPart, DawnAppearancer.COLOR_LOCKED_REMOTELY, DawnAppearancer.DEFAULT_BORDER_THICKNESS);
+ switch (type)
+ {
+ case DawnAppearancer.TYPE_LOCKED_GLOBALLY:
+ {
+ setBorder(editPart, DawnColorConstants.COLOR_LOCKED_REMOTELY, DawnAppearancer.DEFAULT_BORDER_THICKNESS);
+ break;
+ }
+ case DawnAppearancer.TYPE_LOCKED_LOCALLY:
+ {
+ setBorder(editPart, DawnColorConstants.COLOR_LOCKED_LOCALLY, DawnAppearancer.DEFAULT_BORDER_THICKNESS);
+ break;
+ }
+ }
}
}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/impl/DawnBasicTextAwareEditPartStylizerImpl.java b/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/impl/DawnBasicTextAwareEditPartStylizerImpl.java
index 332f238973..7323bb38b4 100644
--- a/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/impl/DawnBasicTextAwareEditPartStylizerImpl.java
+++ b/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/impl/DawnBasicTextAwareEditPartStylizerImpl.java
@@ -11,6 +11,7 @@
package org.eclipse.emf.cdo.dawn.gmf.appearance.impl;
import org.eclipse.emf.cdo.dawn.gmf.appearance.DawnAppearancer;
+import org.eclipse.emf.cdo.dawn.ui.DawnColorConstants;
import org.eclipse.draw2d.Border;
import org.eclipse.gef.EditPart;
@@ -43,7 +44,7 @@ public class DawnBasicTextAwareEditPartStylizerImpl extends DawnBasicGraphicalEd
// e.getFigure().setForegroundColor(DawnAppearancer.COLOR_DELETE_CONFLICT);
oldValues.put(e, e.getFigure().getBorder());
- setBorder(editPart, DawnAppearancer.COLOR_DELETE_CONFLICT, DawnAppearancer.DEFAULT_BORDER_THICKNESS);
+ setBorder(editPart, DawnColorConstants.COLOR_DELETE_CONFLICT, DawnAppearancer.DEFAULT_BORDER_THICKNESS);
// View view = (View)e.getModel();
// FontStyle style = (FontStyle)view.getStyle(NotationPackage.eINSTANCE.getFontStyle());
// if (style == null)
@@ -59,6 +60,6 @@ public class DawnBasicTextAwareEditPartStylizerImpl extends DawnBasicGraphicalEd
@Override
public void setLocked(EditPart editPart, int type)
{
- setBorder(editPart, DawnAppearancer.COLOR_LOCKED_REMOTELY, DawnAppearancer.DEFAULT_BORDER_THICKNESS);
+ setBorder(editPart, DawnColorConstants.COLOR_LOCKED_REMOTELY, DawnAppearancer.DEFAULT_BORDER_THICKNESS);
}
}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/impl/DawnBlinkingNodeEditPartStylizerImpl.java b/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/impl/DawnBlinkingNodeEditPartStylizerImpl.java
index 6ccd19b4cb..39c47118dd 100644
--- a/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/impl/DawnBlinkingNodeEditPartStylizerImpl.java
+++ b/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/appearance/impl/DawnBlinkingNodeEditPartStylizerImpl.java
@@ -11,6 +11,7 @@
package org.eclipse.emf.cdo.dawn.gmf.appearance.impl;
import org.eclipse.emf.cdo.dawn.gmf.appearance.DawnAppearancer;
+import org.eclipse.emf.cdo.dawn.ui.DawnColorConstants;
import org.eclipse.gef.EditPart;
@@ -35,7 +36,7 @@ public class DawnBlinkingNodeEditPartStylizerImpl extends DawnBasicGraphicalEdit
public void setDefault(EditPart editPart)
{
blinkingThread.stop(editPart);
- setBorder(editPart, DawnAppearancer.COLOR_NO_CONFLICT, 0);
+ setBorder(editPart, DawnColorConstants.COLOR_NO_CONFLICT, 0);
}
@Override
@@ -47,7 +48,7 @@ public class DawnBlinkingNodeEditPartStylizerImpl extends DawnBasicGraphicalEdit
@Override
public void setLocked(EditPart editPart, int type)
{
- setBorder(editPart, DawnAppearancer.COLOR_LOCKED_REMOTELY, DawnAppearancer.DEFAULT_BORDER_THICKNESS);
+ setBorder(editPart, DawnColorConstants.COLOR_LOCKED_REMOTELY, DawnAppearancer.DEFAULT_BORDER_THICKNESS);
}
/**
@@ -68,11 +69,11 @@ public class DawnBlinkingNodeEditPartStylizerImpl extends DawnBasicGraphicalEdit
{
if (editParts.get(e))
{
- setBorder(e, DawnAppearancer.COLOR_NO_CONFLICT, DawnAppearancer.DEFAULT_BORDER_THICKNESS);
+ setBorder(e, DawnColorConstants.COLOR_NO_CONFLICT, DawnAppearancer.DEFAULT_BORDER_THICKNESS);
}
else
{
- setBorder(e, DawnAppearancer.COLOR_DELETE_CONFLICT, DawnAppearancer.DEFAULT_BORDER_THICKNESS);
+ setBorder(e, DawnColorConstants.COLOR_DELETE_CONFLICT, DawnAppearancer.DEFAULT_BORDER_THICKNESS);
}
editParts.put(e, !editParts.get(e));
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 474475682b..94ed9dd306 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
@@ -13,26 +13,35 @@ package org.eclipse.emf.cdo.dawn.gmf.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.gmf.appearance.DawnAppearancer;
+import org.eclipse.emf.cdo.dawn.gmf.appearance.DawnEditPartStylizer;
+import org.eclipse.emf.cdo.dawn.gmf.appearance.DawnEditPartStylizerRegistry;
import org.eclipse.emf.cdo.dawn.gmf.notifications.impl.DawnGMFHandler;
+import org.eclipse.emf.cdo.dawn.gmf.notifications.impl.DawnGMFLockingHandler;
import org.eclipse.emf.cdo.dawn.gmf.util.DawnDiagramUpdater;
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.ecore.EObject;
import org.eclipse.emf.transaction.RecordingCommand;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.gef.EditPart;
import org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor;
+import org.eclipse.gmf.runtime.notation.View;
/**
* @author Martin Fluegge
*/
public class DawnGMFEditorSupport extends DawnAbstractEditorSupport
{
+ private DawnGMFHandler dawnGMFHandler;
+
public DawnGMFEditorSupport(IDawnEditor editor)
{
super(editor);
+ dawnGMFHandler = new DawnGMFHandler(editor);
}
public void close()
@@ -44,18 +53,37 @@ public class DawnGMFEditorSupport extends DawnAbstractEditorSupport
}
}
- public void registerListeners()
+ // @Override
+ // public void registerListeners()
+ // {
+ // BasicDawnListener listener = new DawnGMFHandler(getEditor());
+ // CDOView view = getView();
+ // view.addListener(listener);
+ //
+ // if (view instanceof CDOTransaction)
+ // {
+ // CDOTransaction transaction = (CDOTransaction)view;
+ // transaction.addTransactionHandler(listener);
+ // transaction.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.CDO);
+ // }
+ // }
+
+ @Override
+ protected BasicDawnListener getBasicHandler()
{
- BasicDawnListener listener = new DawnGMFHandler(getEditor());
- CDOView view = getView();
- view.addListener(listener);
+ return dawnGMFHandler;
+ }
- if (view instanceof CDOTransaction)
- {
- CDOTransaction transaction = (CDOTransaction)view;
- transaction.addTransactionHandler(listener);
- transaction.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.CDO);
- }
+ @Override
+ protected BasicDawnListener getLockingHandler()
+ {
+ return new DawnGMFLockingHandler(getEditor());
+ }
+
+ @Override
+ protected CDOTransactionHandlerBase getTransactionHandler()
+ {
+ return dawnGMFHandler;
}
/**
@@ -77,4 +105,68 @@ public class DawnGMFEditorSupport extends DawnAbstractEditorSupport
}
});
}
+
+ public void refresh()
+ {
+ final DiagramDocumentEditor diagramDocumentEditor = (DiagramDocumentEditor)getEditor();
+ TransactionalEditingDomain editingDomain = diagramDocumentEditor.getEditingDomain();
+ editingDomain.getCommandStack().execute(new RecordingCommand(editingDomain)
+ {
+ @Override
+ public void doExecute()
+ {
+ DawnDiagramUpdater.refreshEditPart(diagramDocumentEditor.getDiagramEditPart());
+ }
+ });
+ }
+
+ public void lockObject(Object objectToBeLocked)
+ {
+ if (objectToBeLocked instanceof EditPart)
+ {
+ EditPart editPart = (EditPart)objectToBeLocked;
+ Object model = editPart.getModel();
+
+ if (model instanceof EObject)
+ {
+ CDOUtil.getCDOObject((EObject)model).cdoWriteLock().lock();
+ if (model instanceof View)
+ {
+ EObject element = ((View)model).getElement();
+ CDOUtil.getCDOObject(element).cdoWriteLock().lock();
+ }
+ }
+ DawnEditPartStylizer stylizer = DawnEditPartStylizerRegistry.instance.getStylizer(editPart);
+ if (stylizer != null)
+ {
+ stylizer.setLocked(editPart, DawnAppearancer.TYPE_LOCKED_LOCALLY);
+ }
+ }
+ refresh();
+ }
+
+ public void unlockObject(Object objectToBeUnlocked)
+ {
+ if (objectToBeUnlocked instanceof EditPart)
+ {
+ EditPart editPart = (EditPart)objectToBeUnlocked;
+ Object model = editPart.getModel();
+
+ if (model instanceof EObject)
+ {
+ CDOUtil.getCDOObject((EObject)model).cdoWriteLock().unlock();
+ if (model instanceof View)
+ {
+ EObject element = ((View)model).getElement();
+ CDOUtil.getCDOObject(element).cdoWriteLock().unlock();
+ }
+ }
+ DawnEditPartStylizer stylizer = DawnEditPartStylizerRegistry.instance.getStylizer(editPart);
+ if (stylizer != null)
+ {
+ stylizer.setDefault(editPart);
+ }
+ }
+ refresh();
+ }
}
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 efed2c2d1f..9ce8de2ea5 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
@@ -15,7 +15,7 @@ import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
import org.eclipse.emf.cdo.dawn.editors.IDawnEditor;
import org.eclipse.emf.cdo.dawn.gmf.synchronize.DawnConflictHelper;
import org.eclipse.emf.cdo.dawn.gmf.util.DawnDiagramUpdater;
-import org.eclipse.emf.cdo.dawn.notifications.BasicDawnListener;
+import org.eclipse.emf.cdo.dawn.notifications.BasicDawnTransactionHandler;
import org.eclipse.emf.cdo.internal.dawn.bundle.OM;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.transaction.CDOTransactionConflictEvent;
@@ -45,7 +45,7 @@ import org.eclipse.swt.widgets.Display;
/**
* @author Martin Fluegge
*/
-public class DawnGMFHandler extends BasicDawnListener
+public class DawnGMFHandler extends BasicDawnTransactionHandler
{
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, DawnGMFHandler.class);
@@ -209,7 +209,6 @@ public class DawnGMFHandler extends BasicDawnListener
private void handleObject(CDOObject dirtyObject)
{
-
if (dirtyObject.cdoInvalid())
{
return;
diff --git a/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/notifications/impl/DawnGMFLockingHandler.java b/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/notifications/impl/DawnGMFLockingHandler.java
new file mode 100644
index 0000000000..61a0dad7ba
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.gmf/src/org/eclipse/emf/cdo/dawn/gmf/notifications/impl/DawnGMFLockingHandler.java
@@ -0,0 +1,117 @@
+/*
+ * 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.gmf.notifications.impl;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.lock.CDOLockState;
+import org.eclipse.emf.cdo.common.revision.CDOIDAndBranch;
+import org.eclipse.emf.cdo.dawn.editors.IDawnEditor;
+import org.eclipse.emf.cdo.dawn.gmf.appearance.DawnAppearancer;
+import org.eclipse.emf.cdo.dawn.gmf.util.DawnDiagramUpdater;
+import org.eclipse.emf.cdo.dawn.notifications.BasicDawnListener;
+import org.eclipse.emf.cdo.transaction.CDOTransactionConflictEvent;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.view.CDOView;
+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.ecore.EObject;
+
+import org.eclipse.gef.EditPart;
+import org.eclipse.gmf.runtime.diagram.ui.resources.editor.parts.DiagramDocumentEditor;
+import org.eclipse.gmf.runtime.notation.View;
+
+/**
+ * @author Martin Fluegge
+ */
+public class DawnGMFLockingHandler extends BasicDawnListener
+{
+ public DawnGMFLockingHandler(IDawnEditor editor)
+ {
+ super(editor);
+ }
+
+ public void handleViewInvalidationEvent(CDOViewInvalidationEvent event)
+ {
+ System.out.println("DawnGMFLockingHandler.handleViewInvalidationEvent()");
+ }
+
+ public void handleTransactionConflictEvent(CDOTransactionConflictEvent event)
+ {
+ System.out.println("DawnGMFLockingHandler.handleTransactionConflictEvent()");
+ }
+
+ public void handleEvent(IEvent event)
+ {
+ if (event instanceof CDOViewLocksChangedEvent)
+ {
+ CDOViewLocksChangedEvent lockEvent = (CDOViewLocksChangedEvent)event;
+
+ CDOLockState[] lockStates = lockEvent.getLockStates();
+ for (CDOLockState state : lockStates)
+ {
+ Object lockedObject = state.getLockedObject();
+
+ CDOView view = editor.getDawnEditorSupport().getView();
+ CDOID id;
+ if (lockedObject instanceof CDOID)
+ {
+ id = (CDOID)lockedObject;
+ }
+ else if (lockedObject instanceof CDOIDAndBranch)
+ {
+ id = ((CDOIDAndBranch)lockedObject).getID();
+ }
+ else
+ {
+ throw new RuntimeException("Unexpected object type: " + lockedObject);
+ }
+
+ if (id != null)
+ {
+ CDOObject object = view.getObject(id);
+ handleLock(object, view);
+ System.out.println(object);
+ }
+ }
+
+ System.out.println("DawnGMFLockingHandler.handleEvent()");
+ editor.getDawnEditorSupport().refresh();
+ }
+ }
+
+ private void handleLock(CDOObject object, CDOView cdoView)
+ {
+ EObject element = CDOUtil.getEObject(object); // either semantic object or notational
+ View view = DawnDiagramUpdater.findView(element);
+ if (view != null)
+ {
+ // if there is no view, the semantic object is not displayed.
+ EditPart editPart = DawnDiagramUpdater.createOrFindEditPartIfViewExists(view, (DiagramDocumentEditor)editor);
+
+ if (object.cdoWriteLock().isLocked())
+ {
+ DawnAppearancer.setEditPartLocked(editPart, DawnAppearancer.TYPE_LOCKED_LOCALLY);
+ }
+ else if (object.cdoWriteLock().isLockedByOthers())
+ {
+ DawnAppearancer.setEditPartLocked(editPart, DawnAppearancer.TYPE_LOCKED_GLOBALLY);
+ }
+ else
+ {
+ DawnAppearancer.setEditPartDefault(editPart);
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/AllTestsDawnUISWTBot.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/AllTestsDawnUISWTBot.java
index a2789adeb0..de39754868 100644
--- a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/AllTestsDawnUISWTBot.java
+++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/AllTestsDawnUISWTBot.java
@@ -19,8 +19,12 @@ import org.eclipse.emf.cdo.dawn.tests.ui.DawnProjectExplorerTest;
import org.eclipse.emf.cdo.dawn.tests.ui.emf.DawnEMFCreationWizardTest;
import org.eclipse.emf.cdo.dawn.tests.ui.emf.DawnEMFHandleEditorTest;
import org.eclipse.emf.cdo.dawn.tests.ui.emf.EMFEditorRollbackTest;
+import org.eclipse.emf.cdo.dawn.tests.ui.emf.EMFLockingTest;
+import org.eclipse.emf.cdo.dawn.tests.ui.gmf.ConflictTest;
import org.eclipse.emf.cdo.dawn.tests.ui.gmf.DawnCreationWizardSWTBotTest;
+import org.eclipse.emf.cdo.dawn.tests.ui.gmf.GMFLockingTest;
import org.eclipse.emf.cdo.dawn.tests.ui.gmf.MultipleResourcesTest;
+import org.eclipse.emf.cdo.dawn.tests.ui.gmf.RollbackTest;
import org.eclipse.emf.cdo.dawn.tests.ui.gmf.SimpleDiagramTest;
import org.eclipse.emf.cdo.tests.AllTests;
import org.eclipse.emf.cdo.tests.config.IScenario;
@@ -54,24 +58,26 @@ public class AllTestsDawnUISWTBot extends ConfigTestSuite
@Override
protected void initTestClasses(List<Class<? extends ConfigTest>> testClasses, IScenario scenario)
{
- /******************** General **********************/
+ // /******************** General **********************/
// testClasses.add(DawnCodeGenerationTest.class);
-
- /******************** GMF **********************/
+ testClasses.add(DawnProjectExplorerTest.class);
testClasses.add(DawnPreferencesTest.class);
+
+ // /******************** GMF **********************/
testClasses.add(DawnCreationWizardSWTBotTest.class);
testClasses.add(SimpleDiagramTest.class);
testClasses.add(MultipleResourcesTest.class);
- testClasses.add(DawnProjectExplorerTest.class);
- // testClasses.add(RollbackTest.class);
- // testClasses.add(ConflictTest.class);
+ testClasses.add(GMFLockingTest.class);
+ testClasses.add(ConflictTest.class);
+ testClasses.add(RollbackTest.class);
- /******************** EMF **********************/
+ // /******************** EMF **********************/
testClasses.add(DawnEMFCreationWizardTest.class);
testClasses.add(EMFEditorRollbackTest.class);
testClasses.add(DawnEMFHandleEditorTest.class);
+ testClasses.add(EMFLockingTest.class);
- /******************** Bugzilla **********************/
+ // /******************** Bugzilla **********************/
testClasses.add(Bugzilla_321024_Test.class);
testClasses.add(Bugzilla_333291_Test.class);
testClasses.add(Bugzilla_333187_Test.class);
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/emf/EMFEditorRollbackTest.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/emf/EMFEditorRollbackTest.java
index 0226f3d9b6..0d4780ad25 100644
--- a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/emf/EMFEditorRollbackTest.java
+++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/emf/EMFEditorRollbackTest.java
@@ -10,10 +10,19 @@
*/
package org.eclipse.emf.cdo.dawn.tests.ui.emf;
+import org.eclipse.emf.cdo.dawn.editors.IDawnEditor;
+import org.eclipse.emf.cdo.dawn.examples.acore.AClass;
+import org.eclipse.emf.cdo.dawn.examples.acore.ACoreRoot;
import org.eclipse.emf.cdo.dawn.tests.AbstractDawnEMFTest;
+import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnAcoreTestUtil;
+import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnSWTBotEMFEditor;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -28,5 +37,38 @@ public class EMFEditorRollbackTest extends AbstractDawnEMFTest
@Test
public void testGMFAClassConflictMove() throws Exception
{
+ DawnSWTBotEMFEditor editor = DawnAcoreTestUtil.openNewAcoreEMFEditor("default.acore", getBot());
+ assertNotNull(editor);
+ SWTBotTree tree = editor.getSelectionPageTree();
+
+ selectFolder(tree.getAllItems(), "ACore Root", false);
+
+ editor.clickContextMenu(tree.widget, "AClass");
+ editor.save();
+ // selectFolder(tree.getAllItems(), "AClass", false);
+
+ IDawnEditor dawnEditor = (IDawnEditor)editor.getReference().getEditor(false);
+
+ CDOResource resource = dawnEditor.getDawnEditorSupport().getView().getResource("/default.acore");
+ AClass aClass = ((ACoreRoot)resource.getContents().get(0)).getClasses().get(0);
+ aClass.setName("BClass");
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource2 = transaction.getResource("/default.acore");
+ AClass aClass2 = ((ACoreRoot)resource2.getContents().get(0)).getClasses().get(0);
+ aClass2.setName("CClass");
+ transaction.commit();
+ }
+ sleep(500);
+ assertEquals(true, aClass.cdoConflict());
+ editor.clickContextMenu(tree.widget, "Solve Conflict");
+
+ getBot().button("yes").click();
+ assertEquals(false, aClass.cdoConflict());
+ assertEquals("CClass", aClass.getName());
+ editor.close();
+
}
}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/emf/EMFLockingTest.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/emf/EMFLockingTest.java
new file mode 100644
index 0000000000..b69facbc3f
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/emf/EMFLockingTest.java
@@ -0,0 +1,105 @@
+/*
+ * 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.tests.ui.emf;
+
+import org.eclipse.emf.cdo.dawn.editors.IDawnEditor;
+import org.eclipse.emf.cdo.dawn.examples.acore.AClass;
+import org.eclipse.emf.cdo.dawn.examples.acore.ACoreRoot;
+import org.eclipse.emf.cdo.dawn.tests.AbstractDawnEMFTest;
+import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnAcoreTestUtil;
+import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnSWTBotEMFEditor;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * @author Martin Fluegge
+ */
+@CleanRepositoriesBefore
+@RunWith(SWTBotJunit4ClassRunner.class)
+public class EMFLockingTest extends AbstractDawnEMFTest
+{
+ @Test
+ public void testAClassLockRemotely() throws Exception
+ {
+ DawnSWTBotEMFEditor editor = DawnAcoreTestUtil.openNewAcoreEMFEditor("default.acore", getBot());
+ assertNotNull(editor);
+ SWTBotTree tree = editor.getSelectionPageTree();
+
+ selectFolder(tree.getAllItems(), "ACore Root", false);
+
+ editor.clickContextMenu(tree.widget, "AClass");
+ editor.save();
+
+ IDawnEditor dawnEditor = (IDawnEditor)editor.getReference().getEditor(false);
+ CDOResource resource = dawnEditor.getDawnEditorSupport().getView().getResource("/default.acore");
+ AClass aClass = ((ACoreRoot)resource.getContents().get(0)).getClasses().get(0);
+ aClass.setName("BClass");
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource2 = transaction.getResource("/default.acore");
+ AClass aClass2 = ((ACoreRoot)resource2.getContents().get(0)).getClasses().get(0);
+ aClass2.cdoWriteLock().lock();
+ }
+ sleep(500);
+ assertEquals(true, aClass.cdoWriteLock().isLockedByOthers());
+
+ editor.close();
+ }
+
+ @Test
+ public void testAClassLockLocally() throws Exception
+ {
+ DawnSWTBotEMFEditor editor = DawnAcoreTestUtil.openNewAcoreEMFEditor("default.acore", getBot());
+ assertNotNull(editor);
+ SWTBotTree tree = editor.getSelectionPageTree();
+
+ selectFolder(tree.getAllItems(), "ACore Root", false);
+
+ editor.clickContextMenu(tree.widget, "AClass");
+ editor.save();
+
+ selectFolder(tree.getAllItems(), "AClass", false);
+
+ editor.clickContextMenu(tree.widget, "Lock");
+ sleep(500);
+
+ IDawnEditor dawnEditor = (IDawnEditor)editor.getReference().getEditor(false);
+ CDOResource resource = dawnEditor.getDawnEditorSupport().getView().getResource("/default.acore");
+ AClass aClass = ((ACoreRoot)resource.getContents().get(0)).getClasses().get(0);
+ assertEquals(true, aClass.cdoWriteLock().isLocked());
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource2 = transaction.getResource("/default.acore");
+ AClass aClass2 = ((ACoreRoot)resource2.getContents().get(0)).getClasses().get(0);
+ assertEquals(true, aClass2.cdoWriteLock().isLockedByOthers());
+
+ sleep(500);
+
+ editor.clickContextMenu(tree.widget, "Unlock");
+ sleep(500);
+
+ assertEquals(false, aClass.cdoWriteLock().isLocked());
+ assertEquals(false, aClass2.cdoWriteLock().isLockedByOthers());
+
+ editor.close();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/gmf/GMFLockingTest.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/gmf/GMFLockingTest.java
new file mode 100644
index 0000000000..9a2e9cf655
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/gmf/GMFLockingTest.java
@@ -0,0 +1,128 @@
+/*
+ * 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.tests.ui.gmf;
+
+import org.eclipse.emf.cdo.dawn.editors.IDawnEditor;
+import org.eclipse.emf.cdo.dawn.tests.AbstractDawnGEFTest;
+import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnAcoreTestUtil;
+import org.eclipse.emf.cdo.dawn.ui.DawnColorConstants;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+
+import org.eclipse.gef.EditPart;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.Node;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor;
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+import org.eclipse.ui.IEditorPart;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Martin Fluegge
+ */
+@CleanRepositoriesBefore
+@RunWith(SWTBotJunit4ClassRunner.class)
+public class GMFLockingTest extends AbstractDawnGEFTest
+{
+ @Test
+ public void testAClassLockRemotely() throws Exception
+ {
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", getBot());
+ assertNotNull(editor);
+
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", getBot(), editor);
+ editor.save();
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource2 = transaction.getResource("/default.acore_diagram");
+
+ Diagram diagram = (Diagram)resource2.getContents().get(0);
+
+ assertEquals(1, diagram.getChildren().size());
+
+ Node nodeA = (Node)diagram.getChildren().get(0);
+
+ CDOUtil.getCDOObject(nodeA).cdoWriteLock().lock();
+ }
+ sleep(500);
+
+ List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor);
+ SWTBotGefEditPart classBEditpart = aClassEditParts.get(0);
+
+ assertEquals(true, DawnAcoreTestUtil.showsLock(classBEditpart.part(), DawnColorConstants.COLOR_LOCKED_REMOTELY));
+ }
+
+ @Test
+ public void testAClassLockLocally() throws Exception
+ {
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", getBot());
+ assertNotNull(editor);
+
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", getBot(), editor);
+ editor.save();
+
+ List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor);
+ SWTBotGefEditPart classBEditpart = aClassEditParts.get(0);
+ EditPart part = classBEditpart.part();
+
+ List<Object> toBeLocked = new ArrayList<Object>();
+ toBeLocked.add(part);
+
+ IEditorPart editorPart = editor.getReference().getEditor(false);
+ ((IDawnEditor)editorPart).getDawnEditorSupport().lockObjects(toBeLocked);
+
+ assertEquals(true, DawnAcoreTestUtil.showsLock(part, DawnColorConstants.COLOR_LOCKED_LOCALLY));
+ }
+
+ @Test
+ public void testAClassUnlockRemotely() throws Exception
+ {
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreGMFEditor("default.acore_diagram", getBot());
+ assertNotNull(editor);
+
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", getBot(), editor);
+ editor.save();
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource2 = transaction.getResource("/default.acore_diagram");
+
+ Diagram diagram = (Diagram)resource2.getContents().get(0);
+
+ assertEquals(1, diagram.getChildren().size());
+
+ Node nodeA = (Node)diagram.getChildren().get(0);
+
+ CDOUtil.getCDOObject(nodeA).cdoWriteLock().lock();
+
+ sleep(500);
+
+ List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor);
+ SWTBotGefEditPart classBEditpart = aClassEditParts.get(0);
+
+ assertEquals(true, DawnAcoreTestUtil.showsLock(classBEditpart.part(), DawnColorConstants.COLOR_LOCKED_REMOTELY));
+
+ CDOUtil.getCDOObject(nodeA).cdoWriteLock().unlock();
+
+ assertEquals(true, DawnAcoreTestUtil.showsNoLock(classBEditpart.part()));
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/util/DawnAcoreTestUtil.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/util/DawnAcoreTestUtil.java
index 74a4697d2b..eec251bc78 100644
--- a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/util/DawnAcoreTestUtil.java
+++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/util/DawnAcoreTestUtil.java
@@ -21,7 +21,7 @@ import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AInterfaceEdit
import org.eclipse.emf.cdo.dawn.examples.acore.diagram.part.AcoreVisualIDRegistry;
import org.eclipse.emf.cdo.dawn.examples.acore.diagram.providers.AcoreElementTypes;
import org.eclipse.emf.cdo.dawn.examples.acore.diagram.providers.AcoreViewProvider;
-import org.eclipse.emf.cdo.dawn.gmf.appearance.DawnAppearancer;
+import org.eclipse.emf.cdo.dawn.ui.DawnColorConstants;
import org.eclipse.emf.cdo.dawn.ui.DawnEditorInput;
import org.eclipse.emf.cdo.dawn.ui.helper.EditorDescriptionHelper;
@@ -36,6 +36,7 @@ import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.gmf.runtime.notation.Edge;
import org.eclipse.gmf.runtime.notation.Node;
import org.eclipse.gmf.runtime.notation.datatype.RelativeBendpoint;
+import org.eclipse.swt.graphics.Color;
import org.eclipse.swtbot.eclipse.gef.finder.SWTGefBot;
import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart;
import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor;
@@ -276,7 +277,33 @@ public class DawnAcoreTestUtil
GraphicalEditPart e = (GraphicalEditPart)editPart;
IFigure figure = e.getFigure();
- return ((LineBorder)figure.getBorder()).getColor().equals(DawnAppearancer.COLOR_DELETE_CONFLICT);
+ return ((LineBorder)figure.getBorder()).getColor().equals(DawnColorConstants.COLOR_DELETE_CONFLICT);
+ }
+ return false;
+ }
+
+ public static Object showsLock(EditPart editPart, Color lockColor)
+ {
+ if (editPart instanceof AClassEditPart || editPart instanceof AInterfaceEditPart)
+ {
+ GraphicalEditPart e = (GraphicalEditPart)editPart;
+
+ IFigure figure = e.getFigure();
+ return ((LineBorder)figure.getBorder()).getColor().equals(lockColor);
+ }
+ return false;
+ }
+
+ public static Object showsNoLock(EditPart editPart)
+ {
+ if (editPart instanceof AClassEditPart || editPart instanceof AInterfaceEditPart)
+ {
+ GraphicalEditPart e = (GraphicalEditPart)editPart;
+
+ IFigure figure = e.getFigure();
+ Color color = ((LineBorder)figure.getBorder()).getColor();
+ return !(color.equals(DawnColorConstants.COLOR_LOCKED_REMOTELY) && color
+ .equals(DawnColorConstants.COLOR_LOCKED_LOCALLY));
}
return false;
}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/util/DawnEcoreTestUtil.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/util/DawnEcoreTestUtil.java
index dc07a0a6d8..4fd68fd53d 100644
--- a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/util/DawnEcoreTestUtil.java
+++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/util/DawnEcoreTestUtil.java
@@ -12,7 +12,7 @@ package org.eclipse.emf.cdo.dawn.tests.ui.util;
import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AClassEditPart;
import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AInterfaceEditPart;
-import org.eclipse.emf.cdo.dawn.gmf.appearance.DawnAppearancer;
+import org.eclipse.emf.cdo.dawn.ui.DawnColorConstants;
import org.eclipse.emf.cdo.dawn.ui.DawnEditorInput;
import org.eclipse.emf.cdo.dawn.ui.helper.EditorDescriptionHelper;
@@ -174,7 +174,7 @@ public class DawnEcoreTestUtil
GraphicalEditPart e = (GraphicalEditPart)editPart;
IFigure figure = e.getFigure();
- return ((LineBorder)figure.getBorder()).getColor().equals(DawnAppearancer.COLOR_DELETE_CONFLICT);
+ return ((LineBorder)figure.getBorder()).getColor().equals(DawnColorConstants.COLOR_DELETE_CONFLICT);
}
return false;
}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/util/DawnSWTBotEMFEditor.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/util/DawnSWTBotEMFEditor.java
index 6ed468e7ed..86f0a08983 100644
--- a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/util/DawnSWTBotEMFEditor.java
+++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/util/DawnSWTBotEMFEditor.java
@@ -45,7 +45,7 @@ public class DawnSWTBotEMFEditor extends SWTBotEditor
}
/**
- * return the tree auf the EMF editor
+ * return the tree of the EMF editor
*/
public SWTBotTree getSelectionPageTree()
{
@@ -251,7 +251,6 @@ public class DawnSWTBotEMFEditor extends SWTBotEditor
display.asyncExec(new Runnable()
{
-
public void run()
{
item.widget.setData(text);
diff --git a/plugins/org.eclipse.emf.cdo.dawn.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.dawn.ui/META-INF/MANIFEST.MF
index 0eb2f0d48d..8b8249a8c7 100644
--- a/plugins/org.eclipse.emf.cdo.dawn.ui/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.cdo.dawn.ui/META-INF/MANIFEST.MF
@@ -8,7 +8,8 @@ Require-Bundle: org.eclipse.ui;bundle-version="[3.4.0,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)",
org.eclipse.emf.cdo.ui;bundle-version="[4.0.0,5.0.0)",
org.eclipse.emf.cdo.dawn.util;bundle-version="[2.0.0,3.0.0)",
- org.eclipse.emf.cdo.dawn;bundle-version="[2.0.0,3.0.0)"
+ org.eclipse.emf.cdo.dawn;bundle-version="[2.0.0,3.0.0)",
+ org.eclipse.draw2d;bundle-version="[3.5.0,4.0.0)"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Vendor: %providerName
@@ -16,6 +17,7 @@ Bundle-Localization: plugin
Export-Package: org.eclipse.emf.cdo.dawn.internal.ui.bundle;version="2.0.0",
org.eclipse.emf.cdo.dawn.ui;version="2.0.0",
org.eclipse.emf.cdo.dawn.ui.composites;version="2.0.0",
+ org.eclipse.emf.cdo.dawn.ui.handlers;version="2.0.0";x-internal:=true,
org.eclipse.emf.cdo.dawn.ui.helper;version="2.0.0",
org.eclipse.emf.cdo.dawn.ui.messages;version="2.0.0",
org.eclipse.emf.cdo.dawn.ui.views;version="2.0.0",
diff --git a/plugins/org.eclipse.emf.cdo.dawn.ui/plugin.xml b/plugins/org.eclipse.emf.cdo.dawn.ui/plugin.xml
index f564fd3074..b60aab9f69 100644
--- a/plugins/org.eclipse.emf.cdo.dawn.ui/plugin.xml
+++ b/plugins/org.eclipse.emf.cdo.dawn.ui/plugin.xml
@@ -42,4 +42,84 @@
name="Dawn">
</category>
</extension>
+ <extension
+ point="org.eclipse.ui.commands">
+ <command
+ defaultHandler="org.eclipse.emf.cdo.dawn.ui.handlers.LockObjectsHandler"
+ id="org.eclipse.emf.cdo.dawn.ui.lockobjects"
+ name="Lock objects">
+ </command>
+ <command
+ defaultHandler="org.eclipse.emf.cdo.dawn.ui.handlers.UnLockObjectsHandler"
+ id="org.eclipse.emf.cdo.dawn.ui.unlockobjects"
+ name="Unlock objects">
+ </command>
+ </extension>
+ <extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ locationURI="popup:org.eclipse.ui.popup.any?after=additions">
+ <menu
+ label="Locking">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="activePart">
+ <instanceof
+ value="org.eclipse.emf.cdo.dawn.editors.IDawnEditor">
+ </instanceof>
+ </with>
+ </visibleWhen>
+ <command
+ commandId="org.eclipse.emf.cdo.dawn.ui.lockobjects"
+ label="Lock"
+ mnemonic="%contributions.view.refresh.mnemonic">
+ </command>
+ <command
+ commandId="org.eclipse.emf.cdo.dawn.ui.unlockobjects"
+ label="Unlock"
+ mnemonic="%contributions.view.refresh.mnemonic">
+ </command>
+ </menu>
+ </menuContribution>
+
+ </extension>
+ <extension
+ point="org.eclipse.ui.menus">
+ <menuContribution
+ locationURI="popup:org.eclipse.ui.popup.any?after=additions">
+ <menu
+ label="Conflict">
+ <visibleWhen
+ checkEnabled="false">
+ <with
+ variable="activePart">
+ <instanceof
+ value="org.eclipse.emf.cdo.dawn.editors.IDawnEditor">
+ </instanceof>
+ </with>
+ </visibleWhen>
+ <command
+ commandId="org.eclipse.emf.cdo.dawn.commands.solveconflict"
+ label="Solve Conflict"
+ mnemonic="%contributions.view.refresh.mnemonic">
+ </command>
+ </menu>
+ </menuContribution>
+
+ </extension>
+ <extension
+ point="org.eclipse.ui.commands">
+ <command
+ id="org.eclipse.emf.cdo.dawn.commands.solveconflict"
+ name="Solve Confilct">
+ </command>
+ </extension>
+ <extension
+ point="org.eclipse.ui.handlers">
+ <handler
+ class="org.eclipse.emf.cdo.dawn.ui.handlers.SolveConflictHandler"
+ commandId="org.eclipse.emf.cdo.dawn.commands.solveconflict">
+ </handler>
+ </extension>
</plugin>
diff --git a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/DawnColorConstants.java b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/DawnColorConstants.java
new file mode 100644
index 0000000000..bcffd7b11b
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/DawnColorConstants.java
@@ -0,0 +1,33 @@
+/*
+ * 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.ui;
+
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * @author Martin Fluegge
+ * @since 2.0
+ */
+public class DawnColorConstants
+{
+ public static final Color COLOR_NO_BORDER = new Color(null, 255, 255, 255);
+
+ public static final Color COLOR_LOCKED_REMOTELY = ColorConstants.yellow;
+
+ public static final Color COLOR_LOCKED_LOCALLY = ColorConstants.green;
+
+ public static final Color COLOR_DELETE_CONFLICT = new Color(null, 255, 0, 0);
+
+ public static final Color COLOR_CHANGE_CONFLICT = new Color(null, 0, 0, 255);
+
+ public static final Color COLOR_NO_CONFLICT = new Color(null, 255, 255, 255);
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/DawnLabelProvider.java b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/DawnLabelProvider.java
index 0f8218e2c1..228c56c8ca 100644
--- a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/DawnLabelProvider.java
+++ b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/DawnLabelProvider.java
@@ -11,11 +11,14 @@
package org.eclipse.emf.cdo.dawn.ui;
import org.eclipse.emf.cdo.ui.CDOLabelProvider;
+import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.emf.cdo.view.CDOView;
import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.graphics.Color;
/**
* @author Martin Fluegge
@@ -27,4 +30,21 @@ public class DawnLabelProvider extends CDOLabelProvider
{
super(adapterFactory, view, viewer);
}
+
+ @Override
+ public Color getForeground(Object object)
+ {
+ // makes sure that the object is adapted
+ Color foreground = super.getForeground(object);
+ if (CDOUtil.getCDOObject((EObject)object).cdoWriteLock().isLocked())
+ {
+ return DawnColorConstants.COLOR_LOCKED_LOCALLY;
+ }
+ else if (CDOUtil.getCDOObject((EObject)object).cdoWriteLock().isLockedByOthers())
+ {
+ return DawnColorConstants.COLOR_LOCKED_REMOTELY;
+ }
+ // Use default
+ return foreground;
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/handlers/LockObjectsHandler.java b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/handlers/LockObjectsHandler.java
new file mode 100644
index 0000000000..77eb9f342c
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/handlers/LockObjectsHandler.java
@@ -0,0 +1,32 @@
+/*
+ * 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:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.dawn.ui.handlers;
+
+import org.eclipse.emf.cdo.dawn.editors.IDawnEditor;
+import org.eclipse.emf.cdo.dawn.helper.DawnEditorHelper;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+
+/**
+ * @author Martin Fluegge
+ * @since 2.0
+ */
+public class LockObjectsHandler extends SelectionHandler
+{
+ public Object execute(ExecutionEvent event) throws ExecutionException
+ {
+ System.out.println("Lock");
+ ((IDawnEditor)DawnEditorHelper.getActiveEditor()).getDawnEditorSupport().lockObjects(getSelectedObjects(event));
+
+ return null;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/handlers/SelectionHandler.java b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/handlers/SelectionHandler.java
new file mode 100644
index 0000000000..286777b1a7
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/handlers/SelectionHandler.java
@@ -0,0 +1,45 @@
+/*
+ * 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.ui.handlers;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * @author Martin Fluegge
+ * @since 2.0
+ */
+public abstract class SelectionHandler extends AbstractHandler
+{
+ protected List<Object> getSelectedObjects(ExecutionEvent event)
+ {
+ List<Object> objects = new ArrayList<Object>();
+ ISelection selection = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getSelection();
+ if (selection != null & selection instanceof IStructuredSelection)
+ {
+ IStructuredSelection structuredSelection = (IStructuredSelection)selection;
+ for (@SuppressWarnings("unchecked")
+ Iterator<Object> iterator = structuredSelection.iterator(); iterator.hasNext();)
+ {
+ Object element = iterator.next();
+ objects.add(element);
+ }
+ }
+ return objects;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/handlers/SolveConflictHandler.java b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/handlers/SolveConflictHandler.java
index 6e7ed62273..351dcd76ac 100644
--- a/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/handlers/SolveConflictHandler.java
+++ b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/handlers/SolveConflictHandler.java
@@ -8,11 +8,11 @@
* Contributors:
* Eike Stepper - initial API and implementation
*/
-package org.eclipse.emf.cdo.dawn.handlers;
+package org.eclipse.emf.cdo.dawn.ui.handlers;
import org.eclipse.emf.cdo.dawn.editors.IDawnEditor;
import org.eclipse.emf.cdo.dawn.helper.DawnEditorHelper;
-import org.eclipse.emf.cdo.internal.dawn.bundle.OM;
+import org.eclipse.emf.cdo.dawn.internal.ui.bundle.OM;
import org.eclipse.net4j.util.om.trace.ContextTracer;
diff --git a/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/handlers/UnLockObjectsHandler.java b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/handlers/UnLockObjectsHandler.java
new file mode 100644
index 0000000000..34b0830208
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/handlers/UnLockObjectsHandler.java
@@ -0,0 +1,32 @@
+/*
+ * 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:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.dawn.ui.handlers;
+
+import org.eclipse.emf.cdo.dawn.editors.IDawnEditor;
+import org.eclipse.emf.cdo.dawn.helper.DawnEditorHelper;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+
+/**
+ * @author Martin Fluegge
+ * @since 2.0
+ */
+public class UnLockObjectsHandler extends SelectionHandler
+{
+ public Object execute(ExecutionEvent event) throws ExecutionException
+ {
+ System.out.println("Unlock");
+ ((IDawnEditor)DawnEditorHelper.getActiveEditor()).getDawnEditorSupport().unlockObjects(getSelectedObjects(event));
+
+ return null;
+ }
+}
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 17d5724285..744997fe05 100644
--- a/plugins/org.eclipse.emf.cdo.dawn/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.cdo.dawn/META-INF/MANIFEST.MF
@@ -21,12 +21,12 @@ Export-Package: org.eclipse.emf.cdo.dawn;version="2.0.0",
org.eclipse.emf.cdo.dawn.conflicts;version="2.0.0",
org.eclipse.emf.cdo.dawn.editors;version="2.0.0",
org.eclipse.emf.cdo.dawn.editors.impl;version="2.0.0",
- org.eclipse.emf.cdo.dawn.handlers;version="2.0.0";x-internal:=true,
org.eclipse.emf.cdo.dawn.helper;version="2.0.0",
org.eclipse.emf.cdo.dawn.notifications;version="2.0.0",
org.eclipse.emf.cdo.dawn.preferences;version="2.0.0",
org.eclipse.emf.cdo.dawn.resources;version="2.0.0",
org.eclipse.emf.cdo.dawn.resources.impl;version="2.0.0",
+ org.eclipse.emf.cdo.dawn.spi;version="2.0.0",
org.eclipse.emf.cdo.dawn.transaction;version="2.0.0",
org.eclipse.emf.cdo.internal.dawn.bundle;version="2.0.0"
Bundle-Vendor: %providerName
diff --git a/plugins/org.eclipse.emf.cdo.dawn/plugin.xml b/plugins/org.eclipse.emf.cdo.dawn/plugin.xml
index 9e55302dd1..2195a87505 100644
--- a/plugins/org.eclipse.emf.cdo.dawn/plugin.xml
+++ b/plugins/org.eclipse.emf.cdo.dawn/plugin.xml
@@ -111,42 +111,4 @@
name="UnlockObjects">
</command>
</extension>-->
- <extension
- point="org.eclipse.ui.menus">
- <menuContribution
- locationURI="popup:org.eclipse.ui.popup.any?after=additions">
- <menu
- label="Conflict">
- <visibleWhen
- checkEnabled="false">
- <with
- variable="activePart">
- <instanceof
- value="org.eclipse.emf.cdo.dawn.editors.IDawnEditor">
- </instanceof>
- </with>
- </visibleWhen>
- <command
- commandId="org.eclipse.emf.cdo.dawn.commands.solveconflict"
- label="Solve Conflict"
- mnemonic="%contributions.view.refresh.mnemonic">
- </command>
- </menu>
- </menuContribution>
-
- </extension>
- <extension
- point="org.eclipse.ui.commands">
- <command
- id="org.eclipse.emf.cdo.dawn.commands.solveconflict"
- name="Solve Confilct">
- </command>
- </extension>
- <extension
- point="org.eclipse.ui.handlers">
- <handler
- class="org.eclipse.emf.cdo.dawn.handlers.SolveConflictHandler"
- commandId="org.eclipse.emf.cdo.dawn.commands.solveconflict">
- </handler>
- </extension>
</plugin>
diff --git a/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/editors/IDawnEditor.java b/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/editors/IDawnEditor.java
index 76de5af52f..79f230e322 100644
--- a/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/editors/IDawnEditor.java
+++ b/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/editors/IDawnEditor.java
@@ -10,23 +10,14 @@
*/
package org.eclipse.emf.cdo.dawn.editors;
-import org.eclipse.emf.cdo.view.CDOView;
+import org.eclipse.emf.cdo.dawn.spi.IDawnUIElement;
import org.eclipse.ui.IEditorPart;
/**
* @author Martin Fluegge
*/
-public interface IDawnEditor extends IEditorPart
+public interface IDawnEditor extends IDawnUIElement, IEditorPart
{
public String getContributorID();
-
- public CDOView getView();
-
- public void setDirty();
-
- /**
- * @since 1.0
- */
- public IDawnEditorSupport getDawnEditorSupport();
}
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
index b8bf67f483..1cecf69c95 100644
--- 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
@@ -10,27 +10,12 @@
*/
package org.eclipse.emf.cdo.dawn.editors;
-import org.eclipse.emf.cdo.view.CDOView;
+import org.eclipse.emf.cdo.dawn.spi.IDawnEditingSupport;
/**
* @author Martin Fluegge
*/
-public interface IDawnEditorSupport
+public interface IDawnEditorSupport extends IDawnEditingSupport
{
- public void setDirty(boolean dirty);
- public boolean isDirty();
-
- public CDOView getView();
-
- public void setView(CDOView view);
-
- public void close();
-
- public void registerListeners();
-
- /**
- * @since 1.0
- */
- public void rollback();
}
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
index 29f4574f4b..88dce2bc11 100644
--- 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
@@ -12,9 +12,14 @@ 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.dawn.notifications.BasicDawnListener;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.transaction.CDOTransactionHandlerBase;
+import org.eclipse.emf.cdo.view.CDOAdapterPolicy;
import org.eclipse.emf.cdo.view.CDOView;
+import java.util.List;
+
/**
* @author Martin Fluegge
*/
@@ -57,6 +62,72 @@ public abstract class DawnAbstractEditorSupport implements IDawnEditorSupport
}
/**
+ * This method registeres the listeners for the DawnEditorSupport. Concrete implementaions can influence the
+ * registered listeneres by implementing the methods
+ * <ul>
+ * <li>getBasicHandler()</li>
+ * <li>getLockingHandler()</li>
+ * </ul>
+ * If one of these methods returns null the specific handler will not be registered and activated.
+ *
+ * @see #getBasicHandler()
+ * @see #getLockingHandler()
+ * @since 2.0
+ */
+ public void registerListeners()
+ {
+ BasicDawnListener listener = getBasicHandler();
+ CDOView view = getView();
+
+ if (listener != null)
+ {
+ view.addListener(listener);
+ }
+
+ BasicDawnListener lockingHandler = getLockingHandler();
+ if (lockingHandler != null)
+ {
+ view.addListener(lockingHandler);
+ view.options().setLockNotificationEnabled(true);
+ }
+
+ if (view instanceof CDOTransaction)
+ {
+ CDOTransaction transaction = (CDOTransaction)view;
+ CDOTransactionHandlerBase transactionHandler = getTransactionHandler();
+ if (transactionHandler != null)
+ {
+ transaction.addTransactionHandler(transactionHandler);
+ }
+ transaction.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.CDO);
+ }
+ }
+
+ /**
+ * Subclasses must implement this method to deliver a IDawnListener that implements the behavior for Session
+ * invalidations. If the method returns null, the handler will not be registered.
+ *
+ * @since 2.0
+ */
+ protected abstract BasicDawnListener getBasicHandler();
+
+ /**
+ * Subclasses must implement this method to deliver a IDawnListener that implements the behavior for remote locking
+ * notifications. If the method returns null, the handler will not be registered.
+ *
+ * @since 2.0
+ */
+ protected abstract BasicDawnListener getLockingHandler();
+
+ /**
+ * Subclasses must implement this method to deliver a CDOTransactionHandlerBase that implements the behavior for
+ * remote changes notifications. If the method returns null, the handler will not be registered.
+ *
+ * @since 2.0
+ */
+ protected abstract CDOTransactionHandlerBase getTransactionHandler();
+
+ /**
* @since 1.0
*/
public void rollback()
@@ -68,4 +139,26 @@ public abstract class DawnAbstractEditorSupport implements IDawnEditorSupport
((CDOTransaction)view).rollback();
}
}
+
+ /**
+ * @since 2.0
+ */
+ public void lockObjects(List<Object> objectsToBeLocked)
+ {
+ for (Object objectToBeLocked : objectsToBeLocked)
+ {
+ lockObject(objectToBeLocked);
+ }
+ }
+
+ /**
+ * @since 2.0
+ */
+ public void unlockObjects(List<Object> objectsToBeLocked)
+ {
+ for (Object objectToBeUnlocked : objectsToBeLocked)
+ {
+ unlockObject(objectToBeUnlocked);
+ }
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/notifications/BasicDawnListener.java b/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/notifications/BasicDawnListener.java
index d6127aeaac..50b0581d8c 100644
--- a/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/notifications/BasicDawnListener.java
+++ b/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/notifications/BasicDawnListener.java
@@ -10,25 +10,17 @@
*/
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.editors.IDawnEditor;
-import org.eclipse.emf.cdo.internal.dawn.bundle.OM;
-import org.eclipse.emf.cdo.transaction.CDOCommitContext;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.transaction.CDOTransactionConflictEvent;
import org.eclipse.emf.cdo.view.CDOViewInvalidationEvent;
import org.eclipse.net4j.util.event.IEvent;
-import org.eclipse.net4j.util.om.trace.ContextTracer;
/**
* @author Martin Fluegge
*/
public abstract class BasicDawnListener implements IDawnListener// implements IListener
{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, BasicDawnListener.class);
-
protected IDawnEditor editor;
/**
@@ -64,72 +56,9 @@ public abstract class BasicDawnListener implements IDawnListener// implements IL
{
handleTransactionConflictEvent((CDOTransactionConflictEvent)event);
}
- }
-
- /**
- * @since 1.0
- */
- public void attachingObject(CDOTransaction transaction, CDOObject object)
- {
- if (TRACER.isEnabled())
+ else
{
- TRACER.format("attachingObject {0}", object); //$NON-NLS-1$
+ handleEvent(event);
}
- editor.setDirty();
- }
-
- /**
- * @since 1.0
- */
- public void detachingObject(CDOTransaction transaction, CDOObject object)
- {
- if (TRACER.isEnabled())
- {
- TRACER.format("detachingObject {0}", object); //$NON-NLS-1$
- }
-
- editor.setDirty();
- }
-
- /**
- * @since 1.0
- */
- public void modifyingObject(CDOTransaction transaction, CDOObject object, CDOFeatureDelta featureDelta)
- { // This method can be overwritten be subclasses
- }
-
- /**
- * @since 1.0
- */
- public void committingTransaction(CDOTransaction transaction, CDOCommitContext commitContext)
- { // This method can be overwritten be subclasses
- }
-
- /**
- * @since 1.0
- */
- public void committedTransaction(CDOTransaction transaction, CDOCommitContext commitContext)
- { // This method can be overwritten be subclasses
- }
-
- /**
- * @since 1.0
- */
- public void rolledBackTransaction(CDOTransaction transaction)
- { // This method can be overwritten be subclasses
- }
-
- /**
- * @since 1.0
- */
- public void handleViewInvalidationEvent(CDOViewInvalidationEvent event)
- { // This method can be overwritten be subclasses
- }
-
- /**
- * @since 1.0
- */
- public void handleTransactionConflictEvent(CDOTransactionConflictEvent event)
- { // This method can be overwritten be subclasses
}
}
diff --git a/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/notifications/BasicDawnTransactionHandler.java b/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/notifications/BasicDawnTransactionHandler.java
new file mode 100644
index 0000000000..9ce08ce567
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/notifications/BasicDawnTransactionHandler.java
@@ -0,0 +1,84 @@
+/*
+ * 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.notifications;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
+import org.eclipse.emf.cdo.dawn.editors.IDawnEditor;
+import org.eclipse.emf.cdo.internal.dawn.bundle.OM;
+import org.eclipse.emf.cdo.transaction.CDOCommitContext;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.transaction.CDOTransactionConflictEvent;
+import org.eclipse.emf.cdo.view.CDOViewInvalidationEvent;
+
+import org.eclipse.net4j.util.event.IEvent;
+import org.eclipse.net4j.util.om.trace.ContextTracer;
+
+/**
+ * @author Martin Fluegge
+ * @since 2.0
+ */
+public class BasicDawnTransactionHandler extends BasicDawnListener implements IDawnTransactionHandler
+{
+ private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, BasicDawnTransactionHandler.class);
+
+ public BasicDawnTransactionHandler(IDawnEditor editor)
+ {
+ super(editor);
+ }
+
+ public void attachingObject(CDOTransaction transaction, CDOObject object)
+ {
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("attachingObject {0}", object); //$NON-NLS-1$
+ }
+ editor.setDirty();
+ }
+
+ public void detachingObject(CDOTransaction transaction, CDOObject object)
+ {
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("detachingObject {0}", object); //$NON-NLS-1$
+ }
+
+ editor.setDirty();
+ }
+
+ public void modifyingObject(CDOTransaction transaction, CDOObject object, CDOFeatureDelta featureDelta)
+ { // This method can be overwritten be subclasses
+ }
+
+ public void committingTransaction(CDOTransaction transaction, CDOCommitContext commitContext)
+ { // This method can be overwritten be subclasses
+ }
+
+ public void committedTransaction(CDOTransaction transaction, CDOCommitContext commitContext)
+ { // This method can be overwritten be subclasses
+ }
+
+ public void rolledBackTransaction(CDOTransaction transaction)
+ { // This method can be overwritten be subclasses
+ }
+
+ public void handleViewInvalidationEvent(CDOViewInvalidationEvent event)
+ { // This method can be overwritten be subclasses
+ }
+
+ public void handleTransactionConflictEvent(CDOTransactionConflictEvent event)
+ { // This method can be overwritten be subclasses
+ }
+
+ public void handleEvent(IEvent event)
+ {
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/notifications/IDawnListener.java b/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/notifications/IDawnListener.java
index 4f0eba4760..febf0ca633 100644
--- a/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/notifications/IDawnListener.java
+++ b/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/notifications/IDawnListener.java
@@ -11,18 +11,23 @@
package org.eclipse.emf.cdo.dawn.notifications;
import org.eclipse.emf.cdo.transaction.CDOTransactionConflictEvent;
-import org.eclipse.emf.cdo.transaction.CDOTransactionHandler;
import org.eclipse.emf.cdo.view.CDOViewInvalidationEvent;
+import org.eclipse.net4j.util.event.IEvent;
import org.eclipse.net4j.util.event.IListener;
/**
* @author Martin Fluegge
* @since 1.0
*/
-public interface IDawnListener extends CDOTransactionHandler, IListener
+public interface IDawnListener extends IListener
{
public void handleViewInvalidationEvent(CDOViewInvalidationEvent event);
public void handleTransactionConflictEvent(CDOTransactionConflictEvent event);
+
+ /**
+ * @since 2.0
+ */
+ public void handleEvent(IEvent event);
}
diff --git a/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/notifications/IDawnTransactionHandler.java b/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/notifications/IDawnTransactionHandler.java
new file mode 100644
index 0000000000..b641e4038b
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/notifications/IDawnTransactionHandler.java
@@ -0,0 +1,21 @@
+/*
+ * 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.notifications;
+
+import org.eclipse.emf.cdo.transaction.CDOTransactionHandler;
+
+/**
+ * @author Martin Fluegge
+ * @since 2.0
+ */
+public interface IDawnTransactionHandler extends CDOTransactionHandler
+{
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/spi/IDawnEditingSupport.java b/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/spi/IDawnEditingSupport.java
new file mode 100644
index 0000000000..84f5a1441b
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/spi/IDawnEditingSupport.java
@@ -0,0 +1,99 @@
+/*
+ * 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.spi;
+
+import org.eclipse.emf.cdo.view.CDOView;
+
+import java.util.List;
+
+/**
+ * The IDawnEditingSupport is the direct connection the the Dawn Runtime. Service Providers must implement this
+ * interface to react on repository changes or local data manipulation. For implementation example @see
+ * org.eclipse.emf.cdo.dawn.gmf.editors.impl.DawnGMFEditorSupport.
+ *
+ * @author Martin Fluegge
+ * @since 2.0
+ */
+public interface IDawnEditingSupport
+{
+ /**
+ * Sets the element dirty. Implementations must ensure that all necessary operations a made to represent a dirty
+ * state. E.g. display the state in the user interface.
+ */
+ public void setDirty(boolean dirty);
+
+ /**
+ * Returns the dirty state of the UI element.
+ *
+ * @return true if the specific parts of the model that should be reflected as dirty to the UI are dirty, else
+ * otherwise.
+ */
+ public boolean isDirty();
+
+ /**
+ * Returns the CDO view that is responsible for the data represented be the IDawnEditingSupport.
+ */
+ public CDOView getView();
+
+ /**
+ * Sets the CDO view that is responsible for the data represented be the IDawnEditingSupport.
+ */
+ public void setView(CDOView view);
+
+ /**
+ * Handles all actions that must be executed when the UI element ist closed. E.g. close the related view.
+ */
+ public void close();
+
+ /**
+ * Registers the default listeners which are used to interact with the repository and the user interface.
+ */
+ public void registerListeners();
+
+ /**
+ * Implementations must process all operations that are need to provide a clean rollback. This includes the rollback
+ * on the repository site and the refreshing of the user interface.
+ *
+ * @since 1.0
+ */
+ public void rollback();
+
+ /**
+ * Refreshes the internal components of the IDawnEditor
+ *
+ * @since 2.0
+ */
+ public void refresh();
+
+ /**
+ * Locks the objects
+ *
+ * @since 2.0
+ */
+ public void lockObjects(List<Object> objectsToBeLocked);
+
+ /**
+ * @since 2.0
+ */
+ public void lockObject(Object objectToBeLocked);
+
+ /**
+ * Unlocks the objects
+ *
+ * @since 2.0
+ */
+ public void unlockObjects(List<Object> objectsToBeLocked);
+
+ /**
+ * @since 2.0
+ */
+ public void unlockObject(Object objectToBeUnlocked);
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/spi/IDawnUIElement.java b/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/spi/IDawnUIElement.java
new file mode 100644
index 0000000000..78e481f8fd
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/spi/IDawnUIElement.java
@@ -0,0 +1,27 @@
+/*
+ * 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.spi;
+
+import org.eclipse.emf.cdo.dawn.editors.IDawnEditorSupport;
+import org.eclipse.emf.cdo.view.CDOView;
+
+/**
+ * @author Martin Fluegge
+ * @since 2.0
+ */
+public interface IDawnUIElement
+{
+ public CDOView getView();
+
+ public void setDirty();
+
+ public IDawnEditorSupport getDawnEditorSupport();
+}

Back to the top