From 4e7428cad8fb510b7b1dea2a6bf46105457f76cd Mon Sep 17 00:00:00 2001
From: Martin Fluegge
Date: Sun, 25 Sep 2011 10:07:47 +0000
Subject: [319486] [Dawn] Implement locking mechanism for extended editors
https://bugs.eclipse.org/bugs/show_bug.cgi?id=319486
---
.../META-INF/MANIFEST.MF | 4 +-
plugins/org.eclipse.emf.cdo.dawn.ui/plugin.xml | 80 ++++++++++++++++++++++
.../emf/cdo/dawn/ui/DawnColorConstants.java | 33 +++++++++
.../eclipse/emf/cdo/dawn/ui/DawnLabelProvider.java | 20 ++++++
.../cdo/dawn/ui/handlers/LockObjectsHandler.java | 32 +++++++++
.../emf/cdo/dawn/ui/handlers/SelectionHandler.java | 45 ++++++++++++
.../cdo/dawn/ui/handlers/SolveConflictHandler.java | 60 ++++++++++++++++
.../cdo/dawn/ui/handlers/UnLockObjectsHandler.java | 32 +++++++++
8 files changed, 305 insertions(+), 1 deletion(-)
create mode 100644 plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/DawnColorConstants.java
create mode 100644 plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/handlers/LockObjectsHandler.java
create mode 100644 plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/handlers/SelectionHandler.java
create mode 100644 plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/handlers/SolveConflictHandler.java
create mode 100644 plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/handlers/UnLockObjectsHandler.java
(limited to 'plugins/org.eclipse.emf.cdo.dawn.ui')
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">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
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