Author: max.andersen(a)jboss.com
Date: 2007-10-25 13:44:49 -0400 (Thu, 25 Oct 2007)
New Revision: 4521
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:
JBIDE-1171 (regression) run eclipse formatter on generated code
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
17:24:49 UTC (rev 4520)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/model/impl/ExporterFactory.java 2007-10-25
17:44:49 UTC (rev 4521)
@@ -17,6 +17,7 @@
import org.hibernate.console.HibernateConsoleRuntimeException;
import org.hibernate.eclipse.launch.HibernateLaunchConstants;
import org.hibernate.eclipse.launch.PathHelper;
+import org.hibernate.tool.hbm2x.ArtifactCollector;
import org.hibernate.tool.hbm2x.Exporter;
import org.hibernate.tool.hbm2x.GenericExporter;
import org.hibernate.util.StringHelper;
@@ -160,18 +161,21 @@
/**
* Creates exporter with the specified settings; also resolves any relevant properties
via Eclipse VariablesPlugin.
+ * @param collector
* @throws CoreException in case of resolve variables issues.
*/
public Exporter createConfiguredExporter(Configuration cfg, String
defaultOutputDirectory,
- String customTemplatePath, Properties globalProperties, Set outputDirectories) throws
CoreException {
+ String customTemplatePath, Properties globalProperties, Set outputDirectories,
ArtifactCollector collector) throws CoreException {
Exporter exporter = getExporterDefinition().createExporterInstance();
+
Properties props = new Properties();
props.putAll(globalProperties);
props.putAll(getProperties());
exporter.setProperties(props);
+ exporter.setArtifactCollector(collector);
exporter.setOutputDirectory(new File(defaultOutputDirectory));
if(props.containsKey("outputdir")) {
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
17:24:49 UTC (rev 4520)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationLaunchDelegate.java 2007-10-25
17:44:49 UTC (rev 4521)
@@ -38,7 +38,6 @@
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;
@@ -56,7 +55,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;
@@ -70,7 +69,6 @@
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;
@@ -139,6 +137,8 @@
formatGeneratedCode( monitor, collector );
}
+
+
Iterator iterator = outputDirectories.iterator();
while (iterator.hasNext()) {
String path = (String) iterator.next();
@@ -158,10 +158,11 @@
}
private void formatGeneratedCode(IProgressMonitor monitor, ArtifactCollector collector)
{
- final TextFileBufferOperation operation = new FormatGeneratedCode(
"java-artifact-format" );
+ final TextFileBufferOperation operation = new FormatGeneratedCode( "Formate
generated code" );
File[] javaFiles = collector.getFiles("java");
if(javaFiles.length>0) {
+
IPath[] locations = new IPath[javaFiles.length];
for (int i = 0; i < javaFiles.length; i++) {
@@ -182,6 +183,7 @@
HibernateConsolePlugin.getDefault().logErrorMessage("exception during java
format", e);
}
}
+
}
private void refreshOutputDir(String outputdir) {
@@ -222,9 +224,9 @@
return null;
return (ArtifactCollector) cc.execute(new Command() {
- private ArtifactCollector artifactCollector = new ArtifactCollector();
public Object execute() {
+ ArtifactCollector artifactCollector = new ArtifactCollector();
String templatePaths = null;
@@ -246,7 +248,7 @@
Exporter exporter;
try {
- exporter = exporterFactories[i].createConfiguredExporter(cfg, outputPathRes,
templatePaths, globalProperties, outputDirectories);
+ exporter = exporterFactories[i].createConfiguredExporter(cfg, outputPathRes,
templatePaths, globalProperties, outputDirectories, artifactCollector);
} catch (CoreException e) {
throw new HibernateConsoleRuntimeException("Error while setting up " +
exporterFactories[i].getExporterDefinition(), e);
}
@@ -254,12 +256,9 @@
exporter.start();
monitor.worked(1);
}
- return getArtififactCollector();
+ return artifactCollector;
}
- private ArtifactCollector getArtififactCollector() {
- return artifactCollector ;
- }
});
Show replies by date