[jbosstools-commits] JBoss Tools SVN: r39468 - in trunk/hibernatetools: plugins/org.hibernate.eclipse/src/org/hibernate/console/ext and 10 other directories.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Tue Mar 13 07:28:30 EDT 2012


Author: dgeraskov
Date: 2012-03-13 07:28:27 -0400 (Tue, 13 Mar 2012)
New Revision: 39468

Modified:
   trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/workbench/ConsoleConfigurationWorkbenchAdapter.java
   trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/criteriaeditor/CriteriaEditor.java
   trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationLaunchDelegate.java
   trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfiguration.java
   trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ext/HibernateExtension.java
   trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/OrmDiagram.java
   trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OpenDiagramActionDelegate.java
   trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OrmLabelProvider.java
   trunk/hibernatetools/plugins/org.jboss.tools.hibernate3_5/src/org/jboss/tools/hibernate3_5/HibernateExtension3_5.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/HibernateExtension3_6.java
   trunk/hibernatetools/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/HibernateExtension4_0.java
   trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/BaseTestSetCase.java
   trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/HbmExportExceptionTest.java
Log:
https://issues.jboss.org/browse/JBIDE-11118
Build mappings in HibernateExtension when do so in ConsoleConfiguration.

Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfiguration.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfiguration.java	2012-03-13 10:46:13 UTC (rev 39467)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ConsoleConfiguration.java	2012-03-13 11:28:27 UTC (rev 39468)
@@ -258,6 +258,16 @@
 	public boolean hasConfiguration() {
 		return configuration != null;
 	}
+	
+	public void buildMappings(){
+		execute(new Command() {
+			public Object execute() {
+				getConfiguration().buildMappings();
+				return null;
+			}
+		});
+		getHibernateExtension().buildMappings();
+	}
 
 	public void buildSessionFactory() {
 		execute(new Command() {

Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ext/HibernateExtension.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ext/HibernateExtension.java	2012-03-13 10:46:13 UTC (rev 39467)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse/src/org/hibernate/console/ext/HibernateExtension.java	2012-03-13 11:28:27 UTC (rev 39468)
@@ -10,9 +10,7 @@
  ******************************************************************************/
 package org.hibernate.console.ext;
 
-import org.hibernate.SessionFactory;
 import org.hibernate.console.QueryInputModel;
-import org.hibernate.console.execution.ExecutionContext;
 import org.hibernate.console.execution.ExecutionContext.Command;
 import org.hibernate.console.preferences.ConsoleConfigurationPreferences;
 
@@ -26,6 +24,8 @@
 	
 	public void build();
 	
+	public void buildMappings();
+	
 	public void buildSessionFactory();
 	
 	public boolean closeSessionFactory();

Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/workbench/ConsoleConfigurationWorkbenchAdapter.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/workbench/ConsoleConfigurationWorkbenchAdapter.java	2012-03-13 10:46:13 UTC (rev 39467)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/workbench/ConsoleConfigurationWorkbenchAdapter.java	2012-03-13 11:28:27 UTC (rev 39468)
@@ -27,7 +27,6 @@
 import org.hibernate.console.ConsoleConfiguration;
 import org.hibernate.console.ImageConstants;
 import org.hibernate.console.KnownConfigurations;
-import org.hibernate.console.execution.ExecutionContext;
 import org.hibernate.eclipse.console.HibernateConsoleMessages;
 import org.hibernate.eclipse.console.utils.EclipseImages;
 
@@ -36,17 +35,9 @@
 	public Object[] getChildren(Object o) {
 		final ConsoleConfiguration ccfg = getConsoleConfiguration( o );
 		//String sfError = null;
-		if(ccfg.getConfiguration()==null) {
+		if(!ccfg.hasConfiguration()) {
 			ccfg.build();
-			ccfg.execute( new ExecutionContext.Command() {
-
-				public Object execute() {
-					if(ccfg.hasConfiguration()) {
-						ccfg.getConfiguration().buildMappings();
-					}
-					return ccfg;
-				}
-			} );
+			ccfg.buildMappings();
 		}
 
 		/*if(ccfg.getSessionFactory()==null) { // initialize later?

Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/criteriaeditor/CriteriaEditor.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/criteriaeditor/CriteriaEditor.java	2012-03-13 10:46:13 UTC (rev 39467)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/criteriaeditor/CriteriaEditor.java	2012-03-13 11:28:27 UTC (rev 39468)
@@ -63,7 +63,6 @@
 import org.hibernate.console.ConsoleConfiguration;
 import org.hibernate.console.KnownConfigurations;
 import org.hibernate.console.QueryPage;
-import org.hibernate.console.execution.ExecutionContext;
 import org.hibernate.console.execution.ExecutionContext.Command;
 import org.hibernate.eclipse.console.AbstractQueryEditor;
 import org.hibernate.eclipse.console.HibernateConsoleMessages;
@@ -176,17 +175,10 @@
 
 		final ConsoleConfiguration consoleConfiguration = getConsoleConfiguration();
 
-		if(consoleConfiguration.getConfiguration()==null) {
+		if(!consoleConfiguration.hasConfiguration()) {
 			try {
 			 	consoleConfiguration.build();
-			 	consoleConfiguration.execute( new ExecutionContext.Command() {
-			 		public Object execute() {
-			 			if(consoleConfiguration.hasConfiguration()) {
-			 			consoleConfiguration.getConfiguration().buildMappings();
-			 		}
-			 			return consoleConfiguration;
-			 		}
-				});
+	 			consoleConfiguration.buildMappings();
 			} catch (HibernateException e) {
 				String mess = NLS.bind(HibernateConsoleMessages.CompletionHelper_error_could_not_build_cc, consoleConfiguration.getName());
 				HibernateConsolePlugin.getDefault().logErrorMessage(mess, e);

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-03-13 10:46:13 UTC (rev 39467)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenerationLaunchDelegate.java	2012-03-13 11:28:27 UTC (rev 39468)
@@ -491,16 +491,8 @@
 			return cfg;
 		} else {
 			cc.build();
-			final Configuration configuration = cc.getConfiguration();
-
-			cc.execute(new Command() {
-				public Object execute() {
-
-					configuration.buildMappings();
-					return configuration;
-				}
-			});
-			return configuration;
+			cc.buildMappings();
+			return cc.getConfiguration();
 		}
 	}
 

Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/OrmDiagram.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/OrmDiagram.java	2012-03-13 10:46:13 UTC (rev 39467)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/diagram/editors/model/OrmDiagram.java	2012-03-13 11:28:27 UTC (rev 39468)
@@ -800,10 +800,10 @@
 		}
 		final ConsoleConfiguration consoleConfig = getConsoleConfig();
 		if (consoleConfig != null) {
-			Configuration config = consoleConfig.getConfiguration();
-			if (config == null) {
+			if (!consoleConfig.hasConfiguration()) {
 				try {
     				consoleConfig.build();
+    				consoleConfig.buildMappings();
 				} catch (HibernateException he) {
 					// here just ignore this
 					if (error != null) {
@@ -815,17 +815,8 @@
 						}
 					}
 				}
-				consoleConfig.execute(new ExecutionContext.Command() {
-					public Object execute() {
-						if (consoleConfig.hasConfiguration()) {
-							consoleConfig.getConfiguration().buildMappings();
-						}
-						return consoleConfig;
-					}
-				} );
-				config = consoleConfig.getConfiguration();
 			}
-			return config;
+			return consoleConfig.getConfiguration();
 		}
 		if (error != null && consoleConfigName != null && consoleConfigName.length() > 0) {
 			error.append(consoleConfigName);

Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OpenDiagramActionDelegate.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OpenDiagramActionDelegate.java	2012-03-13 10:46:13 UTC (rev 39467)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OpenDiagramActionDelegate.java	2012-03-13 11:28:27 UTC (rev 39468)
@@ -85,14 +85,9 @@
     						DiagramViewerMessages.OpenDiagramActionDelegate_could_not_load_configuration + 
     						' ' + consoleConfig.getName(), he);
     				}
-    				consoleConfig.execute( new ExecutionContext.Command() {
-    					public Object execute() {
-    						if (consoleConfig.hasConfiguration()) {
-    							consoleConfig.getConfiguration().buildMappings();
-    						}
-    						return consoleConfig;
-    					}
-    				} );
+					if (consoleConfig.hasConfiguration()) {
+						consoleConfig.buildMappings();
+					}
     				config = consoleConfig.getConfiguration();
     			}
     			if (config != null) {

Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OrmLabelProvider.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OrmLabelProvider.java	2012-03-13 10:46:13 UTC (rev 39467)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui/src/org/jboss/tools/hibernate/ui/view/OrmLabelProvider.java	2012-03-13 11:28:27 UTC (rev 39468)
@@ -68,24 +68,15 @@
 	protected Configuration getConfig() {
 		final ConsoleConfiguration consoleConfig = getConsoleConfig();
 		if (consoleConfig != null) {
-			Configuration config = consoleConfig.getConfiguration();
-			if (config == null) {
+			if (!consoleConfig.hasConfiguration()) {
 				try {
     				consoleConfig.build();
+    				consoleConfig.buildMappings();
 				} catch (HibernateException he) {
 					// here just ignore this
 				}
-				consoleConfig.execute(new ExecutionContext.Command() {
-					public Object execute() {
-						if (consoleConfig.hasConfiguration()) {
-							consoleConfig.getConfiguration().buildMappings();
-						}
-						return consoleConfig;
-					}
-				} );
-				config = consoleConfig.getConfiguration();
 			}
-			return config;
+			return consoleConfig.getConfiguration();
 		}
 		return null;
 	}

Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate3_5/src/org/jboss/tools/hibernate3_5/HibernateExtension3_5.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate3_5/src/org/jboss/tools/hibernate3_5/HibernateExtension3_5.java	2012-03-13 10:46:13 UTC (rev 39467)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate3_5/src/org/jboss/tools/hibernate3_5/HibernateExtension3_5.java	2012-03-13 11:28:27 UTC (rev 39468)
@@ -324,4 +324,14 @@
 	public String generateSQL(final String query) {
 		return QueryHelper.generateSQL(executionContext, sessionFactory, query);
 	}
+
+	@Override
+	public void buildMappings() {
+		execute(new Command() {
+			public Object execute() {
+				getConfiguration().buildMappings();
+				return null;
+			}
+		});
+	}
 }

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-03-13 10:46:13 UTC (rev 39467)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate3_5/src/org/jboss/tools/hibernate3_5/console/ConsoleExtension3_5.java	2012-03-13 11:28:27 UTC (rev 39468)
@@ -77,14 +77,7 @@
 		if (!hibernateExtension.hasConfiguration()){
 			try {
 				hibernateExtension.build();
-				hibernateExtension.execute( new ExecutionContext.Command() {
-			 		public Object execute() {
-			 			if(hibernateExtension.hasConfiguration()) {
-			 				hibernateExtension.getConfiguration().buildMappings();
-				 		}
-			 			return null;
-			 		}
-				});
+				hibernateExtension.buildMappings();
 			} catch (HibernateException e){
 				//FIXME
 				//String mess = NLS.bind(HibernateConsoleMessages.CompletionHelper_error_could_not_build_cc, consoleConfiguration.getName());
@@ -269,16 +262,8 @@
 			return cfg;
 		} else {
 			cc.build();
-			final Configuration configuration = cc.getConfiguration();
-
-			cc.execute(new Command() {
-				public Object execute() {
-
-					configuration.buildMappings();
-					return configuration;
-				}
-			});
-			return configuration;
+			cc.buildMappings();
+			return cc.getConfiguration();
 		}
 	}
 	

Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate3_6/src/org/jboss/tools/hibernate3_6/HibernateExtension3_6.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate3_6/src/org/jboss/tools/hibernate3_6/HibernateExtension3_6.java	2012-03-13 10:46:13 UTC (rev 39467)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate3_6/src/org/jboss/tools/hibernate3_6/HibernateExtension3_6.java	2012-03-13 11:28:27 UTC (rev 39468)
@@ -331,4 +331,14 @@
 	public String generateSQL(final String query) {
 		return QueryHelper.generateSQL(executionContext, sessionFactory, query);
 	}
+
+	@Override
+	public void buildMappings() {
+		execute(new Command() {
+			public Object execute() {
+				getConfiguration().buildMappings();
+				return null;
+			}
+		});
+	}
 }
\ No newline at end of file

Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/HibernateExtension4_0.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/HibernateExtension4_0.java	2012-03-13 10:46:13 UTC (rev 39467)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate4_0/src/org/jboss/tools/hibernate4_0/HibernateExtension4_0.java	2012-03-13 11:28:27 UTC (rev 39468)
@@ -15,7 +15,6 @@
 import java.security.PrivilegedAction;
 import java.sql.DriverManager;
 import java.sql.SQLException;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
@@ -37,16 +36,9 @@
 import org.hibernate.console.ext.QueryResultImpl;
 import org.hibernate.console.preferences.ConsoleConfigurationPreferences;
 import org.hibernate.console.preferences.PreferencesClassPathUtils;
-import org.hibernate.eclipse.console.HibernateConsoleMessages;
-import org.hibernate.eclipse.console.utils.QLFormatHelper;
-import org.hibernate.engine.query.spi.HQLQueryPlan;
-import org.hibernate.hql.spi.QueryTranslator;
-import org.hibernate.internal.SessionFactoryImpl;
 import org.hibernate.service.ServiceRegistry;
 import org.hibernate.service.ServiceRegistryBuilder;
 import org.hibernate.service.internal.StandardServiceRegistryImpl;
-import org.hibernate.type.Type;
-import org.hibernate.util.xpl.StringHelper;
 
 /**
  * 
@@ -349,4 +341,14 @@
 	public String generateSQL(final String query) {
 		return QueryHelper.generateSQL(executionContext, sessionFactory, query);
 	}
+
+	@Override
+	public void buildMappings() {
+		execute(new Command() {
+			public Object execute() {
+				getConfiguration().buildMappings();
+				return null;
+			}
+		});
+	}
 }
\ No newline at end of file

Modified: trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/BaseTestSetCase.java
===================================================================
--- trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/BaseTestSetCase.java	2012-03-13 10:46:13 UTC (rev 39467)
+++ trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/BaseTestSetCase.java	2012-03-13 11:28:27 UTC (rev 39468)
@@ -10,6 +10,8 @@
  ******************************************************************************/
 package org.hibernate.eclipse.console.test.mappingproject;
 
+import junit.framework.TestCase;
+
 import org.eclipse.jdt.core.IPackageFragment;
 import org.eclipse.osgi.util.NLS;
 import org.eclipse.swt.widgets.Display;
@@ -20,15 +22,12 @@
 import org.hibernate.cfg.Configuration;
 import org.hibernate.console.ConsoleConfiguration;
 import org.hibernate.console.KnownConfigurations;
-import org.hibernate.console.execution.ExecutionContext;
 import org.hibernate.eclipse.console.test.ConsoleTestMessages;
 import org.hibernate.eclipse.console.workbench.ConfigurationWorkbenchAdapter;
 import org.hibernate.eclipse.console.workbench.ConsoleConfigurationWorkbenchAdapter;
 import org.hibernate.eclipse.console.workbench.PersistentClassWorkbenchAdapter;
 import org.hibernate.eclipse.console.workbench.PropertyWorkbenchAdapter;
 
-import junit.framework.TestCase;
-
 /**
  * @author vy (vyemialyanchyk at gmail.com)
  */
@@ -72,14 +71,7 @@
 		}
 		assertTrue(consCFG.hasConfiguration());
 		if (resetCC) {
-			consCFG.execute(new ExecutionContext.Command() {
-				public Object execute() {
-					if (consCFG.hasConfiguration()) {
-						consCFG.getConfiguration().buildMappings();
-					}
-					return consCFG;
-				}
-			});
+			consCFG.buildMappings();
 		}
 		Object[] configs = null;
 		Object[] persClasses = null;

Modified: trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/HbmExportExceptionTest.java
===================================================================
--- trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/HbmExportExceptionTest.java	2012-03-13 10:46:13 UTC (rev 39467)
+++ trunk/hibernatetools/tests/org.hibernate.eclipse.console.test/src/org/hibernate/eclipse/console/test/mappingproject/HbmExportExceptionTest.java	2012-03-13 11:28:27 UTC (rev 39468)
@@ -24,7 +24,6 @@
 import org.eclipse.osgi.util.NLS;
 import org.hibernate.cfg.Configuration;
 import org.hibernate.console.ConsoleConfiguration;
-import org.hibernate.console.execution.ExecutionContext;
 import org.hibernate.eclipse.console.test.ConsoleTestMessages;
 import org.hibernate.eclipse.console.test.project.ConfigurableTestProject;
 import org.hibernate.eclipse.console.test.utils.ConsoleConfigUtils;
@@ -95,14 +94,7 @@
 					consCFG.reset();
 					consCFG.build();
 					assertTrue(consCFG.hasConfiguration());
-					consCFG.execute(new ExecutionContext.Command() {
-						public Object execute() {
-							if(consCFG.hasConfiguration()) {
-								consCFG.getConfiguration().buildMappings();
-							}
-							return consCFG;
-						}
-					});
+					consCFG.getConfiguration().buildMappings();
 					config = consCFG.getConfiguration();
 				} catch (CoreException e) {
 					String out = NLS.bind(ConsoleTestMessages.UpdateConfigurationTest_error_customising_file_for_package,



More information about the jbosstools-commits mailing list