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-2007 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.modules.visualweb.gravy.properties.editors;
043:
044: import javax.swing.JDialog;
045: import org.netbeans.jellytools.Bundle;
046: import org.netbeans.modules.visualweb.gravy.NbDialogOperator;
047: import org.netbeans.jemmy.operators.*;
048:
049: /** Class implementing all necessary methods for handling Icon Custom Editor.
050: */
051: public class IconCustomEditorOperator extends NbDialogOperator {
052:
053: /** Creates new IconCustomEditorOperator that can handle it.
054: * Throws TimeoutExpiredException when NbDialog not found.
055: * @param title title of custom editor
056: */
057: public IconCustomEditorOperator(String title) {
058: super (title);
059: }
060:
061: /** Creates new IconCustomEditorOperator.
062: * @param wrapper JDialogOperator wrapper for custom editor
063: */
064: public IconCustomEditorOperator(JDialogOperator wrapper) {
065: super ((JDialog) wrapper.getSource());
066: }
067:
068: private JRadioButtonOperator _rbURL;
069: private JRadioButtonOperator _rbFile;
070: private JRadioButtonOperator _rbClasspath;
071: private JRadioButtonOperator _rbNoPicture;
072: private JTextFieldOperator _txtName;
073: private JButtonOperator _btSelectFile;
074:
075: //******************************
076: // Subcomponents definition part
077: //******************************
078:
079: /** Tries to find "URL" JRadioButton in this dialog.
080: * @return JRadioButtonOperator instance
081: */
082: public JRadioButtonOperator rbURL() {
083: if (_rbURL == null) {
084: _rbURL = new JRadioButtonOperator(
085: this ,
086: Bundle
087: .getString(
088: "org.openide.explorer.propertysheet.editors.Bundle",
089: "CTL_URL"));
090: }
091: return _rbURL;
092: }
093:
094: /** Tries to find "File" JRadioButton in this dialog.
095: * @return JRadioButtonOperator instance
096: */
097: public JRadioButtonOperator rbFile() {
098: if (_rbFile == null) {
099: _rbFile = new JRadioButtonOperator(
100: this ,
101: Bundle
102: .getString(
103: "org.openide.explorer.propertysheet.editors.Bundle",
104: "CTL_File"));
105: }
106: return _rbFile;
107: }
108:
109: /** Tries to find "Classpath" JRadioButton in this dialog.
110: * @return JRadioButtonOperator instance
111: */
112: public JRadioButtonOperator rbClasspath() {
113: if (_rbClasspath == null) {
114: _rbClasspath = new JRadioButtonOperator(
115: this ,
116: Bundle
117: .getString(
118: "org.openide.explorer.propertysheet.editors.Bundle",
119: "CTL_Classpath"));
120: }
121: return _rbClasspath;
122: }
123:
124: /** Tries to find "No picture" JRadioButton in this dialog.
125: * @return JRadioButtonOperator instance
126: */
127: public JRadioButtonOperator rbNoPicture() {
128: if (_rbNoPicture == null) {
129: _rbNoPicture = new JRadioButtonOperator(
130: this ,
131: Bundle
132: .getString(
133: "org.openide.explorer.propertysheet.editors.Bundle",
134: "CTL_NoPicture"));
135: }
136: return _rbNoPicture;
137: }
138:
139: /** Tries to find Name JTextField in this dialog.
140: * @return JTextFieldOperator instance
141: */
142: public JTextFieldOperator txtName() {
143: if (_txtName == null) {
144: _txtName = new JTextFieldOperator(this );
145: }
146: return _txtName;
147: }
148:
149: /** Tries to find "Select File" JButton in this dialog.
150: * @return JButtonOperator instance
151: */
152: public JButtonOperator btSelectFile() {
153: if (_btSelectFile == null) {
154: _btSelectFile = new JButtonOperator(
155: this ,
156: Bundle
157: .getString(
158: "org.openide.explorer.propertysheet.editors.Bundle",
159: "CTL_ButtonSelect"));
160: }
161: return _btSelectFile;
162: }
163:
164: //****************************************
165: // Low-level functionality definition part
166: //****************************************
167:
168: /** Clicks on "URL" JRadioButton. */
169: public void uRL() {
170: rbURL().push();
171: }
172:
173: /** Clicks on "File" JRadioButton. */
174: public void file() {
175: rbFile().push();
176: }
177:
178: /** Clicks on "Classpath" JRadioButton. */
179: public void classpath() {
180: rbClasspath().push();
181: }
182:
183: /** Clicks on "No picture" JRadioButton. */
184: public void noPicture() {
185: rbNoPicture().push();
186: }
187:
188: /** Gets text from Name text field.
189: * @return text from Name text field.
190: */
191: public String getName() {
192: return txtName().getText();
193: }
194:
195: /** Sets text in Name text field.
196: * @param text text to be written to Name text field
197: */
198: public void setName(String text) {
199: txtName().setText(text);
200: }
201:
202: /** Types text in Name text field.
203: * @param text text to be written to Name text field
204: */
205: public void typeName(String text) {
206: txtName().typeText(text);
207: }
208:
209: /** Clicks on "Select File" JButton. */
210: public void selectFile() {
211: btSelectFile().pushNoBlock();
212: }
213:
214: //*****************************************
215: // High-level functionality definition part
216: //*****************************************
217:
218: /** Performs verification of this operator by accessing all its components.
219: */
220: public void verify() {
221: rbURL();
222: rbFile();
223: rbClasspath();
224: rbNoPicture();
225: txtName();
226: btSelectFile();
227: btOK();
228: btCancel();
229: }
230: }
|