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: package org.netbeans.jellytools.modules.javacvs;
042:
043: import javax.swing.JTextField;
044: import org.netbeans.jellytools.Bundle;
045: import org.netbeans.jellytools.OptionsOperator;
046: import org.netbeans.jellytools.WizardOperator;
047: import org.netbeans.jemmy.operators.JButtonOperator;
048: import org.netbeans.jemmy.operators.JCheckBoxOperator;
049: import org.netbeans.jemmy.operators.JComboBoxOperator;
050: import org.netbeans.jemmy.operators.JLabelOperator;
051: import org.netbeans.jemmy.operators.JPasswordFieldOperator;
052: import org.netbeans.jemmy.operators.JRadioButtonOperator;
053: import org.netbeans.jemmy.operators.JTextFieldOperator;
054:
055: /** Class implementing all necessary methods for handling "CVS Root" panel of
056: * Checkout or Import wizard.
057: * <br>
058: * Usage:<br>
059: * <pre>
060: * CheckoutWizardOperator.invoke();
061: * CVSRootStepOperator cvsRootOper = new CVSRootStepOperator();
062: * cvsRootOper.setPassword("password");
063: * cvsRootOper.setCVSRoot(":pserver:user@host:repository");
064: * cvsRootOper.next();
065: * ModuleToCheckoutStepOperator moduleOper = new ModuleToCheckoutStepOperator();
066: * moduleOper.setModule("module");
067: * moduleOper.setBranch("branch");
068: * moduleOper.setLocalFolder("/tmp");
069: * moduleOper.finish();
070: * </pre>
071: * @see CheckoutWizardOperator
072: * @see ImportWizardOperator
073: * @see EditCVSRootOperator
074: *
075: * @author Jiri.Skrivanek@sun.com
076: */
077: public class CVSRootStepOperator extends WizardOperator {
078:
079: /** Waits for CVS Root panel. */
080: public CVSRootStepOperator() {
081: // It can be in either Checkout or Import Project Options wizards
082: super ("");
083: stepsWaitSelectedValue(Bundle
084: .getString(
085: "org.netbeans.modules.versioning.system.cvss.ui.wizards.Bundle",
086: "BK0006"));
087: }
088:
089: private JLabelOperator _lblCVSRoot;
090: private JComboBoxOperator _cboCVSRoot;
091: /** :fork: item. */
092: public static final String ITEM_FORK = ":fork:"; // NOI18N
093: /** :local: item. */
094: public static final String ITEM_LOCAL = ":local:"; // NOI18N
095: private JButtonOperator _btEdit;
096: private JLabelOperator _lblPassword;
097: private JPasswordFieldOperator _txtPassword;
098: private JButtonOperator _btProxyConfiguration;
099: // for "ext" CVS root
100: private JRadioButtonOperator _rbUseInternalSSH;
101: private JCheckBoxOperator _cbRememberPassword;
102: private JRadioButtonOperator _rbUseExternalShell;
103: private JLabelOperator _lblSSHCommand;
104: private JTextFieldOperator _txtSSHCommand;
105:
106: //******************************
107: // Subcomponents definition part
108: //******************************
109:
110: /** Tries to find "CVS Root:" JLabel in this dialog.
111: * @return JLabelOperator
112: */
113: public JLabelOperator lblCVSRoot() {
114: if (_lblCVSRoot == null) {
115: _lblCVSRoot = new JLabelOperator(
116: this ,
117: Bundle
118: .getStringTrimmed(
119: "org.netbeans.modules.versioning.system.cvss.ui.wizards.Bundle",
120: "BK0002"));
121: }
122: return _lblCVSRoot;
123: }
124:
125: /** Tries to find null JComboBox in this dialog.
126: * @return JComboBoxOperator
127: */
128: public JComboBoxOperator cboCVSRoot() {
129: if (_cboCVSRoot == null) {
130: _cboCVSRoot = new JComboBoxOperator(this );
131: }
132: return _cboCVSRoot;
133: }
134:
135: /** Tries to find "Edit..." JButton in this dialog.
136: * @return JButtonOperator
137: */
138: public JButtonOperator btEdit() {
139: if (_btEdit == null) {
140: _btEdit = new JButtonOperator(
141: this ,
142: Bundle
143: .getStringTrimmed(
144: "org.netbeans.modules.versioning.system.cvss.ui.wizards.Bundle",
145: "BK1105"));
146: }
147: return _btEdit;
148: }
149:
150: /** Tries to find "Password:" JLabel in this dialog.
151: * @return JLabelOperator
152: */
153: public JLabelOperator lblPassword() {
154: if (_lblPassword == null) {
155: _lblPassword = new JLabelOperator(
156: this ,
157: Bundle
158: .getStringTrimmed(
159: "org.netbeans.modules.versioning.system.cvss.ui.wizards.Bundle",
160: "BK0003"));
161: }
162: return _lblPassword;
163: }
164:
165: /** Tries to find null JPasswordField in this dialog.
166: * @return JPasswordFieldOperator
167: */
168: public JPasswordFieldOperator txtPassword() {
169: if (_txtPassword == null) {
170: _txtPassword = new JPasswordFieldOperator(this );
171: }
172: return _txtPassword;
173: }
174:
175: /** Tries to find "Proxy Configuration..." JButton in this dialog.
176: * @return JButtonOperator
177: */
178: public JButtonOperator btProxyConfiguration() {
179: if (_btProxyConfiguration == null) {
180: _btProxyConfiguration = new JButtonOperator(
181: this ,
182: Bundle
183: .getStringTrimmed(
184: "org.netbeans.modules.versioning.system.cvss.ui.wizards.Bundle",
185: "BK0005"));
186: }
187: return _btProxyConfiguration;
188: }
189:
190: //********** ext CVS root ********************
191:
192: /** Tries to find "Use Internal SSH" JRadioButton in this dialog.
193: * @return JRadioButtonOperator
194: */
195: public JRadioButtonOperator rbUseInternalSSH() {
196: if (_rbUseInternalSSH == null) {
197: _rbUseInternalSSH = new JRadioButtonOperator(
198: this ,
199: Bundle
200: .getStringTrimmed(
201: "org.netbeans.modules.versioning.system.cvss.ui.wizards.Bundle",
202: "BK1100"));
203: }
204: return _rbUseInternalSSH;
205: }
206:
207: /** Tries to find "Remember Password" JCheckBox in this dialog.
208: * @return JCheckBoxOperator
209: */
210: public JCheckBoxOperator cbRememberPassword() {
211: if (_cbRememberPassword == null) {
212: _cbRememberPassword = new JCheckBoxOperator(
213: this ,
214: Bundle
215: .getStringTrimmed(
216: "org.netbeans.modules.versioning.system.cvss.ui.wizards.Bundle",
217: "BK1012"));
218: }
219: return _cbRememberPassword;
220: }
221:
222: /** Tries to find "Use External Shell" JRadioButton in this dialog.
223: * @return JRadioButtonOperator
224: */
225: public JRadioButtonOperator rbUseExternalShell() {
226: if (_rbUseExternalShell == null) {
227: _rbUseExternalShell = new JRadioButtonOperator(
228: this ,
229: Bundle
230: .getStringTrimmed(
231: "org.netbeans.modules.versioning.system.cvss.ui.wizards.Bundle",
232: "BK1101"));
233: }
234: return _rbUseExternalShell;
235: }
236:
237: /** Tries to find "SSH Command:" JLabel in this dialog.
238: * @return JLabelOperator
239: */
240: public JLabelOperator lblSSHCommand() {
241: if (_lblSSHCommand == null) {
242: _lblSSHCommand = new JLabelOperator(
243: this ,
244: Bundle
245: .getStringTrimmed(
246: "org.netbeans.modules.versioning.system.cvss.ui.wizards.Bundle",
247: "BK1013"));
248: }
249: return _lblSSHCommand;
250: }
251:
252: /** Tries to find null JTextField in this dialog.
253: * @return JTextFieldOperator
254: */
255: public JTextFieldOperator txtSSHCommand() {
256: if (_txtSSHCommand == null) {
257: _txtSSHCommand = new JTextFieldOperator(
258: (JTextField) lblSSHCommand().getLabelFor());
259: }
260: return _txtSSHCommand;
261: }
262:
263: //****************************************
264: // Low-level functionality definition part
265: //****************************************
266:
267: /** returns selected item for cboCVSRoot
268: * @return String item
269: */
270: public String getCVSRoot() {
271: return cboCVSRoot().getSelectedItem().toString();
272: }
273:
274: /** selects item for cboCVSRoot
275: * @param item String item
276: */
277: public void selectCVSRoot(String item) {
278: cboCVSRoot().selectItem(item);
279: }
280:
281: /** types text for cboCVSRoot
282: * @param text String text
283: */
284: public void setCVSRoot(String text) {
285: cboCVSRoot().clearText();
286: cboCVSRoot().typeText(text);
287: // value typed in combo box editor is not taken into account otherwise
288: EditCVSRootOperator editOper = edit();
289: // confirm when enabled otherwise cancel
290: if (editOper.btOK().isEnabled()) {
291: editOper.ok();
292: } else {
293: editOper.cancel();
294: }
295: }
296:
297: /** clicks on "Edit..." JButton and returns instance of EditCVSRootOperator.
298: * @return instance of EditCVSRootOperator
299: */
300: public EditCVSRootOperator edit() {
301: btEdit().pushNoBlock();
302: return new EditCVSRootOperator();
303: }
304:
305: /** sets text for txtPassword
306: * @param text String text
307: */
308: public void setPassword(String text) {
309: txtPassword().clearText();
310: txtPassword().typeText(text);
311: }
312:
313: /** clicks on "Proxy Configuration..." JButton and returns OptionsOperator.
314: * @return instance of OptionsOperator
315: */
316: public OptionsOperator proxyConfiguration() {
317: btProxyConfiguration().pushNoBlock();
318: return new OptionsOperator();
319: }
320:
321: //************* for ext CVS root ***************************
322:
323: /** clicks on "Use Internal SSH" JRadioButton
324: */
325: public void useInternalSSH() {
326: rbUseInternalSSH().push();
327: }
328:
329: /** checks or unchecks given JCheckBox
330: * @param state boolean requested state
331: */
332: public void checkRememberPassword(boolean state) {
333: if (cbRememberPassword().isSelected() != state) {
334: cbRememberPassword().push();
335: }
336: }
337:
338: /** clicks on "Use External Shell" JRadioButton
339: */
340: public void useExternalShell() {
341: rbUseExternalShell().push();
342: }
343:
344: /** types text for txtSSHCommand
345: * @param text String text
346: */
347: public void setSSHCommand(String text) {
348: txtSSHCommand().clearText();
349: txtSSHCommand().typeText(text);
350: }
351:
352: //*****************************************
353: // High-level functionality definition part
354: //*****************************************
355:
356: /** Performs verification of Checkout by accessing all its components.
357: */
358: public void verify() {
359: lblCVSRoot();
360: cboCVSRoot();
361: btEdit();
362: lblPassword();
363: txtPassword();
364: btProxyConfiguration();
365: }
366: }
|