|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.jellytools.modules.db; import org.netbeans.jemmy.operators.*; /** Class implementing all necessary methods for handling "New Database Connection" NbDialog. * * @author Patrik Knakal * @version 1.1 */ public class NewDatabaseConnectionOperator extends JDialogOperator { /** Creates new NewDatabaseConnectionOperator that can handle it. */ public NewDatabaseConnectionOperator() { super("New Database Connection"); //NOI18N } private JTabbedPaneOperator _tbpJTabbedPane; private JComboBoxOperator _cboName; private JTextFieldOperator _txtDatabaseURL; private JTextFieldOperator _txtUserName; private JPasswordFieldOperator _txtPassword; private JCheckBoxOperator _cbRememberPasswordDuringThisSession; private JComboBoxOperator _cboSelectSchema; private JButtonOperator _btOK; private JButtonOperator _btCancel; /* public static final String ITEM_IBMDB2LOCAL = "IBM DB2 (local)"; public static final String ITEM_IBMDB2NET = "IBM DB2 (net)"; public static final String ITEM_JDBCODBCBRIDGE = "JDBC-ODBC Bridge"; public static final String ITEM_MICROSOFTSQLSERVERWEBLOGICDRIVER = "Microsoft SQL Server (Weblogic driver)"; public static final String ITEM_ORACLETHIN = "Oracle thin"; public static final String ITEM_POINTBASEEMBEDDEDSERVER = "PointBase Embedded Server"; public static final String ITEM_POINTBASEMOBILEEDITION = "PointBase Mobile Edition"; public static final String ITEM_POINTBASENETWORKSERVER = "PointBase Network Server"; public static final String ITEM_CLOUDSCAPE = "Cloudscape"; public static final String ITEM_CLOUDSCAPERMI = "Cloudscape RMI"; public static final String ITEM_IDSSERVER = "IDS Server"; public static final String ITEM_INFORMIXDYNAMICSERVER = "Informix Dynamic Server"; public static final String ITEM_INSTANTDBV313ANDEARLIER = "InstantDB (v3.13 and earlier)"; public static final String ITEM_INSTANTDBV314ANDLATER = "InstantDB (v3.14 and later)"; public static final String ITEM_INTERBASEINTERCLIENTDRIVER = "Interbase (InterClient driver)"; public static final String ITEM_HYPERSONICSQLV12ANDEARLIER = "Hypersonic SQL (v1.2 and earlier)"; public static final String ITEM_HYPERSONICSQLV13ANDLATER = "Hypersonic SQL (v1.3 and later)"; public static final String ITEM_MICROSOFTSQLSERVERJTURBODRIVER = "Microsoft SQL Server (JTurbo driver)"; public static final String ITEM_MICROSOFTSQLSERVERSPRINTADRIVER = "Microsoft SQL Server (Sprinta driver)"; public static final String ITEM_MICROSOFTSQLSERVER2000MICROSOFTDRIVER = "Microsoft SQL Server 2000 (Microsoft driver)"; public static final String ITEM_MYSQLMMMYSQLDRIVER = "MySQL (MM.MySQL driver)"; public static final String ITEM_ORACLE = "Oracle"; public static final String ITEM_POSTGRESQLV65ANDEARLIER = "PostgreSQL (v6.5 and earlier)"; public static final String ITEM_POSTGRESQLV70ANDLATER = "PostgreSQL (v7.0 and later)"; public static final String ITEM_SYBASEJCONNECT42ANDEARLIER = "Sybase (jConnect 4.2 and earlier)"; public static final String ITEM_SYBASEJCONNECT52 = "Sybase (jConnect 5.2)"; public static final String ITEM_HYPERSONICSQLDATABASEV170ORLATER = "Hypersonic SQL database (v1.70 or later)"; */ //****************************** // Subcomponents definition part //****************************** /** Tries to find null JTabbedPane in this dialog. * @return JTabbedPaneOperator */ public JTabbedPaneOperator tbpJTabbedPane() { if (_tbpJTabbedPane==null) { _tbpJTabbedPane = new JTabbedPaneOperator(this); } return _tbpJTabbedPane; } /** Tries to find null JComboBox in this dialog. * @return JComboBoxOperator */ public JComboBoxOperator cboName() { if (_cboName==null) { _cboName = new JComboBoxOperator(selectPageBasicSetting()); } selectPageBasicSetting(); return _cboName; } /** Tries to find null JTextField in this dialog. * @return JTextFieldOperator */ public JTextFieldOperator txtDatabaseURL() { if (_txtDatabaseURL==null) { _txtDatabaseURL = new JTextFieldOperator(selectPageBasicSetting(), 1); } selectPageBasicSetting(); return _txtDatabaseURL; } /** Tries to find null JTextField in this dialog. * @return JTextFieldOperator */ public JTextFieldOperator txtUserName() { if (_txtUserName==null) { _txtUserName = new JTextFieldOperator(selectPageBasicSetting(), 2); } selectPageBasicSetting(); return _txtUserName; } /** Tries to find null JPasswordField in this dialog. * @return JPasswordFieldOperator */ public JPasswordFieldOperator txtPassword() { if (_txtPassword==null) { _txtPassword = new JPasswordFieldOperator(selectPageBasicSetting()); } selectPageBasicSetting(); return _txtPassword; } /** Tries to find "Remember password during this session" JCheckBox in this dialog. * @return JCheckBoxOperator */ public JCheckBoxOperator cbRememberPasswordDuringThisSession() { if (_cbRememberPasswordDuringThisSession==null) { _cbRememberPasswordDuringThisSession = new JCheckBoxOperator(selectPageBasicSetting(), "Remember password during this session"); //NOI18N } selectPageBasicSetting(); return _cbRememberPasswordDuringThisSession; } /** Tries to find null JComboBox in this dialog. * @return JComboBoxOperator */ public JComboBoxOperator cboSelectSchema() { if (_cboSelectSchema==null) { _cboSelectSchema = new JComboBoxOperator(selectPageAdvanced()); } selectPageAdvanced(); return _cboSelectSchema; } /** Tries to find "OK" JButton in this dialog. * @return JButtonOperator */ public JButtonOperator btOK() { if (_btOK==null) { _btOK = new JButtonOperator(this, "OK"); //NOI18N } return _btOK; } /** Tries to find "Cancel" JButton in this dialog. * @return JButtonOperator */ public JButtonOperator btCancel() { if (_btCancel==null) { _btCancel = new JButtonOperator(this, "Cancel"); //NOI18N } return _btCancel; } //**************************************** // Low-level functionality definition part //**************************************** /** changes current selected tab * @param tabName String tab name */ public void selectJTabbedPanePage(String tabName) { tbpJTabbedPane().selectPage(tabName); } /** * changes current selected tab ... non blocking operation (added, not generated) * @param tabName String tab name */ public void selectJTabbedPanePageNoBlock(String tabName) { final String tabNameTmp = tabName; new Thread( new Runnable() { public void run() { tbpJTabbedPane().selectPage(tabNameTmp); } }).start(); } /** * get name of the selected tab within JTabbedPane (added, not generated) * @return name of the selected tab */ public String getSelectedJTabbedPanePage() { return this.tbpJTabbedPane().getTitleAt(this.tbpJTabbedPane().getSelectedIndex() ); } /** changes current selected tab to "Basic setting" * @return JTabbedPaneOperator of parent tabbed pane */ public JTabbedPaneOperator selectPageBasicSetting() { tbpJTabbedPane().selectPage("Basic setting"); //NOI18N return tbpJTabbedPane(); } /** returns selected item for cboName * @return String item */ public String getSelectedName() { return cboName().getSelectedItem().toString(); } /** selects item for cboName * @param item String item */ public void selectName(String item) { cboName().selectItem(item); } /** types text for cboName * @param text String text */ public void typeName(String text) { cboName().typeText(text); } /** gets text for txtDatabaseURL * @return String text */ public String getDatabaseURL() { return txtDatabaseURL().getText(); } /** sets text for txtDatabaseURL * @param text String text */ public void setDatabaseURL(String text) { txtDatabaseURL().setText(text); } /** types text for txtDatabaseURL * @param text String text */ public void typeDatabaseURL(String text) { txtDatabaseURL().typeText(text); } /** gets text for txtUserName * @return String text */ public String getUserName() { return txtUserName().getText(); } /** sets text for txtUserName * @param text String text */ public void setUserName(String text) { txtUserName().setText(text); } /** types text for txtUserName * @param text String text */ public void typeUserName(String text) { txtUserName().typeText(text); } /** sets text for txtPassword * @param text String text */ public void setPassword(String text) { txtPassword().setText(text); } /** types text for txtPassword * @param text String text */ public void typePassword(String text) { txtPassword().typeText(text); } /** checks or unchecks given JCheckBox * @param state boolean requested state */ public void checkRememberPasswordDuringThisSession(boolean state) { if (cbRememberPasswordDuringThisSession().isSelected()!=state) { cbRememberPasswordDuringThisSession().push(); } } /** changes current selected tab to "Advanced" * @return JTabbedPaneOperator of parent tabbed pane */ public JTabbedPaneOperator selectPageAdvanced() { tbpJTabbedPane().selectPage("Advanced"); //NOI18N return tbpJTabbedPane(); } /** returns selected item for cboSelectSchema * @return String item */ public String getSelectedSelectSchema() { return cboSelectSchema().getSelectedItem().toString(); } /** selects item for cboSelectSchema * @param item String item */ public void selectSelectSchema(String item) { cboSelectSchema().selectItem(item); } /** types text for cboSelectSchema * @param text String text */ public void typeSelectSchema(String text) { cboSelectSchema().typeText(text); } /** clicks on "OK" JButton */ public void oK() { btOK().push(); } /** * clicks on "OK" JButton ... non blocking operation (added, not generated) */ public void oKNoBlock() { btOK().pushNoBlock(); } /** clicks on "Cancel" JButton */ public void cancel() { btCancel().push(); } //***************************************** // High-level functionality definition part //***************************************** /** Performs verification of NewDatabaseConnectionOperator by accessing all its components. */ public void verify() { tbpJTabbedPane(); cboName(); txtDatabaseURL(); txtUserName(); txtPassword(); cbRememberPasswordDuringThisSession(); cboSelectSchema(); btOK(); btCancel(); } /** Performs simple test of NewDatabaseConnectionOperator * @param args the command line arguments */ public static void main(String args[]) { new NewDatabaseConnectionOperator().verify(); System.out.println("NewDatabaseConnectionOperator verification finished."); //NOI18N } } |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.