Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/InteractionOperatorKindCompatibleMapping.java40
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CombinedFragmentEditPart.java36
2 files changed, 72 insertions, 4 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/InteractionOperatorKindCompatibleMapping.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/InteractionOperatorKindCompatibleMapping.java
new file mode 100644
index 00000000000..859b6776e16
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/InteractionOperatorKindCompatibleMapping.java
@@ -0,0 +1,40 @@
+package org.eclipse.papyrus.uml.diagram.sequence.util;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.uml2.uml.InteractionOperatorKind;
+
+public class InteractionOperatorKindCompatibleMapping {
+ /**
+ * Set the true if the kind of InteractionOperator supports multi operand
+ */
+ private static final Map<InteractionOperatorKind, Boolean> map = new HashMap<InteractionOperatorKind, Boolean>();
+
+ static {
+ map.put(InteractionOperatorKind.SEQ_LITERAL, true);
+ map.put(InteractionOperatorKind.ALT_LITERAL, true);
+ map.put(InteractionOperatorKind.OPT_LITERAL, false);
+ map.put(InteractionOperatorKind.BREAK_LITERAL, false);
+ map.put(InteractionOperatorKind.PAR_LITERAL, true);
+ map.put(InteractionOperatorKind.STRICT_LITERAL, true);
+ map.put(InteractionOperatorKind.LOOP_LITERAL, false);
+ map.put(InteractionOperatorKind.CRITICAL_LITERAL, true);
+ map.put(InteractionOperatorKind.NEG_LITERAL, false);
+ map.put(InteractionOperatorKind.ASSERT_LITERAL, true);
+ map.put(InteractionOperatorKind.IGNORE_LITERAL, true);
+ map.put(InteractionOperatorKind.CONSIDER_LITERAL, true);
+ }
+
+ /**
+ * Check if the InteractionOperator supports multi operand
+ *
+ * @param kind
+ * @return
+ */
+ public static boolean supportMultiOperand(InteractionOperatorKind kind) {
+ Boolean multiOperandSupport = map.get(kind);
+ return multiOperandSupport == null ? false : multiOperandSupport;
+ }
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CombinedFragmentEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CombinedFragmentEditPart.java
index 96bbe2978d1..e872d271790 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CombinedFragmentEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/CombinedFragmentEditPart.java
@@ -14,18 +14,23 @@
package org.eclipse.papyrus.uml.diagram.sequence.edit.parts;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.Shape;
import org.eclipse.draw2d.StackLayout;
+import org.eclipse.emf.common.command.AbstractCommand;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.edit.command.AddCommand;
import org.eclipse.emf.edit.command.RemoveCommand;
import org.eclipse.emf.edit.command.SetCommand;
+import org.eclipse.emf.transaction.RecordingCommand;
+import org.eclipse.emf.transaction.TransactionalEditingDomain;
+import org.eclipse.emf.transaction.util.TransactionUtil;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.EditPolicy;
import org.eclipse.gef.Request;
@@ -61,9 +66,13 @@ import org.eclipse.papyrus.uml.diagram.sequence.part.UMLDiagramEditorPlugin;
import org.eclipse.papyrus.uml.diagram.sequence.part.UMLVisualIDRegistry;
import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
import org.eclipse.papyrus.uml.diagram.sequence.util.CommandHelper;
+import org.eclipse.papyrus.uml.diagram.sequence.util.InteractionOperatorKindCompatibleMapping;
+import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceDeleteHelper;
+import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceUtil;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Display;
import org.eclipse.uml2.uml.CombinedFragment;
+import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.InteractionOperand;
import org.eclipse.uml2.uml.InteractionOperatorKind;
import org.eclipse.uml2.uml.Lifeline;
@@ -1138,14 +1147,33 @@ public class CombinedFragmentEditPart extends InteractionFragmentEditPart {
return;
}
EList<InteractionOperand> operands = combinedFragment.getOperands();
- if(operands == null || operands.size() <= 1) {
- // If CombinedFragment have no operand, we can change the OperatorKind
+ if (operands == null || operands.size() <= 1) {
+ // If CombinedFragment have no operand, we can change the
+ // OperatorKind
updateHeaderLabel();
- } else if(notification.getOldValue() instanceof InteractionOperatorKind && !newStringValue.equals(getPrimaryShape().getHeaderLabel().getText())) {
+ } else {
+ if (notification.getOldValue() instanceof InteractionOperatorKind) {
+ InteractionOperatorKind newValue = (InteractionOperatorKind) notification
+ .getNewValue();
+ if (!InteractionOperatorKindCompatibleMapping
+ .supportMultiOperand(newValue)) {
+ MessageDialog.openError(Display.getCurrent()
+ .getActiveShell(), FORBIDDEN_ACTION,
+ BLOCK_OPERATOR_MODIFICATION_MSG);
+ CommandHelper.executeCommandWithoutHistory(
+ getEditingDomain(), SetCommand.create(
+ getEditingDomain(), combinedFragment,
+ feature, notification.getOldValue()));
+ } else {
+ updateHeaderLabel();
+ }
+ }
+ }
+ /*else if(notification.getOldValue() instanceof InteractionOperatorKind && !newStringValue.equals(getPrimaryShape().getHeaderLabel().getText())) {
MessageDialog.openError(Display.getCurrent().getActiveShell(), FORBIDDEN_ACTION, BLOCK_OPERATOR_MODIFICATION_MSG);
CommandHelper.executeCommandWithoutHistory(getEditingDomain(), SetCommand.create(getEditingDomain(), combinedFragment, feature, notification.getOldValue()));
return;
- }
+ }*/
// update guards on enclosed operands
for(InteractionOperandEditPart ioep : getOperandChildrenEditParts()) {
ioep.getPrimaryShape().updateConstraintLabel();

Back to the top