[jbosstools-commits] JBoss Tools SVN: r6687 - trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Wed Mar 5 04:43:42 EST 2008


Author: dgeraskov
Date: 2008-03-05 04:43:42 -0500 (Wed, 05 Mar 2008)
New Revision: 6687

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/PathHelper.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1845

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-05 08:04:32 UTC (rev 6686)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationLaunchDelegate.java	2008-03-05 09:43:42 UTC (rev 6687)
@@ -35,6 +35,7 @@
 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;
@@ -42,6 +43,7 @@
 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;
@@ -208,9 +210,23 @@
 				return null;
 			
 			
-			final String outputPathRes = PathHelper.getLocationAsStringPath(attributes.getOutputPath());
+			String outputPathRes = PathHelper.getLocationAsStringPath(attributes.getOutputPath());			
+			if (outputPathRes == null){
+				IFolder folder = (IFolder) PathHelper.getOrCreateFolder(attributes.getOutputPath());
+				if (folder != null) {
+					outputPathRes = PathHelper.getLocation( folder ).toOSString();
+				}
+			}			
+			final String fOutputPathRes = outputPathRes;
 	        
-	        final String templatePath = PathHelper.getLocationAsStringPath(attributes.getTemplatePath());
+	        String templatePath = PathHelper.getLocationAsStringPath(attributes.getTemplatePath());	       
+	        if (templatePath == null){
+	        	IFolder folder = (IFolder) PathHelper.getOrCreateFolder(attributes.getTemplatePath());
+				if (folder != null) {
+					templatePath = PathHelper.getLocation( folder ).toOSString();
+				}
+			}
+	        final String fTemplatePath = templatePath;
 	        
 			ConsoleConfiguration cc = KnownConfigurations.getInstance().find(attributes.getConsoleConfigurationName());
 			if (attributes.isReverseEngineer()) {
@@ -230,8 +246,8 @@
 					
 					String templatePaths = null;
 					
-					if(StringHelper.isNotEmpty(templatePath)) {
-	                	templatePaths = templatePath;
+					if(StringHelper.isNotEmpty(fTemplatePath)) {
+	                	templatePaths = fTemplatePath;
 	                }
 	                
                     // Global properties
@@ -248,7 +264,7 @@
                        
                        Exporter exporter;
 					try {
-						exporter = exporterFactories[i].createConfiguredExporter(cfg, outputPathRes, templatePaths, globalProperties, outputDirectories, artifactCollector);
+						exporter = exporterFactories[i].createConfiguredExporter(cfg, fOutputPathRes, templatePaths, globalProperties, outputDirectories, artifactCollector);
 					} catch (CoreException e) {
 						throw new HibernateConsoleRuntimeException("Error while setting up " + exporterFactories[i].getExporterDefinition(), e);
 					}

Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/PathHelper.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/PathHelper.java	2008-03-05 08:04:32 UTC (rev 6686)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/PathHelper.java	2008-03-05 09:43:42 UTC (rev 6687)
@@ -3,17 +3,38 @@
 import java.io.File;
 
 import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFolder;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IResource;
 import org.eclipse.core.resources.IWorkspaceRoot;
 import org.eclipse.core.resources.ResourcesPlugin;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.core.variables.IStringVariableManager;
 import org.eclipse.core.variables.VariablesPlugin;
 // TODO: move to internal.
 public class PathHelper {
+	
+	public static IFolder getOrCreateFolder(IPath path) {
+		if (path == null) return null;
+		IFolder folder = ResourcesPlugin.getWorkspace().getRoot().getFolder(path);
+		if (!folder.exists()) {
+			try {
+				folder.create(false, true,
+						new NullProgressMonitor());
+			} catch (Exception ex) {
+				ex.printStackTrace();
+			}
+		}
+		return folder;
+	}
+	
+	public static IFolder getOrCreateFolder(String path) {
+		if (path == null) return null;
+		return getOrCreateFolder(pathOrNull(path));
+	}
 
 	public static String getLocationAsStringPath(String path) {
 		if(path==null) return null;




More information about the jbosstools-commits mailing list