001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.jellytools.properties.editors;
043:
044: import javax.swing.JDialog;
045: import org.netbeans.jellytools.Bundle;
046: import org.netbeans.jellytools.NbDialogOperator;
047: import org.netbeans.jemmy.operators.*;
048:
049: /** Class implementing all necessary methods for handling Icon Custom Editor.
050: * @author <a href="mailto:Marian.Mirilovic@sun.com">Marian Mirilovic</a>
051: * @version 1.0 */
052: public class IconCustomEditorOperator extends NbDialogOperator {
053:
054: /** Creates new IconCustomEditorOperator that can handle it.
055: * Throws TimeoutExpiredException when NbDialog not found.
056: * @param title title of custom editor
057: */
058: public IconCustomEditorOperator(String title) {
059: super (title);
060: }
061:
062: /** Creates new IconCustomEditorOperator.
063: * @param wrapper JDialogOperator wrapper for custom editor
064: */
065: public IconCustomEditorOperator(JDialogOperator wrapper) {
066: super ((JDialog) wrapper.getSource());
067: }
068:
069: private JRadioButtonOperator _rbURL;
070: private JRadioButtonOperator _rbFile;
071: private JRadioButtonOperator _rbClasspath;
072: private JRadioButtonOperator _rbNoPicture;
073: private JTextFieldOperator _txtName;
074: private JButtonOperator _btSelectFile;
075:
076: //******************************
077: // Subcomponents definition part
078: //******************************
079:
080: /** Tries to find "URL" JRadioButton in this dialog.
081: * @return JRadioButtonOperator instance
082: */
083: public JRadioButtonOperator rbURL() {
084: if (_rbURL == null) {
085: _rbURL = new JRadioButtonOperator(
086: this ,
087: Bundle
088: .getString(
089: "org.openide.explorer.propertysheet.editors.Bundle",
090: "CTL_URL"));
091: }
092: return _rbURL;
093: }
094:
095: /** Tries to find "File" JRadioButton in this dialog.
096: * @return JRadioButtonOperator instance
097: */
098: public JRadioButtonOperator rbFile() {
099: if (_rbFile == null) {
100: _rbFile = new JRadioButtonOperator(
101: this ,
102: Bundle
103: .getString(
104: "org.openide.explorer.propertysheet.editors.Bundle",
105: "CTL_File"));
106: }
107: return _rbFile;
108: }
109:
110: /** Tries to find "Classpath" JRadioButton in this dialog.
111: * @return JRadioButtonOperator instance
112: */
113: public JRadioButtonOperator rbClasspath() {
114: if (_rbClasspath == null) {
115: _rbClasspath = new JRadioButtonOperator(
116: this ,
117: Bundle
118: .getString(
119: "org.openide.explorer.propertysheet.editors.Bundle",
120: "CTL_Classpath"));
121: }
122: return _rbClasspath;
123: }
124:
125: /** Tries to find "No picture" JRadioButton in this dialog.
126: * @return JRadioButtonOperator instance
127: */
128: public JRadioButtonOperator rbNoPicture() {
129: if (_rbNoPicture == null) {
130: _rbNoPicture = new JRadioButtonOperator(
131: this ,
132: Bundle
133: .getString(
134: "org.openide.explorer.propertysheet.editors.Bundle",
135: "CTL_NoPicture"));
136: }
137: return _rbNoPicture;
138: }
139:
140: /** Tries to find Name JTextField in this dialog.
141: * @return JTextFieldOperator instance
142: */
143: public JTextFieldOperator txtName() {
144: if (_txtName == null) {
145: _txtName = new JTextFieldOperator(this );
146: }
147: return _txtName;
148: }
149:
150: /** Tries to find "Select File" JButton in this dialog.
151: * @return JButtonOperator instance
152: */
153: public JButtonOperator btSelectFile() {
154: if (_btSelectFile == null) {
155: _btSelectFile = new JButtonOperator(
156: this ,
157: Bundle
158: .getString(
159: "org.openide.explorer.propertysheet.editors.Bundle",
160: "CTL_ButtonSelect"));
161: }
162: return _btSelectFile;
163: }
164:
165: //****************************************
166: // Low-level functionality definition part
167: //****************************************
168:
169: /** Clicks on "URL" JRadioButton. */
170: public void uRL() {
171: rbURL().push();
172: }
173:
174: /** Clicks on "File" JRadioButton. */
175: public void file() {
176: rbFile().push();
177: }
178:
179: /** Clicks on "Classpath" JRadioButton. */
180: public void classpath() {
181: rbClasspath().push();
182: }
183:
184: /** Clicks on "No picture" JRadioButton. */
185: public void noPicture() {
186: rbNoPicture().push();
187: }
188:
189: /** Gets text from Name text field.
190: * @return text from Name text field.
191: */
192: public String getName() {
193: return txtName().getText();
194: }
195:
196: /** Sets text in Name text field.
197: * @param text text to be written to Name text field
198: */
199: public void setName(String text) {
200: txtName().setText(text);
201: }
202:
203: /** Types text in Name text field.
204: * @param text text to be written to Name text field
205: */
206: public void typeName(String text) {
207: txtName().typeText(text);
208: }
209:
210: /** Clicks on "Select File" JButton. */
211: public void selectFile() {
212: btSelectFile().pushNoBlock();
213: }
214:
215: //*****************************************
216: // High-level functionality definition part
217: //*****************************************
218:
219: /** Performs verification of this operator by accessing all its components.
220: */
221: public void verify() {
222: rbURL();
223: rbFile();
224: rbClasspath();
225: rbNoPicture();
226: txtName();
227: btSelectFile();
228: btOK();
229: btCancel();
230: }
231: }
|