Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2015-05-16 12:06:43 +0000
committerEike Stepper2015-05-16 12:06:43 +0000
commit95d2be88f607c6b94bfaab37e988366e729b25c8 (patch)
tree0640bde055045857fc24e5fcec0d26fb8dabd1a9 /plugins/org.eclipse.emf.cdo.ui
parentd32eb48416444187c7ace373e777ca90bcdf0c7e (diff)
downloadcdo-95d2be88f607c6b94bfaab37e988366e729b25c8.tar.gz
cdo-95d2be88f607c6b94bfaab37e988366e729b25c8.tar.xz
cdo-95d2be88f607c6b94bfaab37e988366e729b25c8.zip
[467442] Add Interactive Transaction Conflict Resolution
https://bugs.eclipse.org/bugs/show_bug.cgi?id=467442
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.ui')
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/InteractiveConflictHandlerSelector.java99
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/RollbackTransactionDialog.java15
2 files changed, 112 insertions, 2 deletions
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/InteractiveConflictHandlerSelector.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/InteractiveConflictHandlerSelector.java
new file mode 100644
index 0000000000..1c9dd43585
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/InteractiveConflictHandlerSelector.java
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2004-2014 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.internal.ui;
+
+import org.eclipse.emf.cdo.internal.ui.dialogs.RollbackTransactionDialog;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.ui.shared.SharedIcons;
+
+import org.eclipse.emf.internal.cdo.transaction.CDOHandlingConflictResolver.ConflictHandler;
+import org.eclipse.emf.internal.cdo.transaction.CDOHandlingConflictResolver.ConflictHandlerSelector;
+
+import org.eclipse.net4j.util.ui.UIUtil;
+
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IWorkbenchPage;
+
+import java.util.List;
+
+/**
+ * @author Eike Stepper
+ */
+public class InteractiveConflictHandlerSelector implements ConflictHandlerSelector
+{
+ public InteractiveConflictHandlerSelector()
+ {
+ }
+
+ public ConflictHandler selectConflictHandler(final CDOTransaction transaction, final List<ConflictHandler> choices)
+ {
+ final ConflictHandler[] result = { null };
+
+ final IWorkbenchPage workbenchPage = UIUtil.getActiveWorkbenchPage();
+
+ Display display = workbenchPage.getWorkbenchWindow().getShell().getDisplay();
+ display.syncExec(new Runnable()
+ {
+ public void run()
+ {
+ String title = "Conflict Error";
+ new RollbackTransactionDialog(workbenchPage, title, title, transaction)
+ {
+ @Override
+ protected String getQuestion()
+ {
+ return null;
+ }
+
+ @Override
+ protected Control createDialogArea(Composite parent)
+ {
+ Control control = super.createDialogArea(parent);
+ setTitleImage(SharedIcons.getImage(SharedIcons.WIZBAN_CONFLICT));
+ setMessage("The transaction contains unresolved conflicts.");
+ return control;
+ }
+
+ @Override
+ protected void createButtonsForButtonBar(Composite parent)
+ {
+ boolean defaultButton = true;
+
+ for (final ConflictHandler conflictHandler : choices)
+ {
+ Button button = createButton(parent, IDialogConstants.OK_ID, conflictHandler.getLabel(), defaultButton);
+ button.addSelectionListener(new SelectionAdapter()
+ {
+ @Override
+ public void widgetSelected(SelectionEvent e)
+ {
+ result[0] = conflictHandler;
+ }
+ });
+
+ defaultButton = false;
+ }
+
+ createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
+ }
+ }.open();
+ }
+ });
+
+ return result[0];
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/RollbackTransactionDialog.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/RollbackTransactionDialog.java
index 568872acbc..e900d8b97b 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/RollbackTransactionDialog.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/dialogs/RollbackTransactionDialog.java
@@ -14,6 +14,7 @@ package org.eclipse.emf.cdo.internal.ui.dialogs;
import org.eclipse.emf.cdo.internal.ui.messages.Messages;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.net4j.util.StringUtil;
import org.eclipse.net4j.util.ui.UIUtil;
import org.eclipse.jface.dialogs.TitleAreaDialog;
@@ -84,11 +85,21 @@ public class RollbackTransactionDialog extends TitleAreaDialog
append(builder, transaction.getDetachedObjects().size(), Messages.getString("RollbackTransactionDialog.8"), //$NON-NLS-1$
Messages.getString("RollbackTransactionDialog.9")); //$NON-NLS-1$
- builder.append("\n\n"); //$NON-NLS-1$
- builder.append(Messages.getString("RollbackTransactionDialog.11")); //$NON-NLS-1$
+ String question = getQuestion();
+ if (!StringUtil.isEmpty(question))
+ {
+ builder.append("\n\n"); //$NON-NLS-1$
+ builder.append(question);
+ }
+
return builder.toString();
}
+ protected String getQuestion()
+ {
+ return Messages.getString("RollbackTransactionDialog.11");
+ }
+
private void append(StringBuilder builder, int count, String labelSingular, String labelPlural)
{
if (count > 0)

Back to the top