Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnsgar Radermacher2014-01-27 16:23:48 +0000
committerAnsgar Radermacher2014-01-27 16:24:32 +0000
commit0fd966709954db55bff763e2212a6a92acab3183 (patch)
treecb4bfbf4f271d8ff99525943f0e3ec60db4acfb3 /extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src
parentc04a4bd96accb96c4c9aca0558a4c2561f6d8a12 (diff)
downloadorg.eclipse.papyrus-0fd966709954db55bff763e2212a6a92acab3183.tar.gz
org.eclipse.papyrus-0fd966709954db55bff763e2212a6a92acab3183.tar.xz
org.eclipse.papyrus-0fd966709954db55bff763e2212a6a92acab3183.zip
426720 - [QDesginer] Need to re-target connectors after template binding
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/acceleo/StateMachine.mtl4
-rw-r--r--extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src/org/eclipse/papyrus/qompass/modellibs/core/acceleo/StateMachineUtil.java37
-rw-r--r--extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src/org/eclipse/papyrus/qompass/modellibs/core/acceleo/StateMachineUtil.mtl7
-rw-r--r--extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src/org/eclipse/papyrus/qompass/modellibs/core/acceleo/acceptableEvents.mtl34
-rw-r--r--extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src/org/eclipse/papyrus/qompass/modellibs/core/iconfigurators/AnimServiceConfigurator.java5
5 files changed, 63 insertions, 24 deletions
diff --git a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src/org/eclipse/papyrus/qompass/modellibs/core/acceleo/StateMachine.mtl b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src/org/eclipse/papyrus/qompass/modellibs/core/acceleo/StateMachine.mtl
index 4dd53ec0045..99c915d4197 100644
--- a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src/org/eclipse/papyrus/qompass/modellibs/core/acceleo/StateMachine.mtl
+++ b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src/org/eclipse/papyrus/qompass/modellibs/core/acceleo/StateMachine.mtl
@@ -5,11 +5,11 @@
[import org::eclipse::papyrus::qompass::designer::core::acceleo::UMLTool/]
[import org::eclipse::papyrus::qompass::modellibs::core::acceleo::acceptableEvents/]
-[template public StateMachine(clazz : Class)]
+[template public StateMachine(clazz : BehavioredClassifier)]
// processEvents body - generated by Qompass
//
-// supports ports [for (port : Port | clazz.ownedPort)] [literal('PortEnum_'+clazz.name, 'port_'+port.name)/] [/for]
+// supports ports [if clazz.oclIsKindOf(Class)][for (port : Port | clazz.oclAsType(Class).ownedPort)] [literal('PortEnum_'+clazz.name, 'port_'+port.name)/] [/for][/if]
TRACEpr (AO);
PR ("IN [clazz.name/]::checkPreCond()" << showI);
diff --git a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src/org/eclipse/papyrus/qompass/modellibs/core/acceleo/StateMachineUtil.java b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src/org/eclipse/papyrus/qompass/modellibs/core/acceleo/StateMachineUtil.java
index 4d2ec77d755..6c8efd7ce81 100644
--- a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src/org/eclipse/papyrus/qompass/modellibs/core/acceleo/StateMachineUtil.java
+++ b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src/org/eclipse/papyrus/qompass/modellibs/core/acceleo/StateMachineUtil.java
@@ -16,9 +16,11 @@ package org.eclipse.papyrus.qompass.modellibs.core.acceleo;
import org.eclipse.papyrus.qompass.designer.core.Utils;
import org.eclipse.papyrus.qompass.designer.core.acceleo.UMLTool;
+import org.eclipse.papyrus.qompass.designer.core.templates.TemplateUtils;
import org.eclipse.papyrus.qompass.designer.core.transformations.TransformationContext;
import org.eclipse.uml2.uml.Package;
import org.eclipse.uml2.uml.PackageableElement;
+import org.eclipse.uml2.uml.TemplateBinding;
import org.eclipse.uml2.uml.Type;
@@ -30,31 +32,44 @@ public class StateMachineUtil {
* This is required by the state machine template which needs to access operation IDs
* provided by the call interceptor.
*
- * TODO: seems not very clean: why hardcoded operationIDs? precondition: package with suitable
- * postfix must have been created
- *
- * @param actual
+ * @param actual The actual for template binding
* @return
*/
public static Package boundPackageRef(Type actual) {
- String suffix = "_" + actual.getName();
for(Package nestedPkg : Utils.getTop(actual).getNestedPackages()) {
- if(nestedPkg.getName().endsWith(suffix)) {
- return nestedPkg;
+ if(nestedPkg.getTemplateBindings().size() > 0) {
+ TemplateBinding binding = nestedPkg.getTemplateBindings().get(0);
+ if (actual == TemplateUtils.getFirstActualFromBinding(binding)) {
+ return nestedPkg;
+ }
}
}
return null;
}
-
+
/**
* Declares a dependency from the current classifier which is produced by template instantiation
- * to the element "OperationIDs, if found within the passed package.
- *
+ * to the element (enum) "OperationIDs", if found within the passed package.
+ * Called by Acceleo script "acceptableEvents.mtl".
* @param pkg
* @return
*/
public static void declareDependencyToOperationIDs(Package pkg) {
- PackageableElement type = pkg.getPackagedElement("OperationIDs");
+ PackageableElement type = pkg.getPackagedElement("OperationIDs"); //$NON-NLS-1$
+ if(type instanceof Type) {
+ UMLTool.declareDependency(TransformationContext.classifier, (Type)type);
+ }
+ }
+
+ /**
+ * Declares a dependency from the current classifier which is produced by template instantiation
+ * to the element (enum) "SignalIDs", if found within the passed package.
+ * Called by Acceleo script "acceptableEvents.mtl".
+ * @param pkg the package in which an enumeration is looked up
+ * @return
+ */
+ public static void declareDependencyToSignalIDs(Package pkg) {
+ PackageableElement type = pkg.getPackagedElement("SignalIDs"); //$NON-NLS-1$
if(type instanceof Type) {
UMLTool.declareDependency(TransformationContext.classifier, (Type)type);
}
diff --git a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src/org/eclipse/papyrus/qompass/modellibs/core/acceleo/StateMachineUtil.mtl b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src/org/eclipse/papyrus/qompass/modellibs/core/acceleo/StateMachineUtil.mtl
index b61f5800ab7..39dd285efdf 100644
--- a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src/org/eclipse/papyrus/qompass/modellibs/core/acceleo/StateMachineUtil.mtl
+++ b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src/org/eclipse/papyrus/qompass/modellibs/core/acceleo/StateMachineUtil.mtl
@@ -6,7 +6,14 @@
'boundPackageRef(org.eclipse.uml2.uml.Type)',
Sequence{actual}) /]
+[comment called by acceptableEvents.mtl/]
[query public declareDependencyToOperationIDs(pkg : Package) : OclVoid =
invoke('org.eclipse.papyrus.qompass.modellibs.core.acceleo.StateMachineUtil',
'declareDependencyToOperationIDs(org.eclipse.uml2.uml.Package)',
Sequence{pkg}) /]
+
+[comment called by acceptableEvents.mtl/]
+[query public declareDependencyToSignalIDs(pkg : Package) : OclVoid =
+ invoke('org.eclipse.papyrus.qompass.modellibs.core.acceleo.StateMachineUtil',
+ 'declareDependencyToSignalIDs(org.eclipse.uml2.uml.Package)',
+ Sequence{pkg}) /]
diff --git a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src/org/eclipse/papyrus/qompass/modellibs/core/acceleo/acceptableEvents.mtl b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src/org/eclipse/papyrus/qompass/modellibs/core/acceleo/acceptableEvents.mtl
index 3cfe740f28d..5b26fad3114 100644
--- a/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src/org/eclipse/papyrus/qompass/modellibs/core/acceleo/acceptableEvents.mtl
+++ b/extraplugins/qompass-designer/org.eclipse.papyrus.qompass.modellibs.core/src/org/eclipse/papyrus/qompass/modellibs/core/acceleo/acceptableEvents.mtl
@@ -2,16 +2,26 @@
[import org::eclipse::papyrus::qompass::modellibs::core::acceleo::TransitionService /]
[import org::eclipse::papyrus::qompass::modellibs::core::acceleo::StateMachineUtil /]
[import org::eclipse::papyrus::qompass::designer::core::acceleo::UMLTool /]
+[import org::eclipse::papyrus::qompass::designer::core::acceleo::EnumService /]
[import org::eclipse::papyrus::qompass::designer::vsl::ParseVSL /]
[comment produce a call event trigger label (TODO) /]
+[comment
+Pass the actual to which the port is bound. In case of a CallEvent, pass the implemented interface
+(Not the class to which the state machine is bound)
+/]
[template public cetrigger(operation: Operation) post(trim())]
[boundPackageRef(operation.implementsInterface()).qualifiedName/]::ID_[name/]
[comment declare dependency to OperationIDs enumeration /]
[boundPackageRef(operation.implementsInterface()).declareDependencyToOperationIDs() /]
[/template]
+[comment
+Use service for global enumerations/]
+[template public setrigger(trigger: Trigger) post(trim())]
+ [literal('SignalEvents', 'SIG_' + trigger.event.oclAsType(SignalEvent).signal.name)/]
+[/template]
[template public acceptableEvents(state: State)]
@@ -42,7 +52,8 @@
[for (transition : Transition | state.outgoing)]
[comment big restriction: will only analyse first of possibly multiple triggers/]
- [if (transition.trigger->asSequence()->first().event.oclIsKindOf(TimeEvent))]
+ [let trigger : Trigger = transition.trigger->asSequence()->first()]
+ [if (trigger.event.oclIsKindOf(TimeEvent))]
// transition [transition.name/] - trigger: TimeEvent (there should be at most one outgoing timed transition per state).
if (event.operationID == core::ContainerServices::EventPool::ID_TIMEOUT) {
newState = STATE_[transition.target.name/];
@@ -50,23 +61,28 @@
[/if]
}
[/if]
- [if (transition.trigger->asSequence()->first().event.oclIsKindOf(CallEvent))]
- // transition [name/] - trigger: CallEvent, operation [transition.trigger.event.oclAsType(CallEvent).operation.name/]
- if (event.operationID == [cetrigger(transition.trigger->asSequence()->first().event.oclAsType(CallEvent).operation)/]) {
+ [if (trigger.event.oclIsKindOf(CallEvent))]
+ // transition [name/] - trigger: CallEvent ([trigger.event.name/]), operation [trigger.event.oclAsType(CallEvent).operation.name/]
+ if (event.operationID == [cetrigger(trigger.event.oclAsType(CallEvent).operation)/]) {
newState = STATE_[transition.target.name/];
[if not (transition.effect = null)] executor->[state.containingStateMachine().name/]_[transition.name/]_[transition.effect.name/]();
[/if]
}
[/if]
- [if (transition.trigger->asSequence()->first().event.oclIsKindOf(SignalEvent))]
- // transition [name/] - trigger: SignalEvent, signal [transition.trigger.event.oclAsType(SignalEvent).signal.name/]
- if (event.operationID == SIG_[transition.trigger.event.oclAsType(SignalEvent).signal.name/]) {
- newState = STATE_[transition.target.name/]) ;
-[if not (transition.effect = null)] executor->[state.containingStateMachine().name/]_[transition.name/]_[transition.effect.name/]();
+ [if (trigger.event.oclIsKindOf(SignalEvent))]
+ [let signalEvent : SignalEvent = trigger.event.oclAsType(SignalEvent)]
+ // transition [name/] - trigger: SignalEvent ([signalEvent.name/]), signal [signalEvent.signal.name/]
+ if (event.operationID == [setrigger(trigger)/]) {
+ newState = STATE_[transition.target.name/];
+[if not (transition.effect = null)] [if signalEvent.signal.attribute->size() > 0]void* data = &event.params;[/if]
+ executor->[state.containingStateMachine().name/]_[transition.name/]_[transition.effect.name/]([if signalEvent.signal.attribute->size() > 0]data[/if]);
+
[/if]
// ok = EvQUEUE ;
}
+ [/let]
[/if]
+ [/let]
[/for]
if (newState != m_currentState) {
m_currentState = newState;
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 21bc29e0e2e..5ac32b50f4e 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.TransformationRTException;
import org.eclipse.uml2.uml.InstanceSpecification;
import org.eclipse.uml2.uml.NamedElement;
import org.eclipse.uml2.uml.Property;
@@ -55,13 +54,15 @@ public class AnimServiceConfigurator implements IInstanceConfigurator {
EList<InstanceSpecification> nodes = AllocUtils.getAllNodesOrThreadsParent(parentInstance);
if (nodes.size() > 0) {
InstanceSpecification node = nodes.get(0);
+ // problem: instance specification is within intermediate model, thus incomplete.
+ // option: explicitly pre-create singletons (and allocate these?)
NamedElement animService = node.getNearestPackage().getMember(eclipseAnimService);
if (animService instanceof InstanceSpecification) {
AllocUtils.allocate(instance, (InstanceSpecification)animService);
return;
}
}
- throw new TransformationRTException(String.format("Cannot find node <%s> in platform definition", eclipseAnimService));
+ // throw new TransformationRTException(String.format("Cannot find node <%s> in platform definition", eclipseAnimService));
}
}

Back to the top