Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/org.eclipse.emf.cdo.ui.compare/plugin.xml8
-rw-r--r--plugins/org.eclipse.emf.cdo.ui.compare/src/org/eclipse/emf/cdo/ui/compare/CDOCompareEditorUtil.java36
-rw-r--r--plugins/org.eclipse.emf.cdo.ui.compare/src/org/eclipse/emf/cdo/ui/internal/compare/AbstractAction.java101
-rw-r--r--plugins/org.eclipse.emf.cdo.ui.compare/src/org/eclipse/emf/cdo/ui/internal/compare/CompareWithEachOtherAction.java40
-rw-r--r--plugins/org.eclipse.emf.cdo.ui.compare/src/org/eclipse/emf/cdo/ui/internal/compare/CompareWithPreviousVersionAction.java57
-rw-r--r--plugins/org.eclipse.emf.cdo.ui.compare/src/org/eclipse/emf/cdo/ui/internal/compare/MergeAction.java47
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/widgets/CommitHistoryComposite.java2
7 files changed, 195 insertions, 96 deletions
diff --git a/plugins/org.eclipse.emf.cdo.ui.compare/plugin.xml b/plugins/org.eclipse.emf.cdo.ui.compare/plugin.xml
index bdb503dd73..8d63162bc7 100644
--- a/plugins/org.eclipse.emf.cdo.ui.compare/plugin.xml
+++ b/plugins/org.eclipse.emf.cdo.ui.compare/plugin.xml
@@ -43,6 +43,14 @@
id="org.eclipse.emf.cdo.ui.compare.contribution2"
objectClass="org.eclipse.emf.cdo.common.commit.CDOCommitInfo">
<action
+ class="org.eclipse.emf.cdo.ui.internal.compare.CompareWithEachOtherAction"
+ enablesFor="2"
+ id="org.eclipse.emf.cdo.ui.compare.CompareWithEachOtherAction"
+ label="Compare With Each Other..."
+ menubarPath="additions"
+ style="push">
+ </action>
+ <action
class="org.eclipse.emf.cdo.ui.internal.compare.CompareWithPreviousVersionAction"
enablesFor="1"
id="org.eclipse.emf.cdo.ui.compare.CompareWithPreviousVersionAction"
diff --git a/plugins/org.eclipse.emf.cdo.ui.compare/src/org/eclipse/emf/cdo/ui/compare/CDOCompareEditorUtil.java b/plugins/org.eclipse.emf.cdo.ui.compare/src/org/eclipse/emf/cdo/ui/compare/CDOCompareEditorUtil.java
index b7959a44e8..4b8a19e3bb 100644
--- a/plugins/org.eclipse.emf.cdo.ui.compare/src/org/eclipse/emf/cdo/ui/compare/CDOCompareEditorUtil.java
+++ b/plugins/org.eclipse.emf.cdo.ui.compare/src/org/eclipse/emf/cdo/ui/compare/CDOCompareEditorUtil.java
@@ -40,25 +40,15 @@ import org.eclipse.compare.CompareUI;
*/
public class CDOCompareEditorUtil
{
- public static boolean openDialog(CDOCommitInfo commitInfo)
+ public static boolean openDialog(CDOSession session, CDOBranchPoint leftPoint, CDOBranchPoint rightPoint)
{
- long previousTimeStamp = commitInfo.getPreviousTimeStamp();
- if (previousTimeStamp == CDOBranchPoint.UNSPECIFIED_DATE)
- {
- return false;
- }
-
- CDORepositoryInfo repositoryInfo = (CDORepositoryInfo)commitInfo.getCommitInfoManager().getRepository();
- CDOSession session = repositoryInfo.getSession();
- CDOBranchPoint previous = CDOBranchUtil.normalizeBranchPoint(commitInfo.getBranch(), previousTimeStamp);
-
CDOView leftView = null;
CDOView rightView = null;
try
{
- leftView = session.openView(commitInfo);
- rightView = session.openView(previous);
+ leftView = session.openView(leftPoint);
+ rightView = session.openView(rightPoint);
return openDialog(leftView, rightView, null);
}
@@ -69,6 +59,26 @@ public class CDOCompareEditorUtil
}
}
+ public static boolean openDialog(CDOCommitInfo leftCommitInfo, CDOBranchPoint rightPoint)
+ {
+ CDORepositoryInfo repositoryInfo = (CDORepositoryInfo)leftCommitInfo.getCommitInfoManager().getRepository();
+ CDOSession session = repositoryInfo.getSession();
+
+ return openDialog(session, leftCommitInfo, rightPoint);
+ }
+
+ public static boolean openDialog(CDOCommitInfo commitInfo)
+ {
+ long previousTimeStamp = commitInfo.getPreviousTimeStamp();
+ if (previousTimeStamp == CDOBranchPoint.UNSPECIFIED_DATE)
+ {
+ return false;
+ }
+
+ CDOBranchPoint previous = CDOBranchUtil.normalizeBranchPoint(commitInfo.getBranch(), previousTimeStamp);
+ return openDialog(commitInfo, previous);
+ }
+
public static boolean openDialog(CDOView leftView, CDOView rightView, CDOView[] originView)
{
Comparison comparison = CDOCompareUtil.compare(leftView, rightView, originView);
diff --git a/plugins/org.eclipse.emf.cdo.ui.compare/src/org/eclipse/emf/cdo/ui/internal/compare/AbstractAction.java b/plugins/org.eclipse.emf.cdo.ui.compare/src/org/eclipse/emf/cdo/ui/internal/compare/AbstractAction.java
new file mode 100644
index 0000000000..1a6f6332ab
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.ui.compare/src/org/eclipse/emf/cdo/ui/internal/compare/AbstractAction.java
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2004 - 2012 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.ui.internal.compare;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class AbstractAction<TARGET> implements IObjectActionDelegate
+{
+ private final Class<TARGET> targetClass;
+
+ private IWorkbenchPart targetPart;
+
+ private ISelection selection;
+
+ public AbstractAction(Class<TARGET> targetClass)
+ {
+ this.targetClass = targetClass;
+ }
+
+ public IWorkbenchPart getTargetPart()
+ {
+ return targetPart;
+ }
+
+ public void setActivePart(IAction action, IWorkbenchPart targetPart)
+ {
+ this.targetPart = targetPart;
+ }
+
+ public void selectionChanged(IAction action, ISelection selection)
+ {
+ this.selection = selection;
+ }
+
+ public void run(IAction action)
+ {
+ if (selection instanceof IStructuredSelection)
+ {
+ IStructuredSelection ssel = (IStructuredSelection)selection;
+ List<TARGET> targets = new ArrayList<TARGET>();
+
+ @SuppressWarnings("unchecked")
+ Iterator<Object> iterator = ssel.iterator();
+
+ while (iterator.hasNext())
+ {
+ Object element = iterator.next();
+ TARGET target = getAdapter(element, targetClass);
+ if (target != null)
+ {
+ targets.add(target);
+ }
+ }
+
+ run(action, targets);
+ }
+ }
+
+ protected abstract void run(IAction action, List<TARGET> targets);
+
+ @SuppressWarnings("unchecked")
+ public static <T> T getAdapter(Object adaptable, Class<T> c)
+ {
+ if (c.isInstance(adaptable))
+ {
+ return (T)adaptable;
+ }
+
+ if (adaptable instanceof IAdaptable)
+ {
+ IAdaptable a = (IAdaptable)adaptable;
+ Object adapter = a.getAdapter(c);
+ if (c.isInstance(adapter))
+ {
+ return (T)adapter;
+ }
+ }
+
+ return null;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.ui.compare/src/org/eclipse/emf/cdo/ui/internal/compare/CompareWithEachOtherAction.java b/plugins/org.eclipse.emf.cdo.ui.compare/src/org/eclipse/emf/cdo/ui/internal/compare/CompareWithEachOtherAction.java
new file mode 100644
index 0000000000..6426c3dc69
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.ui.compare/src/org/eclipse/emf/cdo/ui/internal/compare/CompareWithEachOtherAction.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2004 - 2012 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.ui.internal.compare;
+
+import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
+import org.eclipse.emf.cdo.ui.compare.CDOCompareEditorUtil;
+
+import org.eclipse.jface.action.IAction;
+
+import java.util.List;
+
+/**
+ * @author Eike Stepper
+ */
+public class CompareWithEachOtherAction extends AbstractAction<CDOCommitInfo>
+{
+ public CompareWithEachOtherAction()
+ {
+ super(CDOCommitInfo.class);
+ }
+
+ @Override
+ protected void run(IAction action, List<CDOCommitInfo> targets)
+ {
+ if (targets.size() == 2)
+ {
+ CDOCommitInfo commitInfo0 = targets.get(0);
+ CDOCommitInfo commitInfo1 = targets.get(1);
+ CDOCompareEditorUtil.openDialog(commitInfo0, commitInfo1);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.ui.compare/src/org/eclipse/emf/cdo/ui/internal/compare/CompareWithPreviousVersionAction.java b/plugins/org.eclipse.emf.cdo.ui.compare/src/org/eclipse/emf/cdo/ui/internal/compare/CompareWithPreviousVersionAction.java
index 055e01a9d0..35dac9b1cc 100644
--- a/plugins/org.eclipse.emf.cdo.ui.compare/src/org/eclipse/emf/cdo/ui/internal/compare/CompareWithPreviousVersionAction.java
+++ b/plugins/org.eclipse.emf.cdo.ui.compare/src/org/eclipse/emf/cdo/ui/internal/compare/CompareWithPreviousVersionAction.java
@@ -13,68 +13,27 @@ package org.eclipse.emf.cdo.ui.internal.compare;
import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
import org.eclipse.emf.cdo.ui.compare.CDOCompareEditorUtil;
-import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IObjectActionDelegate;
-import org.eclipse.ui.IWorkbenchPart;
+
+import java.util.List;
/**
* @author Eike Stepper
*/
-public class CompareWithPreviousVersionAction implements IObjectActionDelegate
+public class CompareWithPreviousVersionAction extends AbstractAction<CDOCommitInfo>
{
- private CDOCommitInfo commitInfo;
-
public CompareWithPreviousVersionAction()
{
+ super(CDOCommitInfo.class);
}
- public void setActivePart(IAction action, IWorkbenchPart targetPart)
- {
- // Do nothing
- }
-
- public void selectionChanged(IAction action, ISelection selection)
- {
- commitInfo = null;
- if (selection instanceof IStructuredSelection)
- {
- Object selectedElement = ((IStructuredSelection)selection).getFirstElement();
- if (selectedElement instanceof CDOCommitInfo)
- {
- commitInfo = getAdapter(selectedElement, CDOCommitInfo.class);
- }
- }
- }
-
- public void run(IAction action)
+ @Override
+ protected void run(IAction action, List<CDOCommitInfo> targets)
{
- if (commitInfo != null)
+ if (targets.size() == 1)
{
+ CDOCommitInfo commitInfo = targets.get(0);
CDOCompareEditorUtil.openDialog(commitInfo);
}
}
-
- @SuppressWarnings("unchecked")
- public static <T> T getAdapter(Object adaptable, Class<T> c)
- {
- if (c.isInstance(adaptable))
- {
- return (T)adaptable;
- }
-
- if (adaptable instanceof IAdaptable)
- {
- IAdaptable a = (IAdaptable)adaptable;
- Object adapter = a.getAdapter(c);
- if (c.isInstance(adapter))
- {
- return (T)adapter;
- }
- }
-
- return null;
- }
}
diff --git a/plugins/org.eclipse.emf.cdo.ui.compare/src/org/eclipse/emf/cdo/ui/internal/compare/MergeAction.java b/plugins/org.eclipse.emf.cdo.ui.compare/src/org/eclipse/emf/cdo/ui/internal/compare/MergeAction.java
index 104761f195..68257fc258 100644
--- a/plugins/org.eclipse.emf.cdo.ui.compare/src/org/eclipse/emf/cdo/ui/internal/compare/MergeAction.java
+++ b/plugins/org.eclipse.emf.cdo.ui.compare/src/org/eclipse/emf/cdo/ui/internal/compare/MergeAction.java
@@ -20,54 +20,36 @@ import org.eclipse.emf.cdo.view.CDOView;
import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IObjectActionDelegate;
-import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchPage;
+
+import java.util.List;
/**
* @author Eike Stepper
*/
-public abstract class MergeAction implements IObjectActionDelegate
+public abstract class MergeAction extends AbstractAction<CDOTransaction>
{
private final boolean allowTimeStamp;
- private IWorkbenchPart targetPart;
-
- private CDOTransaction leftView;
-
public MergeAction(boolean allowTimeStamp)
{
+ super(CDOTransaction.class);
this.allowTimeStamp = allowTimeStamp;
}
- public void setActivePart(IAction action, IWorkbenchPart targetPart)
- {
- this.targetPart = targetPart;
- }
-
- public void selectionChanged(IAction action, ISelection selection)
+ @Override
+ protected void run(IAction action, List<CDOTransaction> targets)
{
- leftView = null;
- if (selection instanceof IStructuredSelection)
+ if (targets.size() == 1)
{
- Object selectedElement = ((IStructuredSelection)selection).getFirstElement();
- if (selectedElement instanceof CDOTransaction)
- {
- leftView = (CDOTransaction)selectedElement;
- }
- }
- }
+ IWorkbenchPage page = getTargetPart().getSite().getPage();
+ CDOTransaction leftView = targets.get(0);
+ CDOSession session = leftView.getSession();
- public void run(IAction action)
- {
- if (leftView != null)
- {
- SelectBranchPointDialog dialog = new SelectBranchPointDialog(targetPart.getSite().getPage(),
- leftView.getSession(), leftView, allowTimeStamp);
+ SelectBranchPointDialog dialog = new SelectBranchPointDialog(page, session, leftView, allowTimeStamp);
if (dialog.open() == SelectBranchPointDialog.OK)
{
- CDOView rightView = openView(dialog.getBranchPoint());
+ CDOView rightView = openView(session, dialog.getBranchPoint());
CDOView[] originView = { null };
try
@@ -86,9 +68,8 @@ public abstract class MergeAction implements IObjectActionDelegate
}
}
- private CDOView openView(CDOBranchPoint branchPoint)
+ private CDOView openView(CDOSession session, CDOBranchPoint branchPoint)
{
- CDOSession session = leftView.getSession();
if (branchPoint.getTimeStamp() == CDOBranchPoint.UNSPECIFIED_DATE)
{
return session.openTransaction(branchPoint.getBranch());
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/widgets/CommitHistoryComposite.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/widgets/CommitHistoryComposite.java
index c1afd2fb53..8d2c1518b9 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/widgets/CommitHistoryComposite.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/widgets/CommitHistoryComposite.java
@@ -197,7 +197,7 @@ public class CommitHistoryComposite extends Composite
protected TableViewer createTableViewer()
{
- return new TableViewer(this, SWT.BORDER | SWT.FULL_SELECTION);
+ return new TableViewer(this, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
}
protected ContentProvider createContentProvider()

Back to the top