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

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

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

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

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

    private JLabelOperator _lblName;
    private JTextFieldOperator _txtName;
    private JLabelOperator _lblSuperClass;
    private JComboBoxOperator _cboSuperClass;
    private JRadioButtonOperator _rbClass;
    private JRadioButtonOperator _rbInterface;
    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 JListOperator _lstJList;
    private JButtonOperator _btUp;
    private JButtonOperator _btDown;
    private JButtonOperator _btAdd;
    private JButtonOperator _btRemove;
    private JButtonOperator _btEdit;
    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, org.netbeans.jellytools.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 "Super Class:" JLabel in this dialog.
     * @return JLabelOperator
     */
    public JLabelOperator lblSuperClass() {
        if (_lblSuperClass==null) {
            _lblSuperClass = new JLabelOperator(this, org.netbeans.jellytools.Bundle.getString("org.openide.src.nodes.Bundle", "CTL_Superclass"));
        }
        return _lblSuperClass;
    }

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

    /** Tries to find "Class" JRadioButton in this dialog.
     * @return JRadioButtonOperator
     */
    public JRadioButtonOperator rbClass() {
        if (_rbClass==null) {
            _rbClass = new JRadioButtonOperator(this, org.netbeans.jellytools.Bundle.getString("org.openide.src.nodes.Bundle", "CTL_Class"));
        }
        return _rbClass;
    }

    /** Tries to find "Interface" JRadioButton in this dialog.
     * @return JRadioButtonOperator
     */
    public JRadioButtonOperator rbInterface() {
        if (_rbInterface==null) {
            _rbInterface = new JRadioButtonOperator(this, org.netbeans.jellytools.Bundle.getString("org.openide.src.nodes.Bundle", "CTL_Interface"));
        }
        return _rbInterface;
    }

    /** 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, org.netbeans.jellytools.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 JList in this dialog.
     * @return JListOperator
     */
    public JListOperator lstJList() {
        if (_lstJList==null) {
            _lstJList = new JListOperator(this);
        }
        return _lstJList;
    }

    /** Tries to find "Up" JButton in this dialog.
     * @return JButtonOperator
     */
    public JButtonOperator btUp() {
        if (_btUp==null) {
            _btUp = new JButtonOperator(this, org.netbeans.jellytools.Bundle.getString("org.openide.explorer.propertysheet.editors.Bundle2", "CTL_MoveUp"));
        }
        return _btUp;
    }

    /** Tries to find "Down" JButton in this dialog.
     * @return JButtonOperator
     */
    public JButtonOperator btDown() {
        if (_btDown==null) {
            _btDown = new JButtonOperator(this, org.netbeans.jellytools.Bundle.getString("org.openide.explorer.propertysheet.editors.Bundle2", "CTL_MoveDown"));
        }
        return _btDown;
    }

    /** Tries to find "Add..." JButton in this dialog.
     * @return JButtonOperator
     */
    public JButtonOperator btAdd() {
        if (_btAdd==null) {
            _btAdd = new JButtonOperator(this, org.netbeans.jellytools.Bundle.getString("org.openide.explorer.propertysheet.editors.Bundle2", "CTL_Add"));
        }
        return _btAdd;
    }

    /** Tries to find "Remove" JButton in this dialog.
     * @return JButtonOperator
     */
    public JButtonOperator btRemove() {
        if (_btRemove==null) {
            _btRemove = new JButtonOperator(this, org.netbeans.jellytools.Bundle.getString("org.openide.explorer.propertysheet.editors.Bundle2", "CTL_Remove"));
        }
        return _btRemove;
    }

    /** Tries to find "Edit..." JButton in this dialog.
     * @return JButtonOperator
     */
    public JButtonOperator btEdit() {
        if (_btEdit==null) {
            _btEdit = new JButtonOperator(this, org.netbeans.jellytools.Bundle.getString("org.openide.explorer.propertysheet.editors.Bundle2", "CTL_Change"));
        }
        return _btEdit;
    }

    /** Tries to find "OK" JButton in this dialog.
     * @return JButtonOperator
     */
    public JButtonOperator btOK() {
        if (_btOK==null) {
            _btOK = new JButtonOperator(this, org.netbeans.jellytools.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, org.netbeans.jellytools.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 cboSuperClass
     * @return String item
     */
    public String getSelectedSuperClass() {
        return cboSuperClass().getSelectedItem().toString();
    }

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

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

    /** clicks on "Class" JRadioButton
     */
    public void _class() {
        rbClass().push();
    }

    /** clicks on "Interface" JRadioButton
     */
    public void _interface() {
        rbInterface().push();
    }

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

    /** clicks on "Up" JButton
     */
    public void up() {
        btUp().push();
    }

    /** clicks on "Down" JButton
     */
    public void down() {
        btDown().push();
    }

    /** clicks on "Add..." JButton
     */
    public void add() {
        btAdd().push();
    }

    /** clicks on "Remove" JButton
     */
    public void remove() {
        btRemove().push();
    }

    /** clicks on "Edit..." JButton
     */
    public void edit() {
        btEdit().push();
    }

    /** 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 ClassCustomizerOperator by accessing all its components.
     */
    public void verify() {
        lblName();
        txtName();
        lblSuperClass();
        cboSuperClass();
        rbClass();
        rbInterface();
        cbAbstract();
        cbFinal();
        cbStatic();
        cbSynchronized();
        cbTransient();
        cbVolatile();
        cbNative();
        lblAccess();
        cboAccess();
        lstJList();
        btUp();
        btDown();
        btAdd();
        btRemove();
        btEdit();
        btOK();
        btCancel();
    }

    /** Performs simple test of ClassCustomizerOperator
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        new ClassCustomizerOperator("Edit New Class").verify();
        System.out.println("ClassCustomizerOperator 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.