Author: akazakov
Date: 2010-10-07 09:51:52 -0400 (Thu, 07 Oct 2010)
New Revision: 25557
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetPreInstallDelegate.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectWizard.java
Log:
https://jira.jboss.org/browse/JBIDE-7262 Fixed NPE for Seam Project Wizard
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetPreInstallDelegate.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetPreInstallDelegate.java 2010-10-07
13:42:51 UTC (rev 25556)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetPreInstallDelegate.java 2010-10-07
13:51:52 UTC (rev 25557)
@@ -7,11 +7,10 @@
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.tools.seam.internal.core.project.facet;
-import java.text.Format;
import java.util.Properties;
import org.eclipse.core.resources.IProject;
@@ -24,14 +23,15 @@
import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
import org.eclipse.wst.common.project.facet.core.IDelegate;
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+
+
/**
* TBD
*
* @author eskimo
*/
public class SeamFacetPreInstallDelegate implements IDelegate {
-
-
+
/**
* Indentation for hibernate property declaration
*/
@@ -41,68 +41,97 @@
* Property declaration in persistence.xml
*/
public static final String PROP_DECL = "<property name=\"{0}\"
value=\"{1}\"/>";
-
+
private static final String EMPTY_STRING = "";
-
+
/**
* Execute pre-install operations for installed facet
*
- * @param project created after finish pressed in wizard
- * @param fv -IProjectFacetversion described facet that will be installed
- * @param config - IDataModel that provide data collected from user
- * @param monitor - IProgressMonitor
- * @throws CoreException when meet the problems
+ * @param project
+ * created after finish pressed in wizard
+ * @param fv
+ * -IProjectFacetversion described facet that will be installed
+ * @param config
+ * - IDataModel that provide data collected from user
+ * @param monitor
+ * - IProgressMonitor
+ * @throws CoreException
+ * when meet the problems
*/
public void execute(IProject project, IProjectFacetVersion fv,
Object config, IProgressMonitor monitor) throws CoreException {
IDataModel model = (IDataModel) config;
- if (model.getProperty(ISeamFacetDataModelProperties.SEAM_CONNECTION_PROFILE) != null)
{
- IConnectionProfile connProfile =
ProfileManager.getInstance().getProfileByName(model.getProperty(ISeamFacetDataModelProperties.SEAM_CONNECTION_PROFILE).toString());
- if (connProfile!=null) {
- Properties props = connProfile.getBaseProperties();
//Properties("org.eclipse.datatools.connectivity.db.generic.connectionProfile");
-
+ if (model
+ .getProperty(ISeamFacetDataModelProperties.SEAM_CONNECTION_PROFILE) != null) {
+ IConnectionProfile connProfile = ProfileManager
+ .getInstance()
+ .getProfileByName(
+ model.getProperty(
+ ISeamFacetDataModelProperties.SEAM_CONNECTION_PROFILE)
+ .toString());
+ if (connProfile != null) {
+ Properties props = connProfile.getBaseProperties(); //
Properties("org.eclipse.datatools.connectivity.db.generic.connectionProfile");
+
// Collect properties name from DTP Connection Profile
- model.setProperty(ISeamFacetDataModelProperties.DB_USER_NAME,
+ model.setProperty(
+ ISeamFacetDataModelProperties.DB_USER_NAME,
props.get("org.eclipse.datatools.connectivity.db.username") == null
//$NON-NLS-1$
- ? "" :
props.get("org.eclipse.datatools.connectivity.db.username").toString());
//$NON-NLS-1$ //$NON-NLS-2$
-
- model.setProperty(ISeamFacetDataModelProperties.JDBC_DRIVER_CLASS_NAME,
+ ? "" :
props.get("org.eclipse.datatools.connectivity.db.username").toString());
//$NON-NLS-1$ //$NON-NLS-2$
+
+ model.setProperty(
+ ISeamFacetDataModelProperties.JDBC_DRIVER_CLASS_NAME,
props.get("org.eclipse.datatools.connectivity.db.driverClass") == null
//$NON-NLS-1$
- ? "" :
props.get("org.eclipse.datatools.connectivity.db.driverClass").toString());
//$NON-NLS-1$ //$NON-NLS-2$
-
- model.setProperty(ISeamFacetDataModelProperties.DB_USER_PASSWORD,
+ ? "" :
props.get("org.eclipse.datatools.connectivity.db.driverClass").toString());
//$NON-NLS-1$ //$NON-NLS-2$
+
+ model.setProperty(
+ ISeamFacetDataModelProperties.DB_USER_PASSWORD,
props.get("org.eclipse.datatools.connectivity.db.password") == null
//$NON-NLS-1$
- ? "" :
props.get("org.eclipse.datatools.connectivity.db.password").toString());
//$NON-NLS-1$ //$NON-NLS-2$
-
- model.setProperty(ISeamFacetDataModelProperties.JDBC_URL_FOR_DB,
+ ? "" :
props.get("org.eclipse.datatools.connectivity.db.password").toString());
//$NON-NLS-1$ //$NON-NLS-2$
+
+ model.setProperty(
+ ISeamFacetDataModelProperties.JDBC_URL_FOR_DB,
props.get("org.eclipse.datatools.connectivity.db.URL") == null
//$NON-NLS-1$
- ? "" :
props.get("org.eclipse.datatools.connectivity.db.URL").toString());
//$NON-NLS-1$ //$NON-NLS-2$
-
- model.setProperty(ISeamFacetDataModelProperties.JDBC_DRIVER_JAR_PATH,
- DriverManager.getInstance().getDriverInstanceByID(
- props.get("org.eclipse.datatools.connectivity.driverDefinitionID").toString()).getJarListAsArray());
//$NON-NLS-1$
+ ? "" :
props.get("org.eclipse.datatools.connectivity.db.URL").toString());
//$NON-NLS-1$ //$NON-NLS-2$
+
+ if(props.get("org.eclipse.datatools.connectivity.driverDefinitionID")!=null)
{
+ model.setProperty(
+ ISeamFacetDataModelProperties.JDBC_DRIVER_JAR_PATH,
+ DriverManager
+ .getInstance()
+ .getDriverInstanceByID(
+ props.get(
+ "org.eclipse.datatools.connectivity.driverDefinitionID").toString()).getJarListAsArray());
//$NON-NLS-1$
+ }
}
}
-
- String defaultSchema = (String)
model.getProperty(ISeamFacetDataModelProperties.DB_DEFAULT_SCHEMA_NAME);
-
+
+ String defaultSchema = (String) model
+ .getProperty(ISeamFacetDataModelProperties.DB_DEFAULT_SCHEMA_NAME);
+
if (!EMPTY_STRING.equals(defaultSchema)) {
- model.setStringProperty(ISeamFacetDataModelProperties.DB_SCHEMA_NAME,
- PROP_INDENT + NLS.bind(PROP_DECL,
- new String[]{
- ISeamFacetDataModelProperties.DB_DEFAULT_SCHEMA_NAME,
- defaultSchema}));
+ model.setStringProperty(
+ ISeamFacetDataModelProperties.DB_SCHEMA_NAME,
+ PROP_INDENT
+ + NLS.bind(
+ PROP_DECL,
+ new String[] {
+ ISeamFacetDataModelProperties.DB_DEFAULT_SCHEMA_NAME,
+ defaultSchema }));
}
- String defaultCatalog = (String)
model.getProperty(ISeamFacetDataModelProperties.DB_DEFAULT_CATALOG_NAME);
-
+ String defaultCatalog = (String) model
+ .getProperty(ISeamFacetDataModelProperties.DB_DEFAULT_CATALOG_NAME);
+
if (!EMPTY_STRING.equals(defaultCatalog)) {
- model.setStringProperty(ISeamFacetDataModelProperties.DB_CATALOG_NAME,
- PROP_INDENT + NLS.bind(PROP_DECL,
- new String[]{
- ISeamFacetDataModelProperties.DB_DEFAULT_CATALOG_NAME,
- defaultCatalog}));
+ model.setStringProperty(
+ ISeamFacetDataModelProperties.DB_CATALOG_NAME,
+ PROP_INDENT
+ + NLS.bind(
+ PROP_DECL,
+ new String[] {
+ ISeamFacetDataModelProperties.DB_DEFAULT_CATALOG_NAME,
+ defaultCatalog }));
}
}
-}
+}
\ No newline at end of file
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectWizard.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectWizard.java 2010-10-07
13:42:51 UTC (rev 25556)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectWizard.java 2010-10-07
13:51:52 UTC (rev 25557)
@@ -414,8 +414,10 @@
JBossServer jbs = (JBossServer) server.loadAdapter(JBossServer.class, new
NullProgressMonitor());
if (jbs != null) {
String[] driverJars = (String[])
model.getProperty(ISeamFacetDataModelProperties.JDBC_DRIVER_JAR_PATH);
- String configFolder = jbs.getConfigDirectory();
- AntCopyUtils.copyFiles(driverJars, new File(configFolder, "lib"), false);
+ if(driverJars!=null) {
+ String configFolder = jbs.getConfigDirectory();
+ AntCopyUtils.copyFiles(driverJars, new File(configFolder, "lib"), false);
+ }
}
RegistrationHelper.runRegisterInServerJob(warProject, server);