diff --git a/base/src/org/compiere/db/CConnection.java b/base/src/org/compiere/db/CConnection.java index 63f986647c..d30fcd44c0 100644 --- a/base/src/org/compiere/db/CConnection.java +++ b/base/src/org/compiere/db/CConnection.java @@ -37,7 +37,7 @@ import org.jboss.security.SimplePrincipal; * @author Marek Mosiewicz - support for RMI over HTTP * @version $Id: CConnection.java,v 1.5 2006/07/30 00:55:13 jjanke Exp $ */ -public class CConnection implements Serializable +public class CConnection implements Serializable, Cloneable { /** Connection */ private static CConnection s_cc = null; @@ -1679,6 +1679,16 @@ public class CConnection implements Serializable m_server = null; } + @Override + public Object clone() throws CloneNotSupportedException { + CConnection c = (CConnection)super.clone(); + String[] info = new String[2]; + info[0] = m_info[0]; + info[1] = m_info[1]; + c.m_info = info; + return c; + } + /************************************************************************** * Testing * @param args ignored @@ -1709,4 +1719,6 @@ public class CConnection implements Serializable new CConnectionDialog(cc); } // main + + } // CConnection diff --git a/base/src/org/compiere/db/CConnectionDialog.java b/base/src/org/compiere/db/CConnectionDialog.java index 0acf75e1a4..51283be86b 100644 --- a/base/src/org/compiere/db/CConnectionDialog.java +++ b/base/src/org/compiere/db/CConnectionDialog.java @@ -126,6 +126,7 @@ public class CConnectionDialog extends CDialog implements ActionListener private CLabel connectionProfileLabel = new CLabel(); private CComboBox connectionProfileField = new CComboBox(CConnection.CONNECTIONProfiles); + private boolean isCancel = true; /** * Static Layout @@ -293,7 +294,12 @@ public class CConnectionDialog extends CDialog implements ActionListener m_cc.setName(); } // Should copy values - m_ccResult = m_cc; + try { + m_ccResult = (CConnection)m_cc.clone(); + } catch (CloneNotSupportedException e) { + // should not happen + e.printStackTrace(); + } // String type = m_cc.getType(); if (type == null || type.length() == 0) @@ -327,6 +333,7 @@ public class CConnectionDialog extends CDialog implements ActionListener m_cc.setName(); m_ccResult = m_cc; dispose(); + isCancel = false; return; } else if (src == bCancel) @@ -354,8 +361,11 @@ public class CConnectionDialog extends CDialog implements ActionListener if (Ini.isClient()) { - m_cc.setAppsHost(appsHostField.getText()); - m_cc.setAppsPort(appsPortField.getText()); + //hengsin: avoid unnecessary requery of application server status + if (!appsHostField.getText().equals(m_cc.getAppsHost())) + m_cc.setAppsHost(appsHostField.getText()); + if (!appsPortField.getText().equals(Integer.toString(m_cc.getAppsPort()))) + m_cc.setAppsPort(appsPortField.getText()); } else m_cc.setAppsHost("localhost"); @@ -511,4 +521,8 @@ public class CConnectionDialog extends CDialog implements ActionListener setBusy (false); } // cmd_testApps + public boolean isCancel() { + return isCancel; + } + } // CConnectionDialog diff --git a/base/src/org/compiere/db/CConnectionEditor.java b/base/src/org/compiere/db/CConnectionEditor.java index c5bb656bc9..6ca2a03e92 100644 --- a/base/src/org/compiere/db/CConnectionEditor.java +++ b/base/src/org/compiere/db/CConnectionEditor.java @@ -274,7 +274,8 @@ public class CConnectionEditor extends JComponent // CConnectionDialog cd = new CConnectionDialog(m_value); setValue(cd.getConnection()); - fireActionPerformed(); + if (!cd.isCancel()) + fireActionPerformed(); // setCursor(Cursor.getDefaultCursor()); m_active = false;