Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/src/org/eclipse/papyrus/uml/diagram/sequence/edit/commands/ConstraintConstrainedElementCreateCommand.java')
-rw-r--r--deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/src/org/eclipse/papyrus/uml/diagram/sequence/edit/commands/ConstraintConstrainedElementCreateCommand.java106
1 files changed, 106 insertions, 0 deletions
diff --git a/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/src/org/eclipse/papyrus/uml/diagram/sequence/edit/commands/ConstraintConstrainedElementCreateCommand.java b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/src/org/eclipse/papyrus/uml/diagram/sequence/edit/commands/ConstraintConstrainedElementCreateCommand.java
new file mode 100644
index 00000000000..f8fcc68e626
--- /dev/null
+++ b/deprecated/org.eclipse.papyrus.uml.diagram.sequence_initial-kepler/src/org/eclipse/papyrus/uml/diagram/sequence/edit/commands/ConstraintConstrainedElementCreateCommand.java
@@ -0,0 +1,106 @@
+/*****************************************************************************
+ * Copyright (c) 2009 CEA
+ *
+ *
+ * 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:
+ * Atos Origin - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.uml.diagram.sequence.edit.commands;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.gmf.runtime.common.core.command.CommandResult;
+import org.eclipse.gmf.runtime.emf.type.core.commands.EditElementCommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.UMLBaseItemSemanticEditPolicy;
+import org.eclipse.uml2.uml.Constraint;
+import org.eclipse.uml2.uml.Element;
+
+/**
+ * @generated
+ */
+public class ConstraintConstrainedElementCreateCommand extends EditElementCommand {
+
+ /**
+ * @generated
+ */
+ protected final EObject source;
+
+ /**
+ * @generated
+ */
+ protected final EObject target;
+
+ /**
+ * @generated
+ */
+ public ConstraintConstrainedElementCreateCommand(CreateRelationshipRequest request, EObject source, EObject target) {
+ super(request.getLabel(), null, request);
+ this.source = source;
+ this.target = target;
+ }
+
+ /**
+ * @generated
+ */
+ public boolean canExecute() {
+ if(source == null && target == null) {
+ return false;
+ }
+ if(source != null && false == source instanceof Constraint) {
+ return false;
+ }
+ if(target != null && false == target instanceof Element) {
+ return false;
+ }
+ if(getSource() == null) {
+ return true; // link creation is in progress; source is not defined yet
+ }
+ // target may be null here but it's possible to check constraint
+ return UMLBaseItemSemanticEditPolicy.getLinkConstraints().canCreateConstraintConstrainedElement_4011(getSource(), getTarget());
+ }
+
+ /**
+ * @generated
+ */
+ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
+ if(!canExecute()) {
+ throw new ExecutionException("Invalid arguments in create link command"); //$NON-NLS-1$
+ }
+
+ if(getSource() != null && getTarget() != null) {
+ getSource().getConstrainedElements().add(getTarget());
+ }
+ return CommandResult.newOKCommandResult();
+
+ }
+
+ /**
+ * @generated
+ */
+ protected void setElementToEdit(EObject element) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * @generated
+ */
+ protected Constraint getSource() {
+ return (Constraint)source;
+ }
+
+ /**
+ * @generated
+ */
+ protected Element getTarget() {
+ return (Element)target;
+ }
+}

Back to the top