diff --git a/core/plugins/org.polarsys.capella.core.data.information.properties/src/org/polarsys/capella/core/data/information/properties/fields/NavigableCheckbox.java b/core/plugins/org.polarsys.capella.core.data.information.properties/src/org/polarsys/capella/core/data/information/properties/fields/NavigableCheckbox.java index d33d2a02bc..9868d9e640 100644 --- a/core/plugins/org.polarsys.capella.core.data.information.properties/src/org/polarsys/capella/core/data/information/properties/fields/NavigableCheckbox.java +++ b/core/plugins/org.polarsys.capella.core.data.information.properties/src/org/polarsys/capella/core/data/information/properties/fields/NavigableCheckbox.java @@ -21,6 +21,8 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory; import org.polarsys.capella.common.data.modellingcore.ModellingcorePackage; +import org.polarsys.capella.common.ef.command.AbstractCompoundCommand; +import org.polarsys.capella.common.ef.command.ICommand; import org.polarsys.capella.common.helpers.EObjectExt; import org.polarsys.capella.core.data.capellacore.CapellacorePackage; import org.polarsys.capella.core.data.capellacore.Classifier; @@ -82,8 +84,10 @@ public void widgetSelected(SelectionEvent event) { if (oppositeMember != null) { EObject oppositeTypeElement = (EObject) oppositeMember.eGet(ModellingcorePackage.Literals.ABSTRACT_TYPED_ELEMENT__ABSTRACT_TYPE); if (oppositeTypeElement != null) { - moveDataValue(semanticElement, oppositeTypeElement, CapellacorePackage.Literals.CLASSIFIER__OWNED_FEATURES); - addDataValue(ownerElement, InformationPackage.Literals.ASSOCIATION__NAVIGABLE_MEMBERS, semanticElement); + AbstractCompoundCommand command = new AbstractCompoundCommand() {}; + command.append(createMoveDataValueCommand(semanticElement, oppositeTypeElement, CapellacorePackage.Literals.CLASSIFIER__OWNED_FEATURES)); + command.append(createAddDataValueCommand(ownerElement, InformationPackage.Literals.ASSOCIATION__NAVIGABLE_MEMBERS, semanticElement)); + executeCommand(command); } } } @@ -96,8 +100,10 @@ public void widgetSelected(SelectionEvent event) { } if ((typeElement instanceof Classifier) && (referencerElement instanceof Association)) { - moveDataValue(semanticElement, referencerElement, InformationPackage.Literals.ASSOCIATION__OWNED_MEMBERS); - removeDataValue(referencerElement, InformationPackage.Literals.ASSOCIATION__NAVIGABLE_MEMBERS, semanticElement); + AbstractCompoundCommand command = new AbstractCompoundCommand() {}; + command.append(createMoveDataValueCommand(semanticElement, referencerElement, InformationPackage.Literals.ASSOCIATION__OWNED_MEMBERS)); + command.append(createRemoveDataValueCommand(referencerElement, InformationPackage.Literals.ASSOCIATION__NAVIGABLE_MEMBERS, semanticElement)); + executeCommand(command); } } } diff --git a/core/plugins/org.polarsys.capella.core.ui.properties/src/org/polarsys/capella/core/ui/properties/fields/AbstractSemanticField.java b/core/plugins/org.polarsys.capella.core.ui.properties/src/org/polarsys/capella/core/ui/properties/fields/AbstractSemanticField.java index 34b6a5d03f..9936fa75c9 100644 --- a/core/plugins/org.polarsys.capella.core.ui.properties/src/org/polarsys/capella/core/ui/properties/fields/AbstractSemanticField.java +++ b/core/plugins/org.polarsys.capella.core.ui.properties/src/org/polarsys/capella/core/ui/properties/fields/AbstractSemanticField.java @@ -430,16 +430,17 @@ public void run() { * @param feature * @param value */ - protected void addDataValue(final EObject object, final EStructuralFeature feature, final Object value) { + protected AbstractReadWriteCommand createAddDataValueCommand(final EObject object, final EStructuralFeature feature, final Object value) { if (NotificationHelper.isNotificationRequired(object, feature, value)) { - AbstractReadWriteCommand command = new AbstractReadWriteCommand() { + return new AbstractReadWriteCommand() { @Override @SuppressWarnings({ "unchecked", "rawtypes" }) public void run() { ((List) object.eGet(feature)).add(value); } }; - executeCommand(command); + } else { + return null; } } @@ -451,8 +452,8 @@ public void run() { * @param feature */ @SuppressWarnings("unchecked") - protected void moveDataValue(final EObject object, final EObject owner, final EStructuralFeature feature) { - AbstractReadWriteCommand command = new AbstractReadWriteCommand() { + protected AbstractReadWriteCommand createMoveDataValueCommand(final EObject object, final EObject owner, final EStructuralFeature feature) { + return new AbstractReadWriteCommand() { @Override public void run() { if (feature.isMany()) { @@ -462,7 +463,6 @@ public void run() { } } }; - executeCommand(command); } /** @@ -472,9 +472,9 @@ public void run() { * @param feature * @param value */ - protected void removeDataValue(final EObject object, final EStructuralFeature feature, final Object value) { + protected AbstractReadWriteCommand createRemoveDataValueCommand(final EObject object, final EStructuralFeature feature, final Object value) { if (NotificationHelper.isNotificationRequired(object, feature, value)) { - AbstractReadWriteCommand command = new AbstractReadWriteCommand() { + return new AbstractReadWriteCommand() { @Override public void run() { if ((feature instanceof EReference) && ((EReference) feature).isContainment()) { @@ -484,7 +484,8 @@ public void run() { } } }; - executeCommand(command); + } else { + return null; } }