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.JCheckBoxOperator;
047: import org.netbeans.jemmy.operators.JFileChooserOperator;
048: import org.netbeans.jemmy.operators.JLabelOperator;
049: import org.netbeans.jemmy.operators.JTextAreaOperator;
050: import org.netbeans.jemmy.operators.JTextFieldOperator;
051:
052: /** Class implementing all necessary methods for handling "Folder to Import" panel of
053: * Import wizard.
054: * <br>
055: * Usage:<br>
056: * <pre>
057: * ImportWizardOperator.invoke();
058: * CVSRootStepOperator cvsRootOper = new CVSRootStepOperator();
059: * cvsRootOper.setPassword("password");
060: * cvsRootOper.setCVSRoot(":pserver:user@host:repository");
061: * cvsRootOper.next();
062: * FolderToImportStepOperator folderToImportOper = new FolderToImportStepOperator();
063: * folderToImportOper.setFolderToImport("/tmp/myLocalfolder");
064: * folderToImportOper.setImportMessage("Import message");
065: * folderToImportOper.setRepositoryFolder("folder");
066: * folderToImportOper.finish();
067: * </pre>
068: * @see ImportWizardOperator
069: * @see BrowseRepositoryFolderOperator
070: *
071: * @author Jiri.Skrivanek@sun.com
072: */
073: public class FolderToImportStepOperator extends ImportWizardOperator {
074:
075: /** Waits for Folder to Import panel. */
076: public FolderToImportStepOperator() {
077: super ();
078: stepsWaitSelectedValue(Bundle
079: .getString(
080: "org.netbeans.modules.versioning.system.cvss.ui.actions.project.Bundle",
081: "BK0014"));
082: }
083:
084: private JLabelOperator _lblFolderToImport;
085: private JTextFieldOperator _txtFolderToImport;
086: private JButtonOperator _btBrowse;
087: private JLabelOperator _lblImportMessage;
088: private JTextAreaOperator _txtImportMessage;
089: private JLabelOperator _lblRepositoryFolder;
090: private JTextFieldOperator _txtRepositoryFolder;
091: private JButtonOperator _btBrowse2;
092: private JCheckBoxOperator _cbCheckoutAfterImport;
093:
094: //******************************
095: // Subcomponents definition part
096: //******************************
097:
098: /** Tries to find "Folder to Import:" JLabel in this dialog.
099: * @return JLabelOperator
100: */
101: public JLabelOperator lblFolderToImport() {
102: if (_lblFolderToImport == null) {
103: _lblFolderToImport = new JLabelOperator(
104: this ,
105: Bundle
106: .getStringTrimmed(
107: "org.netbeans.modules.versioning.system.cvss.ui.actions.project.Bundle",
108: "BK1104"));
109: }
110: return _lblFolderToImport;
111: }
112:
113: /** Tries to find null JTextField in this dialog.
114: * @return JTextFieldOperator
115: */
116: public JTextFieldOperator txtFolderToImport() {
117: if (_txtFolderToImport == null) {
118: _txtFolderToImport = new JTextFieldOperator(
119: (JTextField) lblFolderToImport().getLabelFor());
120: }
121: return _txtFolderToImport;
122: }
123:
124: /** Tries to find "Browse..." JButton in this dialog.
125: * @return JButtonOperator
126: */
127: public JButtonOperator btBrowseFolderToImport() {
128: if (_btBrowse == null) {
129: _btBrowse = new JButtonOperator(
130: this ,
131: Bundle
132: .getStringTrimmed(
133: "org.netbeans.modules.versioning.system.cvss.ui.wizards.Bundle",
134: "BK2003"));
135: }
136: return _btBrowse;
137: }
138:
139: /** Tries to find "Import Message:" JLabel in this dialog.
140: * @return JLabelOperator
141: */
142: public JLabelOperator lblImportMessage() {
143: if (_lblImportMessage == null) {
144: _lblImportMessage = new JLabelOperator(
145: this ,
146: Bundle
147: .getStringTrimmed(
148: "org.netbeans.modules.versioning.system.cvss.ui.actions.project.Bundle",
149: "BK0001"));
150: }
151: return _lblImportMessage;
152: }
153:
154: /** Tries to find null KTextArea in this dialog.
155: * @return JTextAreaOperator
156: */
157: public JTextAreaOperator txtImportMessage() {
158: if (_txtImportMessage == null) {
159: _txtImportMessage = new JTextAreaOperator(this );
160: }
161: return _txtImportMessage;
162: }
163:
164: /** Tries to find "Repository Folder:" JLabel in this dialog.
165: * @return JLabelOperator
166: */
167: public JLabelOperator lblRepositoryFolder() {
168: if (_lblRepositoryFolder == null) {
169: _lblRepositoryFolder = new JLabelOperator(
170: this ,
171: Bundle
172: .getStringTrimmed(
173: "org.netbeans.modules.versioning.system.cvss.ui.actions.project.Bundle",
174: "Bk0002"));
175: }
176: return _lblRepositoryFolder;
177: }
178:
179: /** Tries to find null JTextField in this dialog.
180: * @return JTextFieldOperator
181: */
182: public JTextFieldOperator txtRepositoryFolder() {
183: if (_txtRepositoryFolder == null) {
184: _txtRepositoryFolder = new JTextFieldOperator(
185: (JTextField) lblRepositoryFolder().getLabelFor());
186: }
187: return _txtRepositoryFolder;
188: }
189:
190: /** Tries to find "Browse..." JButton in this dialog.
191: * @return JButtonOperator
192: */
193: public JButtonOperator btBrowseRepositoryFolder() {
194: if (_btBrowse2 == null) {
195: _btBrowse2 = new JButtonOperator(
196: this ,
197: Bundle
198: .getStringTrimmed(
199: "org.netbeans.modules.versioning.system.cvss.ui.wizards.Bundle",
200: "BK2003"), 1);
201: }
202: return _btBrowse2;
203: }
204:
205: /** Tries to find "Checkout After Import" JCheckBox in this dialog.
206: * @return JCheckBoxOperator
207: */
208: public JCheckBoxOperator cbCheckoutAfterImport() {
209: if (_cbCheckoutAfterImport == null) {
210: _cbCheckoutAfterImport = new JCheckBoxOperator(
211: this ,
212: Bundle
213: .getStringTrimmed(
214: "org.netbeans.modules.versioning.system.cvss.ui.actions.project.Bundle",
215: "BK0011"));
216: }
217: return _cbCheckoutAfterImport;
218: }
219:
220: //****************************************
221: // Low-level functionality definition part
222: //****************************************
223:
224: /** gets text for txtFolderToImport
225: * @return String text
226: */
227: public String getFolderToImport() {
228: return txtFolderToImport().getText();
229: }
230:
231: /** sets text for txtFolderToImport
232: * @param text String text
233: */
234: public void setFolderToImport(String text) {
235: txtFolderToImport().clearText();
236: txtFolderToImport().typeText(text);
237: }
238:
239: /** clicks on "Browse..." button to browse for folder to import and returns
240: * JFileChooserOperator.
241: * @return JFileChooserOperator instance
242: */
243: public JFileChooserOperator browseFolderToImport() {
244: btBrowseFolderToImport().pushNoBlock();
245: return new JFileChooserOperator();
246: }
247:
248: /** gets text for txtImportMessage
249: * @return String text
250: */
251: public String getImportMessage() {
252: return txtImportMessage().getText();
253: }
254:
255: /** sets text for txtImportMessage
256: * @param text String text
257: */
258: public void setImportMessage(String text) {
259: txtImportMessage().clearText();
260: txtImportMessage().typeText(text);
261: }
262:
263: /** gets text for txtRepositoryFolder
264: * @return String text
265: */
266: public String getRepositoryFolder() {
267: return txtRepositoryFolder().getText();
268: }
269:
270: /** sets text for txtRepositoryFolder
271: * @param text String text
272: */
273: public void setRepositoryFolder(String text) {
274: txtRepositoryFolder().clearText();
275: txtRepositoryFolder().typeText(text);
276: }
277:
278: /** Clicks on "Browse..." button to browse for repository folder and returns
279: * BrowseRepositoryFolderOperator.
280: * @return BrowseRepositoryFolderOperator instance
281: */
282: public BrowseRepositoryFolderOperator browseRepositoryFolder() {
283: btBrowseRepositoryFolder().pushNoBlock();
284: return new BrowseRepositoryFolderOperator();
285: }
286:
287: /** checks or unchecks given JCheckBox
288: * @param state boolean requested state
289: */
290: public void checkCheckoutAfterImport(boolean state) {
291: if (cbCheckoutAfterImport().isSelected() != state) {
292: cbCheckoutAfterImport().push();
293: }
294: }
295:
296: //*****************************************
297: // High-level functionality definition part
298: //*****************************************
299:
300: /**
301: * Performs verification of FolderToImportStepOperator by accessing all its components.
302: */
303: public void verify() {
304: lblFolderToImport();
305: txtFolderToImport();
306: btBrowseFolderToImport();
307: lblImportMessage();
308: txtImportMessage();
309: lblRepositoryFolder();
310: txtRepositoryFolder();
311: btBrowseRepositoryFolder();
312: cbCheckoutAfterImport();
313: }
314: }
|