diff --git a/org.adempiere.install/META-INF/MANIFEST.MF b/org.adempiere.install/META-INF/MANIFEST.MF
index be1b1f11da..786e6e043f 100644
--- a/org.adempiere.install/META-INF/MANIFEST.MF
+++ b/org.adempiere.install/META-INF/MANIFEST.MF
@@ -6,8 +6,7 @@ Bundle-Version: 1.0.0.qualifier
Bundle-ClassPath: install.jar,
ant-contrib-1.0b3.jar
Export-Package: org.compiere.install
-Require-Bundle: org.adempiere.base;bundle-version="1.0.0",
- org.adempiere.ui.swing;bundle-version="1.0.0"
+Require-Bundle: org.adempiere.base;bundle-version="1.0.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: javax.mail;version="1.4.1",
javax.mail.internet;version="1.4.1",
diff --git a/org.adempiere.install/plugin.xml b/org.adempiere.install/plugin.xml
index 4f264a6626..18bb0df87c 100644
--- a/org.adempiere.install/plugin.xml
+++ b/org.adempiere.install/plugin.xml
@@ -2,11 +2,22 @@
-
+
+
+
+
+
+
diff --git a/org.adempiere.install/src/org/compiere/install/Config.java b/org.adempiere.install/src/org/compiere/install/Config.java
index 2432bc2c66..c02f18a830 100644
--- a/org.adempiere.install/src/org/compiere/install/Config.java
+++ b/org.adempiere.install/src/org/compiere/install/Config.java
@@ -20,7 +20,8 @@ import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
-import org.compiere.swing.CCheckBox;
+import javax.swing.JCheckBox;
+
import org.compiere.util.CLogger;
import org.compiere.util.DB;
@@ -119,7 +120,7 @@ public abstract class Config
* @param critical true if critical
* @param errorMsg error Message
*/
- void signalOK (CCheckBox cb, String resString,
+ void signalOK (JCheckBox cb, String resString,
boolean pass, boolean critical, String errorMsg)
{
p_data.p_panel.signalOK(cb, resString, pass, critical, errorMsg);
diff --git a/org.adempiere.install/src/org/compiere/install/ConfigurationData.java b/org.adempiere.install/src/org/compiere/install/ConfigurationData.java
index 51133bd619..de5d278389 100644
--- a/org.adempiere.install/src/org/compiere/install/ConfigurationData.java
+++ b/org.adempiere.install/src/org/compiere/install/ConfigurationData.java
@@ -175,7 +175,7 @@ public class ConfigurationData
public static final String ADEMPIERE_WEBSTORES = "ADEMPIERE_WEBSTORES";
- private void updateProperty(String property, String value) {
+ public void updateProperty(String property, String value) {
if (value == null) value = "";
String currentValue = (String)p_properties.get(property);
if (currentValue == null)
@@ -183,6 +183,11 @@ public class ConfigurationData
else if (!currentValue.equals(value))
p_properties.put(property, value);
}
+
+ public String getProperty(String property)
+ {
+ return p_properties.getProperty(property);
+ }
/**
* Load Configuration Data
@@ -291,7 +296,7 @@ public class ConfigurationData
// Database Server
initDatabase("");
String connectionName = getDatabaseDiscovered();
- if (connectionName != null) {
+ if (connectionName != null && connectionName.trim().length() > 0) {
setDatabaseName(resolveDatabaseName(connectionName));
}
setDatabaseSystemPassword("");
@@ -402,7 +407,7 @@ public class ConfigurationData
* Test Adempiere and set AdempiereHome
* @return error message or null if OK
*/
- private String testAdempiere()
+ public String testAdempiere()
{
// Adempiere Home
m_adempiereHome = new File (getAdempiereHome());
@@ -460,15 +465,13 @@ public class ConfigurationData
* Test (optional) Mail
* @return error message or null, if OK
*/
- private String testMail()
+ public String testMail()
{
// Mail Server
String server = p_panel != null
? p_panel.fMailServer.getText()
: (String)p_properties.get(ADEMPIERE_MAIL_SERVER);
- boolean pass = server != null && server.length() > 0
- && server.toLowerCase().indexOf("localhost") == -1
- && !server.equals("127.0.0.1");
+ boolean pass = server != null && server.length() > 0;
String error = "Error Mail Server = " + server;
InetAddress mailServer = null;
try
@@ -898,9 +901,18 @@ public class ConfigurationData
*/
public String getKeyStore ()
{
- char[] pw = p_panel.fKeyStore.getPassword();
- if (pw != null)
- return new String(pw);
+ if (p_panel != null)
+ {
+ char[] pw = p_panel.fKeyStore.getPassword();
+ if (pw != null)
+ return new String(pw);
+ }
+ else
+ {
+ String pw = getProperty(ADEMPIERE_KEYSTOREPASS);
+ if (pw != null)
+ return pw;
+ }
return "";
} // getKeyStore
@@ -925,17 +937,15 @@ public class ConfigurationData
private static String JAVATYPE_SUN = "sun";
/** Apple VM */
private static String JAVATYPE_MAC = "mac";
- /** IBM VM */
- private static String JAVATYPE_IBM = "";
/** Open JDK */
private static String JAVATYPE_OPENJDK = "OpenJDK";
/** Java VM Types */
- static String[] JAVATYPE = new String[]
- {JAVATYPE_SUN, JAVATYPE_OPENJDK, JAVATYPE_MAC, JAVATYPE_IBM};
+ public static String[] JAVATYPE = new String[]
+ {JAVATYPE_SUN, JAVATYPE_OPENJDK, JAVATYPE_MAC};
/** Virtual machine Configurations */
private Config[] m_javaConfig = new Config[]
- {new ConfigVMSun(this), new ConfigVMOpenJDK(this), new ConfigVMMac(this), null};
+ {new ConfigVMSun(this), new ConfigVMOpenJDK(this), new ConfigVMMac(this)};
private ConfigAppServer m_appsConfig = new ConfigAppServer(this);
/**
@@ -947,7 +957,7 @@ public class ConfigurationData
initJava(index);
} // initDatabase
- private void initJava(int index)
+ public void initJava(int index)
{
if (index < 0 || index >= JAVATYPE.length)
log.warning("JavaType Index invalid: " + index);
@@ -1154,16 +1164,13 @@ public class ConfigurationData
/** Oracle directory */
private static String DBTYPE_ORACLE = "oracle";
- /** Oracle XP */
- private static String DBTYPE_ORACLEXE = "oracleXE";
/** PostgreSQL */
private static String DBTYPE_POSTGRESQL = "postgresql";
/** Database Types */
- static String[] DBTYPE = new String[]
- { DBTYPE_ORACLEXE,
- DBTYPE_ORACLE,
+ public static String[] DBTYPE = new String[]
+ { DBTYPE_ORACLE,
//begin e-evolution vpj-cd 02/07/2005 PostgreSQL
DBTYPE_POSTGRESQL
};
@@ -1173,7 +1180,6 @@ public class ConfigurationData
private Config[] m_databaseConfig = new Config[]
{
new ConfigOracle(this,true),
- new ConfigOracle(this,false),
//begin e-evolution vpj-cd 02/07/2005 PostgreSQL
new ConfigPostgreSQL(this)
// end e-evolution vpj-cd 02/07/2005 PostgreSQL
@@ -1185,7 +1191,20 @@ public class ConfigurationData
*/
public void initDatabase(String selected)
{
- int index = (p_panel != null ? p_panel.fDatabaseType.getSelectedIndex() : 0);
+ int index = (p_panel != null ? p_panel.fDatabaseType.getSelectedIndex() : -1);
+ if (index < 0)
+ {
+ for(int i = 0; i < DBTYPE.length; i++)
+ {
+ if (DBTYPE[i].equals(selected))
+ {
+ index = i;
+ break;
+ }
+ }
+ if (index < 0)
+ index = 0;
+ }
initDatabase(selected, index);
} // initDatabase
@@ -1274,7 +1293,9 @@ public class ConfigurationData
*/
public String getDatabaseDiscovered ()
{
- return (String)p_panel.fDatabaseDiscovered.getSelectedItem();
+ return p_panel != null
+ ? (String)p_panel.fDatabaseDiscovered.getSelectedItem()
+ : "";
}
/**
* @param databaseDiscovered The database Discovered to set.
@@ -1436,5 +1457,91 @@ public class ConfigurationData
else
updateProperty(ADEMPIERE_DB_USER, databaseUser);
}
-
+
+ /**
+ * @return Returns the mail Server.
+ */
+ public String getMailServer ()
+ {
+ return p_panel != null
+ ? p_panel.fMailServer.getText()
+ : (String)p_properties.get(ADEMPIERE_MAIL_SERVER);
+ }
+
+ public void setMailServer(String mailServer)
+ {
+ if (p_panel != null)
+ p_panel.fMailServer.setText(mailServer);
+ else
+ updateProperty(ADEMPIERE_MAIL_SERVER, mailServer);
+ }
+
+ /**
+ * @return Returns the mailUser.
+ */
+ public String getMailUser ()
+ {
+ return p_panel != null
+ ? p_panel.fMailUser.getText()
+ : (String)p_properties.get(ADEMPIERE_MAIL_USER);
+ }
+ /**
+ * @param mailUser The mailUser to set.
+ */
+ public void setMailUser (String mailUser)
+ {
+ if (p_panel != null)
+ p_panel.fMailUser.setText(mailUser);
+ else
+ updateProperty(ADEMPIERE_MAIL_USER, mailUser);
+ }
+
+ /**
+ * @return Returns the mail User Password.
+ */
+ public String getMailPassword ()
+ {
+ if (p_panel != null)
+ {
+ char[] pw = p_panel.fMailPassword.getPassword();
+ if (pw != null)
+ return new String(pw);
+ return "";
+ }
+ else
+ {
+ String pw = (String)p_properties.get(ADEMPIERE_MAIL_PASSWORD);
+ return (pw != null ? pw : "");
+ }
+ }
+ /**
+ * @param mailPassword The mailPassword to set.
+ */
+ public void setMailPassword (String mailPassword)
+ {
+ if (p_panel != null)
+ p_panel.fMailPassword.setText(mailPassword);
+ else
+ updateProperty(ADEMPIERE_MAIL_PASSWORD, mailPassword);
+ }
+
+ /**
+ * @return Returns the admin email
+ */
+ public String getAdminEMail()
+ {
+ return p_panel != null
+ ? p_panel.fAdminEMail.getText()
+ : (String)p_properties.get(ADEMPIERE_ADMIN_EMAIL);
+ }
+ /**
+ * @param adminEMail The admin email
+ */
+ public void setAdminEMail(String adminEMail)
+ {
+ if (p_panel != null)
+ p_panel.fAdminEMail.setText(adminEMail);
+ else
+ updateProperty(ADEMPIERE_ADMIN_EMAIL, adminEMail);
+ }
} // ConfigurationData
diff --git a/org.adempiere.install/src/org/compiere/install/ConfigurationPanel.java b/org.adempiere.install/src/org/compiere/install/ConfigurationPanel.java
index ee50c5646e..44543b8a7d 100644
--- a/org.adempiere.install/src/org/compiere/install/ConfigurationPanel.java
+++ b/org.adempiere.install/src/org/compiere/install/ConfigurationPanel.java
@@ -29,22 +29,21 @@ import java.util.ResourceBundle;
import java.util.logging.Level;
import javax.swing.ImageIcon;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JComboBox;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JPasswordField;
import javax.swing.JSeparator;
+import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.border.TitledBorder;
import org.adempiere.base.Core;
import org.apache.tools.ant.Main;
-import org.compiere.swing.CButton;
-import org.compiere.swing.CCheckBox;
-import org.compiere.swing.CComboBox;
-import org.compiere.swing.CLabel;
-import org.compiere.swing.CPanel;
-import org.compiere.swing.CPassword;
-import org.compiere.swing.CTextField;
import org.compiere.util.CLogger;
/**
@@ -53,7 +52,7 @@ import org.compiere.util.CLogger;
* @author Jorg Janke
* @version $Id: ConfigurationPanel.java,v 1.3 2006/07/30 00:57:42 jjanke Exp $
*/
-public class ConfigurationPanel extends CPanel implements ActionListener
+public class ConfigurationPanel extends JPanel implements ActionListener
{
/**
*
@@ -103,68 +102,68 @@ public class ConfigurationPanel extends CPanel implements ActionListener
private GridBagLayout gridBagLayout = new GridBagLayout();
private static final int FIELDLENGTH = 15;
// Java
- private CLabel lJavaHome = new CLabel();
- CTextField fJavaHome = new CTextField(FIELDLENGTH);
- CCheckBox okJavaHome = new CCheckBox();
- private CButton bJavaHome = new CButton(iOpen);
- private CLabel lJavaType = new CLabel();
- CComboBox fJavaType = new CComboBox(ConfigurationData.JAVATYPE);
+ private JLabel lJavaHome = new JLabel();
+ JTextField fJavaHome = new JTextField(FIELDLENGTH);
+ JCheckBox okJavaHome = new JCheckBox();
+ private JButton bJavaHome = new JButton(iOpen);
+ private JLabel lJavaType = new JLabel();
+ JComboBox fJavaType = new JComboBox(ConfigurationData.JAVATYPE);
// Adempiere - KeyStore
- private CLabel lAdempiereHome = new CLabel();
- CTextField fAdempiereHome = new CTextField(FIELDLENGTH);
- CCheckBox okAdempiereHome = new CCheckBox();
- private CButton bAdempiereHome = new CButton(iOpen);
- private CLabel lKeyStore = new CLabel();
- CPassword fKeyStore = new CPassword();
- CCheckBox okKeyStore = new CCheckBox();
+ private JLabel lAdempiereHome = new JLabel();
+ JTextField fAdempiereHome = new JTextField(FIELDLENGTH);
+ JCheckBox okAdempiereHome = new JCheckBox();
+ private JButton bAdempiereHome = new JButton(iOpen);
+ private JLabel lKeyStore = new JLabel();
+ JPasswordField fKeyStore = new JPasswordField();
+ JCheckBox okKeyStore = new JCheckBox();
// Apps Server - Type
- CLabel lAppsServer = new CLabel();
- CTextField fAppsServer = new CTextField(FIELDLENGTH);
- CCheckBox okAppsServer = new CCheckBox();
+ JLabel lAppsServer = new JLabel();
+ JTextField fAppsServer = new JTextField(FIELDLENGTH);
+ JCheckBox okAppsServer = new JCheckBox();
// Web Ports
- private CLabel lWebPort = new CLabel();
- CTextField fWebPort = new CTextField(FIELDLENGTH);
- CCheckBox okWebPort = new CCheckBox();
- private CLabel lSSLPort = new CLabel();
- CTextField fSSLPort = new CTextField(FIELDLENGTH);
- CCheckBox okSSLPort = new CCheckBox();
+ private JLabel lWebPort = new JLabel();
+ JTextField fWebPort = new JTextField(FIELDLENGTH);
+ JCheckBox okWebPort = new JCheckBox();
+ private JLabel lSSLPort = new JLabel();
+ JTextField fSSLPort = new JTextField(FIELDLENGTH);
+ JCheckBox okSSLPort = new JCheckBox();
// Database
- private CLabel lDatabaseType = new CLabel();
- CComboBox fDatabaseType = new CComboBox(ConfigurationData.DBTYPE);
+ private JLabel lDatabaseType = new JLabel();
+ JComboBox fDatabaseType = new JComboBox(ConfigurationData.DBTYPE);
//
- CLabel lDatabaseServer = new CLabel();
- CTextField fDatabaseServer = new CTextField(FIELDLENGTH);
- private CLabel lDatabaseName = new CLabel();
- CTextField fDatabaseName = new CTextField(FIELDLENGTH);
- private CLabel lDatabaseDiscovered = new CLabel();
- CComboBox fDatabaseDiscovered = new CComboBox();
- private CLabel lDatabasePort = new CLabel();
- CTextField fDatabasePort = new CTextField(FIELDLENGTH);
- private CLabel lSystemPassword = new CLabel();
- CPassword fSystemPassword = new CPassword();
- private CLabel lDatabaseUser = new CLabel();
- CTextField fDatabaseUser = new CTextField(FIELDLENGTH);
- private CLabel lDatabasePassword = new CLabel();
- CPassword fDatabasePassword = new CPassword();
- CCheckBox okDatabaseServer = new CCheckBox();
- CCheckBox okDatabaseUser = new CCheckBox();
- CCheckBox okDatabaseSystem = new CCheckBox();
- CCheckBox okDatabaseSQL = new CCheckBox();
+ JLabel lDatabaseServer = new JLabel();
+ JTextField fDatabaseServer = new JTextField(FIELDLENGTH);
+ private JLabel lDatabaseName = new JLabel();
+ JTextField fDatabaseName = new JTextField(FIELDLENGTH);
+ private JLabel lDatabaseDiscovered = new JLabel();
+ JComboBox fDatabaseDiscovered = new JComboBox();
+ private JLabel lDatabasePort = new JLabel();
+ JTextField fDatabasePort = new JTextField(FIELDLENGTH);
+ private JLabel lSystemPassword = new JLabel();
+ JPasswordField fSystemPassword = new JPasswordField();
+ private JLabel lDatabaseUser = new JLabel();
+ JTextField fDatabaseUser = new JTextField(FIELDLENGTH);
+ private JLabel lDatabasePassword = new JLabel();
+ JPasswordField fDatabasePassword = new JPasswordField();
+ JCheckBox okDatabaseServer = new JCheckBox();
+ JCheckBox okDatabaseUser = new JCheckBox();
+ JCheckBox okDatabaseSystem = new JCheckBox();
+ JCheckBox okDatabaseSQL = new JCheckBox();
//
- CLabel lMailServer = new CLabel();
- CTextField fMailServer = new CTextField(FIELDLENGTH);
- private CLabel lAdminEMail = new CLabel();
- CTextField fAdminEMail = new CTextField(FIELDLENGTH);
- private CLabel lMailUser = new CLabel();
- CTextField fMailUser = new CTextField(FIELDLENGTH);
- private CLabel lMailPassword = new CLabel();
- CPassword fMailPassword = new CPassword();
- CCheckBox okMailServer = new CCheckBox();
- CCheckBox okMailUser = new CCheckBox();
+ JLabel lMailServer = new JLabel();
+ JTextField fMailServer = new JTextField(FIELDLENGTH);
+ private JLabel lAdminEMail = new JLabel();
+ JTextField fAdminEMail = new JTextField(FIELDLENGTH);
+ private JLabel lMailUser = new JLabel();
+ JTextField fMailUser = new JTextField(FIELDLENGTH);
+ private JLabel lMailPassword = new JLabel();
+ JPasswordField fMailPassword = new JPasswordField();
+ JCheckBox okMailServer = new JCheckBox();
+ JCheckBox okMailUser = new JCheckBox();
//
- private CButton bHelp = new CButton(iHelp);
- private CButton bTest = new CButton();
- private CButton bSave = new CButton(iSave);
+ private JButton bHelp = new JButton(iHelp);
+ private JButton bTest = new JButton();
+ private JButton bSave = new JButton(iSave);
/**
@@ -411,7 +410,7 @@ public class ConfigurationPanel extends CPanel implements ActionListener
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 0, 2, 5), 0, 0));
//grap extra space when window is maximized
- CPanel filler = new CPanel();
+ JPanel filler = new JPanel();
filler.setOpaque(false);
filler.setBorder(null);
this.add(filler, new GridBagConstraints(0, 21, 1, 1, 0.0, 1.0
@@ -499,7 +498,7 @@ public class ConfigurationPanel extends CPanel implements ActionListener
* Set Path in Field
* @param field field to set Path
*/
- private void setPath (CTextField field)
+ private void setPath (JTextField field)
{
JFileChooser fc = new JFileChooser(field.getText());
fc.setDialogType(JFileChooser.OPEN_DIALOG);
@@ -516,9 +515,9 @@ public class ConfigurationPanel extends CPanel implements ActionListener
* @param saveIt save
* @return SwingWorker
*/
- private org.compiere.apps.SwingWorker startTest(final boolean saveIt)
+ private org.compiere.install.util.SwingWorker startTest(final boolean saveIt)
{
- org.compiere.apps.SwingWorker worker = new org.compiere.apps.SwingWorker()
+ org.compiere.install.util.SwingWorker worker = new org.compiere.install.util.SwingWorker()
{
// Start it
public Object construct()
@@ -587,7 +586,7 @@ public class ConfigurationPanel extends CPanel implements ActionListener
* @param critical true if critical
* @param errorMsg error Message
*/
- void signalOK (CCheckBox cb, String resString,
+ void signalOK (JCheckBox cb, String resString,
boolean pass, boolean critical, String errorMsg)
{
m_errorString = res.getString(resString);
diff --git a/org.adempiere.install/src/org/compiere/install/KeyStoreDialog.java b/org.adempiere.install/src/org/compiere/install/KeyStoreDialog.java
index 43ff926d33..6bbdbc6e90 100644
--- a/org.adempiere.install/src/org/compiere/install/KeyStoreDialog.java
+++ b/org.adempiere.install/src/org/compiere/install/KeyStoreDialog.java
@@ -21,18 +21,19 @@ import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.HeadlessException;
import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import javax.swing.JButton;
+import javax.swing.JDialog;
import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
-import org.compiere.apps.AEnv;
-import org.compiere.apps.ALayout;
-import org.compiere.apps.ALayoutConstraint;
-import org.compiere.apps.ConfirmPanel;
-import org.compiere.swing.CButton;
-import org.compiere.swing.CDialog;
-import org.compiere.swing.CLabel;
-import org.compiere.swing.CPanel;
-import org.compiere.swing.CTextField;
+import org.compiere.install.util.AEnv;
+import org.compiere.install.util.ALayout;
+import org.compiere.install.util.ALayoutConstraint;
+import org.compiere.install.util.ConfirmPanel;
/**
@@ -41,7 +42,7 @@ import org.compiere.swing.CTextField;
* @author Jorg Janke
* @version $Id: KeyStoreDialog.java,v 1.3 2006/07/30 00:57:42 jjanke Exp $
*/
-public class KeyStoreDialog extends CDialog
+public class KeyStoreDialog extends JDialog implements ActionListener
{
/**
@@ -73,21 +74,21 @@ public class KeyStoreDialog extends CDialog
AEnv.showCenterWindow(owner, this);
} // KeyStoreDialog
- private CLabel lCN = new CLabel("(ON) Common Name");
- private CTextField fCN = new CTextField(20);
- private CLabel lOU = new CLabel("(OU) Organization Unit");
- private CTextField fOU = new CTextField(20);
- private CLabel lO = new CLabel("(O) Organization");
- private CTextField fO = new CTextField(20);
- private CLabel lL = new CLabel("(L) Locale/Town");
- private CTextField fL = new CTextField(20);
- private CLabel lS = new CLabel("(S) State");
- private CTextField fS = new CTextField(20);
- private CLabel lC = new CLabel("(C) Country (2 Char)");
- private CTextField fC = new CTextField(2);
+ private JLabel lCN = new JLabel("(ON) Common Name");
+ private JTextField fCN = new JTextField(20);
+ private JLabel lOU = new JLabel("(OU) Organization Unit");
+ private JTextField fOU = new JTextField(20);
+ private JLabel lO = new JLabel("(O) Organization");
+ private JTextField fO = new JTextField(20);
+ private JLabel lL = new JLabel("(L) Locale/Town");
+ private JTextField fL = new JTextField(20);
+ private JLabel lS = new JLabel("(S) State");
+ private JTextField fS = new JTextField(20);
+ private JLabel lC = new JLabel("(C) Country (2 Char)");
+ private JTextField fC = new JTextField(2);
- private CButton bOK = ConfirmPanel.createOKButton("OK");
- private CButton bCancel = ConfirmPanel.createCancelButton("Cancel");
+ private JButton bOK = ConfirmPanel.createOKButton("OK");
+ private JButton bCancel = ConfirmPanel.createCancelButton("Cancel");
private boolean m_ok = false;
/**
@@ -95,7 +96,7 @@ public class KeyStoreDialog extends CDialog
*/
private void jbInit()
{
- CPanel panel = new CPanel(new ALayout());
+ JPanel panel = new JPanel(new ALayout());
panel.add(lCN, new ALayoutConstraint(0, 0));
panel.add(fCN, null);
panel.add(lOU, new ALayoutConstraint(1, 0));
@@ -113,7 +114,7 @@ public class KeyStoreDialog extends CDialog
getContentPane().setLayout(new BorderLayout());
getContentPane().add (panel, BorderLayout.CENTER);
//
- CPanel confirmPanel = new CPanel(new FlowLayout(FlowLayout.RIGHT));
+ JPanel confirmPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
confirmPanel.add(bCancel);
confirmPanel.add(bOK);
getContentPane().add (confirmPanel, BorderLayout.SOUTH);
diff --git a/org.adempiere.install/src/org/compiere/install/Setup.java b/org.adempiere.install/src/org/compiere/install/Setup.java
index b009d4ffde..3b95fbb1b2 100644
--- a/org.adempiere.install/src/org/compiere/install/Setup.java
+++ b/org.adempiere.install/src/org/compiere/install/Setup.java
@@ -30,12 +30,11 @@ import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
+import javax.swing.JMenuItem;
import javax.swing.JPanel;
import org.compiere.Adempiere;
-import org.compiere.apps.AEnv;
-import org.compiere.swing.CFrame;
-import org.compiere.swing.CMenuItem;
+import org.compiere.install.util.AEnv;
import org.compiere.util.CLogFile;
import org.compiere.util.CLogMgt;
import org.compiere.util.CLogger;
@@ -46,7 +45,7 @@ import org.compiere.util.CLogger;
* @author Jorg Janke
* @version $Id: Setup.java,v 1.2 2006/07/30 00:57:42 jjanke Exp $
*/
-public class Setup extends CFrame implements ActionListener
+public class Setup extends JFrame implements ActionListener
{
/**
*
@@ -94,9 +93,9 @@ public class Setup extends CFrame implements ActionListener
private JPanel contentPane;
private JMenuBar menuBar = new JMenuBar();
private JMenu menuFile = new JMenu();
- private CMenuItem menuFileExit = new CMenuItem();
+ private JMenuItem menuFileExit = new JMenuItem();
private JMenu menuHelp = new JMenu();
- private CMenuItem menuHelpInfo = new CMenuItem();
+ private JMenuItem menuHelpInfo = new JMenuItem();
private JLabel statusBar = new JLabel();
private BorderLayout borderLayout = new BorderLayout();
private ConfigurationPanel configurationPanel = new ConfigurationPanel (statusBar);
diff --git a/org.adempiere.install/src/org/compiere/install/Setup_Help.java b/org.adempiere.install/src/org/compiere/install/Setup_Help.java
index 8a838c5d53..735dd1f779 100644
--- a/org.adempiere.install/src/org/compiere/install/Setup_Help.java
+++ b/org.adempiere.install/src/org/compiere/install/Setup_Help.java
@@ -32,10 +32,10 @@ import java.util.ResourceBundle;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JEditorPane;
+import javax.swing.JPanel;
import javax.swing.JScrollPane;
-import org.compiere.apps.OnlineHelp;
-import org.compiere.swing.CPanel;
+import org.compiere.install.util.OnlineHelp;
/**
* Setup Online Help
@@ -104,8 +104,8 @@ public class Setup_Help extends JDialog implements ActionListener
static ResourceBundle res = ResourceBundle.getBundle("org.compiere.install.SetupRes");
- private CPanel mainPanel = new CPanel();
- private CPanel southPanel = new CPanel();
+ private JPanel mainPanel = new JPanel();
+ private JPanel southPanel = new JPanel();
private JButton bOK = new JButton();
private BorderLayout mainLayout = new BorderLayout();
private JScrollPane centerScrollPane = new JScrollPane();
diff --git a/org.adempiere.install/src/org/compiere/install/console/Application.java b/org.adempiere.install/src/org/compiere/install/console/Application.java
new file mode 100644
index 0000000000..ac8ed03115
--- /dev/null
+++ b/org.adempiere.install/src/org/compiere/install/console/Application.java
@@ -0,0 +1,31 @@
+/**
+ *
+ */
+package org.compiere.install.console;
+
+import org.eclipse.equinox.app.IApplication;
+import org.eclipse.equinox.app.IApplicationContext;
+
+/**
+ * @author hengsin
+ *
+ */
+public class Application implements IApplication {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.IApplicationContext)
+ */
+ @Override
+ public Object start(IApplicationContext context) throws Exception {
+ ConfigurationConsole console = new ConfigurationConsole();
+ console.doSetup();
+ return Application.EXIT_OK;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.equinox.app.IApplication#stop()
+ */
+ @Override
+ public void stop() {
+ }
+}
diff --git a/org.adempiere.install/src/org/compiere/install/console/ConfigurationConsole.java b/org.adempiere.install/src/org/compiere/install/console/ConfigurationConsole.java
new file mode 100644
index 0000000000..f399cffb5c
--- /dev/null
+++ b/org.adempiere.install/src/org/compiere/install/console/ConfigurationConsole.java
@@ -0,0 +1,500 @@
+package org.compiere.install.console;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.security.KeyStore;
+
+import org.compiere.install.ConfigurationData;
+import org.compiere.install.KeyStoreMgt;
+import org.compiere.util.Ini;
+
+public class ConfigurationConsole {
+
+ ConfigurationData data = new ConfigurationData(null);
+
+ public void doSetup() {
+ BufferedReader reader = null;
+ PrintWriter writer = null;
+ reader = new BufferedReader(new InputStreamReader(System.in));
+ writer = new PrintWriter(System.out, true);
+
+ Ini.setShowLicenseDialog(false);
+ data.load();
+
+ try {
+ jvmType(reader, writer);
+ jvmHome(reader, writer);
+
+ adempiereHome(reader, writer);
+ keyStorePass(reader, writer);
+
+ appServerHostname(reader, writer);
+ appServerWebPort(reader, writer);
+ appServerSSLPort(reader, writer);
+
+ dbType(reader, writer);
+ dbHostname(reader, writer);
+ dbPort(reader, writer);
+ dbName(reader, writer);
+ dbUser(reader, writer);
+ dbPassword(reader, writer);
+ dbSystemPassword(reader, writer);
+
+ mailServer(reader, writer);
+ mailUser(reader, writer);
+ mailPassword(reader, writer);
+ mailAdmin(reader, writer);
+ writer.println("Save changes (Y/N) [Y]: ");
+ String yesNo = reader.readLine();
+ if ((yesNo == null || yesNo.trim().length() == 0) || "y".equalsIgnoreCase(yesNo))
+ {
+ boolean b = data.save();
+ if (b)
+ writer.println("Changes save successfully.");
+ else
+ writer.println("Failed to save changes.");
+ }
+ else
+ {
+ writer.println("Changes ignore.");
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private void mailAdmin(BufferedReader reader, PrintWriter writer) throws IOException {
+ while(true)
+ {
+ writer.println("Administrator EMail ["+data.getAdminEMail()+"]:");
+ String adminEMail = reader.readLine();
+ if (adminEMail != null && adminEMail.trim().length() > 0)
+ {
+ data.setAdminEMail(adminEMail);
+ }
+ String error = data.testMail();
+ if (error != null && error.trim().length() > 0)
+ {
+ writer.println("Mail setting validation error: " + error);
+ mailServer(reader, writer);
+ mailUser(reader, writer);
+ mailPassword(reader, writer);
+ continue;
+ }
+ break;
+ }
+ }
+
+ private void mailPassword(BufferedReader reader, PrintWriter writer) throws IOException {
+ writer.println("Mail User Password ["+data.getMailPassword()+"]");
+ String mailPassword = reader.readLine();
+ if (mailPassword != null && mailPassword.trim().length() > 0)
+ {
+ data.setMailPassword(mailPassword);
+ }
+ }
+
+ private void mailUser(BufferedReader reader, PrintWriter writer) throws IOException {
+ writer.println("Mail User Login ["+data.getMailUser()+"]:");
+ String userName = reader.readLine();
+ if (userName != null && userName.trim().length() > 0)
+ {
+ data.setMailUser(userName);
+ }
+ }
+
+ private void mailServer(BufferedReader reader, PrintWriter writer) throws IOException {
+ writer.println("Mail Server Host Name ["+data.getMailServer()+"]:");
+ String hostName = reader.readLine();
+ if (hostName != null && hostName.trim().length() > 0)
+ {
+ data.setMailServer(hostName);
+ }
+ }
+
+ private void dbPort(BufferedReader reader, PrintWriter writer) throws IOException {
+ while (true)
+ {
+ writer.println("Database Server Port ["+data.getDatabasePort()+"]:");
+ String input = reader.readLine();
+ if (input != null && input.trim().length() > 0)
+ {
+ try
+ {
+ int inputPort = Integer.parseInt(input);
+ if (inputPort <= 0 || inputPort > 65535)
+ {
+ writer.println("Invalid input, please enter a valid port number");
+ continue;
+ }
+ data.setDatabasePort(input);
+ break;
+ }
+ catch (NumberFormatException e){
+ writer.println("Invalid input, please enter a valid port number");
+ continue;
+ }
+ }
+ break;
+ }
+ }
+
+ private void dbSystemPassword(BufferedReader reader, PrintWriter writer) throws IOException {
+ while (true)
+ {
+ writer.println("Database System User Password ["+data.getDatabaseSystemPassword()+"]");
+ String dbPassword = reader.readLine();
+ if (dbPassword != null && dbPassword.trim().length() > 0)
+ {
+ data.setDatabaseSystemPassword(dbPassword);
+ }
+ String error = data.testDatabase();
+ if (error != null && error.trim().length() > 0)
+ {
+ writer.println("Database test fail: " + error);
+ dbType(reader, writer);
+ dbHostname(reader, writer);
+ dbPort(reader, writer);
+ dbName(reader, writer);
+ dbUser(reader, writer);
+ dbPassword(reader, writer);
+ continue;
+ }
+ break;
+ }
+ }
+
+ private void dbPassword(BufferedReader reader, PrintWriter writer) throws IOException {
+ writer.println("Database Password [" + data.getDatabasePassword()+"]:");
+ String dbPassword = reader.readLine();
+ if (dbPassword != null && dbPassword.trim().length() > 0)
+ {
+ data.setDatabasePassword(dbPassword);
+ }
+ }
+
+ private void dbUser(BufferedReader reader, PrintWriter writer) throws IOException {
+ writer.println("Database user ["+data.getDatabaseUser()+"]:");
+ String dbUser = reader.readLine();
+ if (dbUser != null && dbUser.trim().length() > 0)
+ {
+ data.setDatabaseUser(dbUser);
+ }
+ }
+
+ private void dbName(BufferedReader reader, PrintWriter writer) throws IOException {
+ writer.println("Database Name["+data.getDatabaseName()+"]:");
+ String dbName = reader.readLine();
+ if (dbName != null && dbName.trim().length() > 0)
+ {
+ data.setDatabaseName(dbName);
+ }
+ }
+
+ private void dbHostname(BufferedReader reader, PrintWriter writer) throws IOException {
+ writer.println("Database Server Host Name ["+data.getDatabaseServer()+"]:");
+ String hostName = reader.readLine();
+ if (hostName != null && hostName.trim().length() > 0)
+ {
+ data.setDatabaseServer(hostName);
+ }
+ }
+
+ private void appServerSSLPort(BufferedReader reader, PrintWriter writer) throws IOException {
+ while (true)
+ {
+ writer.println("Application Server SSL Port["+data.getAppsServerSSLPort()+"]:");
+ String input = reader.readLine();
+ if (input != null && input.trim().length() > 0)
+ {
+ try
+ {
+ int inputPort = Integer.parseInt(input);
+ if (inputPort <= 0 || inputPort > 65535)
+ {
+ writer.println("Invalid input, please enter a valid port number");
+ continue;
+ }
+ data.setAppsServerSSLPort(input);
+ String error = data.testAppsServer();
+ if (error != null && error.trim().length() > 0)
+ {
+ writer.println("Application server test fail: " + error);
+ appServerHostname(reader, writer);
+ appServerWebPort(reader, writer);
+ continue;
+ }
+ break;
+ }
+ catch (NumberFormatException e){
+ writer.println("Invalid input, please enter a valid port number");
+ continue;
+ }
+ }
+ break;
+ }
+
+ }
+
+ private void appServerWebPort(BufferedReader reader, PrintWriter writer) throws IOException {
+ while (true)
+ {
+ writer.println("Application Server Web Port ["+data.getAppsServerWebPort()+"]:");
+ String input = reader.readLine();
+ if (input != null && input.trim().length() > 0)
+ {
+ try
+ {
+ int inputPort = Integer.parseInt(input);
+ if (inputPort <= 0 || inputPort > 65535)
+ {
+ writer.println("Invalid input, please enter a valid port number");
+ continue;
+ }
+ data.setAppsServerWebPort(input);
+ break;
+ }
+ catch (NumberFormatException e){
+ writer.println("Invalid input, please enter a valid port number");
+ continue;
+ }
+ }
+ break;
+ }
+
+ }
+
+ private void appServerHostname(BufferedReader reader, PrintWriter writer) throws IOException {
+ writer.println("Application Server Host Name ["+data.getAppsServer()+"]:");
+ String hostName = reader.readLine();
+ if (hostName != null && hostName.trim().length() > 0)
+ {
+ data.setAppsServer(hostName);
+ }
+ }
+
+ private void keyStorePass(BufferedReader reader, PrintWriter writer) throws Exception {
+ while (true)
+ {
+ writer.println("Key Store Password [" + data.getKeyStore() + "]:");
+ String password = reader.readLine();
+ if (password != null && password.trim().length() > 0)
+ {
+ data.setKeyStore(password);
+ }
+ else
+ {
+ password = data.getKeyStore();
+ }
+
+ File adempiereHome = new File(data.getAdempiereHome());
+ String fileName = KeyStoreMgt.getKeystoreFileName(adempiereHome.getAbsolutePath());
+ KeyStoreMgt storeMgt = new KeyStoreMgt (fileName, password.toCharArray());
+ KeyStore keyStore = storeMgt.getKeyStore();
+ if (keyStore == null)
+ {
+ String cn = data.getProperty(ConfigurationData.ADEMPIERE_CERT_CN);
+ if (cn == null)
+ cn = System.getProperty("user.name");
+ String ou = data.getProperty(ConfigurationData.ADEMPIERE_CERT_ORG_UNIT);
+ if (ou == null)
+ ou = "AdempiereUser";
+ String o = data.getProperty(ConfigurationData.ADEMPIERE_CERT_ORG);
+ if (o == null)
+ o = System.getProperty("user.name");
+ String lt = data.getProperty(ConfigurationData.ADEMPIERE_CERT_LOCATION);
+ if (lt == null)
+ lt = "MyTown";
+ String st = data.getProperty(ConfigurationData.ADEMPIERE_CERT_STATE);
+ if (st == null) st = "";
+ String country = data.getProperty(ConfigurationData.ADEMPIERE_CERT_COUNTRY);
+ if (country == null)
+ country = System.getProperty("user.country");
+
+ writer.println("KeyStore Settings.");
+ writer.println("(ON) Common Name [" + cn + "]:");
+ String input = reader.readLine();
+ if (input != null && input.trim().length() > 0)
+ {
+ cn = input;
+ data.updateProperty(ConfigurationData.ADEMPIERE_CERT_CN, input);
+ }
+
+ writer.println("(OU) Organization Unit [" + ou + "]:");
+ input = reader.readLine();
+ if (input != null && input.trim().length() > 0)
+ {
+ ou = input;
+ data.updateProperty(ConfigurationData.ADEMPIERE_CERT_ORG_UNIT, ou);
+ }
+
+ writer.println("(O) Organization [" + o + "]:");
+ input = reader.readLine();
+ if (input != null && input.trim().length() > 0)
+ {
+ o = input;
+ data.updateProperty(ConfigurationData.ADEMPIERE_CERT_ORG, o);
+ }
+
+ writer.println("(L) Locale/Town [" + lt + "]:");
+ input = reader.readLine();
+ if (input != null && input.trim().length() > 0)
+ {
+ lt = input;
+ data.updateProperty(ConfigurationData.ADEMPIERE_CERT_LOCATION, lt);
+ }
+
+ writer.println("(S) State [" + st + "]:");
+ input = reader.readLine();
+ if (input != null && input.trim().length() > 0)
+ {
+ st = input;
+ data.updateProperty(ConfigurationData.ADEMPIERE_CERT_STATE, st);
+ }
+
+ writer.println("(C) Country (2 Char) [" + country +"]");
+ input = reader.readLine();
+ if (input != null && input.trim().length() > 0)
+ {
+ country = input;
+ data.updateProperty(ConfigurationData.ADEMPIERE_CERT_COUNTRY, input);
+ }
+
+ }
+
+ String error = data.testAdempiere();
+ if (error != null && error.trim().length() > 0)
+ {
+ writer.println("Adempiere home and keystore validation error: " + error);
+ adempiereHome(reader, writer);
+ continue;
+ }
+ break;
+ }
+ }
+
+ private void adempiereHome(BufferedReader reader, PrintWriter writer) throws IOException {
+ writer.println("Adempiere Home ["+data.getAdempiereHome()+"]:");
+ String input = reader.readLine();
+ if (input != null && input.trim().length() > 0)
+ {
+ data.setAdempiereHome(input);
+ }
+ }
+
+ private void jvmHome(BufferedReader reader, PrintWriter writer) throws IOException {
+ while (true)
+ {
+ writer.println("Java Home ["+data.getJavaHome()+"]:");
+ String input = reader.readLine();
+ if (input != null && input.trim().length() > 0)
+ {
+ data.setJavaHome(input);
+ }
+ String error = data.testJava();
+ if (error != null && error.trim().length() > 0)
+ {
+ writer.println("JVM test fail: " + error);
+ jvmType(reader, writer);
+ continue;
+ }
+ break;
+ }
+ }
+
+ private void jvmType(BufferedReader reader, PrintWriter writer) throws IOException {
+ //java type
+ String javaType = data.getJavaType();
+ int javaTypeSelected = 0;
+ for(int i = 0; i < ConfigurationData.JAVATYPE.length; i++)
+ {
+ if (ConfigurationData.JAVATYPE[i].equals(javaType))
+ {
+ javaTypeSelected = i;
+ break;
+ }
+ }
+// console.writer().println("JVM Type:");
+ for(int i = 0; i < ConfigurationData.JAVATYPE.length; i++)
+ {
+ writer.println((i+1) + ". " + ConfigurationData.JAVATYPE[i]);
+ }
+
+ while (true)
+ {
+ writer.println("JVM Type [" + (javaTypeSelected+1) + "]:");
+ String input = reader.readLine();
+ if (input != null && input.trim().length() > 0)
+ {
+ try
+ {
+ int inputIndex = Integer.parseInt(input);
+ if (inputIndex <= 0 || inputIndex > ConfigurationData.JAVATYPE.length)
+ {
+ writer.println("Invalid input, please enter numeric value of 1 to " + ConfigurationData.JAVATYPE.length);
+ continue;
+ }
+ data.initJava(inputIndex-1);
+ data.setJavaType(ConfigurationData.JAVATYPE[inputIndex-1]);
+ break;
+ }
+ catch (NumberFormatException e){
+ writer.println("Invalid input, please enter numeric value of 1 to " + ConfigurationData.JAVATYPE.length);
+ continue;
+ }
+ }
+ else
+ {
+ data.initJava(javaTypeSelected);
+ data.setJavaType(ConfigurationData.JAVATYPE[javaTypeSelected]);
+ }
+ break;
+ }
+ }
+
+ private void dbType(BufferedReader reader, PrintWriter writer) throws IOException {
+ String dbType = data.getDatabaseType();
+ int dbTypeSelected = 0;
+ for(int i = 0; i < ConfigurationData.DBTYPE.length; i++)
+ {
+ if (ConfigurationData.DBTYPE[i].equals(dbType))
+ {
+ dbTypeSelected = i;
+ break;
+ }
+ }
+// console.writer().println("JVM Type:");
+ for(int i = 0; i < ConfigurationData.DBTYPE.length; i++)
+ {
+ writer.println((i+1)+". "+ConfigurationData.DBTYPE[i]);
+ }
+
+ while (true)
+ {
+ writer.println("Database Type ["+(dbTypeSelected+1)+"]");
+ String input = reader.readLine();
+ if (input != null && input.trim().length() > 0)
+ {
+ try
+ {
+ int inputIndex = Integer.parseInt(input);
+ if (inputIndex <= 0 || inputIndex > ConfigurationData.DBTYPE.length)
+ {
+ writer.println("Invalid input, please enter numeric value of 1 to " + ConfigurationData.DBTYPE.length);
+ continue;
+ }
+ data.initDatabase(ConfigurationData.DBTYPE[inputIndex-1]);
+ data.setDatabaseType(ConfigurationData.DBTYPE[inputIndex-1]);
+ break;
+ }
+ catch (NumberFormatException e){
+ writer.println("Invalid input, please enter numeric value of 1 to " + ConfigurationData.DBTYPE.length);
+ }
+ }
+ break;
+ }
+ }
+}
diff --git a/org.adempiere.install/src/org/compiere/install/util/AEnv.java b/org.adempiere.install/src/org/compiere/install/util/AEnv.java
new file mode 100644
index 0000000000..94327a6fdd
--- /dev/null
+++ b/org.adempiere.install/src/org/compiere/install/util/AEnv.java
@@ -0,0 +1,185 @@
+package org.compiere.install.util;
+
+import java.awt.Dimension;
+import java.awt.Frame;
+import java.awt.GraphicsConfiguration;
+import java.awt.Insets;
+import java.awt.Rectangle;
+import java.awt.Toolkit;
+import java.awt.Window;
+
+import javax.swing.SwingConstants;
+
+public class AEnv {
+
+ /**
+ * Show in the center of the screen.
+ * (pack, set location and set visibility)
+ * @param window Window to position
+ */
+ public static void showCenterScreen(Window window)
+ {
+ positionCenterScreen(window);
+ showWindow(window);
+ } // showCenterScreen
+
+ /**
+ * Position in center of the parent window.
+ * (pack, set location and set visibility)
+ * @param parent Parent Window
+ * @param window Window to position
+ */
+ public static void showCenterWindow(Window parent, Window window)
+ {
+ positionCenterWindow(parent, window);
+ showWindow(window);
+ } // showCenterWindow
+
+ /**
+ * Position in center of the parent window
+ *
+ * @param parent Parent Window
+ * @param window Window to position
+ */
+ public static void positionCenterWindow(Window parent, Window window)
+ {
+ if (parent == null)
+ {
+ positionCenterScreen(window);
+ return;
+ }
+ window.pack();
+ //
+ Dimension sSize = Toolkit.getDefaultToolkit().getScreenSize();
+ // take into account task bar and other adornments
+ GraphicsConfiguration config = window.getGraphicsConfiguration();
+ Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(config);
+ sSize.width -= (insets.left + insets.right);
+ sSize.height -= (insets.top + insets.bottom);
+
+ Dimension wSize = window.getSize();
+ // fit on window
+ if (wSize.height > sSize.height)
+ wSize.height = sSize.height;
+ if (wSize.width > sSize.width)
+ wSize.width = sSize.width;
+ window.setSize(wSize);
+ // center in parent
+ Rectangle pBounds = parent.getBounds();
+ // Parent is in upper left corner
+ if (pBounds.x == pBounds.y && pBounds.x == 0)
+ {
+ positionCenterScreen(window);
+ return;
+ }
+ // Find middle
+ int x = pBounds.x + ((pBounds.width-wSize.width)/2);
+ if (x < 0)
+ x = 0;
+ int y = pBounds.y + ((pBounds.height-wSize.height)/2);
+ if (y < 0)
+ y = 0;
+
+ // Is it on Screen?
+ if (x + wSize.width > sSize.width)
+ x = sSize.width - wSize.width;
+ if (y + wSize.height > sSize.height)
+ y = sSize.height - wSize.height;
+ //
+ // System.out.println("Position: x=" + x + " y=" + y + " w=" + wSize.getWidth() + " h=" + wSize.getHeight()
+ // + " - Parent loc x=" + pLoc.x + " y=" + y + " w=" + pSize.getWidth() + " h=" + pSize.getHeight());
+ window.setLocation(x + insets.left, y + insets.top);
+ } // positionCenterScreen
+
+ /**
+ * Position window in center of the screen
+ * @param window Window to position
+ */
+ public static void positionCenterScreen(Window window)
+ {
+ positionScreen (window, SwingConstants.CENTER);
+ } // positionCenterScreen
+
+ /**
+ * Position window in center of the screen
+ * @param window Window to position
+ * @param position SwingConstants
+ */
+ public static void positionScreen (Window window, int position)
+ {
+ window.pack();
+ // take into account task bar and other adornments
+ GraphicsConfiguration config = window.getGraphicsConfiguration();
+ Rectangle bounds = config.getBounds();
+ Dimension sSize = bounds.getSize();
+ Insets insets = Toolkit.getDefaultToolkit().getScreenInsets(config);
+ sSize.width -= (insets.left + insets.right);
+ sSize.height -= (insets.top + insets.bottom);
+
+ Dimension wSize = window.getSize();
+ // fit on window
+ if (wSize.height > sSize.height)
+ wSize.height = sSize.height;
+ if (wSize.width > sSize.width)
+ wSize.width = sSize.width;
+ window.setSize(wSize);
+ // Center
+ int x = (sSize.width - wSize.width) / 2;
+ int y = (sSize.height - wSize.height) / 2;
+ if (position == SwingConstants.CENTER)
+ ;
+ else if (position == SwingConstants.NORTH_WEST)
+ {
+ x = 0;
+ y = 0;
+ }
+ else if (position == SwingConstants.NORTH)
+ {
+ y = 0;
+ }
+ else if (position == SwingConstants.NORTH_EAST)
+ {
+ x = (sSize.width - wSize.width);
+ y = 0;
+ }
+ else if (position == SwingConstants.WEST)
+ {
+ x = 0;
+ }
+ else if (position == SwingConstants.EAST)
+ {
+ x = (sSize.width - wSize.width);
+ }
+ else if (position == SwingConstants.SOUTH)
+ {
+ y = (sSize.height - wSize.height);
+ }
+ else if (position == SwingConstants.SOUTH_WEST)
+ {
+ x = 0;
+ y = (sSize.height - wSize.height);
+ }
+ else if (position == SwingConstants.SOUTH_EAST)
+ {
+ x = (sSize.width - wSize.width);
+ y = (sSize.height - wSize.height);
+ }
+ //
+ window.setLocation(bounds.x + x + insets.left, bounds.y + y + insets.top);
+ } // positionScreen
+
+ /**
+ * Show window: de-iconify and bring it to front
+ * @author teo_sarca [ 1707221 ]
+ */
+ public static void showWindow(Window window) {
+ window.setVisible(true);
+ if (window instanceof Frame) {
+ Frame f = (Frame)window;
+ int state = f.getExtendedState();
+ if ((state & Frame.ICONIFIED) > 0)
+ f.setExtendedState(state & ~Frame.ICONIFIED);
+ }
+ window.toFront();
+ }
+}
diff --git a/org.adempiere.install/src/org/compiere/install/util/ALayout.java b/org.adempiere.install/src/org/compiere/install/util/ALayout.java
new file mode 100644
index 0000000000..835c21210b
--- /dev/null
+++ b/org.adempiere.install/src/org/compiere/install/util/ALayout.java
@@ -0,0 +1,418 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
+ * This program is free software; you can redistribute it and/or modify it *
+ * under the terms version 2 of the GNU General Public License as published *
+ * by the Free Software Foundation. This program is distributed in the hope *
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
+ * See the GNU General Public License for more details. *
+ * You should have received a copy of the GNU General Public License along *
+ * with this program; if not, write to the Free Software Foundation, Inc., *
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.install.util;
+
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.Dimension;
+import java.awt.Insets;
+import java.awt.LayoutManager;
+import java.awt.LayoutManager2;
+import java.util.Arrays;
+import java.util.Iterator;
+
+/**
+ * Application Layout Manager.
+ *
+ * panel.setLayout(new ALayout());
+ * panel.add(field11, new ALayoutConstraint(0,0));
+ * panel.add(field12, null);
+ * panel.add(field13, null);
+ * panel.add(field14, null);
+ * panel.add(field21, new ALayoutConstraint(1,0));
+ *
+ *
+ * @author Jorg Janke
+ * @version $Id: ALayout.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $
+ */
+public class ALayout implements LayoutManager2
+{
+ /**
+ * Default Constructor with spacing of 2 and columns filled
+ */
+ public ALayout()
+ {
+ this (2,4, true);
+ } // ALayout
+
+ /**
+ * Detail Contructor
+ * @param spaceH horizontal space (top, between rows, button)
+ * @param spaceV vertical space (left, between columns, right)
+ * @param colFill fields are fully filled (rather then preferred size)
+ */
+ public ALayout(int spaceH, int spaceV, boolean colFill)
+ {
+ setSpaceH(spaceH);
+ setSpaceV(spaceV);
+ m_colFill = colFill;
+ } // ALayout
+
+ /** Data Storage */
+ private ALayoutCollection m_data = new ALayoutCollection();
+ /** Horizontal Space */
+ private int m_spaceH;
+ /** Vertical Space */
+ private int m_spaceV;
+ /** Column Fill */
+ private boolean m_colFill;
+
+ /**
+ * Add To Layout with NULL constraint
+ *
+ * @param name the string to be associated with the component - ignored
+ * @param comp the component to be added
+ */
+ public void addLayoutComponent(String name, Component comp)
+ {
+ addLayoutComponent (comp, null);
+ } // addLayoutComponent
+
+ /**
+ * Adds the specified component to the layout, using the specified
+ * constraint object. If the constraint is not a ALayoutConstraint
+ * the component is added with a NULL constraint.
+ *
+ * Components with a NULL constraint are added as the next column to the last row
+ *
+ * @param component the component to be added
+ * @param constraint where/how the component is added to the layout.
+ * @see ALayoutConstraint
+ */
+ public void addLayoutComponent(Component component, Object constraint)
+ {
+ ALayoutConstraint con = null;
+ if (constraint instanceof ALayoutConstraint)
+ con = (ALayoutConstraint)constraint;
+ //
+ m_data.put(con, component);
+ } // addLayoutComponent
+
+ /**
+ * Removes the specified component from the layout.
+ * @param comp the component to be removed
+ */
+ public void removeLayoutComponent(Component comp)
+ {
+ if (!m_data.containsValue(comp))
+ return;
+ Iterator it = m_data.keySet().iterator();
+ while (it.hasNext())
+ {
+ Object key = it.next();
+ if (m_data.get(key).equals(comp))
+ {
+ m_data.remove(key);
+ return;
+ }
+ }
+ } // removeLayoutComponent
+
+ /**
+ * Calculates the preferred size dimensions for the specified
+ * container, given the components it contains.
+ * @param parent the container to be laid out
+ * @return Size
+ * @see #minimumLayoutSize
+ */
+ public Dimension preferredLayoutSize(Container parent)
+ {
+ return calculateLayoutSize (parent, 'P');
+ } // preferredLayoutSize
+
+ /**
+ * Calculates the minimum size dimensions for the specified
+ * container, given the components it contains.
+ * @param parent the component to be laid out
+ * @return Size
+ * @see #preferredLayoutSize
+ */
+ public Dimension minimumLayoutSize(Container parent)
+ {
+ return calculateLayoutSize (parent, 'm');
+ } // minimumLayoutSize
+
+ /**
+ * Calculates the maximum size dimensions for the specified container,
+ * given the components it contains.
+ * @param parent Parent Container
+ * @return Size
+ * @see java.awt.Component#getMaximumSize
+ * @see LayoutManager
+ */
+ public Dimension maximumLayoutSize(Container parent)
+ {
+ return calculateLayoutSize (parent, 'M');
+ } // maximumLayoutSize
+
+ /**
+ * Calculate Layout Size
+ * @param parent Parent Container
+ * @param how P=Preferred - M=Maximum = m=Mimimum
+ * @return Size
+ */
+ private Dimension calculateLayoutSize(Container parent, char how)
+ {
+ checkComponents(parent);
+ // -- Create 2D Dimension Array
+ int rows = getRowCount();
+ int cols = getColCount();
+ Dimension[][] dim = new Dimension[rows][cols];
+ //
+ Object[] keys = m_data.keySet().toArray();
+ Arrays.sort(keys);
+ for (int i = 0; i < keys.length; i++)
+ {
+ ALayoutConstraint constraint = (ALayoutConstraint)keys[i];
+ Component component = (Component)m_data.get(keys[i]);
+ Dimension d = null;
+ if (how == 'P')
+ d = component.getPreferredSize();
+ else if (how == 'M')
+ d = component.getMaximumSize();
+ else
+ d = component.getMinimumSize();
+ if (component.isVisible())
+ dim [constraint.getRow()][constraint.getCol()] = d;
+ else
+ dim [constraint.getRow()][constraint.getCol()] = null;
+ }
+
+ // -- Calculate 2D Dimension Size
+ Insets insets = parent.getInsets();
+ Dimension retValue = new Dimension (insets.left+insets.right, insets.top+insets.bottom);
+ retValue.height += m_spaceH;
+ retValue.width += m_spaceV;
+ int maxWidth = 0;
+ for (int r = 0; r < rows; r++)
+ {
+ int height = 0;
+ int width = 0;
+ for (int c = 0; c < cols; c++)
+ {
+ Dimension d = dim[r][c];
+ if (d != null)
+ {
+ width += d.width;
+ height = Math.max(height, d.height);
+ }
+ width += m_spaceV;
+ } // for all columns
+ retValue.height += height + m_spaceH;
+ maxWidth += Math.max(maxWidth, width);
+ } // for all rows
+ retValue.width += maxWidth;
+ // Log.trace(this,Log.l6_Database, "ALayout.calculateLayoutSize", retValue.toString());
+ return retValue;
+ } // calculateLayoutSize
+
+ /**
+ * Lays out the specified container.
+ * @param parent the container to be laid out
+ */
+ public void layoutContainer(Container parent)
+ {
+ checkComponents(parent);
+ // -- Create 2D Component Array
+ int rows = getRowCount();
+ int cols = getColCount();
+ Component[][] com = new Component[rows][cols];
+ //
+ Object[] keys = m_data.keySet().toArray();
+ Arrays.sort(keys);
+ for (int i = 0; i < keys.length; i++)
+ {
+ ALayoutConstraint constraint = (ALayoutConstraint)keys[i];
+ Component component = (Component)m_data.get(keys[i]);
+ if (component.isVisible())
+ com [constraint.getRow()][constraint.getCol()] = component;
+ else
+ com [constraint.getRow()][constraint.getCol()] = null;
+ }
+
+ // -- Calculate Column Size
+ int[] colWidth = new int[cols];
+ int[] rowHeight = new int[rows];
+ int columnWidth = m_spaceV;
+ for (int c = 0; c < cols; c++)
+ {
+ int width = 0;
+ for (int r = 0; r < rows; r++)
+ {
+ Component component = com[r][c];
+ if (component != null)
+ {
+ width = Math.max (width, component.getPreferredSize().width);
+ rowHeight[r] = Math.max (rowHeight[r], component.getPreferredSize().height);
+ }
+ }
+ colWidth[c] = width;
+ columnWidth += width + m_spaceV;
+ }
+
+ // -- Stretch/Squeeze Columns to fit target width
+ int parentWidth = parent.getSize().width;
+ double multiplier = (double)parentWidth / (double)columnWidth;
+ if (multiplier < .5) // limit sqeezing
+ multiplier = .5;
+ for (int c = 0; c < cols; c++)
+ colWidth[c] = (int) (colWidth[c] * multiplier);
+ int spaceV = (int)(m_spaceV * multiplier);
+ //
+// log.fine( "ALayout.layoutContainer",
+// "ParentWidth=" + parentWidth + ", ColumnWidth=" + columnWidth + ", SpaceV=" + spaceV + ", Multiplier=" + multiplier);
+
+ // -- Lay out components
+ Insets insets = parent.getInsets();
+ int posH = insets.top + m_spaceH;
+ for (int r = 0; r < rows; r++)
+ {
+ int posV = insets.left + spaceV;
+ int height = 0;
+ for (int c = 0; c < cols; c++)
+ {
+ Component component = com[r][c];
+ if (component != null)
+ {
+ Dimension ps = component.getPreferredSize();
+ int w = ps.width;
+ if (m_colFill || w > colWidth[c]) // limit or stretch
+ w = colWidth[c];
+ int h = ps.height;
+ int topSpace = 0;
+ if (h < rowHeight[r]) // push a little bit lower
+ topSpace = (rowHeight[r] - h) / 3;
+ height = Math.max(height, h);
+ component.setBounds(posV, posH+topSpace, w, h);
+// log.fine( "ALayout.layoutContainer",
+// "Row=" + r + ", Col=" + c + ", PosV=" + posV + ", PosH=" + posH + "/" + topSpace + ", width=" + w + ", height=" + h);
+ }
+ posV += colWidth[c] + spaceV;
+ } // for all columns
+ posH += height + m_spaceH;
+ } // for all rows
+ } // layoutContainer
+
+ /**
+ * Returns the alignment along the x axis. This specifies how
+ * the component would like to be aligned relative to other
+ * components. The value should be a number between 0 and 1
+ * where 0 represents alignment along the origin, 1 is aligned
+ * the furthest away from the origin, 0.5 is centered, etc.
+ * @param target target
+ * @return 0f
+ */
+ public float getLayoutAlignmentX(Container target)
+ {
+ return 0f;
+ } // getLayoutAlignmentX
+
+ /**
+ * Returns the alignment along the y axis. This specifies how
+ * the component would like to be aligned relative to other
+ * components. The value should be a number between 0 and 1
+ * where 0 represents alignment along the origin, 1 is aligned
+ * the furthest away from the origin, 0.5 is centered, etc.
+ * @param target target
+ * @return 0f
+ */
+ public float getLayoutAlignmentY(Container target)
+ {
+ return 0f;
+ } // getLayoutAlignmentY
+
+ /**
+ * Invalidates the layout, indicating that if the layout manager
+ * has cached information it should be discarded.
+ * @param target target
+ */
+ public void invalidateLayout(Container target)
+ {
+ } // invalidateLayout
+
+ /*************************************************************************/
+
+ /**
+ * Check target components and add components, which don't have no constraints
+ * @param target target
+ */
+ private void checkComponents (Container target)
+ {
+ int size = target.getComponentCount();
+ for (int i = 0; i < size; i++)
+ {
+ Component comp = target.getComponent(i);
+ if (!m_data.containsValue(comp))
+ m_data.put(null, comp);
+ }
+ } // checkComponents
+
+ /**
+ * Get Number of Rows
+ * @return no pf rows
+ */
+ public int getRowCount()
+ {
+ return m_data.getMaxRow()+1;
+ } // getRowCount
+
+ /**
+ * Get Number of Columns
+ * @return no of cols
+ */
+ public int getColCount()
+ {
+ return m_data.getMaxCol()+1;
+ } // getColCount
+
+ /**
+ * Set Horizontal Space (top, between rows, button)
+ * @param spaceH horizontal space (top, between rows, button)
+ */
+ public void setSpaceH (int spaceH)
+ {
+ m_spaceH = spaceH;
+ } // setSpaceH
+
+ /**
+ * Get Horizontal Space (top, between rows, button)
+ * @return spaceH horizontal space (top, between rows, button)
+ */
+ public int getSpaceH()
+ {
+ return m_spaceH;
+ } // getSpaceH
+
+ /**
+ * Set Vertical Space (left, between columns, right)
+ * @param spaceV vertical space (left, between columns, right)
+ */
+ public void setSpaceV(int spaceV)
+ {
+ m_spaceV = spaceV;
+ } // setSpaceV
+
+ /**
+ * Get Vertical Space (left, between columns, right)
+ * @return spaceV vertical space (left, between columns, right)
+ */
+ public int getSpaceV()
+ {
+ return m_spaceV;
+ } // getSpaceV
+
+} // ALayout
diff --git a/org.adempiere.install/src/org/compiere/install/util/ALayoutCollection.java b/org.adempiere.install/src/org/compiere/install/util/ALayoutCollection.java
new file mode 100644
index 0000000000..878c99ee27
--- /dev/null
+++ b/org.adempiere.install/src/org/compiere/install/util/ALayoutCollection.java
@@ -0,0 +1,135 @@
+/******************************************************************************
+ * Product: Adempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 1999-2006 ComPiere, Inc. All Rights Reserved. *
+ * This program is free software; you can redistribute it and/or modify it *
+ * under the terms version 2 of the GNU General Public License as published *
+ * by the Free Software Foundation. This program is distributed in the hope *
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
+ * See the GNU General Public License for more details. *
+ * You should have received a copy of the GNU General Public License along *
+ * with this program; if not, write to the Free Software Foundation, Inc., *
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
+ * For the text or an alternative of this public license, you may reach us *
+ * ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
+ * or via info@compiere.org or http://www.compiere.org/license.html *
+ *****************************************************************************/
+package org.compiere.install.util;
+
+import java.awt.Component;
+import java.util.HashMap;
+import java.util.Iterator;
+
+/**
+ * Collection of Components ordered based on ALayoutConstraint
+ *
+ * @author Jorg Janke
+ * @version $Id: ALayoutCollection.java,v 1.2 2006/07/30 00:51:27 jjanke Exp $
+ */
+class ALayoutCollection extends HashMap