📄 cconnectiondialog.java
字号:
/******************************************************************************
* The contents of this file are subject to the Compiere License Version 1.1
* ("License"); You may not use this file except in compliance with the License
* You may obtain a copy of the License at http://www.compiere.org/license.html
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
* the specific language governing rights and limitations under the License.
* The Original Code is Compiere ERP & CRM Business Solution
* The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
* Portions created by Jorg Janke are Copyright (C) 1999-2001 Jorg Janke, parts
* created by ComPiere are Copyright (C) ComPiere, Inc.; All Rights Reserved.
* Contributor(s): ______________________________________.
*****************************************************************************/
package org.compiere.db;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import org.compiere.util.Ini;
import org.compiere.plaf.*;
import org.compiere.swing.*;
import java.util.ResourceBundle;
/**
* Connection Dialog.
*
* @author Jorg Janke
* @author Marek Mosiewicz<marek.mosiewicz@jotel.com.pl> - support for RMI over HTTP
* @version $Id: CConnectionDialog.java,v 1.13 2003/05/04 18:33:32 marekmosiewicz Exp $
*/
public class CConnectionDialog extends JDialog implements ActionListener
{
/**
* Connection Dialog using current Connection
*/
public CConnectionDialog()
{
this (null);
} // CConnectionDialog
/**
* Connection Dialog
* @param cc Compiere Connection
*/
public CConnectionDialog(CConnection cc)
{
super((Frame)null, true);
try
{
jbInit();
setConnection (cc);
}
catch(Exception e)
{
e.printStackTrace();
}
CompierePLAF.showCenterScreen(this);
} // CConnection
private static ResourceBundle res = ResourceBundle.getBundle("org.compiere.db.DBRes");
private CConnection m_cc = null;
private CConnection m_ccResult = null;
private boolean m_updating = false;
private boolean m_saved = false;
private CPanel mainPanel = new CPanel();
private BorderLayout mainLayout = new BorderLayout();
private CPanel centerPanel = new CPanel();
private CPanel southPanel = new CPanel();
private CButton bOK = CompierePLAF.getOKButton();
private CButton bCancel = CompierePLAF.getCancelButton();
private FlowLayout southLayout = new FlowLayout();
private GridBagLayout centerLayout = new GridBagLayout();
private CLabel nameLabel = new CLabel();
private CTextField nameField = new CTextField();
private CLabel hostLabel = new CLabel();
private CTextField hostField = new CTextField();
private CLabel portLabel = new CLabel();
private CTextField portField = new CTextField();
private CLabel sidLabel = new CLabel();
private CTextField sidField = new CTextField();
private CCheckBox cbFirewall = new CCheckBox();
private CLabel fwHostLabel = new CLabel();
private CTextField fwHostField = new CTextField();
private CLabel fwPortLabel = new CLabel();
private CTextField fwPortField = new CTextField();
private CButton bTestDB = new CButton();
private CLabel typeLabel = new CLabel();
private CComboBox typeField = new CComboBox(Database.DB_NAMES);
private CCheckBox cbBequeath = new CCheckBox();
private CLabel appsHostLabel = new CLabel();
private CTextField appsHostField = new CTextField();
private CLabel appsPortLabel = new CLabel();
private CTextField appsPortField = new CTextField();
private CButton bTestApps = new CButton();
private CCheckBox cbOverwrite = new CCheckBox();
private CLabel dbUidLabel = new CLabel();
private CTextField dbUidField = new CTextField();
private JPasswordField dbPwdField = new JPasswordField();
CCheckBox cbRMIoverHTTP = new CCheckBox();
/**
* Static Layout
* @throws Exception
*/
private void jbInit() throws Exception
{
this.setTitle(res.getString("CConnectionDialog"));
CompiereColor.setBackground(this);
mainPanel.setLayout(mainLayout);
southPanel.setLayout(southLayout);
southLayout.setAlignment(FlowLayout.RIGHT);
centerPanel.setLayout(centerLayout);
nameLabel.setText(res.getString("Name"));
nameField.setColumns(30);
hostLabel.setText(res.getString("DBHost"));
hostField.setColumns(30);
portLabel.setText(res.getString("DBPort"));
portField.setColumns(10);
sidLabel.setText(res.getString("DBName"));
cbFirewall.setToolTipText("");
cbFirewall.setText(res.getString("ViaFirewall"));
fwHostLabel.setText(res.getString("FWHost"));
fwHostField.setColumns(30);
fwPortLabel.setText(res.getString("FWPort"));
bTestDB.setText(res.getString("TestConnection"));
bTestDB.setHorizontalAlignment(JLabel.LEFT);
typeLabel.setText(res.getString("Type"));
sidField.setColumns(30);
fwPortField.setColumns(10);
cbBequeath.setText(res.getString("BequeathConnection"));
appsHostLabel.setText(res.getString("AppsHost"));
appsHostField.setColumns(30);
appsPortLabel.setText(res.getString("AppsPort"));
appsPortField.setColumns(10);
bTestApps.setText(res.getString("TestApps"));
bTestApps.setHorizontalAlignment(JLabel.LEFT);
cbOverwrite.setText(res.getString("Overwrite"));
dbUidLabel.setText(res.getString("DBUidPwd"));
dbUidField.setColumns(10);
cbRMIoverHTTP.addActionListener(this);
cbRMIoverHTTP.setText(res.getString("RMIoverHTTP"));
this.getContentPane().add(mainPanel, BorderLayout.CENTER);
mainPanel.add(centerPanel, BorderLayout.CENTER);
mainPanel.add(southPanel, BorderLayout.SOUTH);
southPanel.add(bCancel, null);
southPanel.add(bOK, null);
centerPanel.add(nameLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(12, 12, 5, 5), 0, 0));
centerPanel.add(nameField, new GridBagConstraints(1, 0, 2, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(12, 0, 5, 12), 0, 0));
centerPanel.add(hostLabel, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 12, 5, 5), 0, 0));
centerPanel.add(hostField, new GridBagConstraints(1, 6, 2, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 5, 12), 0, 0));
centerPanel.add(portLabel, new GridBagConstraints(0, 7, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 5, 5), 0, 0));
centerPanel.add(portField, new GridBagConstraints(1, 7, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 0), 0, 0));
centerPanel.add(sidLabel, new GridBagConstraints(0, 8, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 5, 5), 0, 0));
centerPanel.add(sidField, new GridBagConstraints(1, 8, 2, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 5, 12), 0, 0));
centerPanel.add(cbFirewall, new GridBagConstraints(1, 10, 2, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 12), 0, 0));
centerPanel.add(fwHostLabel, new GridBagConstraints(0, 11, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 5, 5), 0, 0));
centerPanel.add(fwHostField, new GridBagConstraints(1, 11, 2, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 5, 12), 0, 0));
centerPanel.add(fwPortLabel, new GridBagConstraints(0, 12, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 5, 5), 0, 0));
centerPanel.add(fwPortField, new GridBagConstraints(1, 12, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 0), 0, 0));
centerPanel.add(bTestDB, new GridBagConstraints(1, 13, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 12, 0), 0, 0));
centerPanel.add(typeLabel, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 12, 5, 5), 0, 0));
centerPanel.add(typeField, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 0), 0, 0));
centerPanel.add(appsHostLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 12, 5, 5), 0, 0));
centerPanel.add(appsHostField, new GridBagConstraints(1, 1, 2, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 12), 0, 0));
centerPanel.add(appsPortLabel, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 5, 5), 0, 0));
centerPanel.add(appsPortField, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
centerPanel.add(cbBequeath, new GridBagConstraints(2, 5, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 12), 0, 0));
centerPanel.add(cbOverwrite, new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(0, 5, 0, 12), 0, 0));
centerPanel.add(dbUidLabel, new GridBagConstraints(0, 9, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 12, 5, 5), 0, 0));
centerPanel.add(dbUidField, new GridBagConstraints(1, 9, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 0), 0, 0));
centerPanel.add(dbPwdField, new GridBagConstraints(2, 9, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 5, 12), 0, 0));
centerPanel.add(bTestApps, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0
,GridBagConstraints.SOUTHWEST, GridBagConstraints.HORIZONTAL, new Insets(2, -1, 2, 1), 0, 0));
centerPanel.add(cbRMIoverHTTP, new GridBagConstraints(1, 3, 2, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
//
nameField.addActionListener(this);
appsHostField.addActionListener(this);
appsPortField.addActionListener(this);
cbOverwrite.addActionListener(this);
bTestApps.addActionListener(this);
//
typeField.addActionListener(this);
hostField.addActionListener(this);
portField.addActionListener(this);
sidField.addActionListener(this);
cbBequeath.addActionListener(this);
cbFirewall.addActionListener(this);
fwHostField.addActionListener(this);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -