From c335e9c7addf188b4b610ba14069ecd542186931 Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Tue, 16 Jan 2007 08:44:02 +0000 Subject: [PATCH] * [ 1636521 ] Zero Setup for Webstart Client --- dbPort/src/org/compiere/Adempiere.java | 8 ++++++ dbPort/src/org/compiere/db/CConnection.java | 31 +++++++++++++++++---- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/dbPort/src/org/compiere/Adempiere.java b/dbPort/src/org/compiere/Adempiere.java index c8e2361947..7f4e15f4fe 100644 --- a/dbPort/src/org/compiere/Adempiere.java +++ b/dbPort/src/org/compiere/Adempiere.java @@ -396,6 +396,14 @@ public final class Adempiere return null; } } // getCodeBase + + /** + * @return True if client is started using web start + */ + public static boolean isWebStartClient() + { + return getCodeBase() != null; + } /** * Get JNLP CodeBase Host diff --git a/dbPort/src/org/compiere/db/CConnection.java b/dbPort/src/org/compiere/db/CConnection.java index 3d3e0d1bdb..ff13c15e68 100644 --- a/dbPort/src/org/compiere/db/CConnection.java +++ b/dbPort/src/org/compiere/db/CConnection.java @@ -77,11 +77,29 @@ public class CConnection implements Serializable String attributes = Ini.getProperty (Ini.P_CONNECTION); if (attributes == null || attributes.length () == 0) { - CConnectionDialog ccd = new CConnectionDialog (new CConnection(apps_host)); - s_cc = ccd.getConnection (); - // set also in ALogin and Ctrl - Ini.setProperty (Ini.P_CONNECTION, s_cc.toStringLong ()); - Ini.saveProperties (Ini.isClient ()); + //hengsin, zero setup for webstart client + CConnection cc = null; + if (apps_host != null && Adempiere.isWebStartClient()) + { + cc = new CConnection(apps_host); + cc.setConnectionProfile(CConnection.PROFILE_WAN); + cc.setAppsPort(80); + if (cc.testAppsServer() == null) + { + s_cc = cc; + Ini.setProperty(Ini.P_CONNECTION, cc.toStringLong()); + Ini.saveProperties(false); + } + } + if (s_cc == null) + { + if (cc == null) cc = new CConnection(apps_host); + CConnectionDialog ccd = new CConnectionDialog (cc); + s_cc = ccd.getConnection (); + // set also in ALogin and Ctrl + Ini.setProperty (Ini.P_CONNECTION, s_cc.toStringLong ()); + Ini.saveProperties (Ini.isClient ()); + } } else { @@ -560,8 +578,9 @@ public class CConnection implements Serializable else m_connectionProfile = connectionProfile; - //reset initial context to null + //hengsin, reset initial context and env m_iContext = null; + m_env = null; } else log.warning("Invalid: " + connectionProfile);