Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.gmf.codegen/templates-dynmodel.migrated')
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates-dynmodel.migrated/Facility.qvto18
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates-dynmodel.migrated/Facility.xpt157
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates-dynmodel.migrated/MetaModel.xpt113
3 files changed, 288 insertions, 0 deletions
diff --git a/plugins/org.eclipse.gmf.codegen/templates-dynmodel.migrated/Facility.qvto b/plugins/org.eclipse.gmf.codegen/templates-dynmodel.migrated/Facility.qvto
new file mode 100644
index 000000000..cca3ed16f
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates-dynmodel.migrated/Facility.qvto
@@ -0,0 +1,18 @@
+import xpt.GlobalVarOperations;
+
+modeltype genModel uses "http://www.eclipse.org/emf/2002/GenModel";
+modeltype genModel_1 uses "http://www.eclipse.org/gmf/2008/GenModel";
+
+library Facility;
+
+helper getNameToken(gp : genModel::GenPackage) : String {
+ return gp.prefix
+}
+
+helper fieldName(gp : genModel::GenPackage) : String {
+ return 'instance' + getNameToken(gp)
+}
+
+helper getDMA() : genModel_1::DynamicModelAccess {
+ return xpandGetObjectGlobalVar('DynamicModelAccess').oclAsType(genModel_1::DynamicModelAccess)
+}
diff --git a/plugins/org.eclipse.gmf.codegen/templates-dynmodel.migrated/Facility.xpt b/plugins/org.eclipse.gmf.codegen/templates-dynmodel.migrated/Facility.xpt
new file mode 100644
index 000000000..6bb9db52e
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates-dynmodel.migrated/Facility.xpt
@@ -0,0 +1,157 @@
+/*
+ * Copyright (c) 2008 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Artem Tikhomirov (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+«IMPORT 'http://www.eclipse.org/emf/2002/GenModel'»
+
+«EXTENSION Facility»
+
+«DEFINE Main FOR gmfgen::DynamicModelAccess-»
+package «packageName»;
+
+public class «className» {
+
+ «EXPAND field(self) FOREACH editorGen.getAllDomainGenPackages(false)-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private final org.eclipse.emf.ecore.EPackage ePackage;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private «className»(org.eclipse.emf.ecore.EPackage ePackage) {
+ this.ePackage = ePackage;
+ }
+
+ «EXPAND getMethod(self) FOREACH editorGen.getAllDomainGenPackages(false)-»
+
+ «EXPAND getRegistryMethod»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public boolean isInstance(Object obj, String metaClassName) {
+ org.eclipse.emf.ecore.EClass metaClass = getEClass(metaClassName);
+ return obj instanceof org.eclipse.emf.ecore.EObject && metaClass.isSuperTypeOf(((org.eclipse.emf.ecore.EObject) obj).eClass());
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.emf.ecore.EObject newInstance(String metaClassName) {
+ return this.ePackage.getEFactoryInstance().create(getEClass(metaClassName));
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.emf.ecore.EClass getEClass(String metaClassName) {
+ «EXPAND xpt::Common::_assert('metaClassName != null')-»
+ org.eclipse.emf.ecore.EClass metaClass = findMetaClass(metaClassName);
+ assertMetaClass(metaClass, metaClassName);
+ return metaClass;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.emf.ecore.EStructuralFeature getEFeature(String metaClassName, String metaFeatureName) {
+ «EXPAND xpt::Common::_assert('metaFeatureName != null')-»
+ org.eclipse.emf.ecore.EClass metaClass = getEClass(metaClassName);
+ org.eclipse.emf.ecore.EStructuralFeature f = metaClass.getEStructuralFeature(metaFeatureName);
+ assertMetaFeature(f, metaClass, metaFeatureName);
+ return f;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.emf.ecore.EAttribute getEAttribute(String metaClassName, String metaFeatureName) {
+ return (org.eclipse.emf.ecore.EAttribute) getEFeature(metaClassName, metaFeatureName);
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.emf.ecore.EReference getEReference(String metaClassName, String metaFeatureName) {
+ return (org.eclipse.emf.ecore.EReference) getEFeature(metaClassName, metaFeatureName);
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.emf.ecore.EDataType getEDataType(String metaClassName) {
+ «EXPAND xpt::Common::_assert('metaClassName != null')-»
+ org.eclipse.emf.ecore.EClassifier c = this.ePackage.getEClassifier(metaClassName);
+ if (false == c instanceof org.eclipse.emf.ecore.EDataType) {
+ return null;
+ }
+ return (org.eclipse.emf.ecore.EDataType) c;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ public org.eclipse.emf.ecore.EEnum getEEnum(String metaClassName) {
+ «EXPAND xpt::Common::_assert('metaClassName != null')-»
+ org.eclipse.emf.ecore.EClassifier c = this.ePackage.getEClassifier(metaClassName);
+ if (false == c instanceof org.eclipse.emf.ecore.EEnum) {
+ return null;
+ }
+ return (org.eclipse.emf.ecore.EEnum) c;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private org.eclipse.emf.ecore.EClass findMetaClass(String name) {
+ org.eclipse.emf.ecore.EClassifier c = this.ePackage.getEClassifier(name);
+ if (false == c instanceof org.eclipse.emf.ecore.EClass) {
+ return null;
+ }
+ return (org.eclipse.emf.ecore.EClass) c;
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment('Default implementation throws IllegalStateException if metaclass is null')»
+ private void assertMetaClass(org.eclipse.emf.ecore.EClass metaClass, String metaClassName) {
+ if (metaClass == null) {
+ throw new IllegalStateException(java.text.MessageFormat.format("Can't find class {0} in the package {1}", new Object[] {metaClassName, this.ePackage.getName()}));
+ }
+ }
+
+ «EXPAND xpt::Common::generatedMemberComment('Default implementation throws IllegalStateException if meta-feature is null')»
+ private void assertMetaFeature(org.eclipse.emf.ecore.EStructuralFeature metaFeature, org.eclipse.emf.ecore.EClass metaClass, String featureName) {
+ if (metaFeature == null) {
+ throw new IllegalStateException(java.text.MessageFormat.format("Can't find feature {0} of class {1} in the package {2}", new Object[] {featureName, metaClass.getName(), this.ePackage.getName()}));
+ }
+ }
+
+ «EXPAND initMethod FOREACH editorGen.getAllDomainGenPackages(false)-»
+«EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::DynamicModelAccess»«ENDDEFINE»
+
+«DEFINE field(dma : gmfgen::DynamicModelAccess) FOR genmodel::GenPackage-»
+«EXPAND xpt::Common::generatedMemberComment»
+private static «dma.className» «fieldName(self)»;
+«ENDDEFINE»
+
+«DEFINE getMethod(dma : gmfgen::DynamicModelAccess) FOR genmodel::GenPackage-»
+ «EXPAND xpt::Common::generatedMemberComment('@throws IllegalStateException if no EPackage with given URI is registered.')»
+ public static «dma.className» get«getNameToken(self)»() {
+ if («fieldName(self)» == null) {
+ org.eclipse.emf.ecore.EPackage pkg = getRegistry().getEPackage("«ecorePackage.nsURI»");
+ if (pkg == null) {
+ throw new IllegalStateException("Package «ecorePackage.name»(«ecorePackage.nsURI») not found");
+ }
+ «fieldName(self)» = new «dma.className»(pkg);
+ «fieldName(self)».init«getNameToken(self)»();
+ }
+ return «fieldName(self)»;
+ }
+«ENDDEFINE»
+
+«DEFINE initMethod FOR genmodel::GenPackage-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private void init«getNameToken(self)»() {
+ }
+«ENDDEFINE»
+
+«DEFINE getRegistryMethod FOR gmfgen::DynamicModelAccess»
+ «EXPAND xpt::Common::generatedMemberComment('Default implementation returns global registry, clients that need another may redefine.')»
+ private static org.eclipse.emf.ecore.EPackage.Registry getRegistry() {
+ return org.eclipse.emf.ecore.EPackage.Registry.INSTANCE;
+ }
+«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates-dynmodel.migrated/MetaModel.xpt b/plugins/org.eclipse.gmf.codegen/templates-dynmodel.migrated/MetaModel.xpt
new file mode 100644
index 000000000..820889ff3
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates-dynmodel.migrated/MetaModel.xpt
@@ -0,0 +1,113 @@
+/*
+ * Copyright (c) 2008 Borland Software Corporation
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Artem Tikhomirov (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+«IMPORT 'http://www.eclipse.org/emf/2002/GenModel'»
+
+«EXTENSION Facility»
+«EXTENSION xpt::GenModelUtils»
+«EXTENSION xpt::NativeGenModelUtils»
+
+// XXX is isExternalInterface use valid here, won't all objects be just EObject?
+
+«DEFINE IsInstance(accessor : String) FOR genmodel::GenClass-»
+«getDMA().getQualifiedClassName()».get«getNameToken(genPackage)»().isInstance(«accessor», "«ecoreClass.name»")«ENDDEFINE»
+
+«DEFINE NotInstance(accessor : String) FOR genmodel::GenClass»!«EXPAND IsInstance(accessor)»«ENDDEFINE»
+
+«DEFINE IsContainerInstance(_object : String, metaClass : genmodel::GenClass) FOR genmodel::GenClass-»
+«getDMA().getQualifiedClassName()».get«getNameToken(genPackage)»().isInstance(«IF isExternalInterface(self)»((org.eclipse.emf.ecore.EObject) «_object»)«ELSE»«_object»«ENDIF».eContainer(), "«ecoreClass.name»")«ENDDEFINE»
+
+«DEFINE getFeatureValue(containerVar : String, containerClass : genmodel::GenClass) FOR genmodel::GenFeature-»
+((«EXPAND featureTargetType») «IF isExternalInterface(containerClass)-»
+((org.eclipse.emf.ecore.EObject) «containerVar»)«ELSE-»
+«containerVar»«ENDIF-»
+.eGet(«EXPAND MetaFeature»))«ENDDEFINE»
+
+«DEFINE featureTargetType FOR genmodel::GenFeature-»
+«EXPAND _featureTargetType(self) FOR ecoreFeature-»
+«ENDDEFINE»
+
+«DEFINE _featureTargetType(gf : genmodel::GenFeature) FOR ecore::EStructuralFeature»NO-OP«ENDDEFINE»
+«DEFINE _featureTargetType(gf : genmodel::GenFeature) FOR ecore::EReference-»
+«IF isListType(gf)»java.util.List«ELSE»org.eclipse.emf.ecore.EObject«ENDIF-»
+«ENDDEFINE»
+«DEFINE _featureTargetType(gf : genmodel::GenFeature) FOR ecore::EAttribute-»
+«IF isListType(gf)»java.util.List«ELSE»«getObjectCompatibleClassName(eAttributeType)»«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE getFeatureValue(containerVar : String, container : genmodel::GenClass, needsCastToResultType : Boolean) FOR genmodel::GenFeature-»
+// ??? FIXME
+«ENDDEFINE»
+
+«DEFINE setFeatureValue(containerVar : String, containerClass : genmodel::GenClass, valueVar : String) FOR genmodel::GenFeature-»
+«IF isExternalInterface(containerClass)-»
+((org.eclipse.emf.ecore.EObject) «containerVar»)«ELSE-»
+«containerVar»«ENDIF-»
+.eSet(«EXPAND MetaFeature», «valueVar»)«ENDDEFINE»
+
+«DEFINE setFeatureValue(containerVar : String, containerClass : genmodel::GenClass, valueVar : String, isPlainObjectValue : Boolean) FOR genmodel::GenFeature-»
+«EXPAND setFeatureValue(containerVar, containerClass, valueVar)»«ENDDEFINE»
+
+«DEFINE MetaClass FOR genmodel::GenDataType»«getDMA().getQualifiedClassName()».get«getNameToken(genPackage)»().getEDataType("«ecoreDataType.name»")«ENDDEFINE»
+«DEFINE MetaClass FOR genmodel::GenEnum»«getDMA().getQualifiedClassName()».get«getNameToken(genPackage)»().getEEnum("«ecoreEnum.name»")«ENDDEFINE»
+«DEFINE MetaClass FOR genmodel::GenClass»«getDMA().getQualifiedClassName()».get«getNameToken(genPackage)»().getEClass("«ecoreClass.name»")«ENDDEFINE»
+
+«DEFINE MetaFeature FOR genmodel::GenFeature»«EXPAND _metaFeature(ecoreFeature)»«ENDDEFINE»
+
+«DEFINE _metaFeature(f : ecore::EStructuralFeature) FOR genmodel::GenFeature»no-op«ENDDEFINE»
+«DEFINE _metaFeature(eRef : ecore::EReference) FOR genmodel::GenFeature»«getDMA().getQualifiedClassName()».get«getNameToken(genClass.genPackage)»().getEReference("«genClass.ecoreClass.name»", "«ecoreFeature.name»")«ENDDEFINE»
+«DEFINE _metaFeature(eAttr : ecore::EAttribute) FOR genmodel::GenFeature»«getDMA().getQualifiedClassName()».get«getNameToken(genClass.genPackage)»().getEAttribute("«genClass.ecoreClass.name»", "«ecoreFeature.name»")«ENDDEFINE»
+
+«DEFINE NewInstance FOR genmodel::GenClass-»
+«getDMA().getQualifiedClassName()».get«getNameToken(genPackage)»().newInstance("«ecoreClass.name»")«ENDDEFINE»
+
+«DEFINE NewInstance(varName : String) FOR genmodel::GenClass-»
+org.eclipse.emf.ecore.EObject «varName» = «EXPAND NewInstance»;«ENDDEFINE»
+
+«DEFINE DowncastToEObject(value : String) FOR genmodel::GenClass»«IF isExternalInterface(self)»(org.eclipse.emf.ecore.EObject) «ENDIF»«value»«ENDDEFINE»
+
+«DEFINE DeclareAndAssign(assignee : String, value : String) FOR genmodel::GenClass-»
+org.eclipse.emf.ecore.EObject «assignee» = «value»;«ENDDEFINE»
+
+«DEFINE DeclareAndAssign(assignee : String, value : String, isPlainObjectValue : Boolean) FOR genmodel::GenClass-»
+org.eclipse.emf.ecore.EObject «assignee» = «IF isPlainObjectValue»(org.eclipse.emf.ecore.EObject)«ENDIF»«value»;«ENDDEFINE»
+
+«DEFINE DeclareAndAssign(assignee : String, value : String, isPlainObjectValue : Boolean) FOR genmodel::GenClassifier»NO-OP«ENDDEFINE»
+
+«DEFINE DeclareAndAssign(assignee : String, value : String, isPlainObjectValue : Boolean) FOR genmodel::GenDataType-»
+«EXPAND QualifiedClassName» «assignee» = («EXPAND QualifiedClassName») «value»;«ENDDEFINE»
+
+
+«DEFINE DeclareAndAssignContainer(assignee : String, _object : String, metaClass : genmodel::GenClass) FOR genmodel::GenClass-»
+org.eclipse.emf.ecore.EObject «assignee» = «IF isExternalInterface(metaClass)»((org.eclipse.emf.ecore.EObject) «_object»)«ELSE»«_object»«ENDIF».eContainer();«ENDDEFINE»
+
+// FIXME - feature value is not necessarily of EObject type
+«DEFINE DeclareAndAssign(assignee : String, src : String, srcMetaClass : genmodel::GenClass, srcFeature : genmodel::GenFeature) FOR genmodel::GenClass-»
+org.eclipse.emf.ecore.EObject «assignee» = «EXPAND getFeatureValue(src, srcMetaClass) FOR srcFeature»;«ENDDEFINE»
+
+«DEFINE DeclareAndAssign2(assignee : String, src : String, srcMetaClass : genmodel::GenClass, srcFeature : genmodel::GenFeature, srcExt : String, needCast : Boolean) FOR genmodel::GenClass-»
+org.eclipse.emf.ecore.EObject «assignee» = «EXPAND getFeatureValue(src, srcMetaClass) FOR srcFeature».«srcExt»;«ENDDEFINE»
+
+«DEFINE CastEObject(eObjectValue : String) FOR genmodel::GenClass»«eObjectValue»«ENDDEFINE»
+
+«DEFINE QualifiedClassName FOR genmodel::GenClassifier»NO-OP«ENDDEFINE»
+«DEFINE QualifiedClassName FOR genmodel::GenClass»org.eclipse.emf.ecore.EObject«ENDDEFINE»
+«DEFINE QualifiedClassName FOR genmodel::GenEnum»org.eclipse.emf.common.util.Enumerator«ENDDEFINE»
+«DEFINE QualifiedClassName FOR genmodel::GenDataType»«getObjectCompatibleClassName(ecoreDataType)»«ENDDEFINE»
+
+«DEFINE PopulateItemProviderFactories(factoryListVar : String) FOR gmfgen::GenEditorGenerator-»
+«REM»
+ NO-OP since ReflectiveItemProviderAdapterFactory should
+ get added anyway.
+«ENDREM»«ENDDEFINE»

Back to the top