diff options
Diffstat (limited to 'extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src/org/eclipse/papyrus/qompass')
4 files changed, 124 insertions, 6 deletions
diff --git a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src/org/eclipse/papyrus/qompass/modellibs/core/Activator.java b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src/org/eclipse/papyrus/qompass/modellibs/core/Activator.java index f2cbe552f92..369b1e2591a 100644 --- a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src/org/eclipse/papyrus/qompass/modellibs/core/Activator.java +++ b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src/org/eclipse/papyrus/qompass/modellibs/core/Activator.java @@ -1,5 +1,6 @@ package org.eclipse.papyrus.qompass.modellibs.core; +import org.eclipse.papyrus.infra.core.log.LogHelper; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; @@ -14,6 +15,8 @@ public class Activator extends AbstractUIPlugin { // The shared instance private static Activator plugin; + public static LogHelper log; + /** * The constructor */ @@ -29,6 +32,9 @@ public class Activator extends AbstractUIPlugin { public void start(BundleContext context) throws Exception { super.start(context); plugin = this; + + // register the login helper + log = new LogHelper(plugin); } /* 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 new file mode 100644 index 00000000000..2f9874c8b1e --- /dev/null +++ b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src/org/eclipse/papyrus/qompass/modellibs/core/bindinghelpers/LoopOperations.java @@ -0,0 +1,114 @@ +package org.eclipse.papyrus.qompass.modellibs.core.bindinghelpers; + +import org.eclipse.emf.common.util.BasicEList; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.papyrus.FCM.util.IBindingHelper; +import org.eclipse.papyrus.qompass.designer.core.acceleo.AcceleoDriverWrapper; +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.Class; +import org.eclipse.uml2.uml.Classifier; +import org.eclipse.uml2.uml.Element; +import org.eclipse.uml2.uml.EnumerationLiteral; +import org.eclipse.uml2.uml.Interface; +import org.eclipse.uml2.uml.OpaqueBehavior; +import org.eclipse.uml2.uml.Operation; +import org.eclipse.uml2.uml.TemplateBinding; +import org.eclipse.uml2.uml.Type; + +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; + } + Interface passedActualIntf = (Interface)actual; + Operation last = null; + EList<Element> removalList = new BasicEList<Element>(); + for(Operation intfOperation : passedActualIntf.getAllOperations()) { + for(Element removalElement : removalList) { + copy.removeForCopy(removalElement); // enable subsequent instantiations + } + removalList.clear(); + last = BindingUtils.instantiateOperation(copy, intfOperation, operation, boundClass); + removalList.add(operation); + for(Behavior method : operation.getMethods()) { + if(method instanceof OpaqueBehavior) { + try { + Behavior newBehavior = + BindingUtils.instantiateBehavior(copy, intfOperation, (OpaqueBehavior)method); + newBehavior.setSpecification(last); + } + catch (TransformationException e) { + Activator.log.error(e);; + } + // removalList.add(method); + copy.removeForCopy(method); // enable subsequent instantiations + } + } + } + // from a logical viewpoint, we need to copy parameters & name, but not the + // operation identity. + copy.put(operation, last); + return last; + /* + else { // not LOOP_OPERATIONS + Operation newOperation = instantiateOperation(actual, template, operation, boundClass); + for(Behavior method : operation.getMethods()) { + if(method instanceof OpaqueBehavior) { + Behavior newBehavior = + instantiateBehavior(actual, template, (OpaqueBehavior)method); + newBehavior.setSpecification(newOperation); + } + } + return newOperation; + */ + } + 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; + } + 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$ + } + } + return newLiteral; + } + return null; + } + + @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/iconfigurators/AnimServiceConfigurator.java b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src/org/eclipse/papyrus/qompass/modellibs/core/iconfigurators/AnimServiceConfigurator.java index 64a82385204..21bc29e0e2e 100644 --- a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src/org/eclipse/papyrus/qompass/modellibs/core/iconfigurators/AnimServiceConfigurator.java +++ b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src/org/eclipse/papyrus/qompass/modellibs/core/iconfigurators/AnimServiceConfigurator.java @@ -17,7 +17,6 @@ package org.eclipse.papyrus.qompass.modellibs.core.iconfigurators; import org.eclipse.emf.common.util.EList; import org.eclipse.papyrus.qompass.designer.core.deployment.AllocUtils; import org.eclipse.papyrus.qompass.designer.core.extensions.IInstanceConfigurator; -import org.eclipse.papyrus.qompass.designer.core.transformations.ContainerContext; import org.eclipse.papyrus.qompass.designer.core.transformations.TransformationRTException; import org.eclipse.uml2.uml.InstanceSpecification; import org.eclipse.uml2.uml.NamedElement; @@ -51,9 +50,9 @@ public class AnimServiceConfigurator implements IInstanceConfigurator { * @param context * container context */ - public void configureInstance(InstanceSpecification instance, Property componentPart, ContainerContext context) + public void configureInstance(InstanceSpecification instance, Property componentPart, InstanceSpecification parentInstance) { - EList<InstanceSpecification> nodes = AllocUtils.getAllNodesOrThreadsParent(context.smIS); + EList<InstanceSpecification> nodes = AllocUtils.getAllNodesOrThreadsParent(parentInstance); if (nodes.size() > 0) { InstanceSpecification node = nodes.get(0); NamedElement animService = node.getNearestPackage().getMember(eclipseAnimService); diff --git a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src/org/eclipse/papyrus/qompass/modellibs/core/iconfigurators/CallEventConfigurator.java b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src/org/eclipse/papyrus/qompass/modellibs/core/iconfigurators/CallEventConfigurator.java index a342c2a9fbb..ca3a437adb0 100644 --- a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src/org/eclipse/papyrus/qompass/modellibs/core/iconfigurators/CallEventConfigurator.java +++ b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src/org/eclipse/papyrus/qompass/modellibs/core/iconfigurators/CallEventConfigurator.java @@ -16,7 +16,6 @@ package org.eclipse.papyrus.qompass.modellibs.core.iconfigurators; import org.eclipse.papyrus.qompass.designer.core.deployment.DepPlanUtils; import org.eclipse.papyrus.qompass.designer.core.extensions.IInstanceConfigurator; -import org.eclipse.papyrus.qompass.designer.core.transformations.ContainerContext; import org.eclipse.uml2.uml.InstanceSpecification; import org.eclipse.uml2.uml.Property; @@ -47,9 +46,9 @@ public class CallEventConfigurator implements IInstanceConfigurator { * @param context * container context */ - public void configureInstance(InstanceSpecification instance, Property componentPart, ContainerContext context) + public void configureInstance(InstanceSpecification instance, Property componentPart, InstanceSpecification parentInstance) { - if(context != null) { + if(parentInstance != null) { // make sure that there is an enum par port // String literalName = "port_" + UMLTool.varName(context.port); //$NON-NLS-1$ |