Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2015-09-11 04:43:35 +0000
committerEike Stepper2015-09-11 04:43:35 +0000
commit130a6994656afb0e0d954a42c50d9db063c755d0 (patch)
tree36d08b44cd47b44a9c4e4716565eacbd5249c434 /plugins/org.eclipse.emf.cdo.explorer.ui
parentf7c4495e58380b03f363d7620c00b5f9ebe8a3f2 (diff)
downloadcdo-130a6994656afb0e0d954a42c50d9db063c755d0.tar.gz
cdo-130a6994656afb0e0d954a42c50d9db063c755d0.tar.xz
cdo-130a6994656afb0e0d954a42c50d9db063c755d0.zip
[477128] Support interactive merging in CDOWorkspace.update()
https://bugs.eclipse.org/bugs/show_bug.cgi?id=477128
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.explorer.ui')
-rw-r--r--plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/handlers/WorkspaceCheckinHandler.java53
-rw-r--r--plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/handlers/WorkspaceUpdateHandler.java99
-rw-r--r--plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/repositories/wizards/RepositoryClonePage.java5
-rw-r--r--plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/repositories/wizards/RepositoryRemotePage.java17
4 files changed, 160 insertions, 14 deletions
diff --git a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/handlers/WorkspaceCheckinHandler.java b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/handlers/WorkspaceCheckinHandler.java
index 055c49d976..f2fe3183fe 100644
--- a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/handlers/WorkspaceCheckinHandler.java
+++ b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/handlers/WorkspaceCheckinHandler.java
@@ -11,13 +11,20 @@
package org.eclipse.emf.cdo.explorer.ui.handlers;
import org.eclipse.emf.cdo.internal.explorer.checkouts.OfflineCDOCheckout;
+import org.eclipse.emf.cdo.util.CommitException;
import org.eclipse.emf.cdo.workspace.CDOWorkspace;
+import org.eclipse.net4j.util.ui.UIUtil;
import org.eclipse.net4j.util.ui.handlers.AbstractBaseHandler;
+import org.eclipse.emf.spi.cdo.InternalCDOTransaction.ChangeSetOutdatedException;
+
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.handlers.HandlerUtil;
/**
* @author Eike Stepper
@@ -47,15 +54,53 @@ public class WorkspaceCheckinHandler extends AbstractBaseHandler<OfflineCDOCheck
}
@Override
- protected void doExecute(ExecutionEvent event, IProgressMonitor monitor) throws Exception
+ protected void doExecute(final ExecutionEvent event, IProgressMonitor monitor) throws Exception
{
OfflineCDOCheckout checkout = elements.get(0);
CDOWorkspace workspace = checkout.getWorkspace();
if (workspace != null)
{
- // TODO Prompt for checkin comment.
- // TODO Use progress monitor.
- workspace.checkin();
+ ChangeSetOutdatedException exception = null;
+
+ try
+ {
+ // TODO Prompt for checkin comment.
+ // TODO Use progress monitor.
+ workspace.checkin();
+ }
+ catch (CommitException ex)
+ {
+ Throwable cause = ex.getCause();
+ if (cause instanceof ChangeSetOutdatedException)
+ {
+ exception = (ChangeSetOutdatedException)cause;
+ }
+ else
+ {
+ throw ex;
+ }
+ }
+ catch (ChangeSetOutdatedException ex)
+ {
+ exception = ex;
+ }
+
+ if (exception != null)
+ {
+ UIUtil.syncExec(new Runnable()
+ {
+ public void run()
+ {
+ Shell shell = HandlerUtil.getActiveShell(event);
+ if (shell == null)
+ {
+ shell = UIUtil.getShell();
+ }
+
+ MessageDialog.openError(shell, "Checkin Error", "Your checkout is outdated and needs to be updated.");
+ }
+ });
+ }
}
}
}
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 02a4937cda..dcba37c9ad 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
@@ -10,11 +10,21 @@
*/
package org.eclipse.emf.cdo.explorer.ui.handlers;
+import org.eclipse.emf.cdo.common.id.CDOID;
import org.eclipse.emf.cdo.internal.explorer.checkouts.OfflineCDOCheckout;
-import org.eclipse.emf.cdo.transaction.CDOMerger;
+import org.eclipse.emf.cdo.transaction.CDOCommitContext;
+import org.eclipse.emf.cdo.transaction.CDODefaultTransactionHandler2;
+import org.eclipse.emf.cdo.transaction.CDOMerger.ConflictException;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.ui.Support;
+import org.eclipse.emf.cdo.ui.compare.CDOCompareEditorUtil;
+import org.eclipse.emf.cdo.ui.internal.compare.CompareCDOMerger;
+import org.eclipse.emf.cdo.util.CommitException;
+import org.eclipse.emf.cdo.util.ConcurrentAccessException;
+import org.eclipse.emf.cdo.view.CDOView;
import org.eclipse.emf.cdo.workspace.CDOWorkspace;
+import org.eclipse.net4j.util.ui.UIUtil;
import org.eclipse.net4j.util.ui.handlers.AbstractBaseHandler;
import org.eclipse.emf.spi.cdo.DefaultCDOMerger;
@@ -22,6 +32,8 @@ import org.eclipse.emf.spi.cdo.DefaultCDOMerger;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.runtime.IProgressMonitor;
+import java.util.Set;
+
/**
* @author Eike Stepper
*/
@@ -35,16 +47,85 @@ public class WorkspaceUpdateHandler extends AbstractBaseHandler<OfflineCDOChecko
@Override
protected void doExecute(ExecutionEvent event, IProgressMonitor monitor) throws Exception
{
- OfflineCDOCheckout checkout = elements.get(0);
- CDOWorkspace workspace = checkout.getWorkspace();
+ final OfflineCDOCheckout checkout = elements.get(0);
+
+ final CDOWorkspace workspace = checkout.getWorkspace();
if (workspace != null)
{
- // TODO Use progress monitor in update().
- CDOMerger merger = new DefaultCDOMerger.PerFeature.ManyValued();
- CDOTransaction transaction = workspace.update(merger);
- transaction.commit(monitor);
-
- checkout.refresh();
+ try
+ {
+ mergeDefault(checkout, workspace, monitor);
+ }
+ catch (ConflictException ex)
+ {
+ if (Support.COMPARE.isAvailable())
+ {
+ mergeCompare(checkout, workspace);
+ }
+ else
+ {
+ throw ex;
+ }
+ }
}
}
+
+ private void mergeCompare(final OfflineCDOCheckout checkout, final CDOWorkspace workspace)
+ {
+ CDOCompareEditorUtil.runWithTitle("Update " + checkout.getLabel(), new Runnable()
+ {
+ public void run()
+ {
+ CDOTransaction transaction = workspace.update(new CompareCDOMerger()
+ {
+ @Override
+ public void merge(CDOTransaction localTransaction, CDOView remoteView, Set<CDOID> affectedIDs)
+ throws ConflictException
+ {
+ remoteView.properties().put(CDOCompareEditorUtil.PROP_COMPARISON_LABEL, "From remote");
+ localTransaction.properties().put(CDOCompareEditorUtil.PROP_COMPARISON_LABEL, "To local");
+
+ super.merge(localTransaction, remoteView, affectedIDs);
+ }
+ });
+
+ 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();
+ }
+ });
+ }
+ });
+ }
+ });
+ }
+
+ private void mergeDefault(final OfflineCDOCheckout checkout, final CDOWorkspace workspace, IProgressMonitor monitor)
+ throws ConcurrentAccessException, CommitException
+ {
+ CDOTransaction transaction = workspace.update(new DefaultCDOMerger.PerFeature.ManyValued());
+ transaction.commit(monitor);
+ transaction.close();
+
+ checkout.refresh();
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/repositories/wizards/RepositoryClonePage.java b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/repositories/wizards/RepositoryClonePage.java
index 66b58c3de2..7e764b05a7 100644
--- a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/repositories/wizards/RepositoryClonePage.java
+++ b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/repositories/wizards/RepositoryClonePage.java
@@ -75,6 +75,11 @@ public class RepositoryClonePage extends AbstractRepositoryPage
{
super.doValidate(properties);
+ if (controller == null)
+ {
+ return;
+ }
+
String connectorDescription = controller.getConnectorDescription();
if (StringUtil.isEmpty(connectorDescription))
{
diff --git a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/repositories/wizards/RepositoryRemotePage.java b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/repositories/wizards/RepositoryRemotePage.java
index f7463ead73..d77e59459e 100644
--- a/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/repositories/wizards/RepositoryRemotePage.java
+++ b/plugins/org.eclipse.emf.cdo.explorer.ui/src/org/eclipse/emf/cdo/explorer/ui/repositories/wizards/RepositoryRemotePage.java
@@ -16,6 +16,7 @@ import org.eclipse.emf.cdo.explorer.ui.checkouts.wizards.CheckoutWizardPage.Vali
import org.eclipse.emf.cdo.internal.explorer.repositories.RemoteCDORepository;
import org.eclipse.net4j.util.StringUtil;
+import org.eclipse.net4j.util.ui.UIUtil;
import org.eclipse.swt.widgets.Composite;
@@ -44,7 +45,21 @@ public class RepositoryRemotePage extends AbstractRepositoryPage
protected void validateController()
{
super.validateController();
- validate();
+
+ if (controller != null)
+ {
+ validate();
+ }
+ else
+ {
+ UIUtil.getDisplay().asyncExec(new Runnable()
+ {
+ public void run()
+ {
+ validate();
+ }
+ });
+ }
}
};
}

Back to the top