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 org.netbeans.jellytools.Bundle;
044: import org.netbeans.jellytools.NbDialogOperator;
045: import org.netbeans.jellytools.modules.javacvs.actions.SwitchToBranchAction;
046: import org.netbeans.jellytools.nodes.Node;
047: import org.netbeans.jemmy.operators.JButtonOperator;
048: import org.netbeans.jemmy.operators.JRadioButtonOperator;
049: import org.netbeans.jemmy.operators.JTextFieldOperator;
050:
051: /** Class implementing all necessary methods for handling "Switch to Branch" dialog.
052: * It is opened from main menu or from popup on versioned file.
053: * <br>
054: * Usage:<br>
055: * <pre>
056: * Node node = new Node(new SourcePackagesNode("MyProject"), "mypackage|MyFile");
057: * SwitchToBranchOperator stbo = SwitchToBranchOperator.invoke(node);
058: * stbo.switchToBranch();
059: * BrowseTagsOperator bto = stbo.browse();
060: * bto.selectBranch("mybranch");
061: * bto.ok();
062: * // or stbo.setBranch("mybranch");
063: * stbo.pushSwitch();
064: *</pre>
065: *
066: * @see BrowseTagsOperator
067: * @see org.netbeans.jellytools.modules.javacvs.actions.SwitchToBranchAction
068: *
069: * @author Jiri.Skrivanek@sun.com
070: */
071: public class SwitchToBranchOperator extends NbDialogOperator {
072:
073: /** Waits for dialog with title "Switch to Branch". */
074: public SwitchToBranchOperator() {
075: super (
076: Bundle
077: .getStringTrimmed(
078: "org.netbeans.modules.versioning.system.cvss.ui.actions.tag.Bundle",
079: "CTL_SwitchBranchDialog_Title"));
080: }
081:
082: /** Selects nodes and call switch to branch action on them.
083: * @param nodes an array of nodes
084: * @return SwitchToBranchOperator instance
085: */
086: public static SwitchToBranchOperator invoke(Node[] nodes) {
087: new SwitchToBranchAction().perform(nodes);
088: return new SwitchToBranchOperator();
089: }
090:
091: /** Selects node and call switch to branch action on it.
092: * @param node node to be selected
093: * @return SwitchToBranchOperator instance
094: */
095: public static SwitchToBranchOperator invoke(Node node) {
096: return invoke(new Node[] { node });
097: }
098:
099: private JRadioButtonOperator _rbSwitchToTrunk;
100: private JRadioButtonOperator _rbSwitchToBranch;
101: private JTextFieldOperator _txtJTextField;
102: private JButtonOperator _btBrowse;
103: private JButtonOperator _btSwitch;
104:
105: //******************************
106: // Subcomponents definition part
107: //******************************
108:
109: /** Tries to find "Switch to Trunk" JRadioButton in this dialog.
110: * @return JRadioButtonOperator
111: */
112: public JRadioButtonOperator rbSwitchToTrunk() {
113: if (_rbSwitchToTrunk == null) {
114: _rbSwitchToTrunk = new JRadioButtonOperator(
115: this ,
116: org.netbeans.jellytools.Bundle
117: .getStringTrimmed(
118: "org.netbeans.modules.versioning.system.cvss.ui.actions.tag.Bundle",
119: "CTL_SwitchBranchForm_ToTrunk"));
120: }
121: return _rbSwitchToTrunk;
122: }
123:
124: /** Tries to find "Switch to Branch:" JRadioButton in this dialog.
125: * @return JRadioButtonOperator
126: */
127: public JRadioButtonOperator rbSwitchToBranch() {
128: if (_rbSwitchToBranch == null) {
129: _rbSwitchToBranch = new JRadioButtonOperator(
130: this ,
131: org.netbeans.jellytools.Bundle
132: .getStringTrimmed(
133: "org.netbeans.modules.versioning.system.cvss.ui.actions.tag.Bundle",
134: "CTL_SwitchBranchForm_ToBranch"));
135: }
136: return _rbSwitchToBranch;
137: }
138:
139: /** Tries to find Switch to branch text field in this dialog.
140: * @return JTextFieldOperator
141: */
142: public JTextFieldOperator txtSwitchToBranch() {
143: if (_txtJTextField == null) {
144: _txtJTextField = new JTextFieldOperator(this );
145: }
146: return _txtJTextField;
147: }
148:
149: /** Tries to find "Browse..." JButton in this dialog.
150: * @return JButtonOperator
151: */
152: public JButtonOperator btBrowse() {
153: if (_btBrowse == null) {
154: _btBrowse = new JButtonOperator(
155: this ,
156: org.netbeans.jellytools.Bundle
157: .getStringTrimmed(
158: "org.netbeans.modules.versioning.system.cvss.ui.actions.tag.Bundle",
159: "CTL_SwitchBranchForm_BrowseBranch"));
160: }
161: return _btBrowse;
162: }
163:
164: /** Tries to find "Switch" JButton in this dialog.
165: * @return JButtonOperator
166: */
167: public JButtonOperator btSwitch() {
168: if (_btSwitch == null) {
169: _btSwitch = new JButtonOperator(
170: this ,
171: org.netbeans.jellytools.Bundle
172: .getStringTrimmed(
173: "org.netbeans.modules.versioning.system.cvss.ui.actions.tag.Bundle",
174: "CTL_SwitchBranchDialog_Action_Switch"));
175: }
176: return _btSwitch;
177: }
178:
179: //****************************************
180: // Low-level functionality definition part
181: //****************************************
182:
183: /** clicks on "Switch to Trunk" JRadioButton
184: */
185: public void switchToTrunk() {
186: rbSwitchToTrunk().push();
187: }
188:
189: /** clicks on "Switch to Branch:" JRadioButton
190: */
191: public void switchToBranch() {
192: rbSwitchToBranch().push();
193: }
194:
195: /** gets text from Switch to branch text field
196: * @return String text
197: */
198: public String getBranch() {
199: return txtSwitchToBranch().getText();
200: }
201:
202: /** sets text for Switch to Branch text field
203: * @param text String text
204: */
205: public void setBranch(String text) {
206: txtSwitchToBranch().clearText();
207: txtSwitchToBranch().typeText(text);
208: }
209:
210: /** clicks on "Browse..." JButton and return BrowseTagsOperator.
211: * @return BrowseTagsOperator instance
212: */
213: public BrowseTagsOperator browse() {
214: btBrowse().pushNoBlock();
215: return new BrowseTagsOperator();
216: }
217:
218: /** clicks on "Switch" JButton
219: */
220: public void pushSwitch() {
221: btSwitch().push();
222: }
223:
224: //*****************************************
225: // High-level functionality definition part
226: //*****************************************
227:
228: /** Performs verification of SwitchToBranchOperator by accessing all its components.
229: */
230: public void verify() {
231: rbSwitchToTrunk();
232: rbSwitchToBranch();
233: txtSwitchToBranch();
234: btBrowse();
235: btSwitch();
236: }
237: }
|