|
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-2003 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.jellytools.modules.db; import org.netbeans.jemmy.JemmyException; import org.netbeans.jemmy.Waitable; import org.netbeans.jemmy.Waiter; import org.netbeans.jemmy.operators.*; import org.netbeans.jemmy.util.NameComponentChooser; /** Class implementing all necessary methods for handling "New Database Connection" NbDialog. * * @author ms113234 * @version 1.0 */ public class NewDatabaseConnection extends JDialogOperator { /** Creates new NewDatabaseConnection that can handle it. */ public NewDatabaseConnection() { super("New Database Connection"); } private JTabbedPaneOperator _tbpDatabaseConnect; private String _selectPageBasicSetting = "Basic setting"; private JLabelOperator _lblName; private JLabelOperator _lblDriver; private JLabelOperator _lblDatabaseURL; private JLabelOperator _lblUserName; private JLabelOperator _lblPassword; private JComboBoxOperator _cboName; public static final String ITEM_ORACLETHIN = "Oracle thin"; private JTextFieldOperator _txtDriver; private JTextFieldOperator _txtDatabaseURL; private JTextFieldOperator _txtUserName; private JPasswordFieldOperator _txtPassword; private JCheckBoxOperator _cbRememberPasswordDuringThisSession; private JProgressBarOperator _prbConnectionProgressBar; private String _selectPageAdvanced = "Advanced"; private JTextAreaOperator _txtSchemaPanelDescription; private JLabelOperator _lblSelectSchema; private JComboBoxOperator _cboSelectSchema; private JButtonOperator _btGetSchemas; private JProgressBarOperator _prbConnectionProgressBar2; private JButtonOperator _btOK; private JButtonOperator _btCancel; //****************************** // Subcomponents definition part //****************************** /** Tries to find null JTabbedPane in this dialog. * @return JTabbedPaneOperator */ public JTabbedPaneOperator tbpDatabaseConnect() { if (_tbpDatabaseConnect==null) { _tbpDatabaseConnect = new JTabbedPaneOperator(this); } return _tbpDatabaseConnect; } /** Tries to find "Name:" JLabel in this dialog. * @return JLabelOperator */ public JLabelOperator lblName() { if (_lblName==null) { _lblName = new JLabelOperator(selectPageBasicSetting(), "Name:"); } selectPageBasicSetting(); return _lblName; } /** Tries to find "Driver:" JLabel in this dialog. * @return JLabelOperator */ public JLabelOperator lblDriver() { if (_lblDriver==null) { _lblDriver = new JLabelOperator(selectPageBasicSetting(), "Driver:"); } selectPageBasicSetting(); return _lblDriver; } /** Tries to find "Database URL:" JLabel in this dialog. * @return JLabelOperator */ public JLabelOperator lblDatabaseURL() { if (_lblDatabaseURL==null) { _lblDatabaseURL = new JLabelOperator(selectPageBasicSetting(), "Database URL:"); } selectPageBasicSetting(); return _lblDatabaseURL; } /** Tries to find "User Name:" JLabel in this dialog. * @return JLabelOperator */ public JLabelOperator lblUserName() { if (_lblUserName==null) { _lblUserName = new JLabelOperator(selectPageBasicSetting(), "User Name:"); } selectPageBasicSetting(); return _lblUserName; } /** Tries to find "Password:" JLabel in this dialog. * @return JLabelOperator */ public JLabelOperator lblPassword() { if (_lblPassword==null) { _lblPassword = new JLabelOperator(selectPageBasicSetting(), "Password:"); } selectPageBasicSetting(); return _lblPassword; } /** 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 txtDriver() { if (_txtDriver==null) { _txtDriver = new JTextFieldOperator(selectPageBasicSetting()); } selectPageBasicSetting(); return _txtDriver; } /** 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"); } selectPageBasicSetting(); return _cbRememberPasswordDuringThisSession; } /** Tries to find null JProgressBar in this dialog. * @return JProgressBarOperator */ public JProgressBarOperator prbConnectionProgressBar() { if (_prbConnectionProgressBar==null) { _prbConnectionProgressBar = new JProgressBarOperator(selectPageBasicSetting()); } selectPageBasicSetting(); return _prbConnectionProgressBar; } /** Tries to find null JTextArea in this dialog. * @return JTextAreaOperator */ public JTextAreaOperator txtSchemaPanelDescription() { if (_txtSchemaPanelDescription==null) { _txtSchemaPanelDescription = new JTextAreaOperator(selectPageAdvanced()); } selectPageAdvanced(); return _txtSchemaPanelDescription; } /** Tries to find "Select schema:" JLabel in this dialog. * @return JLabelOperator */ public JLabelOperator lblSelectSchema() { if (_lblSelectSchema==null) { _lblSelectSchema = new JLabelOperator(selectPageAdvanced(), "Select schema:"); } selectPageAdvanced(); return _lblSelectSchema; } /** 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 "Get Schemas" JButton in this dialog. * @return JButtonOperator */ public JButtonOperator btGetSchemas() { if (_btGetSchemas==null) { _btGetSchemas = new JButtonOperator(selectPageAdvanced(), "Get Schemas"); } selectPageAdvanced(); return _btGetSchemas; } /** Tries to find null JProgressBar in this dialog. * @return JProgressBarOperator */ public JProgressBarOperator prbConnectionProgressBar2() { if (_prbConnectionProgressBar2==null) { _prbConnectionProgressBar2 = new JProgressBarOperator(selectPageAdvanced()); } selectPageAdvanced(); return _prbConnectionProgressBar2; } /** Tries to find "OK" JButton in this dialog. * @return JButtonOperator */ public JButtonOperator btOK() { if (_btOK==null) { _btOK = new JButtonOperator(this, "OK"); } return _btOK; } /** Tries to find "Cancel" JButton in this dialog. * @return JButtonOperator */ public JButtonOperator btCancel() { if (_btCancel==null) { _btCancel = new JButtonOperator(this, "Cancel"); } return _btCancel; } //**************************************** // Low-level functionality definition part //**************************************** /** changes current selected tab * @param tabName String tab name */ public void selectDatabaseConnectPage(String tabName) { tbpDatabaseConnect().selectPage(tabName); } /** changes current selected tab to "Basic setting" * @return JTabbedPaneOperator of parent tabbed pane */ public JTabbedPaneOperator selectPageBasicSetting() { tbpDatabaseConnect().selectPage(_selectPageBasicSetting); return tbpDatabaseConnect(); } /** 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); } /** gets text for txtDriver * @return String text */ public String getDriver() { return txtDriver().getText(); } /** sets text for txtDriver * @param text String text */ public void setDriver(String text) { txtDriver().setText(text); } /** types text for txtDriver * @param text String text */ public void typeDriver(String text) { txtDriver().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() { tbpDatabaseConnect().selectPage(_selectPageAdvanced); return tbpDatabaseConnect(); } /** gets text for txtSchemaPanelDescription * @return String text */ public String getSchemaPanelDescription() { return txtSchemaPanelDescription().getText(); } /** sets text for txtSchemaPanelDescription * @param text String text */ public void setSchemaPanelDescription(String text) { txtSchemaPanelDescription().setText(text); } /** types text for txtSchemaPanelDescription * @param text String text */ public void typeSchemaPanelDescription(String text) { txtSchemaPanelDescription().typeText(text); } /** 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(final String item) { JComboBoxOperator cbo = cboSelectSchema(); // wait while Schema cbo is field try { new Waiter(new Waitable() { public Object actionProduced(Object cbo) { try { ((JComboBoxOperator) cbo).selectItem(item); return Boolean.TRUE; } catch (Exception ex) { return null; } } public String getDescription() { return("Select Schema item '" + item + "' is successful" ); } }).waitAction(cbo); } catch (InterruptedException e) { throw new JemmyException("Interrupted.", e); // NOI18N } } /** clicks on "Get Schemas" JButton and waits to action finish */ public void getSchemas() { btGetSchemas().push(); prbConnectionProgressBar2().waitValue("Connection established"); } /** clicks on "OK" JButton */ public void ok() { btOK().push(); } /** clicks on "Cancel" JButton */ public void cancel() { btCancel().push(); } //***************************************** // High-level functionality definition part //***************************************** /** Performs verification of NewDatabaseConnection by accessing all its components. */ public void verify() { tbpDatabaseConnect(); lblName(); lblDriver(); lblDatabaseURL(); lblUserName(); lblPassword(); cboName(); txtDriver(); txtDatabaseURL(); txtUserName(); txtPassword(); cbRememberPasswordDuringThisSession(); prbConnectionProgressBar(); txtSchemaPanelDescription(); lblSelectSchema(); cboSelectSchema(); btGetSchemas(); prbConnectionProgressBar2(); btOK(); btCancel(); } /** Performs simple test of NewDatabaseConnection * @param args the command line arguments */ public static void main(String args[]) { new NewDatabaseConnection().verify(); System.out.println("NewDatabaseConnection verification finished."); } } |
... 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.