Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.gmf.codegen/templates-dynmodel.migrated/Facility.xpt')
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates-dynmodel.migrated/Facility.xpt157
1 files changed, 157 insertions, 0 deletions
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

Back to the top