Author: max.andersen(a)jboss.com
Date: 2007-10-25 12:06:10 -0400 (Thu, 25 Oct 2007)
New Revision: 4516
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/.classpath
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
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/PathHelper.java
Log:
Make sure to refresh all output directories when code generation have been executed.
Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/.classpath
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/.classpath 2007-10-25
16:00:03 UTC (rev 4515)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/.classpath 2007-10-25
16:06:10 UTC (rev 4516)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
- <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
<classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="build/eclipse"/>
</classpath>
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 2007-10-25
16:00:03 UTC (rev 4515)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/model/impl/ExporterFactory.java 2007-10-25
16:06:10 UTC (rev 4516)
@@ -6,6 +6,7 @@
import java.util.List;
import java.util.Map;
import java.util.Properties;
+import java.util.Set;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.variables.IStringVariableManager;
@@ -162,7 +163,7 @@
* @throws CoreException in case of resolve variables issues.
*/
public Exporter createConfiguredExporter(Configuration cfg, String
defaultOutputDirectory,
- String customTemplatePath, Properties globalProperties) throws CoreException {
+ String customTemplatePath, Properties globalProperties, Set outputDirectories) throws
CoreException {
Exporter exporter = getExporterDefinition().createExporterInstance();
@@ -181,6 +182,7 @@
}
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));
}
}
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 2007-10-25
16:00:03 UTC (rev 4515)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationLaunchDelegate.java 2007-10-25
16:06:10 UTC (rev 4516)
@@ -23,10 +23,12 @@
import java.io.File;
import java.lang.reflect.Constructor;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
+import java.util.Set;
import org.eclipse.core.filebuffers.FileBuffers;
import org.eclipse.core.filebuffers.ITextFileBuffer;
@@ -36,6 +38,7 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -53,7 +56,7 @@
import org.eclipse.jdt.core.formatter.CodeFormatter;
import org.eclipse.jface.text.DocumentRewriteSessionType;
import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.util.Assert;
+
import org.eclipse.text.edits.TextEdit;
import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.JDBCMetaDataConfiguration;
@@ -67,6 +70,7 @@
import org.hibernate.console.execution.ExecutionContext.Command;
import org.hibernate.eclipse.console.HibernateConsolePlugin;
import org.hibernate.eclipse.console.model.impl.ExporterFactory;
+import org.hibernate.tool.hbm2x.AbstractExporter;
import org.hibernate.tool.hbm2x.ArtifactCollector;
import org.hibernate.tool.hbm2x.Exporter;
import org.hibernate.util.ReflectHelper;
@@ -126,15 +130,20 @@
}
}
+ Set outputDirectories = new HashSet();
+ outputDirectories.add((String)attributes.getOutputPath());
ExporterFactory[] exporters = (ExporterFactory[]) exporterFactories.toArray( new
ExporterFactory[exporterFactories.size()] );
- ArtifactCollector collector = runExporters(attributes, exporters, monitor);
- refreshOutputDir( attributes.getOutputPath() );
-
- if(collector==null) {
- return;
+ ArtifactCollector collector = runExporters(attributes, exporters,
outputDirectories, monitor);
+
+ if(collector!=null) {
+ formatGeneratedCode( monitor, collector );
}
- formatGeneratedCode( monitor, collector );
+ Iterator iterator = outputDirectories.iterator();
+ while (iterator.hasNext()) {
+ String path = (String) iterator.next();
+ refreshOutputDir( path );
+ }
RefreshTab.refreshResources(configuration, monitor);
@@ -187,7 +196,7 @@
}
}
- private ArtifactCollector runExporters (final ExporterAttributes attributes, final
ExporterFactory[] exporterFactories, final IProgressMonitor monitor)
+ private ArtifactCollector runExporters (final ExporterAttributes attributes, final
ExporterFactory[] exporterFactories, final Set outputDirectories, final IProgressMonitor
monitor)
throws CoreException
{
@@ -237,11 +246,11 @@
Exporter exporter;
try {
- exporter = exporterFactories[i].createConfiguredExporter(cfg, outputPathRes,
templatePaths, globalProperties);
+ exporter = exporterFactories[i].createConfiguredExporter(cfg, outputPathRes,
templatePaths, globalProperties, outputDirectories);
} catch (CoreException e) {
throw new HibernateConsoleRuntimeException("Error while setting up " +
exporterFactories[i].getExporterDefinition(), e);
}
-
+
exporter.start();
monitor.worked(1);
}
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 2007-10-25
16:00:03 UTC (rev 4515)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/PathHelper.java 2007-10-25
16:06:10 UTC (rev 4516)
@@ -2,6 +2,7 @@
import java.io.File;
+import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
@@ -32,7 +33,15 @@
public static IResource findMember(IWorkspaceRoot root, String path) {
Path pathOrNull = PathHelper.pathOrNull(path);
if(pathOrNull==null) return null;
- return root.findMember(pathOrNull);
+
+ IResource findMember = root.findMember(pathOrNull);
+ if(findMember==null) {
+ IContainer[] findContainersForLocation = root.findContainersForLocation(pathOrNull);
+ if(findContainersForLocation.length>0) {
+ findMember = findContainersForLocation[0];
+ }
+ }
+ return findMember;
}
public static IPath getLocation(final IResource resource) {