Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates/MetaModel.xpt36
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/commands/CreateLinkCommand.xpt10
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/commands/CreateLinkUtils.xpt8
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/commands/CreateNodeCommand.xpt4
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/commands/CreateRefLinkCommand.xpt6
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/commands/ReorientLinkUtils.xpt15
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates/xpt/editor/DiagramEditorUtil.xpt2
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates/xpt/providers/ElementInitializers.xpt6
8 files changed, 42 insertions, 45 deletions
diff --git a/plugins/org.eclipse.gmf.codegen/templates/MetaModel.xpt b/plugins/org.eclipse.gmf.codegen/templates/MetaModel.xpt
index b42ee8d60..98e0daaf8 100644
--- a/plugins/org.eclipse.gmf.codegen/templates/MetaModel.xpt
+++ b/plugins/org.eclipse.gmf.codegen/templates/MetaModel.xpt
@@ -69,15 +69,39 @@ false == «EXPAND IsInstance(accessor)»«ENDDEFINE»
«ENDIF-»
«ENDDEFINE»
-«DEFINE setFeatureValue(String containerVar, genmodel::GenClass containerGenClass, String valueVar) FOR genmodel::GenFeature-»
-«EXPAND setFeatureValue(containerVar, containerGenClass, valueVar, false)»«ENDDEFINE»
+«DEFINE modifyFeature(String targetVar, GenClass targetType, String value) FOR GenFeature-»
+«IF isListType()-»
+«EXPAND getFeatureValue(targetVar, targetType)».add(«value»);«-»
+«ELSE-»
+«EXPAND setFeatureValue(targetVar, targetType, value)»;«-»
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE replaceFeatureValue(String targetVar, GenClass targetType, String oldValue, String newValue) FOR GenFeature-»
+«IF isListType()-»
+ «EXPAND getFeatureValue(targetVar, targetType)».remove(«oldValue»);
+«ENDIF-»
+ «EXPAND modifyFeature(targetVar, targetType, newValue)-»
+«ENDDEFINE»
+
+«DEFINE moveFeatureValue(String oldTarget, String newTarget, GenClass targetType, String value) FOR GenFeature-»
+«IF isListType()-»
+ «EXPAND getFeatureValue(oldTarget, targetType)».remove(«value»);
+«ELSE-»
+ «EXPAND setFeatureValue(oldTarget, targetType, "null")»;
+«ENDIF-»
+ «EXPAND modifyFeature(newTarget, targetType, value)-»
+«ENDDEFINE»
+
+«DEFINE setFeatureValue(String targetVar, genmodel::GenClass targetType, String valueVar) FOR genmodel::GenFeature-»
+«EXPAND setFeatureValue(targetVar, targetType, valueVar, false)»«ENDDEFINE»
// FIXME support list features as well, i.e. do .add() instead of eSet
-«DEFINE setFeatureValue(String containerVar, genmodel::GenClass containerGenClass, String valueVar, boolean isPlainObjectValue) FOR genmodel::GenFeature-»
-«IF isExternalInterface(containerGenClass)-»
-((org.eclipse.emf.ecore.EObject) «containerVar»).eSet(«EXPAND MetaFeature», «valueVar»)«-»
+«DEFINE setFeatureValue(String targetVar, genmodel::GenClass targetType, String valueVar, boolean isPlainObjectValue) FOR genmodel::GenFeature-»
+«IF isExternalInterface(targetType)-»
+((org.eclipse.emf.ecore.EObject) «targetVar»).eSet(«EXPAND MetaFeature», «valueVar»)«-»
«ELSE-»
-«containerVar».set«getAccessorName(this)»(«IF !isPlainObjectValue»«valueVar»«ELSE»«IF isPrimitiveType()»«EXPAND _unwrapObjectToPrimitiveValue(valueVar)»«ELSE»(«EXPAND featureTargetType») «valueVar»«ENDIF»«ENDIF»)«-»
+«targetVar».set«getAccessorName(this)»(«IF !isPlainObjectValue»«valueVar»«ELSE»«IF isPrimitiveType()»«EXPAND _unwrapObjectToPrimitiveValue(valueVar)»«ELSE»(«EXPAND featureTargetType») «valueVar»«ENDIF»«ENDIF»)«-»
«ENDIF-»
«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/commands/CreateLinkCommand.xpt b/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/commands/CreateLinkCommand.xpt
index 0c484e398..806576127 100644
--- a/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/commands/CreateLinkCommand.xpt
+++ b/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/commands/CreateLinkCommand.xpt
@@ -68,16 +68,16 @@ public class «createCommandClassName» extends org.eclipse.gmf.runtime.emf.type.c
«EXPAND xpt::Common::generatedMemberComment»
protected org.eclipse.emf.ecore.EObject doDefaultElementCreation() {
«EXPAND MetaModel::NewInstance("newElement") FOR metaClass-»
- «EXPAND CreateLinkUtils::addValue(hasContainerOtherThanSource() ? "getContainer()" : "getSource()", containmentMetaFeature.genClass, "newElement") FOR containmentMetaFeature-»
+ «EXPAND MetaModel::modifyFeature(hasContainerOtherThanSource() ? "getContainer()" : "getSource()", containmentMetaFeature.genClass, "newElement") FOR containmentMetaFeature-»
«IF sourceMetaFeature != null-»
- «EXPAND CreateLinkUtils::addValue("newElement", metaClass, "getSource()") FOR sourceMetaFeature-»
+ «EXPAND MetaModel::modifyFeature("newElement", metaClass, "getSource()") FOR sourceMetaFeature-»
«ENDIF-»
- «EXPAND CreateLinkUtils::addValue("newElement", metaClass, "getTarget()") FOR targetMetaFeature-»
+ «EXPAND MetaModel::modifyFeature("newElement", metaClass, "getTarget()") FOR targetMetaFeature-»
«IF hasExplicitChildFeature()-»
«IF sourceMetaFeature != null-»
- «EXPAND CreateLinkUtils::addValue("getContainer()", containmentMetaFeature.genClass, "newElement") FOR childMetaFeature-»
+ «EXPAND MetaModel::modifyFeature("getContainer()", containmentMetaFeature.genClass, "newElement") FOR childMetaFeature-»
«ELSE-»
- «EXPAND CreateLinkUtils::addValue("getSource()", getSourceType(), "newElement") FOR childMetaFeature-»
+ «EXPAND MetaModel::modifyFeature("getSource()", getSourceType(), "newElement") FOR childMetaFeature-»
«ENDIF-»
«ENDIF-»
«EXPAND initialize(link, "newElement")-»
diff --git a/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/commands/CreateLinkUtils.xpt b/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/commands/CreateLinkUtils.xpt
index 9226b28b5..e5b109ea5 100644
--- a/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/commands/CreateLinkUtils.xpt
+++ b/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/commands/CreateLinkUtils.xpt
@@ -153,12 +153,4 @@
«ELSE-»
super.setElementToEdit(«EXPAND MetaModel::DowncastToEObject("source") FOR containmentMetaFeature.genClass»);
«ENDIF-»
-«ENDDEFINE»
-
-«DEFINE addValue(String containerVar, genmodel::GenClass containerClass, String valueVar) FOR genmodel::GenFeature-»
-«IF isListType()-»
- «EXPAND MetaModel::getFeatureValue(containerVar, containerClass)».add(«valueVar»);
-«ELSE-»
- «EXPAND MetaModel::setFeatureValue(containerVar, containerClass, valueVar)»;
-«ENDIF-»
«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/commands/CreateNodeCommand.xpt b/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/commands/CreateNodeCommand.xpt
index ef98d179c..b9fb375eb 100644
--- a/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/commands/CreateNodeCommand.xpt
+++ b/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/commands/CreateNodeCommand.xpt
@@ -143,11 +143,11 @@ protected org.eclipse.emf.ecore.EObject doDefaultElementCreation() {
«EXPAND MetaModel::NewInstance("newElement") FOR metaClass»
«IF containmentMetaFeature != null-»
«EXPAND MetaModel::DeclareAndAssign("owner", "getElementToEdit()") FOR containmentMetaFeature.genClass»
- «EXPAND CreateLinkUtils::addValue("owner", containmentMetaFeature.genClass, "newElement") FOR containmentMetaFeature-»
+ «EXPAND MetaModel::modifyFeature("owner", containmentMetaFeature.genClass, "newElement") FOR containmentMetaFeature-»
«ENDIF»
«IF hasExplicitChildFeature(this)-»
«EXPAND MetaModel::DeclareAndAssign("childHolder", "getElementToEdit()") FOR childMetaFeature.genClass»
- «EXPAND CreateLinkUtils::addValue("childHolder", childMetaFeature.genClass, "newElement") FOR childMetaFeature»
+ «EXPAND MetaModel::modifyFeature("childHolder", childMetaFeature.genClass, "newElement") FOR childMetaFeature»
«ENDIF-»
«EXPAND initialize(node, "newElement")-»
return «EXPAND MetaModel::DowncastToEObject("newElement") FOR metaClass»;
diff --git a/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/commands/CreateRefLinkCommand.xpt b/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/commands/CreateRefLinkCommand.xpt
index defdd97e6..eeae067a7 100644
--- a/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/commands/CreateRefLinkCommand.xpt
+++ b/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/commands/CreateRefLinkCommand.xpt
@@ -55,9 +55,5 @@ public class «createCommandClassName» extends org.eclipse.gmf.runtime.emf.type.c
Code to update reference.
«ENDREM»
«DEFINE setValue FOR gmfgen::FeatureLinkModelFacet-»
- «IF metaFeature.ecoreFeature.many-»
- «EXPAND MetaModel::getFeatureValue("getSource()", getSourceType()) FOR metaFeature».add(getTarget());
- «ELSE-»
- «EXPAND MetaModel::setFeatureValue("getSource()", getSourceType(), "getTarget()") FOR metaFeature»;
- «ENDIF-»
+«EXPAND MetaModel::modifyFeature("getSource()", getSourceType(), "getTarget()") FOR metaFeature»
«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/commands/ReorientLinkUtils.xpt b/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/commands/ReorientLinkUtils.xpt
index 176dc7ff6..5e7937e73 100644
--- a/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/commands/ReorientLinkUtils.xpt
+++ b/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/commands/ReorientLinkUtils.xpt
@@ -275,23 +275,12 @@
Replace old target with the new one in the source.
«ENDREM»
«DEFINE changeTarget(String sourceVar, genmodel::GenClass sourceVarGenClass, String oldTargetVar, String newTargetVar) FOR genmodel::GenFeature-»
- «IF isListType()-»
- «EXPAND MetaModel::getFeatureValue(sourceVar, sourceVarGenClass)».remove(«oldTargetVar»);
- «EXPAND MetaModel::getFeatureValue(sourceVar, sourceVarGenClass)».add(«newTargetVar»);
- «ELSE-»
- «EXPAND MetaModel::setFeatureValue(sourceVar, sourceVarGenClass, newTargetVar)»;
- «ENDIF-»
+«EXPAND MetaModel::replaceFeatureValue(sourceVar, sourceVarGenClass, oldTargetVar, newTargetVar)»
«ENDDEFINE»
«REM»
Move target from old source to the new one.
«ENDREM»
«DEFINE changeSource(String targetVar, String oldSourceVar, String newSourceVar, genmodel::GenClass sourceVarGenClass) FOR genmodel::GenFeature-»
- «IF isListType()-»
- «EXPAND MetaModel::getFeatureValue(oldSourceVar, sourceVarGenClass)».remove(«targetVar»);
- «EXPAND MetaModel::getFeatureValue(newSourceVar, sourceVarGenClass)».add(«targetVar»);
- «ELSE-»
- «EXPAND MetaModel::setFeatureValue(oldSourceVar, sourceVarGenClass, "null")»;
- «EXPAND MetaModel::setFeatureValue(newSourceVar, sourceVarGenClass, targetVar)»;
- «ENDIF-»
+«EXPAND MetaModel::moveFeatureValue(oldSourceVar, newSourceVar, sourceVarGenClass, targetVar)»
«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates/xpt/editor/DiagramEditorUtil.xpt b/plugins/org.eclipse.gmf.codegen/templates/xpt/editor/DiagramEditorUtil.xpt
index 91e4623cc..284d75da2 100644
--- a/plugins/org.eclipse.gmf.codegen/templates/xpt/editor/DiagramEditorUtil.xpt
+++ b/plugins/org.eclipse.gmf.codegen/templates/xpt/editor/DiagramEditorUtil.xpt
@@ -256,7 +256,7 @@ public class «diagramEditorUtilClassName» {
«EXPAND MetaModel::NewInstance("docRoot") FOR getDocumentRoot()»
«LET getDocumentRootSetFeature() AS f»«IF f == null-»
docRoot.set«domainDiagramElement.ecoreClass.name»(model); // FIXME name of the set method is pure guess«ELSE-»
- «EXPAND MetaModel::setFeatureValue("docRoot", getDocumentRoot(), "model") FOR f»;«ENDIF»
+ «EXPAND MetaModel::modifyFeature("docRoot", getDocumentRoot(), "model") FOR f»;«ENDIF»
«ENDLET-»
return docRoot;
}
diff --git a/plugins/org.eclipse.gmf.codegen/templates/xpt/providers/ElementInitializers.xpt b/plugins/org.eclipse.gmf.codegen/templates/xpt/providers/ElementInitializers.xpt
index 2ad49196f..622e42d3f 100644
--- a/plugins/org.eclipse.gmf.codegen/templates/xpt/providers/ElementInitializers.xpt
+++ b/plugins/org.eclipse.gmf.codegen/templates/xpt/providers/ElementInitializers.xpt
@@ -109,11 +109,7 @@ public class ElementInitializers {
«LET getSuffixes(counters, newElementInitializers.indexOf(newElemInit)) AS initializerCounters-»
«LET getVariableName("newInstance", initializerCounters) AS newInstanceVar-»
«EXPAND MetaModel::NewInstance(newInstanceVar) FOR newElemInit.elementClass»
-«IF isListType(feature)-»
-«EXPAND MetaModel::getFeatureValue(instanceVar, instanceClass) FOR feature».add(«newInstanceVar»);
-«ELSE-»
-«EXPAND MetaModel::setFeatureValue(instanceVar, instanceClass, newInstanceVar) FOR feature»;
-«ENDIF-»
+«EXPAND MetaModel::modifyFeature(instanceVar, instanceClass, newInstanceVar) FOR feature»;
«FOREACH newElemInit.initializers AS i»«EXPAND performInit(diagramElement, newInstanceVar, newElemInit.elementClass, getSuffixes(initializerCounters, newElemInit.initializers.indexOf(i))) FOR i»«ENDFOREACH»
«ENDLET-»
«ENDLET-»

Back to the top