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.jemmy.operators.JButtonOperator;
046: import org.netbeans.jemmy.operators.JFileChooserOperator;
047: import org.netbeans.jemmy.operators.JLabelOperator;
048: import org.netbeans.jemmy.operators.JTextFieldOperator;
049:
050: /**
051: * Class implementing all necessary methods for handling "Module to Checkout" panel of
052: * Checkout wizard.
053: * <br>
054: * Usage:<br>
055: * <pre>
056: * CheckoutWizardOperator.invoke();
057: * CVSRootStepOperator cvsRootOper = new CVSRootStepOperator();
058: * cvsRootOper.setPassword("password");
059: * cvsRootOper.setCVSRoot(":pserver:user@host:repository");
060: * cvsRootOper.next();
061: * ModuleToCheckoutStepOperator moduleOper = new ModuleToCheckoutStepOperator();
062: * moduleOper.setModule("module");
063: * moduleOper.setBranch("branch");
064: * moduleOper.setLocalFolder("/tmp");
065: * moduleOper.finish();
066: * </pre>
067: *
068: * @author Jiri.Skrivanek@sun.com
069: * @see CheckoutWizardOperator
070: * @see BrowseCVSModuleOperator
071: * @see BrowseTagsOperator
072: */
073: public class ModuleToCheckoutStepOperator extends
074: CheckoutWizardOperator {
075:
076: /** Waits for "Module to Checkout" panel. */
077: public ModuleToCheckoutStepOperator() {
078: super ();
079: stepsWaitSelectedValue(Bundle
080: .getString(
081: "org.netbeans.modules.versioning.system.cvss.ui.wizards.Bundle",
082: "BK2009"));
083: }
084:
085: private JLabelOperator _lblModule;
086: private JTextFieldOperator _txtModule;
087: private JButtonOperator _btBrowse;
088: private JLabelOperator _lblBranch;
089: private JTextFieldOperator _txtBranch;
090: private JButtonOperator _btBrowse2;
091: private JLabelOperator _lblLocalFolder;
092: private JTextFieldOperator _txtLocalFolder;
093: private JButtonOperator _btBrowse3;
094:
095: //******************************
096: // Subcomponents definition part
097: //******************************
098:
099: /** Tries to find "Module:" JLabel in this dialog.
100: * @return JLabelOperator
101: */
102: public JLabelOperator lblModule() {
103: if (_lblModule == null) {
104: _lblModule = new JLabelOperator(
105: this ,
106: Bundle
107: .getStringTrimmed(
108: "org.netbeans.modules.versioning.system.cvss.ui.wizards.Bundle",
109: "BK2002"));
110: }
111: return _lblModule;
112: }
113:
114: /** Tries to find null JTextField in this dialog.
115: * @return JTextFieldOperator
116: */
117: public JTextFieldOperator txtModule() {
118: if (_txtModule == null) {
119: _txtModule = new JTextFieldOperator(
120: (JTextField) lblModule().getLabelFor());
121: }
122: return _txtModule;
123: }
124:
125: /** Tries to find "Browse..." JButton in this dialog.
126: * @return JButtonOperator
127: */
128: public JButtonOperator btBrowseModule() {
129: if (_btBrowse == null) {
130: _btBrowse = new JButtonOperator(
131: this ,
132: Bundle
133: .getStringTrimmed(
134: "org.netbeans.modules.versioning.system.cvss.ui.wizards.Bundle",
135: "BK2003"));
136: }
137: return _btBrowse;
138: }
139:
140: /** Tries to find "Branch:" JLabel in this dialog.
141: * @return JLabelOperator
142: */
143: public JLabelOperator lblBranch() {
144: if (_lblBranch == null) {
145: _lblBranch = new JLabelOperator(
146: this ,
147: Bundle
148: .getStringTrimmed(
149: "org.netbeans.modules.versioning.system.cvss.ui.wizards.Bundle",
150: "BK2005"));
151: }
152: return _lblBranch;
153: }
154:
155: /** Tries to find null JTextField in this dialog.
156: * @return JTextFieldOperator
157: */
158: public JTextFieldOperator txtBranch() {
159: if (_txtBranch == null) {
160: _txtBranch = new JTextFieldOperator(
161: (JTextField) lblBranch().getLabelFor());
162: }
163: return _txtBranch;
164: }
165:
166: /** Tries to find "Browse..." JButton in this dialog.
167: * @return JButtonOperator
168: */
169: public JButtonOperator btBrowseBranch() {
170: if (_btBrowse2 == null) {
171: _btBrowse2 = new JButtonOperator(
172: this ,
173: Bundle
174: .getStringTrimmed(
175: "org.netbeans.modules.versioning.system.cvss.ui.wizards.Bundle",
176: "BK2003"), 1);
177: }
178: return _btBrowse2;
179: }
180:
181: /** Tries to find "Local Folder:" JLabel in this dialog.
182: * @return JLabelOperator
183: */
184: public JLabelOperator lblLocalFolder() {
185: if (_lblLocalFolder == null) {
186: _lblLocalFolder = new JLabelOperator(
187: this ,
188: Bundle
189: .getStringTrimmed(
190: "org.netbeans.modules.versioning.system.cvss.ui.wizards.Bundle",
191: "BK2007"));
192: }
193: return _lblLocalFolder;
194: }
195:
196: /** Tries to find null JTextField in this dialog.
197: * @return JTextFieldOperator
198: */
199: public JTextFieldOperator txtLocalFolder() {
200: if (_txtLocalFolder == null) {
201: _txtLocalFolder = new JTextFieldOperator(
202: (JTextField) lblLocalFolder().getLabelFor());
203: }
204: return _txtLocalFolder;
205: }
206:
207: /** Tries to find "Browse..." JButton in this dialog.
208: * @return JButtonOperator
209: */
210: public JButtonOperator btBrowseLocalFolder() {
211: if (_btBrowse3 == null) {
212: _btBrowse3 = new JButtonOperator(
213: this ,
214: Bundle
215: .getStringTrimmed(
216: "org.netbeans.modules.versioning.system.cvss.ui.wizards.Bundle",
217: "BK2003"), 2);
218: }
219: return _btBrowse3;
220: }
221:
222: //****************************************
223: // Low-level functionality definition part
224: //****************************************
225:
226: /** gets text for txtModule
227: * @return String text
228: */
229: public String getModule() {
230: return txtModule().getText();
231: }
232:
233: /** sets text for txtModule
234: * @param text String text
235: */
236: public void setModule(String text) {
237: txtModule().clearText();
238: txtModule().typeText(text);
239: }
240:
241: /**
242: * clicks on "Browse..." JButton and returns BrowseCVSModuleOperator
243: *
244: * @return instance of BrowseCVSModuleOperator
245: */
246: public BrowseCVSModuleOperator browseModule() {
247: btBrowseModule().pushNoBlock();
248: return new BrowseCVSModuleOperator();
249: }
250:
251: /** gets text for txtBranch
252: * @return String text
253: */
254: public String getBranch() {
255: return txtBranch().getText();
256: }
257:
258: /** sets text for txtBranch
259: * @param text String text
260: */
261: public void setBranch(String text) {
262: txtBranch().clearText();
263: txtBranch().typeText(text);
264: }
265:
266: /** clicks on "Browse..." button and returns BrowseTagsOperator
267: * @return instance of BrowseTagsOperator
268: */
269: public BrowseTagsOperator browseBranch() {
270: btBrowseBranch().pushNoBlock();
271: return new BrowseTagsOperator();
272: }
273:
274: /** gets text for txtLocalFolder
275: * @return String text
276: */
277: public String getLocalFolder() {
278: return txtLocalFolder().getText();
279: }
280:
281: /** sets text for txtLocalFolder
282: * @param text String text
283: */
284: public void setLocalFolder(String text) {
285: txtLocalFolder().clearText();
286: txtLocalFolder().typeText(text);
287: }
288:
289: /** clicks on "Browse..." and returns JFileChooserOperator instance.
290: * @return instance of JFileChooserOperator
291: */
292: public JFileChooserOperator browseLocalFolder() {
293: btBrowseLocalFolder().pushNoBlock();
294: return new JFileChooserOperator();
295: }
296:
297: //*****************************************
298: // High-level functionality definition part
299: //*****************************************
300:
301: /**
302: * Performs verification of ModuleToCheckoutStepOperator by accessing all its components.
303: */
304: public void verify() {
305: lblModule();
306: txtModule();
307: btBrowseModule();
308: lblBranch();
309: txtBranch();
310: btBrowseBranch();
311: lblLocalFolder();
312: txtLocalFolder();
313: btBrowseLocalFolder();
314: }
315: }
|