From a1a9f7f770adea8126713306bebeee0bf44b0bf7 Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Sat, 17 Nov 2007 07:38:27 +0000 Subject: [PATCH] [ 1833556 ] Ok in connection dialog doesn't always save changes [ 1833558 ] connection dialog test database fail on a new installation --- base/src/org/compiere/db/CConnection.java | 6 ++- .../org/compiere/db/CConnectionDialog.java | 51 ++++++++++--------- 2 files changed, 32 insertions(+), 25 deletions(-) diff --git a/base/src/org/compiere/db/CConnection.java b/base/src/org/compiere/db/CConnection.java index 419c4daba9..eaf1c3e36e 100644 --- a/base/src/org/compiere/db/CConnection.java +++ b/base/src/org/compiere/db/CConnection.java @@ -100,6 +100,9 @@ public class CConnection implements Serializable, Cloneable if (cc == null) cc = new CConnection(apps_host); CConnectionDialog ccd = new CConnectionDialog (cc); s_cc = ccd.getConnection (); + if (!s_cc.isDatabaseOK() && !ccd.isCancel()) { + s_cc.testDatabase(true); + } // set also in ALogin and Ctrl Ini.setProperty (Ini.P_CONNECTION, s_cc.toStringLong ()); Ini.saveProperties (Ini.isClient ()); @@ -955,8 +958,7 @@ public class CConnection implements Serializable, Cloneable if (!retest && m_ds != null && m_okDB) return null; - if (m_ds != null) - getDatabase().close(); + getDatabase().close(); m_ds = null; setDataSource(); // the actual test diff --git a/base/src/org/compiere/db/CConnectionDialog.java b/base/src/org/compiere/db/CConnectionDialog.java index 51283be86b..635c21943f 100644 --- a/base/src/org/compiere/db/CConnectionDialog.java +++ b/base/src/org/compiere/db/CConnectionDialog.java @@ -330,7 +330,8 @@ public class CConnectionDialog extends CDialog implements ActionListener if (src == bOK) { - m_cc.setName(); + updateCConnection(); + m_cc.setName(); m_ccResult = m_cc; dispose(); isCancel = false; @@ -359,6 +360,31 @@ public class CConnectionDialog extends CDialog implements ActionListener } + updateCConnection(); + // + if (src == bTestApps) + cmd_testApps(); + + // Database Selection Changed + else if (src == dbTypeField) + { + m_cc.setType((String)dbTypeField.getSelectedItem()); + dbPortField.setText(String.valueOf(m_cc.getDbPort())); + cbBequeath.setSelected(m_cc.isBequeath()); + fwPortField.setText(String.valueOf(m_cc.getFwPort())); + } + // + else if (src == bTestDB) + cmd_testDB(); + + // Name + if (src == nameField) + m_cc.setName(nameField.getText()); + + updateInfo(); + } // actionPerformed + + private void updateCConnection() { if (Ini.isClient()) { //hengsin: avoid unnecessary requery of application server status @@ -383,28 +409,7 @@ public class CConnectionDialog extends CDialog implements ActionListener m_cc.setViaFirewall(cbFirewall.isSelected()); m_cc.setFwHost(fwHostField.getText()); m_cc.setFwPort(fwPortField.getText()); - // - if (src == bTestApps) - cmd_testApps(); - - // Database Selection Changed - else if (src == dbTypeField) - { - m_cc.setType((String)dbTypeField.getSelectedItem()); - dbPortField.setText(String.valueOf(m_cc.getDbPort())); - cbBequeath.setSelected(m_cc.isBequeath()); - fwPortField.setText(String.valueOf(m_cc.getFwPort())); - } - // - else if (src == bTestDB) - cmd_testDB(); - - // Name - if (src == nameField) - m_cc.setName(nameField.getText()); - - updateInfo(); - } // actionPerformed + } /** * Update Fields from Connection