Author: dgeraskov
Date: 2012-01-24 03:50:26 -0500 (Tue, 24 Jan 2012)
New Revision: 38072
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/ext/ConsoleExtension.java
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationLaunchDelegate.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate3_5/src/org/jboss/tools/hibernate3_5/console/ConsoleExtension3_5.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate3_6/src/org/jboss/tools/hibernate3_6/console/ConsoleExtension3_6.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/console/ConsoleExtension4_0.java
Log:
https://issues.jboss.org/browse/JBIDE-10571
Run code formatting on the generated java files
Modified:
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/ext/ConsoleExtension.java
===================================================================
---
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/ext/ConsoleExtension.java 2012-01-24
07:21:01 UTC (rev 38071)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/ext/ConsoleExtension.java 2012-01-24
08:50:26 UTC (rev 38072)
@@ -10,6 +10,9 @@
******************************************************************************/
package org.hibernate.eclipse.console.ext;
+import java.io.File;
+import java.util.Map;
+
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.debug.core.ILaunch;
@@ -26,7 +29,16 @@
public void setHibernateException(HibernateExtension hibernateExtension);
- public void launchExporters(ILaunchConfiguration configuration, String mode,
+ /**
+ *
+ * @param configuration
+ * @param mode
+ * @param launch
+ * @param monitor
+ * @return the generated files separated by the contents
+ * @throws CoreException
+ */
+ public Map<String, File[]> launchExporters(ILaunchConfiguration configuration,
String mode,
ILaunch launch, IProgressMonitor monitor) throws CoreException;
}
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 2012-01-24
07:21:01 UTC (rev 38071)
+++
trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationLaunchDelegate.java 2012-01-24
08:50:26 UTC (rev 38072)
@@ -265,8 +265,12 @@
ExporterAttributes attributes = new ExporterAttributes(configuration);
ConsoleConfiguration cc =
KnownConfigurations.getInstance().find(attributes.getConsoleConfigurationName());
ConsoleExtension consoleExtension =
ConsoleExtensionManager.getConsoleExtension(cc.getHibernateExtension());
- consoleExtension.launchExporters(configuration, mode, launch, monitor);
-
+ Map<String, File[]> generatedFiles =
consoleExtension.launchExporters(configuration, mode, launch, monitor);
+ // code formatting needs to happen *after* refresh to make sure eclipse will format the
uptodate files!
+ if(generatedFiles!=null) {
+ formatGeneratedCode( monitor, generatedFiles );
+ }
+
/* The code is moved to consoleExtension and delegated method is called instead.
List<ExporterFactory> exporterFactories = attributes.getExporterFactories();
@@ -334,10 +338,10 @@
}
- private void formatGeneratedCode(IProgressMonitor monitor, ArtifactCollector collector)
{
+ private void formatGeneratedCode(IProgressMonitor monitor, Map<String, File[]>
generatedFiles) {
final TextFileBufferOperation operation = new FormatGeneratedCode(
HibernateConsoleMessages.CodeGenerationLaunchDelegate_formate_generated_code );
- File[] javaFiles = collector.getFiles("java"); //$NON-NLS-1$
+ File[] javaFiles = generatedFiles.get("java"); //$NON-NLS-1$
if(javaFiles.length>0) {
IPath[] locations = new IPath[javaFiles.length];
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate3_5/src/org/jboss/tools/hibernate3_5/console/ConsoleExtension3_5.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate3_5/src/org/jboss/tools/hibernate3_5/console/ConsoleExtension3_5.java 2012-01-24
07:21:01 UTC (rev 38071)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate3_5/src/org/jboss/tools/hibernate3_5/console/ConsoleExtension3_5.java 2012-01-24
08:50:26 UTC (rev 38072)
@@ -12,9 +12,11 @@
import java.io.File;
import java.lang.reflect.Constructor;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
import java.util.Set;
@@ -98,8 +100,9 @@
/* (non-Javadoc)
* @see
org.hibernate.eclipse.console.ext.ConsoleExtension#launchExporters(org.hibernate.eclipse.console.ext.ILaunchConfiguration,
java.lang.String, org.hibernate.eclipse.console.ext.ILaunch,
org.eclipse.core.runtime.IProgressMonitor)
*/
+ @SuppressWarnings("unchecked")
@Override
- public void launchExporters(ILaunchConfiguration configuration,
+ public Map<String, File[]> launchExporters(ILaunchConfiguration configuration,
String mode, ILaunch launch, IProgressMonitor monitor)
throws CoreException {
Assert.isNotNull(configuration);
@@ -126,10 +129,14 @@
// code formatting needs to happen *after* refresh to make sure eclipse will format
the uptodate files!
if(collector!=null) {
- //formatGeneratedCode( monitor, collector );
+ Map<String, File[]> map = new HashMap<String, File[]>();
+ Set<String> types = collector.getFileTypes();
+ for (String type : types) {
+ File[] files = collector.getFiles(type.toString());
+ map.put(type, files);
+ }
+ return map;
}
-
-
} catch(Exception e) {
throw new CoreException(HibernateConsolePlugin.throwableToStatus(e, 666));
} catch(NoClassDefFoundError e) {
@@ -137,6 +144,7 @@
} finally {
monitor.done();
}
+ return null;
}
private ArtifactCollector runExporters (final ExporterAttributes attributes, final
ExporterFactory[] exporterFactories, final Set<String> outputDirectories, final
IProgressMonitor monitor)
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate3_6/src/org/jboss/tools/hibernate3_6/console/ConsoleExtension3_6.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate3_6/src/org/jboss/tools/hibernate3_6/console/ConsoleExtension3_6.java 2012-01-24
07:21:01 UTC (rev 38071)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate3_6/src/org/jboss/tools/hibernate3_6/console/ConsoleExtension3_6.java 2012-01-24
08:50:26 UTC (rev 38072)
@@ -12,9 +12,11 @@
import java.io.File;
import java.lang.reflect.Constructor;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
import java.util.Set;
@@ -97,8 +99,9 @@
/* (non-Javadoc)
* @see
org.hibernate.eclipse.console.ext.ConsoleExtension#launchExporters(org.hibernate.eclipse.console.ext.ILaunchConfiguration,
java.lang.String, org.hibernate.eclipse.console.ext.ILaunch,
org.eclipse.core.runtime.IProgressMonitor)
*/
+ @SuppressWarnings("unchecked")
@Override
- public void launchExporters(ILaunchConfiguration configuration,
+ public Map<String, File[]> launchExporters(ILaunchConfiguration configuration,
String mode, ILaunch launch, IProgressMonitor monitor)
throws CoreException {
Assert.isNotNull(configuration);
@@ -125,7 +128,13 @@
// code formatting needs to happen *after* refresh to make sure eclipse will format
the uptodate files!
if(collector!=null) {
- //formatGeneratedCode( monitor, collector );
+ Map<String, File[]> map = new HashMap<String, File[]>();
+ Set<String> types = collector.getFileTypes();
+ for (String type : types) {
+ File[] files = collector.getFiles(type.toString());
+ map.put(type, files);
+ }
+ return map;
}
@@ -136,6 +145,7 @@
} finally {
monitor.done();
}
+ return null;
}
private ArtifactCollector runExporters (final ExporterAttributes attributes, final
ExporterFactory[] exporterFactories, final Set<String> outputDirectories, final
IProgressMonitor monitor)
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/console/ConsoleExtension4_0.java
===================================================================
---
trunk/hibernatetools/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/console/ConsoleExtension4_0.java 2012-01-24
07:21:01 UTC (rev 38071)
+++
trunk/hibernatetools/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/console/ConsoleExtension4_0.java 2012-01-24
08:50:26 UTC (rev 38072)
@@ -12,9 +12,11 @@
import java.io.File;
import java.lang.reflect.Constructor;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
import java.util.Set;
@@ -97,8 +99,9 @@
/* (non-Javadoc)
* @see
org.hibernate.eclipse.console.ext.ConsoleExtension#launchExporters(org.hibernate.eclipse.console.ext.ILaunchConfiguration,
java.lang.String, org.hibernate.eclipse.console.ext.ILaunch,
org.eclipse.core.runtime.IProgressMonitor)
*/
+ @SuppressWarnings("unchecked")
@Override
- public void launchExporters(ILaunchConfiguration configuration,
+ public Map<String, File[]> launchExporters(ILaunchConfiguration configuration,
String mode, ILaunch launch, IProgressMonitor monitor)
throws CoreException {
Assert.isNotNull(configuration);
@@ -125,10 +128,14 @@
// code formatting needs to happen *after* refresh to make sure eclipse will format
the uptodate files!
if(collector!=null) {
- //formatGeneratedCode( monitor, collector );
+ Map<String, File[]> map = new HashMap<String, File[]>();
+ Set<String> types = collector.getFileTypes();
+ for (String type : types) {
+ File[] files = collector.getFiles(type.toString());
+ map.put(type, files);
+ }
+ return map;
}
-
-
} catch(Exception e) {
throw new CoreException(HibernateConsolePlugin.throwableToStatus(e, 666));
} catch(NoClassDefFoundError e) {
@@ -136,6 +143,7 @@
} finally {
monitor.done();
}
+ return null;
}
private ArtifactCollector runExporters (final ExporterAttributes attributes, final
ExporterFactory[] exporterFactories, final Set<String> outputDirectories, final
IProgressMonitor monitor)