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