Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2015-09-13 02:44:59 -0400
committerEike Stepper2015-09-13 02:44:59 -0400
commit73969d5eb69779c1ca2a13fa36a9e9d2fa0b9630 (patch)
tree28091363f4045c1619aecd99d67e8d5a62396ddd
parent9e6ed1e96a0cb9036c0290a9f7c3ae4f9b7c0331 (diff)
downloadcdo-73969d5eb69779c1ca2a13fa36a9e9d2fa0b9630.tar.gz
cdo-73969d5eb69779c1ca2a13fa36a9e9d2fa0b9630.tar.xz
cdo-73969d5eb69779c1ca2a13fa36a9e9d2fa0b9630.zip
477128: Support interactive merging in CDOWorkspace.update()
Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=477128
-rw-r--r--features/org.eclipse.emf.cdo.explorer-feature/build.properties2
-rw-r--r--plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/actions/MergeFromActionProvider.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/handlers/WorkspaceUpdateHandler.java19
-rw-r--r--plugins/org.eclipse.emf.cdo.ui.compare/src/org/eclipse/emf/cdo/ui/compare/CDOCompareEditorUtil.java148
-rw-r--r--plugins/org.eclipse.emf.cdo.ui.compare/src/org/eclipse/emf/cdo/ui/internal/compare/CompareCDOMerger.java70
5 files changed, 156 insertions, 91 deletions
diff --git a/features/org.eclipse.emf.cdo.explorer-feature/build.properties b/features/org.eclipse.emf.cdo.explorer-feature/build.properties
index 56da0aa06d..eae4f9f3fa 100644
--- a/features/org.eclipse.emf.cdo.explorer-feature/build.properties
+++ b/features/org.eclipse.emf.cdo.explorer-feature/build.properties
@@ -22,5 +22,3 @@ src.includes = about.html,\
buckminster.cspex,\
rootfiles/,\
license.html
-
-root = rootfiles
diff --git a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/actions/MergeFromActionProvider.java b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/actions/MergeFromActionProvider.java
index 9dd4b8cf4c..bfd6ef76fa 100644
--- a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/actions/MergeFromActionProvider.java
+++ b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/checkouts/actions/MergeFromActionProvider.java
@@ -13,8 +13,10 @@ package org.eclipse.emf.cdo.explorer.ui.checkouts.actions;
import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
import org.eclipse.emf.cdo.explorer.checkouts.CDOCheckout;
import org.eclipse.emf.cdo.explorer.repositories.CDORepository;
+import org.eclipse.emf.cdo.transaction.CDOTransactionOpener;
import org.eclipse.emf.cdo.ui.Support;
import org.eclipse.emf.cdo.ui.compare.CDOCompareEditorUtil;
+import org.eclipse.emf.cdo.ui.compare.CDOCompareEditorUtil.TransactionOpenerAndEditorCloser;
/**
* @author Eike Stepper
@@ -68,10 +70,12 @@ public class MergeFromActionProvider extends AbstractBranchPointActionProvider
{
if (Support.COMPARE.isAvailable())
{
- CDORepository repository = checkout.getRepository();
+ final CDORepository repository = checkout.getRepository();
CDOBranchPoint left = branchPoint;
CDOBranchPoint right = checkout.getBranchPoint();
- CDOCompareEditorUtil.openEditor(repository, repository, left, right, null, true);
+
+ CDOTransactionOpener transactionOpener = new TransactionOpenerAndEditorCloser(repository, true);
+ CDOCompareEditorUtil.openEditor(repository, transactionOpener, left, right, null, true);
}
}
}
diff --git a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/handlers/WorkspaceUpdateHandler.java b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/handlers/WorkspaceUpdateHandler.java
index d48152802e..acdda31adc 100644
--- a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/handlers/WorkspaceUpdateHandler.java
+++ b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/handlers/WorkspaceUpdateHandler.java
@@ -26,7 +26,6 @@ import org.eclipse.emf.cdo.view.CDOView;
import org.eclipse.emf.cdo.workspace.CDOWorkspace;
import org.eclipse.net4j.util.registry.IRegistry;
-import org.eclipse.net4j.util.ui.UIUtil;
import org.eclipse.net4j.util.ui.handlers.AbstractBaseHandler;
import org.eclipse.emf.spi.cdo.DefaultCDOMerger;
@@ -99,27 +98,9 @@ public class WorkspaceUpdateHandler extends AbstractBaseHandler<OfflineCDOChecko
transaction.addTransactionHandler(new CDODefaultTransactionHandler2()
{
@Override
- public void rolledBackTransaction(CDOTransaction transaction)
- {
- closeTransaction(transaction);
- }
-
- @Override
public void committedTransaction(CDOTransaction transaction, CDOCommitContext commitContext)
{
checkout.refresh();
- closeTransaction(transaction);
- }
-
- private void closeTransaction(final CDOTransaction transaction)
- {
- UIUtil.getDisplay().asyncExec(new Runnable()
- {
- public void run()
- {
- transaction.close();
- }
- });
}
});
}
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 f6af02feae..1084588168 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
@@ -25,6 +25,8 @@ import org.eclipse.emf.cdo.spi.common.branch.CDOBranchUtil;
import org.eclipse.emf.cdo.spi.common.revision.CDOIDMapper;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionDelta;
+import org.eclipse.emf.cdo.transaction.CDOCommitContext;
+import org.eclipse.emf.cdo.transaction.CDODefaultTransactionHandler2;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.transaction.CDOTransactionOpener;
import org.eclipse.emf.cdo.ui.CDOItemProvider;
@@ -33,6 +35,8 @@ import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.emf.cdo.view.CDOView;
import org.eclipse.emf.cdo.view.CDOViewOpener;
+import org.eclipse.net4j.util.lifecycle.ILifecycle;
+import org.eclipse.net4j.util.lifecycle.LifecycleEventAdapter;
import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
import org.eclipse.net4j.util.registry.IRegistry;
import org.eclipse.net4j.util.ui.UIUtil;
@@ -66,6 +70,10 @@ import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IPartListener;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
@@ -103,6 +111,103 @@ public class CDOCompareEditorUtil
private static final ThreadLocal<List<Runnable>> DISPOSE_RUNNABLES = new ThreadLocal<List<Runnable>>();
/**
+ * @since 4.4
+ */
+ public static void closeTransactionAfterCommit(final CDOTransaction transaction)
+ {
+ transaction.addTransactionHandler(new CDODefaultTransactionHandler2()
+ {
+ @Override
+ public void rolledBackTransaction(CDOTransaction transaction)
+ {
+ closeTransaction(transaction);
+ }
+
+ @Override
+ public void committedTransaction(CDOTransaction transaction, CDOCommitContext commitContext)
+ {
+ closeTransaction(transaction);
+ }
+
+ private void closeTransaction(final CDOTransaction transaction)
+ {
+ UIUtil.getDisplay().asyncExec(new Runnable()
+ {
+ public void run()
+ {
+ transaction.close();
+ }
+ });
+ }
+ });
+ }
+
+ /**
+ * @since 4.4
+ */
+ public static void closeEditorWithTransaction(final CDOTransaction transaction)
+ {
+ final IEditorPart[] result = { null };
+
+ final IWorkbenchPage page = UIUtil.getActiveWorkbenchPage();
+ final IPartListener listener = new IPartListener()
+ {
+ @SuppressWarnings("restriction")
+ public void partOpened(IWorkbenchPart part)
+ {
+ if (part instanceof org.eclipse.compare.internal.CompareEditor)
+ {
+ result[0] = (IEditorPart)part;
+ }
+ }
+
+ public void partDeactivated(IWorkbenchPart part)
+ {
+ // Do nothing.
+ }
+
+ public void partClosed(IWorkbenchPart part)
+ {
+ if (part == result[0])
+ {
+ transaction.close();
+ page.removePartListener(this);
+ }
+ }
+
+ public void partBroughtToTop(IWorkbenchPart part)
+ {
+ // Do nothing.
+ }
+
+ public void partActivated(IWorkbenchPart part)
+ {
+ // Do nothing.
+ }
+ };
+
+ page.addPartListener(listener);
+
+ transaction.addListener(new LifecycleEventAdapter()
+ {
+ @Override
+ protected void onDeactivated(ILifecycle lifecycle)
+ {
+ if (result[0] != null)
+ {
+ UIUtil.getDisplay().asyncExec(new Runnable()
+ {
+ public void run()
+ {
+ page.closeEditor(result[0], false);
+ }
+ });
+ }
+ }
+ });
+ }
+
+ /**
* @since 4.3
*/
public static boolean openEditor(CDOViewOpener viewOpener, CDOBranchPoint leftPoint, CDOBranchPoint rightPoint,
@@ -784,4 +889,47 @@ public class CDOCompareEditorUtil
}
}
}
+
+ /**
+ * @author Eike Stepper
+ * @since 4.4
+ */
+ public static final class TransactionOpenerAndEditorCloser implements CDOTransactionOpener
+ {
+ private final CDOTransactionOpener delegate;
+
+ private final boolean closeTransactionAfterCommit;
+
+ public TransactionOpenerAndEditorCloser(CDOTransactionOpener delegate, boolean closeTransactionAfterCommit)
+ {
+ this.delegate = delegate;
+ this.closeTransactionAfterCommit = closeTransactionAfterCommit;
+ }
+
+ public boolean isCloseTransactionAfterCommit()
+ {
+ return closeTransactionAfterCommit;
+ }
+
+ public CDOTransaction openTransaction(String durableLockingID, ResourceSet resourceSet)
+ {
+ return wrap(delegate.openTransaction(durableLockingID, resourceSet));
+ }
+
+ public CDOTransaction openTransaction(CDOBranchPoint target, ResourceSet resourceSet)
+ {
+ return wrap(delegate.openTransaction(target, resourceSet));
+ }
+
+ private CDOTransaction wrap(CDOTransaction transaction)
+ {
+ if (closeTransactionAfterCommit)
+ {
+ closeTransactionAfterCommit(transaction);
+ }
+
+ CDOCompareEditorUtil.closeEditorWithTransaction(transaction);
+ return transaction;
+ }
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo.ui.compare/src/org/eclipse/emf/cdo/ui/internal/compare/CompareCDOMerger.java b/plugins/org.eclipse.emf.cdo.ui.compare/src/org/eclipse/emf/cdo/ui/internal/compare/CompareCDOMerger.java
index 11f6fcb72e..1251dc8a82 100644
--- a/plugins/org.eclipse.emf.cdo.ui.compare/src/org/eclipse/emf/cdo/ui/internal/compare/CompareCDOMerger.java
+++ b/plugins/org.eclipse.emf.cdo.ui.compare/src/org/eclipse/emf/cdo/ui/internal/compare/CompareCDOMerger.java
@@ -18,15 +18,6 @@ import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.ui.compare.CDOCompareEditorUtil;
import org.eclipse.emf.cdo.view.CDOView;
-import org.eclipse.net4j.util.lifecycle.ILifecycle;
-import org.eclipse.net4j.util.lifecycle.LifecycleEventAdapter;
-import org.eclipse.net4j.util.ui.UIUtil;
-
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IPartListener;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
-
import java.util.Set;
/**
@@ -47,65 +38,8 @@ public class CompareCDOMerger implements CDOMerger2
public void merge(final CDOTransaction localTransaction, CDOView remoteView, Set<CDOID> affectedIDs)
throws ConflictException
{
- final IEditorPart[] result = { null };
-
- final IWorkbenchPage page = UIUtil.getActiveWorkbenchPage();
- final IPartListener listener = new IPartListener()
- {
- @SuppressWarnings("restriction")
- public void partOpened(IWorkbenchPart part)
- {
- if (part instanceof org.eclipse.compare.internal.CompareEditor)
- {
- result[0] = (IEditorPart)part;
- }
- }
-
- public void partDeactivated(IWorkbenchPart part)
- {
- // Do nothing.
- }
-
- public void partClosed(IWorkbenchPart part)
- {
- if (part == result[0])
- {
- localTransaction.close();
- page.removePartListener(this);
- }
- }
-
- public void partBroughtToTop(IWorkbenchPart part)
- {
- // Do nothing.
- }
-
- public void partActivated(IWorkbenchPart part)
- {
- // Do nothing.
- }
- };
-
- page.addPartListener(listener);
-
- localTransaction.addListener(new LifecycleEventAdapter()
- {
- @Override
- protected void onDeactivated(ILifecycle lifecycle)
- {
- if (result[0] != null)
- {
- UIUtil.getDisplay().asyncExec(new Runnable()
- {
- public void run()
- {
- page.closeEditor(result[0], false);
- }
- });
- }
- }
- });
-
+ CDOCompareEditorUtil.closeTransactionAfterCommit(localTransaction);
+ CDOCompareEditorUtil.closeEditorWithTransaction(localTransaction);
CDOCompareEditorUtil.openEditor(remoteView, localTransaction, affectedIDs, true);
}
}

Back to the top