summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-10-07 05:38:22 (EDT)
committerEike Stepper2007-10-07 05:38:22 (EDT)
commit790094f357670c5b7954b3ab44f188b2c9849264 (patch)
tree3976e3566734dfec486f331e137cc1d112129c8d
parent273ddd1cd9786578a13bb511285e3f55f4af79c5 (diff)
downloadcdo-790094f357670c5b7954b3ab44f188b2c9849264.zip
cdo-790094f357670c5b7954b3ab44f188b2c9849264.tar.gz
cdo-790094f357670c5b7954b3ab44f188b2c9849264.tar.bz2
[205651] Implement transaction rollback
https://bugs.eclipse.org/bugs/show_bug.cgi?id=205651
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RollbackTransactionAction.java62
1 files changed, 56 insertions, 6 deletions
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RollbackTransactionAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RollbackTransactionAction.java
index 47a2dd2..948367a 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RollbackTransactionAction.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/RollbackTransactionAction.java
@@ -6,8 +6,6 @@ import org.eclipse.emf.cdo.CDOView;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.ui.IWorkbenchPage;
-import java.text.MessageFormat;
-
/**
* @author Eike Stepper
*/
@@ -27,10 +25,62 @@ public final class RollbackTransactionAction extends ViewAction
protected void preRun() throws Exception
{
CDOTransaction transaction = (CDOTransaction)getView();
- String msg = MessageFormat.format("This transaction contains " + "{0} new resources, " + "{1} new objects and "
- + "{2} dirty objects.\n" + "Are you sure to rollback this transaction?", transaction.getNewResources().size(),
- transaction.getNewObjects().size(), transaction.getDirtyObjects().size());
- if (!MessageDialog.openQuestion(getShell(), TITLE, msg))
+ int newResources = transaction.getNewResources().size();
+ int newObjects = transaction.getNewObjects().size();
+ int dirtyObjects = transaction.getDirtyObjects().size();
+ int count = (newResources > 0 ? 1 : 0) + (newObjects > 0 ? 1 : 0) + (dirtyObjects > 0 ? 1 : 0);
+
+ StringBuilder builder = new StringBuilder();
+ builder.append("This transaction contains ");
+ if (newResources > 0)
+ {
+ builder.append(newResources);
+ builder.append(" new resource");
+ if (newResources > 1)
+ {
+ builder.append("s");
+ }
+ }
+
+ if (newObjects > 0)
+ {
+ if (newResources > 0)
+ {
+ if (count > 2)
+ {
+ builder.append(", ");
+ }
+ else
+ {
+ builder.append(" and ");
+ }
+ }
+
+ builder.append(newObjects);
+ builder.append(" new object");
+ if (newObjects > 1)
+ {
+ builder.append("s");
+ }
+ }
+
+ if (dirtyObjects > 0)
+ {
+ if (count > 1)
+ {
+ builder.append(" and ");
+ }
+
+ builder.append(dirtyObjects);
+ builder.append(" dirty object");
+ if (dirtyObjects > 1)
+ {
+ builder.append("s");
+ }
+ }
+
+ builder.append(".\nAre you sure to rollback this transaction?");
+ if (!MessageDialog.openQuestion(getShell(), TITLE, builder.toString()))
{
cancel();
}