Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoratikhomirov2010-04-23 15:52:58 -0400
committeratikhomirov2010-04-23 15:52:58 -0400
commit556aab1cba5bccfb7d233c0be1598509f69f3660 (patch)
tree2dc2e9c4eeb43cb0a265180c16b4c40b5f7ea68e
parentb9e1ee706388b1af6513e9339cc5c31112102392 (diff)
downloadorg.eclipse.gmf-tooling-556aab1cba5bccfb7d233c0be1598509f69f3660.tar.gz
org.eclipse.gmf-tooling-556aab1cba5bccfb7d233c0be1598509f69f3660.tar.xz
org.eclipse.gmf-tooling-556aab1cba5bccfb7d233c0be1598509f69f3660.zip
refactored to use common expressions access template, also in a Java5-friendly manner
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/editpolicies/BaseItemSemanticEditPolicy.xpt4
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates/xpt/expressions/getExpression.xpt11
2 files changed, 10 insertions, 5 deletions
diff --git a/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/editpolicies/BaseItemSemanticEditPolicy.xpt b/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/editpolicies/BaseItemSemanticEditPolicy.xpt
index caa45dd3c..2b1fff338 100644
--- a/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/editpolicies/BaseItemSemanticEditPolicy.xpt
+++ b/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/editpolicies/BaseItemSemanticEditPolicy.xpt
@@ -444,8 +444,8 @@ if (target != null && («EXPAND featureBoundsConditionClause('target', getTarget
return true;
}
if («constraintFieldName» == null) {
- java.util.Map env = java.util.Collections.singletonMap(OPPOSITE_END_VAR, «EXPAND MetaModel::MetaClass FOR oppositeEndContext»);
- «constraintFieldName» = «getQualifiedClassName()».«getExpressionAccessor(valueExpr)»(«valueExpr.getBodyString()», «EXPAND MetaModel::MetaClass FOR context», env); «EXPAND xpt::Common::nonNLS»
+ java.util.Map«EXPAND CodeStyle::G2('String', 'org.eclipse.emf.ecore.EClassifier') FOR container.editorGen.diagram» env = java.util.Collections.«EXPAND CodeStyle::G2('String', 'org.eclipse.emf.ecore.EClassifier') FOR container.editorGen.diagram»singletonMap(OPPOSITE_END_VAR, «EXPAND MetaModel::MetaClass FOR oppositeEndContext»);
+ «constraintFieldName» = «EXPAND xpt::expressions::getExpression::getExpression(valueExpr, context, 'env')»;«EXPAND xpt::Common::nonNLS»
}
Object «sourceEndVar»Val = «constraintFieldName».evaluate(«sourceEndVar», java.util.Collections.singletonMap(OPPOSITE_END_VAR, «targetEndVar»));
if (false == «sourceEndVar»Val instanceof Boolean || !((Boolean) «sourceEndVar»Val).booleanValue()) {
diff --git a/plugins/org.eclipse.gmf.codegen/templates/xpt/expressions/getExpression.xpt b/plugins/org.eclipse.gmf.codegen/templates/xpt/expressions/getExpression.xpt
index 63d145476..98de181ed 100644
--- a/plugins/org.eclipse.gmf.codegen/templates/xpt/expressions/getExpression.xpt
+++ b/plugins/org.eclipse.gmf.codegen/templates/xpt/expressions/getExpression.xpt
@@ -13,11 +13,16 @@
«IMPORT 'http://www.eclipse.org/gmf/2009/GenModel'»
«IMPORT 'http://www.eclipse.org/emf/2002/GenModel'»
-«DEFINE getExpression(valueExpr : gmfgen::ValueExpression, context : genmodel::GenClassifier) FOR gmfgen::GenExpressionInterpreter-»
+«DEFINE getExpression(gmfgen::ValueExpression valueExpr, genmodel::GenClassifier context) FOR gmfgen::GenExpressionInterpreter-»
«getQualifiedClassName()».«getExpressionAccessor(valueExpr)»(«valueExpr.getBodyString()», «EXPAND MetaModel::MetaClass FOR context»)«-»
«ENDDEFINE»
// occasionally we need to use some well-known context type, i.e. String
-«DEFINE getExpression(valueExpr : gmfgen::ValueExpression, String contextMetaClassifier) FOR gmfgen::GenExpressionInterpreter-»
+«DEFINE getExpression(gmfgen::ValueExpression valueExpr, String contextMetaClassifier) FOR gmfgen::GenExpressionInterpreter-»
«getQualifiedClassName()».«getExpressionAccessor(valueExpr)»(«valueExpr.getBodyString()», «contextMetaClassifier»)«-»
-«ENDDEFINE» \ No newline at end of file
+«ENDDEFINE»
+
+// pass specific environment to obtain expression
+«DEFINE getExpression(gmfgen::ValueExpression valueExpr, genmodel::GenClassifier context, String environmentArg) FOR gmfgen::GenExpressionInterpreter-»
+«getQualifiedClassName()».«getExpressionAccessor(valueExpr)»(«valueExpr.getBodyString()», «EXPAND MetaModel::MetaClass FOR context», «environmentArg»)«-»
+«ENDDEFINE»

Back to the top