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

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Fri Aug 6 09:19:19 EDT 2010


Author: vyemialyanchyk
Date: 2010-08-06 09:19:19 -0400 (Fri, 06 Aug 2010)
New Revision: 23970

Modified:
   trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/codegen/ExportAntCodeGenWizardPage.java
   trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.java
   trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.properties
   trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenXMLFactory.java
   trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ExporterAttributes.java
Log:
https://jira.jboss.org/browse/JBIDE-6750 - fixed

Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/codegen/ExportAntCodeGenWizardPage.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/codegen/ExportAntCodeGenWizardPage.java	2010-08-06 13:18:57 UTC (rev 23969)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/codegen/ExportAntCodeGenWizardPage.java	2010-08-06 13:19:19 UTC (rev 23970)
@@ -18,6 +18,7 @@
 import org.eclipse.jdt.internal.ui.wizards.dialogfields.ComboDialogField;
 import org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField;
 import org.eclipse.jdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
+import org.eclipse.jface.dialogs.IMessageProvider;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.layout.GridData;
@@ -29,6 +30,7 @@
 import org.hibernate.eclipse.console.HibernateConsoleMessages;
 import org.hibernate.eclipse.console.utils.LaunchHelper;
 import org.hibernate.eclipse.launch.CodeGenXMLFactory;
+import org.hibernate.eclipse.launch.ExporterAttributes;
 
 /**
  * @author Vitali Yemialyanchyk
@@ -114,10 +116,34 @@
 			if (consoleConfigurationName.getSelectionIndex() == -1) {
 				setErrorMessage(HibernateConsoleMessages.ExportAntCodeGenWizardPage_empty_hibernate_code_generation_configuration);
 				res = false;
+			} else {
+				ILaunchConfiguration lc = getSelectedLaunchConfig();
+				if (lc == null) {
+					setErrorMessage(HibernateConsoleMessages.ExportAntCodeGenWizardPage_cannot_find_selected_hibernate_code_generation_configuration);
+					res = false;
+				} else {
+					String checkMessage = checkCodeGenLaunchConfig(lc);
+					if  (checkMessage != null) {
+						checkMessage = HibernateConsoleMessages.ExportAntCodeGenWizardPage_error_in_hibernate_code_generation_configuration 
+							+  " " + checkMessage; //$NON-NLS-1$
+						setMessage(checkMessage, IMessageProvider.WARNING);
+					}
+				}
 			}
 		}
 		return res;
 	}
+	
+	protected String checkCodeGenLaunchConfig(ILaunchConfiguration lc) {
+		String checkMessage = null;
+		try {
+			ExporterAttributes attributes = new ExporterAttributes(lc);
+			checkMessage = attributes.checkExporterAttributes();
+		} catch (CoreException e) {
+			checkMessage = e.getMessage();
+		}
+		return checkMessage;
+	}
 
 	public ILaunchConfiguration getSelectedLaunchConfig() {
 		ILaunchConfiguration[] launchCfgs;

Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.java	2010-08-06 13:18:57 UTC (rev 23969)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.java	2010-08-06 13:19:19 UTC (rev 23970)
@@ -521,6 +521,8 @@
 	public static String ExportAntCodeGenWizard_page_name;
 	public static String ExportAntCodeGenWizardPage_hibernate_code_generation_configurations;
 	public static String ExportAntCodeGenWizardPage_empty_hibernate_code_generation_configuration;
+	public static String ExportAntCodeGenWizardPage_cannot_find_selected_hibernate_code_generation_configuration;
+	public static String ExportAntCodeGenWizardPage_error_in_hibernate_code_generation_configuration;
 	//
 	static {
 		// initialize resource bundle

Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.properties
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.properties	2010-08-06 13:18:57 UTC (rev 23969)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/console/HibernateConsoleMessages.properties	2010-08-06 13:19:19 UTC (rev 23970)
@@ -521,3 +521,5 @@
 ExportAntCodeGenWizard_page_name=Export Hibernate Code Generation Configuration to Ant Script
 ExportAntCodeGenWizardPage_hibernate_code_generation_configurations=Hibernate Code Generation Configurations:
 ExportAntCodeGenWizardPage_empty_hibernate_code_generation_configuration=Hibernate Code Generation Configuration is empty
+ExportAntCodeGenWizardPage_cannot_find_selected_hibernate_code_generation_configuration=Can't find selected Hibernate Code Generation Configuration
+ExportAntCodeGenWizardPage_error_in_hibernate_code_generation_configuration=Error in Hibernate Code Generation Configuration:

Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenXMLFactory.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenXMLFactory.java	2010-08-06 13:18:57 UTC (rev 23969)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/CodeGenXMLFactory.java	2010-08-06 13:19:19 UTC (rev 23970)
@@ -113,7 +113,8 @@
 		//
 		String hibernatePropFile = null;
 		String generateHibernatePropeties = null;
-		String connProfileName = consoleConfigPrefs.getConnectionProfileName();
+		String connProfileName = consoleConfigPrefs == null ? null : 
+			consoleConfigPrefs.getConnectionProfileName();
 		if (!isEmpty(connProfileName)) {
 			IConnectionProfile profile = ProfileManager.getInstance().getProfileByName(connProfileName);
 			if (profile != null) {
@@ -217,12 +218,13 @@
 		if (attributes.isUseOwnTemplates()) {
 			hibernatetool.addAttribute(CodeGenerationStrings.TEMPLATEPATH, templatePath);
 		}
-		//
-		if (StringHelper.isNotEmpty(hibernatePropFile)) {
-			rootConsoleConfig.addAttribute(ConfigurationXMLStrings.PROPERTYFILE, hibernatePropFile);
+		if (rootConsoleConfig != null) {
+			if (StringHelper.isNotEmpty(hibernatePropFile)) {
+				rootConsoleConfig.addAttribute(ConfigurationXMLStrings.PROPERTYFILE, hibernatePropFile);
+			}
+			// add hibernate console configuration
+			hibernatetool.content().add(rootConsoleConfig);
 		}
-		// add hibernate console configuration
-		hibernatetool.content().add(rootConsoleConfig);
 		//
 		// the path there are user classes
 		Element classpath = hibernatetool.addElement(CodeGenerationStrings.CLASSPATH);
@@ -311,6 +313,9 @@
 	
 	public ConsoleConfigurationPreferences getConsoleConfigPreferences(String consoleConfigName) {
 		ConsoleConfiguration consoleConfig = KnownConfigurations.getInstance().find(consoleConfigName);
+		if (consoleConfig == null) {
+			return null;
+		}
 		return consoleConfig.getPreferences();
 	}
 	

Modified: trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ExporterAttributes.java
===================================================================
--- trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ExporterAttributes.java	2010-08-06 13:18:57 UTC (rev 23969)
+++ trunk/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/launch/ExporterAttributes.java	2010-08-06 13:19:19 UTC (rev 23970)
@@ -47,9 +47,11 @@
 import java.util.Set;
 
 import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.Path;
 import org.eclipse.debug.core.ILaunchConfiguration;
 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.jdt.core.JavaConventions;
 import org.eclipse.osgi.util.NLS;
 import org.hibernate.console.HibernateConsoleRuntimeException;
 import org.hibernate.eclipse.console.ExtensionManager;
@@ -351,4 +353,38 @@
 		return autoOneToOneDetection;
 	}
 
+	/**
+	 * Check exporter attributes and return message with description what is wrong with attributes.
+	 *  
+	 * @return message
+	 */
+	public String checkExporterAttributes() {
+		String msg = null;
+		boolean notSelected = consoleConfigurationName == null || consoleConfigurationName.length() <= 0;
+		if (notSelected) {
+			msg = HibernateConsoleMessages.CodeGenerationSettingsTab_console_cfg_must_be_specified;
+		}
+        if (msg == null) {
+    		msg = PathHelper.checkDirectory(outputPath, HibernateConsoleMessages.CodeGenerationSettingsTab_output_directory, true);
+        }
+        if (msg == null) {
+            if (reverseEngineer && packageName.length() > 0) {
+                IStatus val= JavaConventions.validatePackageName(packageName);
+                if (val.getSeverity() == IStatus.ERROR || val.getSeverity() == IStatus.WARNING) {
+                	msg = val.getMessage();
+                }
+            }
+        }
+        if (msg == null) {
+            if (reverseEngineer && revengSettings.trim().length() > 0) {
+                msg = PathHelper.checkFile(revengSettings, HibernateConsoleMessages.CodeGenerationSettingsTab_reveng_xml_3, true);
+            }
+        }
+        if (msg == null) {
+            if (useOwnTemplates) {
+                msg = PathHelper.checkDirectory(templatePath, HibernateConsoleMessages.CodeGenerationSettingsTab_template_dir, true);
+            }
+        }
+		return msg;
+	}
 }



More information about the jbosstools-commits mailing list