📄 rptconnectconfigui.java
字号:
/* ===========================================================
* JDBMonitor : a flexiable JDBC Monitor for the Java(tm) platform
* ===========================================================
*
* (C) Copyright 2006-2006, by yang zhongke
*
* Project Info: http://www.cownew.com
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This library 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 Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* ---------------
* RptConnectConfigUI.java
* ---------------
* (C) Copyright 2006-2006, by yang zhongke
*
* Original Author: yang zhongke;
*
* Changes
* -------
*
*/
package com.cownew.JDBMonitor.listenerImpl.dataBaseListener;
import java.awt.Frame;
import java.awt.GridLayout;
import java.awt.HeadlessException;
import java.util.prefs.Preferences;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import com.cownew.JDBMonitor.common.CommonUtils;
import com.cownew.JDBMonitor.listenerImpl.DataBaseDBListener;
import com.cownew.JDBMonitor.listenerImpl.uicommon.JCownewDialog;
public class RptConnectConfigUI extends JCownewDialog
{
private static final String LOG_TABLE = "LogTable";
private static final String USER = "User";
private static final String DBURL = "DBURL";
private static final String JDBCDRIVER = "JDBCDriver";
private static final long serialVersionUID = 8640824930537222214L;
protected JComboBox comboJDBCDriver;
protected JTextField txtDBURL;
protected JTextField txtUser;
protected JTextField txtPassword;
protected JTextField txtLogTable;
public RptConnectConfigUI(Frame owner) throws HeadlessException
{
super(owner);
}
protected void initUI()
{
super.initUI();
container.setLayout(new GridLayout(6,2));
JLabel labelJDBCDriver = new JLabel("JDBC Driver:");
container.add(labelJDBCDriver);
comboJDBCDriver = new JComboBox();
comboJDBCDriver.setEditable(true);
container.add(comboJDBCDriver);
comboJDBCDriver.addItem("sun.jdbc.odbc.JdbcOdbcDriver");
comboJDBCDriver.addItem("com.microsoft.jdbc.sqlserver.SQLServerDriver");
comboJDBCDriver.addItem("Com.ibm.db2.jdbc.net.DB2Driver");
comboJDBCDriver.addItem("oracle.jdbc.driver.OracleDriver");
comboJDBCDriver.addItem("org.gjt.mm.mysql.Driver");
comboJDBCDriver.addItem("net.sourceforge.jtds.jdbc.Driver");
comboJDBCDriver.addItem("com.sybase.jdbc2.jdbc.SybDriver");
comboJDBCDriver.addItem("org.postgresql.Driver");
JLabel labelDBURL = new JLabel("Database URL:");
container.add(labelDBURL);
txtDBURL = new JTextField();
container.add(txtDBURL);
JLabel labelUser = new JLabel("User Name:");
container.add(labelUser);
txtUser = new JTextField();
container.add(txtUser);
JLabel labelPassword = new JLabel("Password:");
container.add(labelPassword);
txtPassword = new JTextField();
container.add(txtPassword);
JLabel labelLogTable = new JLabel("Log Table Name:");
container.add(labelLogTable);
txtLogTable = new JTextField(DataBaseDBListener.DEFAULTSQLLOGTABLE);
container.add(txtLogTable);
container.add(createOKBtn());
container.add(createCancelBtn());
}
protected void loadConfig()
{
super.loadConfig();
Preferences prefer = Preferences.userNodeForPackage(getClass());
comboJDBCDriver.setSelectedItem(prefer.get(JDBCDRIVER,comboJDBCDriver.getSelectedItem().toString()));
txtDBURL.setText(prefer.get(DBURL,""));
txtUser.setText(prefer.get(USER,""));
txtLogTable.setText(prefer.get(LOG_TABLE,DataBaseDBListener.DEFAULTSQLLOGTABLE));
}
protected void saveConfig()
{
super.saveConfig();
Preferences prefer = Preferences.userNodeForPackage(getClass());
prefer.put(JDBCDRIVER,comboJDBCDriver.getSelectedItem().toString());
prefer.put(DBURL,txtDBURL.getText());
prefer.put(USER,txtUser.getText());
prefer.put(LOG_TABLE,txtLogTable.getText());
}
public String getJDBCDriver()
{
return ((String) comboJDBCDriver.getSelectedItem()).trim();
}
public String getDBURL()
{
return txtDBURL.getText().trim();
}
public String getUser()
{
if(CommonUtils.isEmptyString(txtUser.getText()))
{
return null;
}
return txtUser.getText().trim();
}
public String getPassword()
{
if(CommonUtils.isEmptyString(txtPassword.getText()))
{
return null;
}
return txtPassword.getText().trim();
}
public String getLogTable()
{
return txtLogTable.getText().trim();
}
protected boolean verifyData()
{
if(CommonUtils.isEmptyString((String) comboJDBCDriver.getSelectedItem()))
{
JOptionPane.showMessageDialog(this,"JDBCDriver cannot be null");
return false;
}
if(CommonUtils.isEmptyString(txtDBURL.getText()))
{
JOptionPane.showMessageDialog(this,"Database URL cannot be null");
return false;
}
if(CommonUtils.isEmptyString(txtLogTable.getText()))
{
JOptionPane.showMessageDialog(this,"Log Table Name cannot be null");
return false;
}
return super.verifyData();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -