bugs fixed
diff --git a/org.eclipse.emf.refactor.refactoring.generator/src/org/eclipse/emf/refactor/refactoring/generator/managers/GenerationManager.java b/org.eclipse.emf.refactor.refactoring.generator/src/org/eclipse/emf/refactor/refactoring/generator/managers/GenerationManager.java index 1e4a1da..9770c7d 100644 --- a/org.eclipse.emf.refactor.refactoring.generator/src/org/eclipse/emf/refactor/refactoring/generator/managers/GenerationManager.java +++ b/org.eclipse.emf.refactor.refactoring.generator/src/org/eclipse/emf/refactor/refactoring/generator/managers/GenerationManager.java
@@ -103,7 +103,7 @@ protected final String REFACTORINGDATAMANAGEMENT = "RefactoringDataManagement"; protected final String REFACTORINGTEST = "RefactoringTest"; - protected final String XMLCONFIG = "Config"; + private final String XMLCONFIG = "Config"; /** @@ -328,6 +328,7 @@ */ protected String generateCode(IProgressMonitor monitor, String template) { String templatePath = this.templateDirectory + template + JAVAJET; + System.out.println("templatePath: " + templatePath); ClassLoader classLoader = getClass().getClassLoader(); this.jetEmitter = new JETEmitter(templatePath, classLoader); this.jetEmitter.getClasspathEntries().addAll(classpathEntries); @@ -359,7 +360,7 @@ * as well as the contained config.xml files. * @param monitor Object monitoring the code generation. */ - protected void createTestFolders(IProgressMonitor monitor) { + private void createTestFolders(IProgressMonitor monitor) { IProject project = ResourcesPlugin.getWorkspace().getRoot() .getProject(this.info.getProjectName()); System.out.println("-- info.getNumberOfTests(): " + info.getNumberOfTests()); @@ -395,8 +396,8 @@ * the config should be saved. */ private void createConfigXml(IProgressMonitor monitor, String path) { -// String generatedCode = this.generateCode(monitor, XMLCONFIG); - String generatedCode = "TO DO"; + String generatedCode = this.generateCode(monitor, XMLCONFIG); +// String generatedCode = "TO DO"; try { // String path = xmlLocation.getCanonicalPath() + "/config.xml"; File configXml = new File(path);
diff --git a/org.eclipse.emf.refactor.refactoring.generator/templates/Config.javajet b/org.eclipse.emf.refactor.refactoring.generator/templates/Config.javajet index 1aef5a4..55b0c26 100644 --- a/org.eclipse.emf.refactor.refactoring.generator/templates/Config.javajet +++ b/org.eclipse.emf.refactor.refactoring.generator/templates/Config.javajet
@@ -6,7 +6,7 @@ <% for (ParameterInfo pi : info.getParameters()) { %> <param> <name><%=pi.getName()%></name> - <value>enter value here</value> + <value>enter value here...</value> </param> <% } %> </config> \ No newline at end of file
diff --git a/org.eclipse.emf.refactor.refactoring.henshin/src/org/eclipse/emf/refactor/refactoring/henshin/managers/HenshinGenerationManager.java b/org.eclipse.emf.refactor.refactoring.henshin/src/org/eclipse/emf/refactor/refactoring/henshin/managers/HenshinGenerationManager.java index 3dab1ce..c57414f 100644 --- a/org.eclipse.emf.refactor.refactoring.henshin/src/org/eclipse/emf/refactor/refactoring/henshin/managers/HenshinGenerationManager.java +++ b/org.eclipse.emf.refactor.refactoring.henshin/src/org/eclipse/emf/refactor/refactoring/henshin/managers/HenshinGenerationManager.java
@@ -1,8 +1,11 @@ package org.eclipse.emf.refactor.refactoring.henshin.managers; +import java.io.File; import java.io.IOException; import java.util.List; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.IProgressMonitor; @@ -34,6 +37,7 @@ "RefactoringInformation"; protected final String REFACTORINGTESTHENSHIN = "RefactoringTestHenshin"; + private final String XMLCONFIGHENSHIN = "ConfigHenshin"; /** * Configuration data used for generating model refactoring code. @@ -113,5 +117,65 @@ } return td; } + + /** + * Creates the set of test folders for the generated model refactoring + * as well as the contained config.xml files. + * @param monitor Object monitoring the code generation. + */ + protected void createTestFolders(IProgressMonitor monitor) { + IProject project = ResourcesPlugin.getWorkspace().getRoot() + .getProject(this.info.getProjectName()); + System.out.println("-- info.getNumberOfTests(): " + info.getNumberOfTests()); + if (this.info.getNumberOfTests() > 0) { + String rootDir = "/tests/" + this.info.getRefactoringId() + "/"; + String dirPath = project.getLocation().append(rootDir).toOSString(); + System.out.println("--- dirPath: " + dirPath); + File testFolder = new File(dirPath); + testFolder.mkdirs(); + if (testFolder.exists() && testFolder.isDirectory()){ + for (int i = 1; i <= this.info.getNumberOfTests(); i++) { + String testDirSnippet = "/test_" + String.format("%03d", i) + "/"; + String testDir = project.getLocation().append(rootDir + testDirSnippet).toOSString(); + System.out.println("--- testDir: " + testDir); + File specifictestfolder = new File(testDir); + if (!specifictestfolder.exists() + || !specifictestfolder.isDirectory()) { + specifictestfolder.mkdir(); + String xmlName = "/config.xml"; + String xmlLocation = project.getLocation().append(rootDir + testDirSnippet + xmlName).toOSString(); + createConfigXml(monitor, xmlLocation); + } + } + } + } + } + + /** + * Creates the config.xml files within the test folders for the + * generated model refactoring. + * @param monitor Object monitoring the code generation. + * @param xmlLocation File object containing the folder in which + * the config should be saved. + */ + private void createConfigXml(IProgressMonitor monitor, String path) { + String generatedCode = this.generateCode(monitor, XMLCONFIGHENSHIN); +// String generatedCode = "TO DO"; + try { +// String path = xmlLocation.getCanonicalPath() + "/config.xml"; + File configXml = new File(path); + System.out.println("---- createConfigXml::path: " + path); + if (!configXml.exists() || !configXml.isFile()) { + this.saveXml(monitor, generatedCode, + configXml.getCanonicalPath().toString()); + } + } catch (IOException e) { + e.printStackTrace(); + } catch (JETException e) { + e.printStackTrace(); + } catch (CoreException e) { + e.printStackTrace(); + } + } }