📄 connectiondialog.java
字号:
url += databaseName;
else
url += "MYDATABASE";
jTextFieldJDBCUrl.setText(url);
}
else if (driver.equalsIgnoreCase("com.inet.tds.TdsDriver")) {
String url = "jdbc:inetdae7:"+server+":1433/";
if (databaseName.length()>0)
url += jTextFieldDBName.getText();
else
url += "MYDATABASE";
jTextFieldJDBCUrl.setText(url);
}
else if (driver.equalsIgnoreCase("org.postgresql.Driver")) {
String url = "jdbc:postgresql://" + server + ":5432/";
if (databaseName.length()>0)
url += databaseName;
else
url += "MYDATABASE";
jTextFieldJDBCUrl.setText(url);
}
else if (driver.equalsIgnoreCase("org.hsqldb.jdbcDriver")) {
String url = "jdbc:hsqldb:[PATH_TO_DB_FILES]/";
if (databaseName.length()>0)
url += databaseName;
else
url += "MYDATABASE";
jTextFieldJDBCUrl.setText(url);
}
else if (driver.equalsIgnoreCase("COM.cloudscape.JDBCDriver ")) {
String url = "jdbc:cloudscape:/cloudscape/";
if (databaseName.length()>0)
url += databaseName;
else
url += "MYDATABASE";
jTextFieldJDBCUrl.setText(url);
}
}//GEN-LAST:event_jButtonWizardActionPerformed
private void jComboBoxConnectionTypeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBoxConnectionTypeActionPerformed
if (init) return;
jPanelConnectionRoot.removeAll();
if (jComboBoxConnectionType.getSelectedIndex() == 0)
{
jPanelConnectionRoot.add("Center", jPanelJDBC);
}
else if (jComboBoxConnectionType.getSelectedIndex() == 1)
{
jPanelConnectionRoot.add("Center", jPanelXML);
}
else if (jComboBoxConnectionType.getSelectedIndex() == 2)
{
jPanelConnectionRoot.add("Center", jPanelBeansSet);
}
else if (jComboBoxConnectionType.getSelectedIndex() == 3)
{
jPanelConnectionRoot.add("Center", jPanelCustomDataSourceFactory);
}
else if (jComboBoxConnectionType.getSelectedIndex() == 4)
{
jPanelConnectionRoot.add("Center", jPanelCSV);
}
jPanelConnectionRoot.updateUI();
}//GEN-LAST:event_jComboBoxConnectionTypeActionPerformed
private void jButtonCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonCancelActionPerformed
setVisible(false);
this.setDialogResult( javax.swing.JOptionPane.CANCEL_OPTION);
dispose();
}//GEN-LAST:event_jButtonCancelActionPerformed
private void jButtonOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonOKActionPerformed
if (this.jTextFieldName.getText().trim().length() <= 0) {
javax.swing.JOptionPane.showMessageDialog(this,"Please insert a valid connection name!","Invalid parameter!",javax.swing.JOptionPane.WARNING_MESSAGE );
return;
}
if (jComboBoxConnectionType.getSelectedIndex() == 0) {
iReportConnection = new JDBCConnection();
iReportConnection.setName( this.jTextFieldName.getText().trim() );
((JDBCConnection)iReportConnection).setServerAddress( this.jTextFieldServerAddress.getText().trim() );
((JDBCConnection)iReportConnection).setDatabase( this.jTextFieldDBName.getText().trim() );
((JDBCConnection)iReportConnection).setUsername( this.jTextFieldUsername.getText().trim() );
if (jCheckBoxSavePassword.isSelected())
((JDBCConnection)iReportConnection).setPassword( this.jTextFieldPassword.getText());
else
((JDBCConnection)iReportConnection).setPassword("");
((JDBCConnection)iReportConnection).setSavePassword( jCheckBoxSavePassword.isSelected() );
((JDBCConnection)iReportConnection).setJDBCDriver( (this.jComboBoxJDBCDriver.getSelectedItem()+"").trim() );
if ((this.jComboBoxJDBCDriver.getSelectedItem()+"").trim().length() == 0) {
javax.swing.JOptionPane.showMessageDialog(this,"Please insert a valid JDBC driver!","Invalid driver!",javax.swing.JOptionPane.WARNING_MESSAGE );
return;
}
if (this.jTextFieldJDBCUrl.getText().trim().length() == 0) {
javax.swing.JOptionPane.showMessageDialog(this,"Please insert a valid JDBC URL!","Invalid url!",javax.swing.JOptionPane.WARNING_MESSAGE );
return;
}
((JDBCConnection)iReportConnection).setUrl(this.jTextFieldJDBCUrl.getText().trim());
}
else if (jComboBoxConnectionType.getSelectedIndex() == 2) {
iReportConnection = new JavaBeanDataSourceConnection();
iReportConnection.setName( this.jTextFieldName.getText().trim() );
((JavaBeanDataSourceConnection)iReportConnection).setFactoryClass( this.jTextFieldJBSetFactoryClass.getText().trim() );
((JavaBeanDataSourceConnection)iReportConnection).setMethodToCall( this.jTextFieldJBSetMethodToCall.getText().trim() );
if (jRadioButtonJBSetArray.isSelected())
{
((JavaBeanDataSourceConnection)iReportConnection).setType( JavaBeanDataSourceConnection.BEAN_ARRAY );
}
else
{
((JavaBeanDataSourceConnection)iReportConnection).setType( JavaBeanDataSourceConnection.BEAN_COLLECTION );
}
}
else if (jComboBoxConnectionType.getSelectedIndex() == 3) {
iReportConnection = new JRCustomDataSourceConnection();
iReportConnection.setName( this.jTextFieldName.getText().trim() );
((JRCustomDataSourceConnection)iReportConnection).setFactoryClass( this.jTextFieldJRCustomDataSourceFactoryClass.getText().trim() );
((JRCustomDataSourceConnection)iReportConnection).setMethodToCall( this.jTextFieldJRCustomDataSourceMethod.getText().trim() );
}
else if (jComboBoxConnectionType.getSelectedIndex() == 4) {
iReportConnection = new JRCSVDataSourceConnection();
iReportConnection.setName( this.jTextFieldName.getText().trim() );
((JRCSVDataSourceConnection)iReportConnection).setFilename( this.jTextFieldCSVFilename.getText().trim() );
}
else if (jComboBoxConnectionType.getSelectedIndex() == 1) {
iReportConnection = new JRXMLDataSourceConnection();
iReportConnection.setName( this.jTextFieldName.getText().trim() );
((JRXMLDataSourceConnection)iReportConnection).setFilename( this.jTextFieldXMLFile.getText().trim() );
((JRXMLDataSourceConnection)iReportConnection).setSelectExpression( this.jTextFieldRecordPath.getText().trim() );
}
setVisible(false);
this.setDialogResult( javax.swing.JOptionPane.OK_OPTION);
dispose();
}//GEN-LAST:event_jButtonOKActionPerformed
/** Closes the dialog */
private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
setVisible(false);
this.setDialogResult( javax.swing.JOptionPane.CLOSED_OPTION);
dispose();
}//GEN-LAST:event_closeDialog
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
new JRParameterDialog(new javax.swing.JFrame(), true).show();
}
/** Getter for property tmpParameter.
* @return Value of property tmpParameter.
*
*/
public it.businesslogic.ireport.JRParameter getParameter() {
return tmpParameter;
}
/** Setter for property tmpParameter.
* @param tmpParameter New value of property tmpParameter.
*
*/
public void setParameter(it.businesslogic.ireport.JRParameter tmpParameter) {
}
/** Getter for property dialogResult.
* @return Value of property dialogResult.
*
*/
public int getDialogResult() {
return dialogResult;
}
/** Setter for property dialogResult.
* @param dialogResult New value of property dialogResult.
*
*/
public void setDialogResult(int dialogResult) {
this.dialogResult = dialogResult;
}
/** Getter for property iReportConnection.
* @return Value of property iReportConnection.
*
*/
public it.businesslogic.ireport.IReportConnection getIReportConnection() {
return iReportConnection;
}
/** Setter for property iReportConnection.
* @param iReportConnection New value of property iReportConnection.
*
*/
public void setIReportConnection(it.businesslogic.ireport.IReportConnection iReportConnection) {
this.iReportConnection = iReportConnection;
this.jTextFieldName.setText( iReportConnection.getName());
if (iReportConnection instanceof JDBCConnection)
{
JDBCConnection con = (JDBCConnection)iReportConnection;
this.jComboBoxConnectionType.setSelectedIndex(0);
this.jComboBoxJDBCDriver.setSelectedItem(con.getJDBCDriver());
this.jTextFieldJDBCUrl.setText( con.getUrl());
this.jTextFieldServerAddress.setText( con.getServerAddress() );
this.jTextFieldDBName.setText( con.getDatabase() );
this.jTextFieldUsername.setText( con.getUsername());
if (con.isSavePassword())
this.jTextFieldPassword.setText( con.getPassword());
else
this.jTextFieldPassword.setText( "");
this.jCheckBoxSavePassword.setSelected( con.isSavePassword());
}
else if (iReportConnection instanceof JRCustomDataSourceConnection)
{
JRCustomDataSourceConnection con = (JRCustomDataSourceConnection)iReportConnection;
this.jComboBoxConnectionType.setSelectedIndex(3);
this.jTextFieldJRCustomDataSourceFactoryClass.setText( con.getFactoryClass());
this.jTextFieldJRCustomDataSourceMethod.setText(con.getMethodToCall());
}
else if (iReportConnection instanceof JavaBeanDataSourceConnection)
{
JavaBeanDataSourceConnection con = (JavaBeanDataSourceConnection)iReportConnection;
this.jComboBoxConnectionType.setSelectedIndex(2);
this.jTextFieldJBSetFactoryClass.setText( con.getFactoryClass());
this.jTextFieldJBSetMethodToCall.setText(con.getMethodToCall());
if (con.getType().equals(con.BEAN_ARRAY) )
{
jRadioButtonJBSetArray.setSelected(true);
jRadioButtonJBSetCollection.setSelected(false);
}
else
{
jRadioButtonJBSetArray.setSelected(false);
jRadioButtonJBSetCollection.setSelected(true);
}
}
else if (iReportConnection instanceof JRCSVDataSourceConnection)
{
JRCSVDataSourceConnection con = (JRCSVDataSourceConnection)iReportConnection;
this.jComboBoxConnectionType.setSelectedIndex(4);
this.jTextFieldCSVFilename.setText( con.getFilename() );
}
else if (iReportConnection instanceof JRXMLDataSourceConnection)
{
JRXMLDataSourceConnection con = (JRXMLDataSourceConnection)iReportConnection;
this.jComboBoxConnectionType.setSelectedIndex(1);
this.jTextFieldXMLFile.setText( con.getFilename() );
this.jTextFieldRecordPath.setText( con.getSelectExpression() );
}
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.ButtonGroup buttonGroupBeansSetType;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButtonCSVFilename;
private javax.swing.JButton jButtonCancel;
private javax.swing.JButton jButtonOK;
private javax.swing.JButton jButtonOK1;
private javax.swing.JButton jButtonWizard;
private javax.swing.JCheckBox jCheckBoxSavePassword;
private javax.swing.JComboBox jComboBoxConnectionType;
private javax.swing.JComboBox jComboBoxJDBCDriver;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel14;
private javax.swing.JLabel jLabel15;
private javax.swing.JLabel jLabel16;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JPanel jPanelBeansSet;
private javax.swing.JPanel jPanelButtons;
private javax.swing.JPanel jPanelCSV;
private javax.swing.JPanel jPanelConnectionRoot;
private javax.swing.JPanel jPanelConnectionType;
private javax.swing.JPanel jPanelCustomDataSourceFactory;
private javax.swing.JPanel jPanelJDBC;
private javax.swing.JPanel jPanelXML;
private javax.swing.JRadioButton jRadioButtonJBSetArray;
private javax.swing.JRadioButton jRadioButtonJBSetCollection;
private javax.swing.JSeparator jSeparator1;
private javax.swing.JSeparator jSeparator2;
private javax.swing.JTextArea jTextArea1;
private javax.swing.JTextField jTextFieldCSVFilename;
private javax.swing.JTextField jTextFieldDBName;
private javax.swing.JTextField jTextFieldJBSetFactoryClass;
private javax.swing.JTextField jTextFieldJBSetMethodToCall;
private javax.swing.JTextField jTextFieldJDBCUrl;
private javax.swing.JTextField jTextFieldJRCustomDataSourceFactoryClass;
private javax.swing.JTextField jTextFieldJRCustomDataSourceMethod;
private javax.swing.JTextField jTextFieldName;
private javax.swing.JPasswordField jTextFieldPassword;
private javax.swing.JTextField jTextFieldRecordPath;
private javax.swing.JTextField jTextFieldServerAddress;
private javax.swing.JTextField jTextFieldUsername;
private javax.swing.JTextField jTextFieldXMLFile;
// End of variables declaration//GEN-END:variables
private int dialogResult;
private IReportConnection iReportConnection;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -