Author: dgeraskov
Date: 2008-03-07 07:56:10 -0500 (Fri, 07 Mar 2008)
New Revision: 6766
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
Create all path segments that don't exists(even new project!) using standard
ContainerCreator.
Removed unnecessary methods from PathHelper.
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-07
12:54:14 UTC (rev 6765)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationLaunchDelegate.java 2008-03-07
12:56:10 UTC (rev 6766)
@@ -32,6 +32,7 @@
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;
@@ -212,7 +213,8 @@
String outputPathRes =
PathHelper.getLocationAsStringPath(attributes.getOutputPath());
if (outputPathRes == null){
- IFolder folder = (IFolder) PathHelper.getOrCreateFolder(attributes.getOutputPath());
+ ContainerCreator cc = new ContainerCreator(ResourcesPlugin.getWorkspace(),
PathHelper.pathOrNull(outputPathRes));
+ IFolder folder = (IFolder) cc.createContainer(new NullProgressMonitor());
if (folder != null) {
outputPathRes = PathHelper.getLocation( folder ).toOSString();
}
@@ -221,7 +223,8 @@
String templatePath =
PathHelper.getLocationAsStringPath(attributes.getTemplatePath());
if (templatePath == null){
- IFolder folder = (IFolder)
PathHelper.getOrCreateFolder(attributes.getTemplatePath());
+ ContainerCreator cc = new ContainerCreator(ResourcesPlugin.getWorkspace(),
PathHelper.pathOrNull(templatePath));
+ IFolder folder = (IFolder) cc.createContainer(new NullProgressMonitor());
if (folder != null) {
templatePath = PathHelper.getLocation( folder ).toOSString();
}
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-07
12:54:14 UTC (rev 6765)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/PathHelper.java 2008-03-07
12:56:10 UTC (rev 6766)
@@ -3,38 +3,17 @@
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;