+ * The main reason for this constructor is to allow clients of this generation to call it from another + * Java file, as it allows for the retrieval of {@link #getProperties()} and + * {@link #getGenerationListeners()}. + *
+ * + * @generated + */ + public GenerateJava() { + // Empty implementation + } + + /** + * Constructor. + * + * @param modelURI + * is the URI of the model. + * @param targetFolder + * is the output folder + * @param arguments + * are the other arguments + * @throws IOException + * Thrown when the output cannot be saved. + * @generated + */ + public GenerateJava(URI modelURI, File targetFolder, List extends Object> arguments) throws IOException { + initialize(modelURI, targetFolder, arguments); + } + + /** + * Constructor. + * + * @param model + * is the root element of the model. + * @param targetFolder + * is the output folder + * @param arguments + * are the other arguments + * @throws IOException + * Thrown when the output cannot be saved. + * @generated + */ + public GenerateJava(EObject model, File targetFolder, List extends Object> arguments) + throws IOException { + initialize(model, targetFolder, arguments); + } + + /** + * Updates the registry used for looking up a package based namespace, in the resource set. + * + * @param resourceSet + * is the resource set + * @generated + */ + @Override + public void registerPackages(ResourceSet resourceSet) { + super.registerPackages(resourceSet); + if (!isInWorkspace(org.eclipse.uml2.uml.UMLPackage.class)) { + resourceSet.getPackageRegistry().put(org.eclipse.uml2.uml.UMLPackage.eINSTANCE.getNsURI(), org.eclipse.uml2.uml.UMLPackage.eINSTANCE); + } + + /* + * 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. + * To register a package properly, please follow the following conventions: + * + * 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). + */ + } + + /** + * Updates the registry used for looking up resources factory in the given resource set. + * + * @param resourceSet + * The resource set that is to be updated. + * @generated NOT + */ + @Override + 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). + */ + + resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE); + } + + /** + * The main method. + * + * @param args + * are the arguments + * @generated + */ + 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+ * The default is {@link org.eclipse.acceleo.engine.generation.strategy.DefaultStrategy}; it generates + * files on the fly. If you only need to preview the results, return a new + * {@link org.eclipse.acceleo.engine.generation.strategy.PreviewStrategy}. Both of these aren't aware of + * the running Eclipse and can be used standalone. + *
+ *+ * If you need the file generation to be aware of the workspace (A typical example is when you wanna + * override files that are under clear case or any other VCS that could forbid the overriding), then + * return a new {@link org.eclipse.acceleo.engine.generation.strategy.WorkspaceAwareStrategy}. + * Note, however, that this cannot be used standalone. + *
+ *+ * All three of these default strategies support merging through JMerge. + *
+ */ + public IAcceleoGenerationStrategy getGenerationStrategy() { + return new DefaultStrategy(); + } + + /** + * This will be called in order to find and load the module that will be launched through this launcher. + * We expect this name not to contain file extension, and the module to be located beside the launcher. + * + * @return The name of the module that is to be launched. + * @generated + */ + @Override + public String getModuleName() { + return MODULE_FILE_NAME; + } + + /** + * If the module(s) called by this launcher require properties files, return their qualified path from + * here.Take note that the first added properties files will take precedence over subsequent ones if they + * contain conflicting keys. + *+ * Properties need to be in source folders, the path that we expect to get as a result of this call are of + * the form <package>.<properties file name without extension>. For example, if you have a file + * named "messages.properties" in package "org.eclipse.acceleo.sample", the path that needs be returned by + * a call to {@link #getProperties()} is "org.eclipse.acceleo.sample.messages". + *
+ * + * @return The list of properties file we need to add to the generation context. + * @see java.util.ResourceBundle#getBundle(String) + * @generated + */ + @Override + public List