Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2014-02-19 14:39:57 +0000
committerChristian W. Damus2014-02-19 14:39:57 +0000
commit9116e0de749915a181a12903f416f1f29027a4da (patch)
treef0ed8f212a5015160180f664a32bcebf990ee09f
parent96980c326c4a7689330ce01c28aa43ef6082c5d2 (diff)
downloadorg.eclipse.papyrus-9116e0de749915a181a12903f416f1f29027a4da.tar.gz
org.eclipse.papyrus-9116e0de749915a181a12903f416f1f29027a4da.tar.xz
org.eclipse.papyrus-9116e0de749915a181a12903f416f1f29027a4da.zip
402525: [Widgets / Transactions] Papyrus dialogs should be transactional
https://bugs.eclipse.org/bugs/show_bug.cgi?id=402525 Cancel operation so that it doesn't end up on the undo history (and rolls back side-effects) when the reference factory ends up not creating anything.
-rw-r--r--plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/MultipleValueEditor.java9
-rw-r--r--plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/ReferenceDialog.java4
2 files changed, 9 insertions, 4 deletions
diff --git a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/MultipleValueEditor.java b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/MultipleValueEditor.java
index 45f9ca98cac..b0694e00bb4 100644
--- a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/MultipleValueEditor.java
+++ b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/MultipleValueEditor.java
@@ -412,10 +412,13 @@ public class MultipleValueEditor extends AbstractListEditor implements Selection
@Override
public void run() {
Object newElement = referenceFactory.createObject(MultipleValueEditor.this, context);
- if(newElement != null) {
- modelProperty.add(newElement);
- commit();
+ if(newElement == null) {
+ // Cancel the operation
+ throw new OperationCanceledException();
}
+
+ modelProperty.add(newElement);
+ commit();
}
}, NLS.bind(Messages.MultipleValueEditor_addOperation, labelText));
}
diff --git a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/ReferenceDialog.java b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/ReferenceDialog.java
index b493b0c2a5f..84c2234678b 100644
--- a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/ReferenceDialog.java
+++ b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/ReferenceDialog.java
@@ -18,6 +18,7 @@ import java.util.Collections;
import java.util.List;
import org.eclipse.core.databinding.observable.value.IObservableValue;
+import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.window.Window;
@@ -223,7 +224,8 @@ public class ReferenceDialog extends AbstractValueEditor implements SelectionLis
public void run() {
Object value = valueFactory.createObject(createInstanceButton, context);
if(value == null) {
- return;
+ // Cancel the operation
+ throw new OperationCanceledException();
}
Collection<Object> validatedObjects = valueFactory.validateObjects(Collections.singleton(value));
if(!validatedObjects.isEmpty()) {

Back to the top