[552988] Track latest Acceleo regeneration
diff --git a/org.eclipse.gmt.modisco.java.generation/src/org/eclipse/gmt/modisco/java/generation/files/GenerateJava.java b/org.eclipse.gmt.modisco.java.generation/src/org/eclipse/gmt/modisco/java/generation/files/GenerateJava.java
index f5c6808..ecd5ab6 100644
--- a/org.eclipse.gmt.modisco.java.generation/src/org/eclipse/gmt/modisco/java/generation/files/GenerateJava.java
+++ b/org.eclipse.gmt.modisco.java.generation/src/org/eclipse/gmt/modisco/java/generation/files/GenerateJava.java
@@ -127,9 +127,9 @@
} else {
URI modelURI = URI.createFileURI(args[0]);
File folder = new File(args[1]);
-
+
List<String> arguments = new ArrayList<String>();
-
+
/*
* If you want to change the content of this method, do NOT forget to change the "@generated"
* tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation
@@ -142,23 +142,23 @@
* If your main template is called on an element of your model and a String, you can
* add in "arguments" this "String" attribute.
*/
-
+
GenerateJava generator = new GenerateJava(modelURI, folder, arguments);
-
+
/*
* Add the properties from the launch arguments.
* If you want to programmatically add new properties, add them in "propertiesFiles"
* You can add the absolute path of a properties files, or even a project relative path.
- * If you want to add another "protocol" for your properties files, please override
+ * If you want to add another "protocol" for your properties files, please override
* "getPropertiesLoaderService(AcceleoService)" in order to return a new property loader.
* The behavior of the properties loader service is explained in the Acceleo documentation
* (Help -> Help Contents).
*/
-
+
for (int i = 2; i < args.length; i++) {
generator.addPropertiesFile(args[i]);
}
-
+
generator.doGenerate(new BasicMonitor());
}
} catch (IOException e) {
@@ -286,29 +286,29 @@
/*
* TODO if your generation module requires access to properties files, add their qualified path to the list here.
- *
+ *
* Properties files can be located in an Eclipse plug-in or in the file system (all Acceleo projects are Eclipse
* plug-in). In order to use properties files located in an Eclipse plugin, you need to add the path of the properties
* files to the "propertiesFiles" list:
- *
+ *
* final String prefix = "platform:/plugin/";
* final String pluginName = "org.eclipse.acceleo.module.sample";
* final String packagePath = "/org/eclipse/acceleo/module/sample/properties/";
* final String fileName = "default.properties";
* propertiesFiles.add(prefix + pluginName + packagePath + fileName);
- *
+ *
* With this mechanism, you can load properties files from your plugin or from another plugin.
- *
+ *
* You may want to load properties files from the file system, for that you need to add the absolute path of the file:
- *
+ *
* propertiesFiles.add("C:\Users\MyName\MyFile.properties");
- *
+ *
* If you want to let your users add properties files located in the same folder as the model:
*
- * if (EMFPlugin.IS_ECLIPSE_RUNNING && model != null && model.eResource() != null) {
+ * if (EMFPlugin.IS_ECLIPSE_RUNNING && model != null && model.eResource() != null) {
* propertiesFiles.addAll(AcceleoEngineUtils.getPropertiesFilesNearModel(model.eResource()));
* }
- *
+ *
* To learn more about Properties Files, have a look at the Acceleo documentation (Help -> Help Contents).
*/
return propertiesFiles;
@@ -348,36 +348,36 @@
@Override
public void registerPackages(ResourceSet resourceSet) {
super.registerPackages(resourceSet);
-
+
/*
* If you want to change the content of this method, do NOT forget to change the "@generated"
* tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation
* of the Acceleo module with the main template that has caused the creation of this class will
* revert your modifications.
*/
-
+
/*
* If you need additional package registrations, you can register them here. The following line
* (in comment) is an example of the package registration for UML.
- *
+ *
* You can use the method "isInWorkspace(Class c)" to check if the package that you are about to
* register is in the workspace.
- *
+ *
* To register a package properly, please follow the following conventions:
*
* If the package is located in another plug-in, already installed in Eclipse. The following content should
* have been generated at the beginning of this method. Do not register the package using this mechanism if
* the metamodel is located in the workspace.
- *
+ *
* if (!isInWorkspace(UMLPackage.class)) {
* // The normal package registration if your metamodel is in a plugin.
* resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
* }
- *
+ *
* If the package is located in another project in your workspace, the plugin containing the package has not
* been register by EMF and Acceleo should register it automatically. If you want to use the generator in
* stand alone, the regular registration (seen a couple lines before) is needed.
- *
+ *
* To learn more about Package Registration, have a look at the Acceleo documentation (Help -> Help Contents).
*/
}
@@ -398,17 +398,23 @@
* of the Acceleo module with the main template that has caused the creation of this class will
* revert your modifications.
*/
-
+
/*
* TODO If you need additional resource factories registrations, you can register them here. the following line
- * (in comment) is an example of the resource factory registration for UML.
+ * (in comment) is an example of the resource factory registration.
*
* If you want to use the generator in stand alone, the resource factory registration will be required.
- *
- * To learn more about the registration of Resource Factories, have a look at the Acceleo documentation (Help -> Help Contents).
- */
-
- // resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
+ *
+ * To learn more about the registration of Resource Factories, have a look at the Acceleo documentation (Help -> Help Contents).
+ */
+
+ // resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(XyzResource.FILE_EXTENSION, XyzResource.Factory.INSTANCE);
+
+ /*
+ * Some metamodels require a very complex setup for standalone usage. For example, if you want to use a generator
+ * targetting UML models in standalone, you NEED to use the following:
+ */
+ // UMLResourcesUtil.init(resourceSet)
}
/**
diff --git a/org.eclipse.modisco.infra.discovery.benchmark.core/src/org/eclipse/modisco/infra/discovery/benchmark/core/internal/reporting/HtmlReport.java b/org.eclipse.modisco.infra.discovery.benchmark.core/src/org/eclipse/modisco/infra/discovery/benchmark/core/internal/reporting/HtmlReport.java
index de96866..80728e1 100644
--- a/org.eclipse.modisco.infra.discovery.benchmark.core/src/org/eclipse/modisco/infra/discovery/benchmark/core/internal/reporting/HtmlReport.java
+++ b/org.eclipse.modisco.infra.discovery.benchmark.core/src/org/eclipse/modisco/infra/discovery/benchmark/core/internal/reporting/HtmlReport.java
@@ -128,9 +128,9 @@
} else {
URI modelURI = URI.createFileURI(args[0]);
File folder = new File(args[1]);
-
+
List<String> arguments = new ArrayList<String>();
-
+
/*
* If you want to change the content of this method, do NOT forget to change the "@generated"
* tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation
@@ -143,23 +143,23 @@
* If your main template is called on an element of your model and a String, you can
* add in "arguments" this "String" attribute.
*/
-
+
HtmlReport generator = new HtmlReport(modelURI, folder, arguments);
-
+
/*
* Add the properties from the launch arguments.
* If you want to programmatically add new properties, add them in "propertiesFiles"
* You can add the absolute path of a properties files, or even a project relative path.
- * If you want to add another "protocol" for your properties files, please override
+ * If you want to add another "protocol" for your properties files, please override
* "getPropertiesLoaderService(AcceleoService)" in order to return a new property loader.
* The behavior of the properties loader service is explained in the Acceleo documentation
* (Help -> Help Contents).
*/
-
+
for (int i = 2; i < args.length; i++) {
generator.addPropertiesFile(args[i]);
}
-
+
generator.doGenerate(new BasicMonitor());
}
} catch (IOException e) {
@@ -281,29 +281,29 @@
/*
* TODO if your generation module requires access to properties files, add their qualified path to the list here.
- *
+ *
* Properties files can be located in an Eclipse plug-in or in the file system (all Acceleo projects are Eclipse
* plug-in). In order to use properties files located in an Eclipse plugin, you need to add the path of the properties
* files to the "propertiesFiles" list:
- *
+ *
* final String prefix = "platform:/plugin/";
* final String pluginName = "org.eclipse.acceleo.module.sample";
* final String packagePath = "/org/eclipse/acceleo/module/sample/properties/";
* final String fileName = "default.properties";
* propertiesFiles.add(prefix + pluginName + packagePath + fileName);
- *
+ *
* With this mechanism, you can load properties files from your plugin or from another plugin.
- *
+ *
* You may want to load properties files from the file system, for that you need to add the absolute path of the file:
- *
+ *
* propertiesFiles.add("C:\Users\MyName\MyFile.properties");
- *
+ *
* If you want to let your users add properties files located in the same folder as the model:
*
- * if (EMFPlugin.IS_ECLIPSE_RUNNING && model != null && model.eResource() != null) {
+ * if (EMFPlugin.IS_ECLIPSE_RUNNING && model != null && model.eResource() != null) {
* propertiesFiles.addAll(AcceleoEngineUtils.getPropertiesFilesNearModel(model.eResource()));
* }
- *
+ *
* To learn more about Properties Files, have a look at the Acceleo documentation (Help -> Help Contents).
*/
return propertiesFiles;
@@ -320,6 +320,7 @@
/*
@Override
*/
+ @Override
public void addPropertiesFile(String propertiesFile) {
this.propertiesFiles.add(propertiesFile);
}
@@ -345,46 +346,36 @@
@Override
public void registerPackages(ResourceSet resourceSet) {
super.registerPackages(resourceSet);
+
/*
* If you want to change the content of this method, do NOT forget to change the "@generated"
* tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation
* of the Acceleo module with the main template that has caused the creation of this class will
* revert your modifications.
*/
-//gdupe> The method isInWorkspace() does not exists in Helios. This avoid
-// to be install MoDisco on an Helios. The code generator is not used in a
-// workspace context : we do not need explicit load of the meta-models
-// That why I've commented the following lines.
-/*
- if (!isInWorkspace(org.eclipse.modisco.infra.discovery.catalog.CatalogPackage.class)) {
- resourceSet.getPackageRegistry().put(org.eclipse.modisco.infra.discovery.catalog.CatalogPackage.eINSTANCE.getNsURI(), org.eclipse.modisco.infra.discovery.catalog.CatalogPackage.eINSTANCE);
- }
- if (!isInWorkspace(org.eclipse.modisco.infra.discovery.launch.LaunchPackage.class)) {
- resourceSet.getPackageRegistry().put(org.eclipse.modisco.infra.discovery.launch.LaunchPackage.eINSTANCE.getNsURI(), org.eclipse.modisco.infra.discovery.launch.LaunchPackage.eINSTANCE);
- }
-*/
+
/*
* If you need additional package registrations, you can register them here. The following line
* (in comment) is an example of the package registration for UML.
- *
+ *
* You can use the method "isInWorkspace(Class c)" to check if the package that you are about to
* register is in the workspace.
- *
+ *
* To register a package properly, please follow the following conventions:
*
* If the package is located in another plug-in, already installed in Eclipse. The following content should
* have been generated at the beginning of this method. Do not register the package using this mechanism if
* the metamodel is located in the workspace.
- *
+ *
* if (!isInWorkspace(UMLPackage.class)) {
* // The normal package registration if your metamodel is in a plugin.
* resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
* }
- *
+ *
* If the package is located in another project in your workspace, the plugin containing the package has not
* been register by EMF and Acceleo should register it automatically. If you want to use the generator in
* stand alone, the regular registration (seen a couple lines before) is needed.
- *
+ *
* To learn more about Package Registration, have a look at the Acceleo documentation (Help -> Help Contents).
*/
}
@@ -405,17 +396,23 @@
* of the Acceleo module with the main template that has caused the creation of this class will
* revert your modifications.
*/
-
+
/*
* TODO If you need additional resource factories registrations, you can register them here. the following line
- * (in comment) is an example of the resource factory registration for UML.
+ * (in comment) is an example of the resource factory registration.
*
* If you want to use the generator in stand alone, the resource factory registration will be required.
- *
- * To learn more about the registration of Resource Factories, have a look at the Acceleo documentation (Help -> Help Contents).
- */
-
- // resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
+ *
+ * To learn more about the registration of Resource Factories, have a look at the Acceleo documentation (Help -> Help Contents).
+ */
+
+ // resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(XyzResource.FILE_EXTENSION, XyzResource.Factory.INSTANCE);
+
+ /*
+ * Some metamodels require a very complex setup for standalone usage. For example, if you want to use a generator
+ * targetting UML models in standalone, you NEED to use the following:
+ */
+ // UMLResourcesUtil.init(resourceSet)
}
}
diff --git a/org.eclipse.modisco.java.discoverer.benchmark/src/org/eclipse/modisco/java/discoverer/benchmark/template/html/HtmlReport.java b/org.eclipse.modisco.java.discoverer.benchmark/src/org/eclipse/modisco/java/discoverer/benchmark/template/html/HtmlReport.java
index 1f9c45e..83a8939 100644
--- a/org.eclipse.modisco.java.discoverer.benchmark/src/org/eclipse/modisco/java/discoverer/benchmark/template/html/HtmlReport.java
+++ b/org.eclipse.modisco.java.discoverer.benchmark/src/org/eclipse/modisco/java/discoverer/benchmark/template/html/HtmlReport.java
@@ -127,36 +127,38 @@
} else {
URI modelURI = URI.createFileURI(args[0]);
File folder = new File(args[1]);
-
+
List<String> arguments = new ArrayList<String>();
+
+ /*
+ * If you want to change the content of this method, do NOT forget to change the "@generated"
+ * tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation
+ * of the Acceleo module with the main template that has caused the creation of this class will
+ * revert your modifications.
+ */
/*
* Add in this list all the arguments used by the starting point of the generation
* If your main template is called on an element of your model and a String, you can
* add in "arguments" this "String" attribute.
*/
-
+
HtmlReport generator = new HtmlReport(modelURI, folder, arguments);
-
+
/*
* Add the properties from the launch arguments.
* If you want to programmatically add new properties, add them in "propertiesFiles"
* You can add the absolute path of a properties files, or even a project relative path.
- * If you want to add another "protocol" for your properties files, please override
+ * If you want to add another "protocol" for your properties files, please override
* "getPropertiesLoaderService(AcceleoService)" in order to return a new property loader.
* The behavior of the properties loader service is explained in the Acceleo documentation
* (Help -> Help Contents).
*/
-
- //Bug 382359 - Compatibility with Helios
- //gdupe> The properties are not used in the generation removing
- // the following lines allow to build against Helios.
- /*
+
for (int i = 2; i < args.length; i++) {
generator.addPropertiesFile(args[i]);
- }
- */
-
+ }
+
generator.doGenerate(new BasicMonitor());
}
} catch (IOException e) {
@@ -188,6 +190,11 @@
//org.eclipse.emf.ecore.util.EcoreUtil.resolveAll(model);
+ /*
+ * If you want to check for potential errors in your models before the launch of the generation, you
+ * use the code below.
+ */
+
//if (model != null && model.eResource() != null) {
// List<org.eclipse.emf.ecore.resource.Resource.Diagnostic> errors = model.eResource().getErrors();
// for (org.eclipse.emf.ecore.resource.Resource.Diagnostic diagnostic : errors) {
@@ -285,21 +292,57 @@
@Override
public List<String> getProperties() {
/*
+ * If you want to change the content of this method, do NOT forget to change the "@generated"
+ * tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation
+ * of the Acceleo module with the main template that has caused the creation of this class will
+ * revert your modifications.
+ */
+
+ /*
* TODO if your generation module requires access to properties files, add their qualified path to the list here.
- * Properties files are expected to be in source folders, and the path here to be the qualified path as if referring
- * to a Java class. For example, if you have a file named "messages.properties" in package "org.eclipse.acceleo.sample",
- * the path that needs be added to this list is "/org/eclipse/acceleo/sample/messages.properties". If you want to change the
- * contentof this method, do NOT forget to change the "@generated" tag in the Javadoc of this method to "@generated NOT".
- * Without this new tag, any compilation of the Acceleo module with the main template that has caused the creation of
- * this class will revert your modifications.
+ *
+ * Properties files can be located in an Eclipse plug-in or in the file system (all Acceleo projects are Eclipse
+ * plug-in). In order to use properties files located in an Eclipse plugin, you need to add the path of the properties
+ * files to the "propertiesFiles" list:
+ *
+ * final String prefix = "platform:/plugin/";
+ * final String pluginName = "org.eclipse.acceleo.module.sample";
+ * final String packagePath = "/org/eclipse/acceleo/module/sample/properties/";
+ * final String fileName = "default.properties";
+ * propertiesFiles.add(prefix + pluginName + packagePath + fileName);
+ *
+ * With this mechanism, you can load properties files from your plugin or from another plugin.
+ *
+ * You may want to load properties files from the file system, for that you need to add the absolute path of the file:
+ *
+ * propertiesFiles.add("C:\Users\MyName\MyFile.properties");
+ *
+ * If you want to let your users add properties files located in the same folder as the model:
*
- * To learn more about Properties Files, have a look at the Acceleo Launcher documentation (Help -> Help Contents).
+ * if (EMFPlugin.IS_ECLIPSE_RUNNING && model != null && model.eResource() != null) {
+ * propertiesFiles.addAll(AcceleoEngineUtils.getPropertiesFilesNearModel(model.eResource()));
+ * }
+ *
+ * To learn more about Properties Files, have a look at the Acceleo documentation (Help -> Help Contents).
*/
return propertiesFiles;
}
/**
* Adds a properties file in the list of properties files.
+ *
+ * @param propertiesFile
+ * The properties file to add.
+ * @generated
+ * @since 3.1
+ */
+ @Override
+ public void addPropertiesFile(String propertiesFile) {
+ this.propertiesFiles.add(propertiesFile);
+ }
+
+ /**
+ * Adds a properties file in the list of properties files.
*
* @param propertiesFile
* The properties file to add.
@@ -361,16 +404,28 @@
public void registerResourceFactories(ResourceSet resourceSet) {
super.registerResourceFactories(resourceSet);
/*
- * TODO If you need additional resource factories registrations, you can register them here. the following line
- * (in comment) is an example of the resource factory registration for UML. If you want to change the content
- * of this method, do NOT forget to change the "@generated" tag in the Javadoc of this method to "@generated NOT".
- * Without this new tag, any compilation of the Acceleo module with the main template that has caused the creation
- * of this class will revert your modifications.
- *
- * To learn more about the registration of Resource Factories, have a look at the Acceleo Launcher documentation (Help -> Help Contents).
+ * If you want to change the content of this method, do NOT forget to change the "@generated"
+ * tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation
+ * of the Acceleo module with the main template that has caused the creation of this class will
+ * revert your modifications.
*/
-
- // resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
+
+ /*
+ * TODO If you need additional resource factories registrations, you can register them here. the following line
+ * (in comment) is an example of the resource factory registration.
+ *
+ * If you want to use the generator in stand alone, the resource factory registration will be required.
+ *
+ * To learn more about the registration of Resource Factories, have a look at the Acceleo documentation (Help -> Help Contents).
+ */
+
+ // resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(XyzResource.FILE_EXTENSION, XyzResource.Factory.INSTANCE);
+
+ /*
+ * Some metamodels require a very complex setup for standalone usage. For example, if you want to use a generator
+ * targetting UML models in standalone, you NEED to use the following:
+ */
+ // UMLResourcesUtil.init(resourceSet)
}
}
diff --git a/org.eclipse.modisco.java.discoverer.benchmark/src/org/eclipse/modisco/java/discoverer/benchmark/template/html/HtmlReport2.java b/org.eclipse.modisco.java.discoverer.benchmark/src/org/eclipse/modisco/java/discoverer/benchmark/template/html/HtmlReport2.java
index 0b8c0e7..a2b38fd 100644
--- a/org.eclipse.modisco.java.discoverer.benchmark/src/org/eclipse/modisco/java/discoverer/benchmark/template/html/HtmlReport2.java
+++ b/org.eclipse.modisco.java.discoverer.benchmark/src/org/eclipse/modisco/java/discoverer/benchmark/template/html/HtmlReport2.java
@@ -313,20 +313,56 @@
@Override
public List<String> getProperties() {
/*
+ * If you want to change the content of this method, do NOT forget to change the "@generated"
+ * tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation
+ * of the Acceleo module with the main template that has caused the creation of this class will
+ * revert your modifications.
+ */
+
+ /*
* TODO if your generation module requires access to properties files, add their qualified path to the list here.
- * Properties files are expected to be in source folders, and the path here to be the qualified path as if referring
- * to a Java class. For example, if you have a file named "messages.properties" in package "org.eclipse.acceleo.sample",
- * the path that needs be added to this list is "/org/eclipse/acceleo/sample/messages.properties". If you want to change the
- * contentof this method, do NOT forget to change the "@generated" tag in the Javadoc of this method to "@generated NOT".
- * Without this new tag, any compilation of the Acceleo module with the main template that has caused the creation of
- * this class will revert your modifications.
+ *
+ * Properties files can be located in an Eclipse plug-in or in the file system (all Acceleo projects are Eclipse
+ * plug-in). In order to use properties files located in an Eclipse plugin, you need to add the path of the properties
+ * files to the "propertiesFiles" list:
+ *
+ * final String prefix = "platform:/plugin/";
+ * final String pluginName = "org.eclipse.acceleo.module.sample";
+ * final String packagePath = "/org/eclipse/acceleo/module/sample/properties/";
+ * final String fileName = "default.properties";
+ * propertiesFiles.add(prefix + pluginName + packagePath + fileName);
+ *
+ * With this mechanism, you can load properties files from your plugin or from another plugin.
+ *
+ * You may want to load properties files from the file system, for that you need to add the absolute path of the file:
+ *
+ * propertiesFiles.add("C:\Users\MyName\MyFile.properties");
+ *
+ * If you want to let your users add properties files located in the same folder as the model:
*
- * To learn more about Properties Files, have a look at the Acceleo Launcher documentation (Help -> Help Contents).
+ * if (EMFPlugin.IS_ECLIPSE_RUNNING && model != null && model.eResource() != null) {
+ * propertiesFiles.addAll(AcceleoEngineUtils.getPropertiesFilesNearModel(model.eResource()));
+ * }
+ *
+ * To learn more about Properties Files, have a look at the Acceleo documentation (Help -> Help Contents).
*/
return propertiesFiles;
}
/**
+ * Adds a properties file in the list of properties files.
+ *
+ * @param propertiesFile
+ * The properties file to add.
+ * @generated
+ * @since 3.1
+ */
+ @Override
+ public void addPropertiesFile(String propertiesFile) {
+ this.propertiesFiles.add(propertiesFile);
+ }
+
+ /**
* Adds a properties file in the list of properties files.
*
* @param propertiesFile
@@ -368,26 +404,37 @@
@Override
public void registerPackages(ResourceSet resourceSet) {
super.registerPackages(resourceSet);
-
+
/*
- * TODO If you need additional package registrations, you can register them here. The following line
- * (in comment) is an example of the package registration for UML. If you want to change the content
- * of this method, do NOT forget to change the "@generated" tag in the Javadoc of this method to
- * "@generated NOT". Without this new tag, any compilation of the Acceleo module with the main template
- * that has caused the creation of this class will revert your modifications. You can use the method
- * "isInWorkspace(Class c)" to check if the package that you are about to register is in the workspace.
+ * If you want to change the content of this method, do NOT forget to change the "@generated"
+ * tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation
+ * of the Acceleo module with the main template that has caused the creation of this class will
+ * revert your modifications.
+ */
+
+ /*
+ * If you need additional package registrations, you can register them here. The following line
+ * (in comment) is an example of the package registration for UML.
+ *
+ * You can use the method "isInWorkspace(Class c)" to check if the package that you are about to
+ * register is in the workspace.
+ *
* To register a package properly, please follow the following conventions:
*
+ * If the package is located in another plug-in, already installed in Eclipse. The following content should
+ * have been generated at the beginning of this method. Do not register the package using this mechanism if
+ * the metamodel is located in the workspace.
+ *
* if (!isInWorkspace(UMLPackage.class)) {
* // The normal package registration if your metamodel is in a plugin.
* resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
- * } else {
- * // The package registration that will be used if the metamodel is not deployed in a plugin.
- * // This should be used if your metamodel is in your workspace and if you are using binary resource serialization.
- * resourceSet.getPackageRegistry().put("/myproject/myfolder/mysubfolder/MyUMLMetamodel.ecore", UMLPackage.eINSTANCE);
* }
- *
- * To learn more about Package Registration, have a look at the Acceleo Launcher documentation (Help -> Help Contents).
+ *
+ * If the package is located in another project in your workspace, the plugin containing the package has not
+ * been register by EMF and Acceleo should register it automatically. If you want to use the generator in
+ * stand alone, the regular registration (seen a couple lines before) is needed.
+ *
+ * To learn more about Package Registration, have a look at the Acceleo documentation (Help -> Help Contents).
*/
}
@@ -403,16 +450,28 @@
public void registerResourceFactories(ResourceSet resourceSet) {
super.registerResourceFactories(resourceSet);
/*
- * TODO If you need additional resource factories registrations, you can register them here. the following line
- * (in comment) is an example of the resource factory registration for UML. If you want to change the content
- * of this method, do NOT forget to change the "@generated" tag in the Javadoc of this method to "@generated NOT".
- * Without this new tag, any compilation of the Acceleo module with the main template that has caused the creation
- * of this class will revert your modifications.
- *
- * To learn more about the registration of Resource Factories, have a look at the Acceleo Launcher documentation (Help -> Help Contents).
+ * If you want to change the content of this method, do NOT forget to change the "@generated"
+ * tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation
+ * of the Acceleo module with the main template that has caused the creation of this class will
+ * revert your modifications.
*/
-
- // resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
+
+ /*
+ * TODO If you need additional resource factories registrations, you can register them here. the following line
+ * (in comment) is an example of the resource factory registration.
+ *
+ * If you want to use the generator in stand alone, the resource factory registration will be required.
+ *
+ * To learn more about the registration of Resource Factories, have a look at the Acceleo documentation (Help -> Help Contents).
+ */
+
+ // resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(XyzResource.FILE_EXTENSION, XyzResource.Factory.INSTANCE);
+
+ /*
+ * Some metamodels require a very complex setup for standalone usage. For example, if you want to use a generator
+ * targetting UML models in standalone, you NEED to use the following:
+ */
+ // UMLResourcesUtil.init(resourceSet)
}
}
diff --git a/org.eclipse.modisco.jee.jsp.generation/src/org/eclipse/modisco/jee/jsp/generation/files/GenerateJsp.java b/org.eclipse.modisco.jee.jsp.generation/src/org/eclipse/modisco/jee/jsp/generation/files/GenerateJsp.java
index 9c35be9..c6669b9 100644
--- a/org.eclipse.modisco.jee.jsp.generation/src/org/eclipse/modisco/jee/jsp/generation/files/GenerateJsp.java
+++ b/org.eclipse.modisco.jee.jsp.generation/src/org/eclipse/modisco/jee/jsp/generation/files/GenerateJsp.java
@@ -36,16 +36,23 @@
*
* @generated
*/
- public static final String MODULE_FILE_NAME = "GenerateJsp"; //$NON-NLS-1$
+ public static final String MODULE_FILE_NAME = "/org/eclipse/modisco/jee/jsp/generation/files/GenerateJsp"; //$NON-NLS-1$
/**
* The name of the templates that are to be generated.
*
* @generated
*/
- public static final String[] TEMPLATE_NAMES = { "write", }; //$NON-NLS-1$
+ public static final String[] TEMPLATE_NAMES = { "write" }; //$NON-NLS-1$
- /**
+ /**
+ * The list of properties files from the launch parameters (Launch configuration).
+ *
+ * @generated
+ */
+ private List<String> propertiesFiles = new ArrayList<String>();
+
+ /**
* Allows the public constructor to be used. Note that a generator created
* this way cannot be used to launch generations before one of
* {@link #initialize(EObject, File, List)} or
@@ -59,9 +66,9 @@
*
* @generated
*/
- public GenerateJsp() {
- // Empty implementation
- }
+ public GenerateJsp() {
+ // Empty implementation
+ }
/**
* This allows clients to instantiates a generator with all required
@@ -83,9 +90,9 @@
* @generated
*/
public GenerateJsp(URI modelURI, File targetFolder,
- List<? extends Object> arguments) throws IOException {
- initialize(modelURI, targetFolder, arguments);
- }
+ List<? extends Object> arguments) throws IOException {
+ initialize(modelURI, targetFolder, arguments);
+ }
/**
* This allows clients to instantiates a generator with all required
@@ -107,9 +114,9 @@
* @generated
*/
public GenerateJsp(EObject model, File targetFolder,
- List<? extends Object> arguments) throws IOException {
- initialize(model, targetFolder, arguments);
- }
+ List<? extends Object> arguments) throws IOException {
+ initialize(model, targetFolder, arguments);
+ }
/**
* This can be used to launch the generation from a standalone application.
@@ -118,24 +125,51 @@
* Arguments of the generation.
* @generated
*/
- public static void main(String[] args) {
- try {
- if (args.length < 2) {
- System.out.println("Arguments not valid : {model, folder}."); //$NON-NLS-1$
- } else {
- URI modelURI = URI.createFileURI(args[0]);
- File folder = new File(args[1]);
- List<String> arguments = new ArrayList<String>();
- for (int i = 2; i < args.length; i++) {
- arguments.add(args[i]);
- }
- GenerateJsp generator = new GenerateJsp(modelURI, folder, arguments);
- generator.doGenerate(new BasicMonitor());
- }
- } catch (IOException e) {
- e.printStackTrace();
+ public static void main(String[] args) {
+ try {
+ if (args.length < 2) {
+ System.out.println("Arguments not valid : {model, folder}.");
+ } else {
+ URI modelURI = URI.createFileURI(args[0]);
+ File folder = new File(args[1]);
+
+ List<String> arguments = new ArrayList<String>();
+
+ /*
+ * If you want to change the content of this method, do NOT forget to change the "@generated"
+ * tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation
+ * of the Acceleo module with the main template that has caused the creation of this class will
+ * revert your modifications.
+ */
+
+ /*
+ * Add in this list all the arguments used by the starting point of the generation
+ * If your main template is called on an element of your model and a String, you can
+ * add in "arguments" this "String" attribute.
+ */
+
+ GenerateJsp generator = new GenerateJsp(modelURI, folder, arguments);
+
+ /*
+ * Add the properties from the launch arguments.
+ * If you want to programmatically add new properties, add them in "propertiesFiles"
+ * You can add the absolute path of a properties files, or even a project relative path.
+ * If you want to add another "protocol" for your properties files, please override
+ * "getPropertiesLoaderService(AcceleoService)" in order to return a new property loader.
+ * The behavior of the properties loader service is explained in the Acceleo documentation
+ * (Help -> Help Contents).
+ */
+
+ for (int i = 2; i < args.length; i++) {
+ generator.addPropertiesFile(args[i]);
+ }
+
+ generator.doGenerate(new BasicMonitor());
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
}
- }
/**
* Launches the generation described by this instance.
@@ -148,13 +182,33 @@
* @generated
*/
@Override
- public void doGenerate(Monitor monitor) throws IOException {
- /*
- * TODO if you wish to change the generation as a whole, override this.
- * The default behavior should be sufficient in most cases.
- */
- super.doGenerate(monitor);
- }
+ public void doGenerate(Monitor monitor) throws IOException {
+ /*
+ * TODO if you wish to change the generation as a whole, override this. The default behavior should
+ * be sufficient in most cases. If you want to change the content of this method, do NOT forget to
+ * change the "@generated" tag in the Javadoc of this method to "@generated NOT". Without this new tag,
+ * any compilation of the Acceleo module with the main template that has caused the creation of this
+ * class will revert your modifications. If you encounter a problem with an unresolved proxy during the
+ * generation, you can remove the comments in the following instructions to check for problems. Please
+ * note that those instructions may have a significant impact on the performances.
+ */
+
+ //org.eclipse.emf.ecore.util.EcoreUtil.resolveAll(model);
+
+ /*
+ * If you want to check for potential errors in your models before the launch of the generation, you
+ * use the code below.
+ */
+
+ //if (model != null && model.eResource() != null) {
+ // List<org.eclipse.emf.ecore.resource.Resource.Diagnostic> errors = model.eResource().getErrors();
+ // for (org.eclipse.emf.ecore.resource.Resource.Diagnostic diagnostic : errors) {
+ // System.err.println(diagnostic.toString());
+ // }
+ //}
+
+ super.doGenerate(monitor);
+ }
/**
* If this generator needs to listen to text generation events, listeners
@@ -165,11 +219,16 @@
* @generated
*/
@Override
- public List<IAcceleoTextGenerationListener> getGenerationListeners() {
- List<IAcceleoTextGenerationListener> listeners = super.getGenerationListeners();
- // TODO if you need to listen to generation event, add listeners to the list here
- return listeners;
- }
+ public List<IAcceleoTextGenerationListener> getGenerationListeners() {
+ List<IAcceleoTextGenerationListener> listeners = super.getGenerationListeners();
+ /*
+ * TODO if you need to listen to generation event, add listeners to the list here. If you want to change
+ * the content of this method, do NOT forget to change the "@generated" tag in the Javadoc of this method
+ * to "@generated NOT". Without this new tag, any compilation of the Acceleo module with the main template
+ * that has caused the creation of this class will revert your modifications.
+ */
+ return listeners;
+ }
/**
* If you need to change the way files are generated, this is your entry
@@ -198,9 +257,10 @@
* launched through this launcher.
* @generated
*/
- public IAcceleoGenerationStrategy getGenerationStrategy() {
- return super.getGenerationStrategy();
- }
+ @Override
+ public IAcceleoGenerationStrategy getGenerationStrategy() {
+ return super.getGenerationStrategy();
+ }
/**
* This will be called in order to find and load the module that will be
@@ -211,9 +271,9 @@
* @generated
*/
@Override
- public String getModuleName() {
- return MODULE_FILE_NAME;
- }
+ public String getModuleName() {
+ return MODULE_FILE_NAME;
+ }
/**
* If the module(s) called by this launcher require properties files, return
@@ -235,21 +295,58 @@
* @generated
*/
@Override
- public List<String> getProperties() {
- List<String> propertiesFiles = super.getProperties();
- /*
- * TODO if your generation module requires access to properties files,
- * add their qualified path to the list here. Properties files are
- * expected to be in source folders, and the path here to be the
- * qualified path as if referring to a Java class. For example, if you
- * have a file named "messages.properties" in package
- * "org.eclipse.acceleo.sample", the path that needs be added to this
- * list is "org.eclipse.acceleo.sample.messages".
- */
- return propertiesFiles;
- }
+ public List<String> getProperties() {
+ /*
+ * If you want to change the content of this method, do NOT forget to change the "@generated"
+ * tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation
+ * of the Acceleo module with the main template that has caused the creation of this class will
+ * revert your modifications.
+ */
+
+ /*
+ * TODO if your generation module requires access to properties files, add their qualified path to the list here.
+ *
+ * Properties files can be located in an Eclipse plug-in or in the file system (all Acceleo projects are Eclipse
+ * plug-in). In order to use properties files located in an Eclipse plugin, you need to add the path of the properties
+ * files to the "propertiesFiles" list:
+ *
+ * final String prefix = "platform:/plugin/";
+ * final String pluginName = "org.eclipse.acceleo.module.sample";
+ * final String packagePath = "/org/eclipse/acceleo/module/sample/properties/";
+ * final String fileName = "default.properties";
+ * propertiesFiles.add(prefix + pluginName + packagePath + fileName);
+ *
+ * With this mechanism, you can load properties files from your plugin or from another plugin.
+ *
+ * You may want to load properties files from the file system, for that you need to add the absolute path of the file:
+ *
+ * propertiesFiles.add("C:\Users\MyName\MyFile.properties");
+ *
+ * If you want to let your users add properties files located in the same folder as the model:
+ *
+ * if (EMFPlugin.IS_ECLIPSE_RUNNING && model != null && model.eResource() != null) {
+ * propertiesFiles.addAll(AcceleoEngineUtils.getPropertiesFilesNearModel(model.eResource()));
+ * }
+ *
+ * To learn more about Properties Files, have a look at the Acceleo documentation (Help -> Help Contents).
+ */
+ return propertiesFiles;
+ }
- /**
+ /**
+ * Adds a properties file in the list of properties files.
+ *
+ * @param propertiesFile
+ * The properties file to add.
+ * @generated
+ * @since 3.1
+ */
+ @Override
+ public void addPropertiesFile(String propertiesFile) {
+ this.propertiesFiles.add(propertiesFile);
+ }
+
+ /**
* This will be used to get the list of templates that are to be launched by
* this launcher.
*
@@ -258,9 +355,9 @@
* @generated
*/
@Override
- public String[] getTemplateNames() {
- return TEMPLATE_NAMES;
- }
+ public String[] getTemplateNames() {
+ return TEMPLATE_NAMES;
+ }
/**
* This can be used to update the resource set's package registry with all
@@ -271,13 +368,41 @@
* @generated
*/
@Override
- public void registerPackages(ResourceSet resourceSet) {
- super.registerPackages(resourceSet);
- resourceSet.getPackageRegistry().put(org.eclipse.modisco.jee.jsp.JspPackage.eINSTANCE.getNsURI(), org.eclipse.modisco.jee.jsp.JspPackage.eINSTANCE);
- resourceSet.getPackageRegistry().put(org.eclipse.gmt.modisco.xml.emf.MoDiscoXMLPackage.eINSTANCE.getNsURI(), org.eclipse.gmt.modisco.xml.emf.MoDiscoXMLPackage.eINSTANCE);
- // TODO If you need additional package registrations, do them here. The following line is an example for UML.
- // resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
- }
+ public void registerPackages(ResourceSet resourceSet) {
+ super.registerPackages(resourceSet);
+
+ /*
+ * If you want to change the content of this method, do NOT forget to change the "@generated"
+ * tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation
+ * of the Acceleo module with the main template that has caused the creation of this class will
+ * revert your modifications.
+ */
+
+ /*
+ * If you need additional package registrations, you can register them here. The following line
+ * (in comment) is an example of the package registration for UML.
+ *
+ * You can use the method "isInWorkspace(Class c)" to check if the package that you are about to
+ * register is in the workspace.
+ *
+ * To register a package properly, please follow the following conventions:
+ *
+ * If the package is located in another plug-in, already installed in Eclipse. The following content should
+ * have been generated at the beginning of this method. Do not register the package using this mechanism if
+ * the metamodel is located in the workspace.
+ *
+ * if (!isInWorkspace(UMLPackage.class)) {
+ * // The normal package registration if your metamodel is in a plugin.
+ * resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
+ * }
+ *
+ * If the package is located in another project in your workspace, the plugin containing the package has not
+ * been register by EMF and Acceleo should register it automatically. If you want to use the generator in
+ * stand alone, the regular registration (seen a couple lines before) is needed.
+ *
+ * To learn more about Package Registration, have a look at the Acceleo documentation (Help -> Help Contents).
+ */
+ }
/**
* This can be used to update the resource set's resource factory registry
@@ -288,10 +413,31 @@
* @generated
*/
@Override
- public void registerResourceFactories(ResourceSet resourceSet) {
- super.registerResourceFactories(resourceSet);
- // TODO If you need additional resource factories registrations, do them here. The following line is an example for UML.
- // resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
- }
+ public void registerResourceFactories(ResourceSet resourceSet) {
+ super.registerResourceFactories(resourceSet);
+ /*
+ * If you want to change the content of this method, do NOT forget to change the "@generated"
+ * tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation
+ * of the Acceleo module with the main template that has caused the creation of this class will
+ * revert your modifications.
+ */
+
+ /*
+ * TODO If you need additional resource factories registrations, you can register them here. the following line
+ * (in comment) is an example of the resource factory registration.
+ *
+ * If you want to use the generator in stand alone, the resource factory registration will be required.
+ *
+ * To learn more about the registration of Resource Factories, have a look at the Acceleo documentation (Help -> Help Contents).
+ */
+
+ // resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(XyzResource.FILE_EXTENSION, XyzResource.Factory.INSTANCE);
+
+ /*
+ * Some metamodels require a very complex setup for standalone usage. For example, if you want to use a generator
+ * targetting UML models in standalone, you NEED to use the following:
+ */
+ // UMLResourcesUtil.init(resourceSet)
+ }
}