Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormgolubev2011-06-01 11:29:24 -0400
committermgolubev2011-06-01 11:29:24 -0400
commit11b09b81773692d137c95a10ee25d467405fcf6c (patch)
tree3c759357afe54d76fb0718eb8202af0482ff7c9f
parent4d88bd20f6aedae924a5cefde2f3a08990ca375e (diff)
downloadorg.eclipse.gmf-tooling-11b09b81773692d137c95a10ee25d467405fcf6c.tar.gz
org.eclipse.gmf-tooling-11b09b81773692d137c95a10ee25d467405fcf6c.tar.xz
org.eclipse.gmf-tooling-11b09b81773692d137c95a10ee25d467405fcf6c.zip
[346952] - Can't generate the diagrams with RC2 -v20110601-2359
UnlimitedNatural may not be casted to Integer, use explicit comparison with * + workarounds around #347960
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates/xpt/OclMigrationProblems.qvto28
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/ViewmapAttributesUtils.qvto9
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/commands/CreateNodeCommand.xpt15
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/editpolicies/BaseItemSemanticEditPolicy.xpt21
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates/xpt/editor/GenDiagram.qvto2
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates/xpt/navigator/Utils.qvto6
6 files changed, 59 insertions, 22 deletions
diff --git a/plugins/org.eclipse.gmf.codegen/templates/xpt/OclMigrationProblems.qvto b/plugins/org.eclipse.gmf.codegen/templates/xpt/OclMigrationProblems.qvto
new file mode 100644
index 000000000..10ec22640
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates/xpt/OclMigrationProblems.qvto
@@ -0,0 +1,28 @@
+modeltype gmfgen uses "http://www.eclipse.org/gmf/2009/GenModel";
+modeltype ecore uses "http://www.eclipse.org/emf/2002/Ecore";
+
+library OclMigrationProblems;
+
+helper isUnbounded(typedElement : ecore::ETypedElement) : Boolean {
+ return typedElement.upperBound = *
+}
+
+helper isSingleValued(typedElement : ecore::ETypedElement) : Boolean {
+ return typedElement.upperBound = 1
+}
+
+helper firstOrNull(oSet : OrderedSet(gmfgen::DefaultSizeAttributes)) : gmfgen::DefaultSizeAttributes {
+ return (if oSet->isEmpty() then null else oSet->first() endif)
+}
+
+helper firstOrNull(oSet : OrderedSet(gmfgen::ResizeConstraints)) : gmfgen::ResizeConstraints {
+ return (if oSet->isEmpty() then null else oSet->first() endif)
+}
+
+helper firstOrNull(oSet : OrderedSet(gmfgen::LabelOffsetAttributes)) : gmfgen::LabelOffsetAttributes {
+ return (if oSet->isEmpty() then null else oSet->first() endif)
+}
+
+helper undefinedAsFalse(param : Boolean) : Boolean {
+ return if param.oclIsUndefined() then false else param endif
+}
diff --git a/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/ViewmapAttributesUtils.qvto b/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/ViewmapAttributesUtils.qvto
index 1168e0160..484efb8df 100644
--- a/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/ViewmapAttributesUtils.qvto
+++ b/plugins/org.eclipse.gmf.codegen/templates/xpt/diagram/ViewmapAttributesUtils.qvto
@@ -9,6 +9,9 @@
* Contributors:
* Dmitry Stadnik (Borland) - initial API and implementation
*/
+
+import xpt.OclMigrationProblems;
+
modeltype gmfgen uses "http://www.eclipse.org/gmf/2009/GenModel";
library ViewmapAttributesUtils;
@@ -34,11 +37,11 @@ helper gmfgen::Viewmap::canUseShapeStyle() : Boolean {
}
helper getResizeConstraints(viewmap : gmfgen::Viewmap) : gmfgen::ResizeConstraints {
- return (if null = viewmap then null else viewmap.attributes[gmfgen::ResizeConstraints]->first() endif)
+ return (if null = viewmap then null else firstOrNull(viewmap.attributes[gmfgen::ResizeConstraints]) endif)
}
helper getDefaultSizeAttributes(viewmap : gmfgen::Viewmap) : gmfgen::DefaultSizeAttributes {
- return (if null = viewmap then null else viewmap.attributes[gmfgen::DefaultSizeAttributes]->first() endif)
+ return (if null = viewmap then null else firstOrNull(viewmap.attributes[gmfgen::DefaultSizeAttributes]) endif)
}
helper defaultSizeWidth(viewmap : gmfgen::Viewmap, defaultValue : Integer) : Integer {
@@ -50,7 +53,7 @@ helper defaultSizeHeight(viewmap : gmfgen::Viewmap, defaultValue : Integer) : In
}
helper getLabelOffsetAttributes(viewmap : gmfgen::Viewmap) : gmfgen::LabelOffsetAttributes {
- return (if null = viewmap then null else viewmap.attributes[gmfgen::LabelOffsetAttributes]->first() endif)
+ return (if null = viewmap then null else firstOrNull(viewmap.attributes[gmfgen::LabelOffsetAttributes]) endif)
}
helper labelOffsetX(viewmap : gmfgen::Viewmap, defaultValue : Integer) : Integer {
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 92c1472c0..252d3cec4 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
@@ -12,6 +12,7 @@
«IMPORT 'http://www.eclipse.org/gmf/2009/GenModel'»
«EXTENSION xpt::diagram::Utils»
+«EXTENSION xpt::OclMigrationProblems»
«DEFINE CreateNodeCommand FOR gmfgen::GenNode-»
«EXPAND xpt::Common::copyright FOR getDiagram().editorGen-»
@@ -101,22 +102,22 @@ protected org.eclipse.emf.ecore.EObject getElementToEdit() {
«ENDDEFINE»
«DEFINE canExecute_Normal FOR gmfgen::TypeModelFacet-»
-«IF containmentMetaFeature.ecoreFeature.upperBound.oclAsType(Integer) > 0 or (childMetaFeature <> containmentMetaFeature and childMetaFeature.ecoreFeature.upperBound.oclAsType(Integer) > 0)-»
+«IF not isUnbounded(containmentMetaFeature.ecoreFeature) or (childMetaFeature <> containmentMetaFeature and not isUnbounded(childMetaFeature.ecoreFeature))-»
«EXPAND MetaModel::DeclareAndAssign('container', 'getElementToEdit()') FOR containmentMetaFeature.genClass-»
- «IF containmentMetaFeature.ecoreFeature.upperBound.oclAsType(Integer) > 0-»
- «IF containmentMetaFeature.ecoreFeature.upperBound.oclAsType(Integer) = 1»
+ «IF not isUnbounded(containmentMetaFeature.ecoreFeature)-»
+ «IF isSingleValued(containmentMetaFeature.ecoreFeature)»
if («EXPAND MetaModel::getFeatureValue('container', containmentMetaFeature.genClass) FOR containmentMetaFeature» != null) {
«ELSE-»
- if («EXPAND MetaModel::getFeatureValue('container', containmentMetaFeature.genClass) FOR containmentMetaFeature».size() >= «containmentMetaFeature.ecoreFeature.upperBound.oclAsType(Integer)») {
+ if («EXPAND MetaModel::getFeatureValue('container', containmentMetaFeature.genClass) FOR containmentMetaFeature».size() >= «containmentMetaFeature.ecoreFeature.upperBound») {
«ENDIF-»
return false;
}
«ENDIF-»
- «IF childMetaFeature <> containmentMetaFeature and childMetaFeature.ecoreFeature.upperBound.oclAsType(Integer) > 0-»
- «IF childMetaFeature.ecoreFeature.upperBound.oclAsType(Integer) = 1-»
+ «IF childMetaFeature <> containmentMetaFeature and not isUnbounded(childMetaFeature.ecoreFeature)-»
+ «IF isSingleValued(childMetaFeature.ecoreFeature)-»
if («EXPAND MetaModel::getFeatureValue('container', containmentMetaFeature.genClass) FOR childMetaFeature» != null) {
«ELSE-»
- if («EXPAND MetaModel::getFeatureValue('container', containmentMetaFeature.genClass) FOR childMetaFeature».size() >= «childMetaFeature.ecoreFeature.upperBound.oclAsType(Integer)») {
+ if («EXPAND MetaModel::getFeatureValue('container', containmentMetaFeature.genClass) FOR childMetaFeature».size() >= «childMetaFeature.ecoreFeature.upperBound») {
«ENDIF-»
return false;
}
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 7525f462f..c85ded6fe 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
@@ -16,6 +16,7 @@
«EXTENSION xpt::diagram::editpolicies::Utils»
«EXTENSION xpt::diagram::Utils»
«EXTENSION xpt::GenModelUtils»
+«EXTENSION xpt::OclMigrationProblems»
«DEFINE BaseItemSemanticEditPolicy FOR gmfgen::GenDiagram-»
«EXPAND xpt::Common::copyright FOR editorGen-»
@@ -408,11 +409,11 @@ public boolean canCreate«getUniqueIdentifier()»(«EXPAND canCreateParameters F
«DEFINE checkEMFConstraints FOR gmfgen::LinkModelFacet»«ERROR 'Unrecognized link model facet in checkEMFConstraints: ' + self.repr()»«ENDDEFINE»
«DEFINE checkEMFConstraints FOR gmfgen::TypeLinkModelFacet-»
- «LET childMetaFeature <> containmentMetaFeature and childMetaFeature.ecoreFeature.upperBound.oclAsType(Integer) > 0 AS checkChildFeatureUpperBound-»
- «IF containmentMetaFeature.ecoreFeature.upperBound.oclAsType(Integer) > 0 or checkChildFeatureUpperBound-»
+ «LET childMetaFeature <> containmentMetaFeature and not isUnbounded(childMetaFeature.ecoreFeature) AS checkChildFeatureBounds-»
+ «IF not isUnbounded(containmentMetaFeature.ecoreFeature) or checkChildFeatureBounds-»
if («getContainerVariable(self)» != null) {
«EXPAND checkEMFConstraints(self) FOR containmentMetaFeature-»
- «IF checkChildFeatureUpperBound-»
+ «IF checkChildFeatureBounds-»
«EXPAND checkEMFConstraints(self) FOR childMetaFeature-»
«ENDIF-»
}
@@ -421,7 +422,7 @@ if («getContainerVariable(self)» != null) {
«ENDDEFINE»
«DEFINE checkEMFConstraints(modelFacet : gmfgen::TypeLinkModelFacet) FOR genmodel::GenFeature-»
-«IF ecoreFeature.upperBound.oclAsType(Integer) > 0-»
+«IF not isUnbounded(ecoreFeature)-»
if («EXPAND featureBoundComparator(getContainerVariable(modelFacet), modelFacet.getSourceType())») {
return false;
}
@@ -448,14 +449,14 @@ if (target != null && («EXPAND featureBoundsConditionClause('target', getTarget
«DEFINE featureBoundsConditionClause(targetVar : String, targetType : genmodel::GenClass) FOR genmodel::GenFeature-»
«REM»Checking upper bounds if was specified in MM«ENDREM»«-»
-«IF ecoreFeature.upperBound.oclAsType(Integer) > 0»«EXPAND featureBoundComparator(targetVar, targetType)»«ENDIF-»
-«REM»Checking uniqueness in addition if upper bounds > 1«ENDREM»«-»
-«IF ecoreFeature.upperBound.oclAsType(Integer) > 1» || «ENDIF-»
-«REM»Checking uniqueness in if upper bounds > 1 or < 0«ENDREM»«-»
-«IF ecoreFeature.upperBound.oclAsType(Integer) <> 1»«EXPAND featureUniquenessComparator(targetVar, targetType)»«ENDIF»
+«IF not isUnbounded(ecoreFeature)»«EXPAND featureBoundComparator(targetVar, targetType)»«ENDIF-»
+«REM»Checking uniqueness in addition if upper bounds != 1«ENDREM»«-»
+«IF not isSingleValued(ecoreFeature) and not isUnbounded(ecoreFeature)» || «ENDIF-»
+«REM»Checking uniqueness in if upper bounds !- 1«ENDREM»«-»
+«IF not isSingleValued(ecoreFeature)»«EXPAND featureUniquenessComparator(targetVar, targetType)»«ENDIF»
«ENDDEFINE»
-«DEFINE featureBoundComparator(featureVar : String, featureVarGenClass : genmodel::GenClass) FOR genmodel::GenFeature»«EXPAND MetaModel::getFeatureValue(featureVar, featureVarGenClass)»«IF ecoreFeature.upperBound.oclAsType(Integer) = 1» != null«ELSE».size() >= «ecoreFeature.upperBound.oclAsType(Integer)»«ENDIF»«ENDDEFINE»
+«DEFINE featureBoundComparator(featureVar : String, featureVarGenClass : genmodel::GenClass) FOR genmodel::GenFeature»«EXPAND MetaModel::getFeatureValue(featureVar, featureVarGenClass)»«IF isSingleValued(ecoreFeature)» != null«ELSE».size() >= «ecoreFeature.upperBound»«ENDIF»«ENDDEFINE»
«DEFINE featureUniquenessComparator(featureVar : String, featureVarGenClass : genmodel::GenClass) FOR genmodel::GenFeature»«EXPAND MetaModel::getFeatureValue(featureVar, featureVarGenClass) FOR self».contains(target)«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates/xpt/editor/GenDiagram.qvto b/plugins/org.eclipse.gmf.codegen/templates/xpt/editor/GenDiagram.qvto
index 267698ad5..68a5d8ec7 100644
--- a/plugins/org.eclipse.gmf.codegen/templates/xpt/editor/GenDiagram.qvto
+++ b/plugins/org.eclipse.gmf.codegen/templates/xpt/editor/GenDiagram.qvto
@@ -35,5 +35,5 @@ helper getDocumentRootSetFeature(genDiagram : gmfgen::GenDiagram) : genmodel::Ge
}
helper isDocRootSetFeature(gf : genmodel::GenFeature, eType : ecore::EClass) : Boolean {
- return not isListType(gf) and gf.ecoreFeature.changeable and (-2 = gf.ecoreFeature.upperBound.oclAsType(Integer) and (gf.ecoreFeature.oclAsType(ecore::EObject).eClass().name = 'EReference' and gf.ecoreFeature.eType.oclAsType(ecore::EClass).isSuperTypeOf(eType)))
+ return not isListType(gf) and gf.ecoreFeature.changeable and (-2 = gf.ecoreFeature.upperBound and (gf.ecoreFeature.oclAsType(ecore::EObject).eClass().name = 'EReference' and gf.ecoreFeature.eType.oclAsType(ecore::EClass).isSuperTypeOf(eType)))
}
diff --git a/plugins/org.eclipse.gmf.codegen/templates/xpt/navigator/Utils.qvto b/plugins/org.eclipse.gmf.codegen/templates/xpt/navigator/Utils.qvto
index d8fe1f64e..00d1e755b 100644
--- a/plugins/org.eclipse.gmf.codegen/templates/xpt/navigator/Utils.qvto
+++ b/plugins/org.eclipse.gmf.codegen/templates/xpt/navigator/Utils.qvto
@@ -11,6 +11,7 @@
*/
import gmf.CodeGenerationUtils;
+import xpt.OclMigrationProblems;
modeltype gmfgen uses "http://www.eclipse.org/gmf/2009/GenModel";
modeltype genmodel uses "http://www.eclipse.org/emf/2002/GenModel";
@@ -49,7 +50,10 @@ helper getNavigatorReference(groupName : String, childReferences : Sequence(gmfg
}
helper getChildReferencesFrom(navigator : gmfgen::GenNavigator, parent : gmfgen::GenCommonBase) : Sequence(gmfgen::GenNavigatorChildReference) {
- return navigator.childReferences->select(r | parent.visualID = r.parent.visualID)->asSequence()
+ return if parent.oclIsUndefined()
+ then Sequence{}
+ else navigator.childReferences->select(r | undefinedAsFalse(parent.visualID = r.parent.visualID))->asSequence()
+ endif
}
helper getChildReferencesTo(navigator : gmfgen::GenNavigator, child : gmfgen::GenCommonBase) : Sequence(gmfgen::GenNavigatorChildReference) {

Back to the top