alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

What this is

This file is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

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.
 */

/*
 * FieldCustomizerOperator.java
 *
 * Created on 9/30/02 3:55 PM
 */
package org.netbeans.jellytools.modules.java;

import org.netbeans.jellytools.Bundle;
import org.netbeans.jellytools.NbDialogOperator;
import org.netbeans.jemmy.operators.*;

/** Class implementing all necessary methods for handling "Add New Field" NbPresenter.
 *
 * @author jb105785
 * @version 1.0
 */
public class FieldCustomizerOperator extends NbDialogOperator {

    /** Creates new FieldCustomizerOperator that can handle it.
     */
    public FieldCustomizerOperator(String title) {
        super(title);
    }

    private JLabelOperator _lblName;
    private JTextFieldOperator _txtName;
    private JLabelOperator _lblType;
    private JComboBoxOperator _cboType;
    private JCheckBoxOperator _cbAbstract;
    private JCheckBoxOperator _cbFinal;
    private JCheckBoxOperator _cbStatic;
    private JCheckBoxOperator _cbSynchronized;
    private JCheckBoxOperator _cbTransient;
    private JCheckBoxOperator _cbVolatile;
    private JCheckBoxOperator _cbNative;
    private JLabelOperator _lblAccess;
    private JComboBoxOperator _cboAccess;
    private JEditorPaneOperator _txtInitialValue;
    private JButtonOperator _btOK;
    private JButtonOperator _btCancel;


    //******************************
    // Subcomponents definition part
    //******************************

    /** Tries to find "Name:" JLabel in this dialog.
     * @return JLabelOperator
     */
    public JLabelOperator lblName() {
        if (_lblName==null) {
            _lblName = new JLabelOperator(this, Bundle.getString("org.openide.src.nodes.Bundle", "CTL_Name"));
        }
        return _lblName;
    }

    /** Tries to find null JTextField in this dialog.
     * @return JTextFieldOperator
     */
    public JTextFieldOperator txtName() {
        if (_txtName==null) {
            _txtName = new JTextFieldOperator(this);
        }
        return _txtName;
    }

    /** Tries to find "Type:" JLabel in this dialog.
     * @return JLabelOperator
     */
    public JLabelOperator lblType() {
        if (_lblType==null) {
            _lblType = new JLabelOperator(this, Bundle.getString("org.openide.src.nodes.Bundle", "CTL_Type"));
        }
        return _lblType;
    }

    /** Tries to find null JComboBox in this dialog.
     * @return JComboBoxOperator
     */
    public JComboBoxOperator cboType() {
        if (_cboType==null) {
            _cboType = new JComboBoxOperator(this);
        }
        return _cboType;
    }

    /** Tries to find "abstract" JCheckBox in this dialog.
     * @return JCheckBoxOperator
     */
    public JCheckBoxOperator cbAbstract() {
        if (_cbAbstract==null) {
            _cbAbstract = new JCheckBoxOperator(this, "abstract"); //NOI18N
        }
        return _cbAbstract;
    }

    /** Tries to find "final" JCheckBox in this dialog.
     * @return JCheckBoxOperator
     */
    public JCheckBoxOperator cbFinal() {
        if (_cbFinal==null) {
            _cbFinal = new JCheckBoxOperator(this, "final"); //NOI18N
        }
        return _cbFinal;
    }

    /** Tries to find "static" JCheckBox in this dialog.
     * @return JCheckBoxOperator
     */
    public JCheckBoxOperator cbStatic() {
        if (_cbStatic==null) {
            _cbStatic = new JCheckBoxOperator(this, "static"); //NOI18N
        }
        return _cbStatic;
    }

    /** Tries to find "synchronized" JCheckBox in this dialog.
     * @return JCheckBoxOperator
     */
    public JCheckBoxOperator cbSynchronized() {
        if (_cbSynchronized==null) {
            _cbSynchronized = new JCheckBoxOperator(this, "synchronized"); //NOI18N
        }
        return _cbSynchronized;
    }

    /** Tries to find "transient" JCheckBox in this dialog.
     * @return JCheckBoxOperator
     */
    public JCheckBoxOperator cbTransient() {
        if (_cbTransient==null) {
            _cbTransient = new JCheckBoxOperator(this, "transient"); //NOI18N
        }
        return _cbTransient;
    }

    /** Tries to find "volatile" JCheckBox in this dialog.
     * @return JCheckBoxOperator
     */
    public JCheckBoxOperator cbVolatile() {
        if (_cbVolatile==null) {
            _cbVolatile = new JCheckBoxOperator(this, "volatile"); //NOI18N
        }
        return _cbVolatile;
    }

    /** Tries to find "native" JCheckBox in this dialog.
     * @return JCheckBoxOperator
     */
    public JCheckBoxOperator cbNative() {
        if (_cbNative==null) {
            _cbNative = new JCheckBoxOperator(this, "native"); //NOI18N
        }
        return _cbNative;
    }

    /** Tries to find "Access:" JLabel in this dialog.
     * @return JLabelOperator
     */
    public JLabelOperator lblAccess() {
        if (_lblAccess==null) {
            _lblAccess = new JLabelOperator(this, Bundle.getString("org.openide.explorer.propertysheet.editors.Bundle2", "LAB_AccessRights"));
        }
        return _lblAccess;
    }

    /** Tries to find null JComboBox in this dialog.
     * @return JComboBoxOperator
     */
    public JComboBoxOperator cboAccess() {
        if (_cboAccess==null) {
            _cboAccess = new JComboBoxOperator(this, 1);
        }
        return _cboAccess;
    }

    /** Tries to find null JEditorPane in this dialog.
     * @return JEditorPaneOperator
     */
    public JEditorPaneOperator txtInitialValue() {
        if (_txtInitialValue==null) {
            _txtInitialValue = new JEditorPaneOperator(this);
        }
        return _txtInitialValue;
    }

    /** Tries to find "OK" JButton in this dialog.
     * @return JButtonOperator
     */
    public JButtonOperator btOK() {
        if (_btOK==null) {
            _btOK = new JButtonOperator(this, Bundle.getString("org.openide.Bundle", "CTL_OK"));
        }
        return _btOK;
    }

    /** Tries to find "Cancel" JButton in this dialog.
     * @return JButtonOperator
     */
    public JButtonOperator btCancel() {
        if (_btCancel==null) {
            _btCancel = new JButtonOperator(this, Bundle.getString("org.openide.Bundle", "CTL_CANCEL"));
        }
        return _btCancel;
    }


    //****************************************
    // Low-level functionality definition part
    //****************************************

    /** gets text for txtName
     * @return String text
     */
    public String getName() {
        return txtName().getText();
    }

    /** sets text for txtName
     * @param text String text
     */
    public void setName(String text) {
        txtName().setText(text);
    }

    /** types text for txtName
     * @param text String text
     */
    public void typeName(String text) {
        txtName().typeText(text);
    }

    /** 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);
    }

    /** checks or unchecks given JCheckBox
     * @param state boolean requested state
     */
    public void checkAbstract(boolean state) {
        if (cbAbstract().isSelected()!=state) {
            cbAbstract().push();
        }
    }

    /** checks or unchecks given JCheckBox
     * @param state boolean requested state
     */
    public void checkFinal(boolean state) {
        if (cbFinal().isSelected()!=state) {
            cbFinal().push();
        }
    }

    /** checks or unchecks given JCheckBox
     * @param state boolean requested state
     */
    public void checkStatic(boolean state) {
        if (cbStatic().isSelected()!=state) {
            cbStatic().push();
        }
    }

    /** checks or unchecks given JCheckBox
     * @param state boolean requested state
     */
    public void checkSynchronized(boolean state) {
        if (cbSynchronized().isSelected()!=state) {
            cbSynchronized().push();
        }
    }

    /** checks or unchecks given JCheckBox
     * @param state boolean requested state
     */
    public void checkTransient(boolean state) {
        if (cbTransient().isSelected()!=state) {
            cbTransient().push();
        }
    }

    /** checks or unchecks given JCheckBox
     * @param state boolean requested state
     */
    public void checkVolatile(boolean state) {
        if (cbVolatile().isSelected()!=state) {
            cbVolatile().push();
        }
    }

    /** checks or unchecks given JCheckBox
     * @param state boolean requested state
     */
    public void checkNative(boolean state) {
        if (cbNative().isSelected()!=state) {
            cbNative().push();
        }
    }

    /** returns selected item for cboAccess
     * @return String item
     */
    public String getSelectedAccess() {
        return cboAccess().getSelectedItem().toString();
    }

    /** selects item for cboAccess
     * @param item String item
     */
    public void selectAccess(String item) {
        cboAccess().selectItem(item);
    }

    /** types text for cboAccess
     * @param text String text
     */
    public void typeAccess(String text) {
        cboAccess().typeText(text);
    }

    /** gets text for txtInitialValue
     * @return String text
     */
    public String getInitialValue() {
        return txtInitialValue().getText();
    }

    /** sets text for txtInitialValue
     * @param text String text
     */
    public void setInitialValue(String text) {
        txtInitialValue().setText(text);
    }

    /** types text for txtInitialValue
     * @param text String text
     */
    public void typeInitialValue(String text) {
        txtInitialValue().typeText(text);
    }

    /** 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 FieldCustomizerOperator by accessing all its components.
     */
    public void verify() {
        lblName();
        txtName();
        lblType();
        cboType();
        cbAbstract();
        cbFinal();
        cbStatic();
        cbSynchronized();
        cbTransient();
        cbVolatile();
        cbNative();
        lblAccess();
        cboAccess();
        txtInitialValue();
        btOK();
        btCancel();
    }

    /** Performs simple test of FieldCustomizerOperator
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        new FieldCustomizerOperator("Add New Field").verify();
        System.out.println("FieldCustomizerOperator verification finished.");
    }
}

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

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.