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: import org.netbeans.jemmy.operators.JDialogOperator;
049:
050: /** Class implementing all necessary methods for handling FileSystem Custom Editor.
051: * It is editor for bean org.openide.filesystems.FileSystem.
052: */
053: public class FilesystemCustomEditorOperator extends NbDialogOperator {
054:
055: /** Creates new FilesystemCustomEditorOperator that can handle it.
056: * Throws TimeoutExpiredException when NbDialog not found
057: * @param title title of custom editor */
058: public FilesystemCustomEditorOperator(String title) {
059: super (title);
060: }
061:
062: /** Creates new FilesytemCustomEditorOperator
063: * @param wrapper JDialogOperator wrapper for custom editor */
064: public FilesystemCustomEditorOperator(JDialogOperator wrapper) {
065: super ((JDialog) wrapper.getSource());
066: }
067:
068: private JRadioButtonOperator _rbAddLocalDirectory;
069: private JTextFieldOperator _txtDirectory;
070: private JButtonOperator _btBrowse;
071: private JRadioButtonOperator _rbAddJARFile;
072: private JTextFieldOperator _txtJARFile;
073: private JButtonOperator _btBrowse2;
074: private JRadioButtonOperator _rbAddOtherFileSystemType;
075: private JComboBoxOperator _cboType;
076:
077: //******************************
078: // Subcomponents definition part
079: //******************************
080:
081: /** Tries to find "Add Local Directory" JRadioButton in this dialog.
082: * @return JRadioButtonOperator instance
083: */
084: public JRadioButtonOperator rbAddLocalDirectory() {
085: if (_rbAddLocalDirectory == null) {
086: _rbAddLocalDirectory = new JRadioButtonOperator(this ,
087: Bundle.getString(
088: "org.netbeans.beaninfo.editors.Bundle",
089: "CTL_FileSystemPanel.dirRadioButton.text"));
090: }
091: return _rbAddLocalDirectory;
092: }
093:
094: /** Tries to find JTextField for Directory in this dialog.
095: * @return JTextFieldOperator instance
096: */
097: public JTextFieldOperator txtDirectory() {
098: if (_txtDirectory == null) {
099: _txtDirectory = new JTextFieldOperator(this );
100: }
101: return _txtDirectory;
102: }
103:
104: /** Tries to find "Browse" JButton to select Directory in this dialog.
105: * @return JButtonOperator instance
106: */
107: public JButtonOperator btBrowse() {
108: if (_btBrowse == null) {
109: _btBrowse = new JButtonOperator(this , Bundle.getString(
110: "org.netbeans.beaninfo.editors.Bundle",
111: "CTL_FileSystemPanel.browseDirButton.text"));
112: }
113: return _btBrowse;
114: }
115:
116: /** Tries to find "Add JAR File" JRadioButton in this dialog.
117: * @return JRadioButtonOperator instance
118: */
119: public JRadioButtonOperator rbAddJARFile() {
120: if (_rbAddJARFile == null) {
121: _rbAddJARFile = new JRadioButtonOperator(this , Bundle
122: .getString("org.netbeans.beaninfo.editors.Bundle",
123: "CTL_FileSystemPanel.jarRadioButton.text"));
124: }
125: return _rbAddJARFile;
126: }
127:
128: /** Tries to find JTextField for JAR File in this dialog.
129: * @return JTextFieldOperator instance
130: */
131: public JTextFieldOperator txtJARFile() {
132: if (_txtJARFile == null) {
133: _txtJARFile = new JTextFieldOperator(this , 1);
134: }
135: return _txtJARFile;
136: }
137:
138: /** Tries to find "Browse" JButton to select JAR File in this dialog.
139: * @return JButtonOperator instance
140: */
141: public JButtonOperator btBrowse2() {
142: if (_btBrowse2 == null) {
143: _btBrowse2 = new JButtonOperator(this , Bundle.getString(
144: "org.netbeans.beaninfo.editors.Bundle",
145: "CTL_FileSystemPanel.browseJarButton.text"), 1);
146: }
147: return _btBrowse2;
148: }
149:
150: /** Tries to find "Add (other file system type)" JRadioButton in this dialog.
151: * @return JRadioButtonOperator instance
152: */
153: public JRadioButtonOperator rbAddOtherFileSystemType() {
154: if (_rbAddOtherFileSystemType == null) {
155: _rbAddOtherFileSystemType = new JRadioButtonOperator(
156: this ,
157: Bundle
158: .getString(
159: "org.netbeans.beaninfo.editors.Bundle",
160: "CTL_FileSystemPanel.otherRadioButton.text"));
161: }
162: return _rbAddOtherFileSystemType;
163: }
164:
165: /** Tries to find JComboBox for Type of filesystem in this dialog.
166: * @return JComboBoxOperator instance
167: */
168: public JComboBoxOperator cboType() {
169: if (_cboType == null) {
170: _cboType = new JComboBoxOperator(this );
171: }
172: return _cboType;
173: }
174:
175: //****************************************
176: // Low-level functionality definition part
177: //****************************************
178:
179: /** clicks on "Add Local Directory" JRadioButton.
180: */
181: public void addLocalDirectory() {
182: rbAddLocalDirectory().push();
183: }
184:
185: /** Gets text from Directory text field.
186: * @return text from Directory text field.
187: */
188: public String getDirectory() {
189: return txtDirectory().getText();
190: }
191:
192: /** Sets text in Directory text field.
193: * @param directory file path to directory
194: */
195: public void setDirectory(String directory) {
196: txtDirectory().setText(directory);
197: }
198:
199: /** Types text in Directory text field.
200: * @param directory file path to directory
201: */
202: public void typeDirectory(String directory) {
203: txtDirectory().typeText(directory);
204: }
205:
206: /** Clicks on "Browse" JButton to set Directory. */
207: public void browse() {
208: btBrowse().pushNoBlock();
209: }
210:
211: /** Clicks on "Add JAR File" JRadioButton. */
212: public void addJARFile() {
213: rbAddJARFile().push();
214: }
215:
216: /** Gets text from JAR File text field.
217: * @return text from JAR File text field
218: */
219: public String getJARFile() {
220: return txtJARFile().getText();
221: }
222:
223: /** Sets text in JAR File text field.
224: * @param jarFile file path to JAR file
225: */
226: public void setJARFile(String jarFile) {
227: txtJARFile().setText(jarFile);
228: }
229:
230: /** Types text in JAR File text field.
231: * @param jarFile file path to JAR file
232: */
233: public void typeJARFile(String jarFile) {
234: txtJARFile().typeText(jarFile);
235: }
236:
237: /** Clicks on "Browse" JButton to select JAR File */
238: public void browse2() {
239: btBrowse2().pushNoBlock();
240: }
241:
242: /** Clicks on "Add (other file system type)" JRadioButton. */
243: public void addOtherFileSystemType() {
244: rbAddOtherFileSystemType().push();
245: }
246:
247: /** Returns selected item from combo box of filesystem type.
248: * @return selected item from combo box of filesystem type
249: */
250: public String getSelectedType() {
251: return cboType().getSelectedItem().toString();
252: }
253:
254: /** Selects item in combo box of filesystem type.
255: * @param item item to be selected
256: */
257: public void selectType(String item) {
258: cboType().selectItem(item);
259: }
260:
261: /** Types text in combo box of filesystem type.
262: * @param filesystemType type of filesystem
263: */
264: public void typeType(String filesystemType) {
265: cboType().typeText(filesystemType);
266: }
267:
268: //*****************************************
269: // High-level functionality definition part
270: //*****************************************
271:
272: /** Performs verification of this operator by accessing all its components.
273: */
274: public void verify() {
275: rbAddLocalDirectory();
276: txtDirectory();
277: btBrowse();
278: rbAddJARFile();
279: txtJARFile();
280: btBrowse2();
281: rbAddOtherFileSystemType();
282: cboType();
283: }
284:
285: }
|