Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Fluegge2011-09-25 10:07:47 +0000
committerMartin Fluegge2011-09-25 10:07:47 +0000
commit4e7428cad8fb510b7b1dea2a6bf46105457f76cd (patch)
tree01107f8b353c9f092c711a7a95385e47834b61c1 /plugins/org.eclipse.emf.cdo.dawn.ui
parent53f0bebdc539db62a911cc27dff34cd49e135ee2 (diff)
downloadcdo-4e7428cad8fb510b7b1dea2a6bf46105457f76cd.tar.gz
cdo-4e7428cad8fb510b7b1dea2a6bf46105457f76cd.tar.xz
cdo-4e7428cad8fb510b7b1dea2a6bf46105457f76cd.zip
[319486] [Dawn] Implement locking mechanism for extended editors
https://bugs.eclipse.org/bugs/show_bug.cgi?id=319486
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.dawn.ui')
-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.java60
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/handlers/UnLockObjectsHandler.java32
8 files changed, 305 insertions, 1 deletions
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.ui/src/org/eclipse/emf/cdo/dawn/ui/handlers/SolveConflictHandler.java b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/handlers/SolveConflictHandler.java
new file mode 100644
index 0000000000..351dcd76ac
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.ui/src/org/eclipse/emf/cdo/dawn/ui/handlers/SolveConflictHandler.java
@@ -0,0 +1,60 @@
+/*
+ * 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.emf.cdo.dawn.internal.ui.bundle.OM;
+
+import org.eclipse.net4j.util.om.trace.ContextTracer;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.ui.IEditorPart;
+
+/**
+ * @author Martin Fluegge
+ */
+public class SolveConflictHandler extends AbstractHandler
+{
+ private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, SolveConflictHandler.class);
+
+ public Object execute(ExecutionEvent event) throws ExecutionException
+ {
+ IEditorPart activeEditor = DawnEditorHelper.getActiveEditor();
+
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Start solving conflicts for {0}", activeEditor); //$NON-NLS-1$
+ }
+
+ if (activeEditor instanceof IDawnEditor)
+ {
+ MessageDialog dialog = new MessageDialog(DawnEditorHelper.getActiveShell(), "Conflict", null,
+ "There are conflicts in your diagram. Would you like to rollback your current transaction?",
+ MessageDialog.QUESTION, new String[] { "yes", "no", "Cancel" }, 1);
+
+ switch (dialog.open())
+ {
+ case 0: // yes
+ ((IDawnEditor)activeEditor).getDawnEditorSupport().rollback();
+ break;
+ case 1: // no
+ break;
+ default: // cancel
+ break;
+ }
+ }
+ return null;
+ }
+}
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;
+ }
+}

Back to the top