/* * 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-2002 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.jellytools.properties.editors; import javax.swing.JDialog; import org.netbeans.jellytools.Bundle; import org.netbeans.jellytools.NbDialogOperator; import org.netbeans.jemmy.operators.*; import org.netbeans.jemmy.operators.JDialogOperator; /** Class implementing all necessary methods for handling Filesystem Custom Editor * @author Marian Mirilovic * @version 1.0 */ public class FilesystemCustomEditorOperator extends NbDialogOperator { /** Creates new Filesystem Custom Editor Operator that can handle it. * @throws TimeoutExpiredException when NbDialog not found * @param title String title of custom editor */ public FilesystemCustomEditorOperator(String title) { super(title); } /** Creates new FilesytemCustomEditorOperator * @param wrapper JDialogOperator wrapper for custom editor */ public FilesystemCustomEditorOperator(JDialogOperator wrapper) { super((JDialog)wrapper.getSource()); } private JRadioButtonOperator _rbAddLocalDirectory; private JTextFieldOperator _txtDirectory; private JButtonOperator _btBrowse; private JRadioButtonOperator _rbAddJARFile; private JTextFieldOperator _txtJARFile; private JButtonOperator _btBrowse2; private JRadioButtonOperator _rbAddOtherFileSystemType; private JComboBoxOperator _cboType; //****************************** // Subcomponents definition part //****************************** /** Tries to find "Add Local Directory" JRadioButton in this dialog. * @return JRadioButtonOperator */ public JRadioButtonOperator rbAddLocalDirectory() { if (_rbAddLocalDirectory==null) { _rbAddLocalDirectory = new JRadioButtonOperator(this, Bundle.getString("org.netbeans.beaninfo.editors.Bundle", "CTL_FileSystemPanel.dirRadioButton.text")); } return _rbAddLocalDirectory; } /** Tries to find null JTextField in this dialog. * @return JTextFieldOperator */ public JTextFieldOperator txtDirectory() { if (_txtDirectory==null) { _txtDirectory = new JTextFieldOperator(this); } return _txtDirectory; } /** Tries to find "Browse..." JButton in this dialog. * @return JButtonOperator */ public JButtonOperator btBrowse() { if (_btBrowse==null) { _btBrowse = new JButtonOperator(this, Bundle.getString("org.netbeans.beaninfo.editors.Bundle", "CTL_FileSystemPanel.browse")); } return _btBrowse; } /** Tries to find "Add JAR File" JRadioButton in this dialog. * @return JRadioButtonOperator */ public JRadioButtonOperator rbAddJARFile() { if (_rbAddJARFile==null) { _rbAddJARFile = new JRadioButtonOperator(this, Bundle.getString("org.netbeans.beaninfo.editors.Bundle", "CTL_FileSystemPanel.jarRadioButton.text")); } return _rbAddJARFile; } /** Tries to find null JTextField in this dialog. * @return JTextFieldOperator */ public JTextFieldOperator txtJARFile() { if (_txtJARFile==null) { _txtJARFile = new JTextFieldOperator(this, 1); } return _txtJARFile; } /** Tries to find "Browse..." JButton in this dialog. * @return JButtonOperator */ public JButtonOperator btBrowse2() { if (_btBrowse2==null) { _btBrowse2 = new JButtonOperator(this, Bundle.getString("org.netbeans.beaninfo.editors.Bundle", "CTL_FileSystemPanel.browse"), 1); } return _btBrowse2; } /** Tries to find "Add (other file system type)" JRadioButton in this dialog. * @return JRadioButtonOperator */ public JRadioButtonOperator rbAddOtherFileSystemType() { if (_rbAddOtherFileSystemType==null) { _rbAddOtherFileSystemType = new JRadioButtonOperator(this, Bundle.getString("org.netbeans.beaninfo.editors.Bundle", "CTL_FileSystemPanel.otherRadioButton.text")); } return _rbAddOtherFileSystemType; } /** Tries to find null JComboBox in this dialog. * @return JComboBoxOperator */ public JComboBoxOperator cboType() { if (_cboType==null) { _cboType = new JComboBoxOperator(this); } return _cboType; } //**************************************** // Low-level functionality definition part //**************************************** /** clicks on "Add Local Directory" JRadioButton */ public void addLocalDirectory() { rbAddLocalDirectory().push(); } /** gets text for txtDirectory * @return String text */ public String getDirectory() { return txtDirectory().getText(); } /** sets text for txtDirectory * @param text String text */ public void setDirectory(String text) { txtDirectory().setText(text); } /** types text for txtDirectory * @param text String text */ public void typeDirectory(String text) { txtDirectory().typeText(text); } /** clicks on "Browse..." JButton */ public void browse() { btBrowse().push(); } /** clicks on "Add JAR File" JRadioButton */ public void addJARFile() { rbAddJARFile().push(); } /** gets text for txtJARFile * @return String text */ public String getJARFile() { return txtJARFile().getText(); } /** sets text for txtJARFile * @param text String text */ public void setJARFile(String text) { txtJARFile().setText(text); } /** types text for txtJARFile * @param text String text */ public void typeJARFile(String text) { txtJARFile().typeText(text); } /** clicks on "Browse..." JButton */ public void browse2() { btBrowse2().push(); } /** clicks on "Add (other file system type)" JRadioButton */ public void addOtherFileSystemType() { rbAddOtherFileSystemType().push(); } /** returns selected item for cboType * @return String item */ public String getSelectedType() { return cboType().getSelectedItem().toString(); } /** selects item for cboType * @param item String item */ public void selectType(String item) { cboType().selectItem(item); } /** types text for cboType * @param text String text */ public void typeType(String text) { cboType().typeText(text); } //***************************************** // High-level functionality definition part //***************************************** /** Performs verification of P_filesystem by accessing all its components. */ public void verify() { rbAddLocalDirectory(); txtDirectory(); btBrowse(); rbAddJARFile(); txtJARFile(); btBrowse2(); rbAddOtherFileSystemType(); cboType(); } /** Performs simple test of P_filesystem * @param args the command line arguments */ public static void main(String args[]) { new FilesystemCustomEditorOperator("Filesystem").verify(); System.out.println("FilesystemCustomEditorOperator verification finished."); } }