Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'extraplugins/propertylifecycle/org.eclipse.papyrus.sysml.propertylifecycle/src/org/eclipse/papyrus/sysml/propertylifecycle/processors/ConstraintPropertyProcessor.java')
-rwxr-xr-xextraplugins/propertylifecycle/org.eclipse.papyrus.sysml.propertylifecycle/src/org/eclipse/papyrus/sysml/propertylifecycle/processors/ConstraintPropertyProcessor.java62
1 files changed, 62 insertions, 0 deletions
diff --git a/extraplugins/propertylifecycle/org.eclipse.papyrus.sysml.propertylifecycle/src/org/eclipse/papyrus/sysml/propertylifecycle/processors/ConstraintPropertyProcessor.java b/extraplugins/propertylifecycle/org.eclipse.papyrus.sysml.propertylifecycle/src/org/eclipse/papyrus/sysml/propertylifecycle/processors/ConstraintPropertyProcessor.java
new file mode 100755
index 00000000000..0e428f51989
--- /dev/null
+++ b/extraplugins/propertylifecycle/org.eclipse.papyrus.sysml.propertylifecycle/src/org/eclipse/papyrus/sysml/propertylifecycle/processors/ConstraintPropertyProcessor.java
@@ -0,0 +1,62 @@
+/*****************************************************************************
+ * Copyright (c) 2016 CEA LIST and others.
+ *
+ * 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:
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.sysml.propertylifecycle.processors;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.gmf.runtime.common.core.command.CompositeCommand;
+import org.eclipse.gmf.runtime.common.core.command.ICommand;
+import org.eclipse.gmf.runtime.emf.type.core.requests.AbstractEditCommandRequest;
+import org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest;
+import org.eclipse.papyrus.propertylifecycle.commands.LifecycleSetCommand;
+import org.eclipse.papyrus.propertylifecycle.messages.Messages;
+import org.eclipse.papyrus.propertylifecycle.utils.CommandValueProcessor;
+import org.eclipse.papyrus.sysml.constraints.ConstraintsPackage;
+import org.eclipse.papyrus.uml.tools.utils.NamedElementUtil;
+import org.eclipse.uml2.uml.NamedElement;
+
+/**
+ *
+ */
+public class ConstraintPropertyProcessor implements CommandValueProcessor {
+
+ @Override
+ public ICommand setValueFromRequest(String featureLabel, boolean isImmutable, AbstractEditCommandRequest request) {
+ return setName(request);
+ }
+
+ public ConstraintPropertyProcessor() {
+
+ }
+
+ public ICommand setName(AbstractEditCommandRequest request) {
+ ICommand gmfCommand = null;
+
+ if (request instanceof ConfigureRequest) {
+ ConfigureRequest confRequest = (ConfigureRequest) request;
+
+ NamedElement element = (NamedElement) confRequest.getElementToConfigure();
+ EStructuralFeature feature = element.eClass().getEStructuralFeature(Messages.FEATURELABEL_NAME);
+ if (element != null && feature != null) {
+
+ // Set default name
+ String initializedName = NamedElementUtil.getDefaultNameWithIncrementFromBase(ConstraintsPackage.eINSTANCE.getConstraintProperty().getName().toLowerCase(), element.eContainer().eContents());
+ LifecycleSetCommand setCommand = new LifecycleSetCommand("ConstraintProperty_SetName", element, feature, initializedName);
+ gmfCommand = CompositeCommand.compose(gmfCommand, setCommand);
+ }
+ }
+
+ return gmfCommand;
+ }
+
+}

Back to the top