Author: dgeraskov
Date: 2008-03-12 11:45:59 -0400 (Wed, 12 Mar 2008)
New Revision: 6897
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/model/impl/ExporterFactory.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationLaunchDelegate.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1845
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/model/impl/ExporterFactory.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/model/impl/ExporterFactory.java 2008-03-12
15:12:43 UTC (rev 6896)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/model/impl/ExporterFactory.java 2008-03-12
15:45:59 UTC (rev 6897)
@@ -178,19 +178,27 @@
exporter.setArtifactCollector(collector);
exporter.setOutputDirectory(new File(defaultOutputDirectory));
+ String outputPath = defaultOutputDirectory;
if(props.containsKey("outputdir")) {
- String resolvedOutputDir = resolve(props.getProperty("outputdir"));
- String loc = PathHelper.getLocationAsStringPath(resolvedOutputDir);
- if(loc==null) {
- throw new HibernateConsoleRuntimeException("Output directory '" +
resolvedOutputDir + "' in " + getExporterDefinition().getDescription() +
" does not exist.");
- }
- props.remove("outputdir"); // done to avoid validation check in hibernate
tools templates
- if(StringHelper.isNotEmpty(loc)) { // only set if something valid found
- outputDirectories.add(loc);
- exporter.setOutputDirectory(new File(loc));
- }
- }
+ outputPath = props.getProperty("outputdir");
+ props.remove("outputdir"); // done to avoid validation check in hibernate
tools templates
+ }
+ if (outputPath == null){
+ throw new HibernateConsoleRuntimeException("Output directory is not specified in
" + getExporterDefinition().getDescription() );
+ }
+
+ String resolvedOutputDir = resolve(outputPath);
+ String loc = PathHelper.getLocationAsStringPath(resolvedOutputDir);
+ if(loc==null) {
+ throw new HibernateConsoleRuntimeException("Output directory '" +
resolvedOutputDir + "' in " + getExporterDefinition().getDescription() +
" does not exist.");
+ }
+
+ if(StringHelper.isNotEmpty(loc)) { // only set if something valid found
+ outputDirectories.add(loc);
+ exporter.setOutputDirectory(new File(loc));
+ }
+
exporter.setConfiguration(cfg);
List templatePathList = new ArrayList();
@@ -204,10 +212,16 @@
}
props.remove("template_path"); // done to avoid validation check in
hibernate tools templates
}
- String resolvedCustomTemplatePath = resolve(customTemplatePath);
- if(StringHelper.isNotEmpty(resolvedCustomTemplatePath)) {
- templatePathList.add(resolvedCustomTemplatePath);
+ if (StringHelper.isNotEmpty(customTemplatePath)){
+ String resolvedCustomTemplatePath = resolve(customTemplatePath);
+ String locationAsStringPath =
PathHelper.getLocationAsStringPath(resolvedCustomTemplatePath);
+ if(locationAsStringPath != null) {
+ templatePathList.add(locationAsStringPath);
+ } else {
+ throw new HibernateConsoleRuntimeException("Template directory '" +
resolvedCustomTemplatePath + "' in " +
getExporterDefinition().getDescription() + " does not exist.");
+ }
}
+
exporter.setTemplatePath((String[]) templatePathList.toArray(new
String[templatePathList.size()]));
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationLaunchDelegate.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationLaunchDelegate.java 2008-03-12
15:12:43 UTC (rev 6896)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationLaunchDelegate.java 2008-03-12
15:45:59 UTC (rev 6897)
@@ -32,11 +32,9 @@
import org.eclipse.core.filebuffers.FileBuffers;
import org.eclipse.core.filebuffers.ITextFileBuffer;
-import org.eclipse.core.filebuffers.manipulation.ContainerCreator;
import org.eclipse.core.filebuffers.manipulation.FileBufferOperationRunner;
import org.eclipse.core.filebuffers.manipulation.MultiTextEditWithProgress;
import org.eclipse.core.filebuffers.manipulation.TextFileBufferOperation;
-import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -44,7 +42,6 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
@@ -132,7 +129,6 @@
}
Set outputDirectories = new HashSet();
- outputDirectories.add((String)attributes.getOutputPath());
ExporterFactory[] exporters = (ExporterFactory[]) exporterFactories.toArray( new
ExporterFactory[exporterFactories.size()] );
ArtifactCollector collector = runExporters(attributes, exporters,
outputDirectories, monitor);
@@ -210,27 +206,6 @@
if (monitor.isCanceled())
return null;
-
- String outputPathRes =
PathHelper.getLocationAsStringPath(attributes.getOutputPath());
- if (outputPathRes == null &&
StringHelper.isNotEmpty(attributes.getOutputPath())){
- ContainerCreator cc = new ContainerCreator(ResourcesPlugin.getWorkspace(),
PathHelper.pathOrNull(attributes.getOutputPath()));
- IFolder folder = (IFolder) cc.createContainer(new NullProgressMonitor());
- if (folder != null) {
- outputPathRes = PathHelper.getLocation( folder ).toOSString();
- }
- }
- final String fOutputPathRes = outputPathRes;
-
- String templatePath =
PathHelper.getLocationAsStringPath(attributes.getTemplatePath());
- if (templatePath == null &&
StringHelper.isNotEmpty(attributes.getTemplatePath())){
- ContainerCreator cc = new ContainerCreator(ResourcesPlugin.getWorkspace(),
PathHelper.pathOrNull(attributes.getTemplatePath()));
- IFolder folder = (IFolder) cc.createContainer(new NullProgressMonitor());
- if (folder != null) {
- templatePath = PathHelper.getLocation( folder ).toOSString();
- }
- }
- final String fTemplatePath = templatePath;
-
ConsoleConfiguration cc =
KnownConfigurations.getInstance().find(attributes.getConsoleConfigurationName());
if (attributes.isReverseEngineer()) {
monitor.subTask("reading jdbc metadata");
@@ -246,12 +221,6 @@
public Object execute() {
ArtifactCollector artifactCollector = new ArtifactCollector();
-
- String templatePaths = null;
-
- if(StringHelper.isNotEmpty(fTemplatePath)) {
- templatePaths = fTemplatePath;
- }
// Global properties
Properties props = new Properties();
@@ -267,7 +236,7 @@
Exporter exporter;
try {
- exporter = exporterFactories[i].createConfiguredExporter(cfg, fOutputPathRes,
templatePaths, globalProperties, outputDirectories, artifactCollector);
+ exporter = exporterFactories[i].createConfiguredExporter(cfg,
attributes.getOutputPath(), attributes.getTemplatePath(), globalProperties,
outputDirectories, artifactCollector);
} catch (CoreException e) {
throw new HibernateConsoleRuntimeException("Error while setting up " +
exporterFactories[i].getExporterDefinition(), e);
}