Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnsgar Radermacher2014-01-27 16:17:48 +0000
committerAnsgar Radermacher2014-01-27 16:24:32 +0000
commitc04a4bd96accb96c4c9aca0558a4c2561f6d8a12 (patch)
tree105e69a3d2f18a417c73419f5bc9b829b52d562f /extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src
parent1a775ea3b3d381899993a8a595df84431e680d45 (diff)
downloadorg.eclipse.papyrus-c04a4bd96accb96c4c9aca0558a4c2561f6d8a12.tar.gz
org.eclipse.papyrus-c04a4bd96accb96c4c9aca0558a4c2561f6d8a12.tar.xz
org.eclipse.papyrus-c04a4bd96accb96c4c9aca0558a4c2561f6d8a12.zip
- 424759 - [QDesginer] Need for more options when binding templates
Diffstat (limited to 'extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src')
-rw-r--r--extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src/org/eclipse/papyrus/qompass/modellibs/core/bindinghelpers/BindOperation.java55
-rw-r--r--extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src/org/eclipse/papyrus/qompass/modellibs/core/bindinghelpers/LoopOperations.java45
2 files changed, 76 insertions, 24 deletions
diff --git a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src/org/eclipse/papyrus/qompass/modellibs/core/bindinghelpers/BindOperation.java b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src/org/eclipse/papyrus/qompass/modellibs/core/bindinghelpers/BindOperation.java
new file mode 100644
index 00000000000..61fb5030c0c
--- /dev/null
+++ b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src/org/eclipse/papyrus/qompass/modellibs/core/bindinghelpers/BindOperation.java
@@ -0,0 +1,55 @@
+package org.eclipse.papyrus.qompass.modellibs.core.bindinghelpers;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.papyrus.FCM.util.IBindingHelper;
+import org.eclipse.papyrus.qompass.designer.core.listeners.CopyListener;
+import org.eclipse.papyrus.qompass.designer.core.templates.BindingUtils;
+import org.eclipse.papyrus.qompass.designer.core.templates.TemplateUtils;
+import org.eclipse.papyrus.qompass.designer.core.transformations.Copy;
+import org.eclipse.papyrus.qompass.designer.core.transformations.TransformationException;
+import org.eclipse.papyrus.qompass.modellibs.core.Activator;
+import org.eclipse.uml2.uml.Behavior;
+import org.eclipse.uml2.uml.Classifier;
+import org.eclipse.uml2.uml.Element;
+import org.eclipse.uml2.uml.OpaqueBehavior;
+import org.eclipse.uml2.uml.Operation;
+import org.eclipse.uml2.uml.TemplateBinding;
+
+/**
+ * Bind an operation to an actual, i.e. evaluate the Acceleo template within the opaque behavior associated with
+ * the operation.
+ */
+public class BindOperation implements IBindingHelper, CopyListener {
+
+ private TemplateBinding binding;
+
+ @Override
+ public EObject copyEObject(Copy copy, EObject sourceEObj) {
+
+ if(sourceEObj instanceof Operation) {
+ Operation operation = (Operation) sourceEObj;
+ Classifier actual = TemplateUtils.getFirstActualFromBinding(binding);
+
+ Operation newOperation = BindingUtils.instantiateOperation(copy, actual, operation);
+ for(Behavior method : operation.getMethods()) {
+ if(method instanceof OpaqueBehavior) {
+ try {
+ Behavior newBehavior =
+ BindingUtils.instantiateBehavior(copy, actual, (OpaqueBehavior)method);
+ newBehavior.setSpecification(newOperation);
+ }
+ catch (TransformationException e) {
+ Activator.log.error(e);
+ }
+ }
+ }
+ return newOperation;
+ }
+ return sourceEObj;
+ }
+
+ @Override
+ public void handleElement(TemplateBinding binding, Element object) {
+ this.binding = binding;
+ }
+}
diff --git a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src/org/eclipse/papyrus/qompass/modellibs/core/bindinghelpers/LoopOperations.java b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src/org/eclipse/papyrus/qompass/modellibs/core/bindinghelpers/LoopOperations.java
index 2f9874c8b1e..11f066f202b 100644
--- a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src/org/eclipse/papyrus/qompass/modellibs/core/bindinghelpers/LoopOperations.java
+++ b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src/org/eclipse/papyrus/qompass/modellibs/core/bindinghelpers/LoopOperations.java
@@ -12,7 +12,6 @@ import org.eclipse.papyrus.qompass.designer.core.transformations.Copy;
import org.eclipse.papyrus.qompass.designer.core.transformations.TransformationException;
import org.eclipse.papyrus.qompass.modellibs.core.Activator;
import org.eclipse.uml2.uml.Behavior;
-import org.eclipse.uml2.uml.Class;
import org.eclipse.uml2.uml.Classifier;
import org.eclipse.uml2.uml.Element;
import org.eclipse.uml2.uml.EnumerationLiteral;
@@ -26,14 +25,12 @@ public class LoopOperations implements IBindingHelper, CopyListener {
private TemplateBinding binding;
- @Override
public EObject copyEObject(Copy copy, EObject sourceEObj) {
if(sourceEObj instanceof Operation) {
Operation operation = (Operation)sourceEObj;
Classifier actual = TemplateUtils.getFirstActualFromBinding(binding);
- Class boundClass = copy.getCopy(operation.getClass_());
if(!(actual instanceof Interface)) {
return sourceEObj;
@@ -46,7 +43,7 @@ public class LoopOperations implements IBindingHelper, CopyListener {
copy.removeForCopy(removalElement); // enable subsequent instantiations
}
removalList.clear();
- last = BindingUtils.instantiateOperation(copy, intfOperation, operation, boundClass);
+ last = BindingUtils.instantiateOperation(copy, intfOperation, operation);
removalList.add(operation);
for(Behavior method : operation.getMethods()) {
if(method instanceof OpaqueBehavior) {
@@ -81,29 +78,29 @@ public class LoopOperations implements IBindingHelper, CopyListener {
*/
}
else if(sourceEObj instanceof EnumerationLiteral) {
- EnumerationLiteral literal = (EnumerationLiteral)sourceEObj;
- Classifier actual = TemplateUtils.getFirstActualFromBinding(binding);
- // Type passedActual = getPassedActual(template, actual, boundClass);
- Type passedActual = actual;
- if(!(passedActual instanceof Interface)) {
- return sourceEObj;
+ EnumerationLiteral literal = (EnumerationLiteral)sourceEObj;
+ Classifier actual = TemplateUtils.getFirstActualFromBinding(binding);
+ // Type passedActual = getPassedActual(template, actual, boundClass);
+ Type passedActual = actual;
+ if(!(passedActual instanceof Interface)) {
+ return sourceEObj;
+ }
+ Interface passedActualIntf = (Interface)passedActual;
+ EnumerationLiteral newLiteral = null;
+ for(Operation intfOperation : passedActualIntf.getAllOperations()) {
+ copy.removeForCopy(literal);
+ newLiteral = copy.getCopy(literal);
+ try {
+ String newName = AcceleoDriverWrapper.evaluate(literal.getName(), intfOperation, null);
+ newLiteral.setName(newName);
}
- Interface passedActualIntf = (Interface)passedActual;
- EnumerationLiteral newLiteral = null;
- for(Operation intfOperation : passedActualIntf.getAllOperations()) {
- copy.removeForCopy(literal);
- newLiteral = copy.getCopy(literal);
- try {
- String newName = AcceleoDriverWrapper.evaluate(literal.getName(), intfOperation, null);
- newLiteral.setName(newName);
- }
- catch (TransformationException e) {
- Activator.log.error(e);
- newLiteral.setName("none"); //$NON-NLS-1$
- }
+ catch (TransformationException e) {
+ Activator.log.error(e);
+ newLiteral.setName("none"); //$NON-NLS-1$
}
- return newLiteral;
}
+ return newLiteral;
+ }
return null;
}

Back to the top