001: /*
002: * CopyToOperator.java
003: *
004: * Created on 16/05/06 11:11
005: */
006: package org.netbeans.test.subversion.operators;
007:
008: import org.netbeans.jellytools.NbDialogOperator;
009: import org.netbeans.jellytools.nodes.Node;
010: import org.netbeans.jemmy.operators.*;
011: import org.netbeans.test.subversion.operators.actions.CopyAction;
012:
013: /** Class implementing all necessary methods for handling "Copy to..." NbDialog.
014: *
015: * @author peter
016: * @version 1.0
017: */
018: public class CopyToOperator extends NbDialogOperator {
019:
020: /**
021: * Creates new CopyToOperator that can handle it.
022: */
023: public CopyToOperator() {
024: super ("Copy");
025: }
026:
027: /** Selects nodes and call copy action on them.
028: * @param nodes an array of nodes
029: * @return CopyToOperator instance
030: */
031: public static CopyToOperator invoke(Node[] nodes) {
032: new CopyAction().perform(nodes);
033: return new CopyToOperator();
034: }
035:
036: /** Selects node and call copy action on it.
037: * @param node node to be selected
038: * @return CommitOperator instance
039: */
040: public static CopyToOperator invoke(Node node) {
041: return invoke(new Node[] { node });
042: }
043:
044: private JTextAreaOperator _txtJTextArea;
045: private JRadioButtonOperator _rbLocalFolder;
046: private JRadioButtonOperator _rbRemoteFolder;
047: private JLabelOperator _lblDescribeTheCopyPurpose;
048: private JLabelOperator _lblRepositoryFolder;
049: private JComboBoxOperator _cboJComboBox;
050: private JButtonOperator _btBrowse;
051: private JCheckBoxOperator _cbSwitchToCopy;
052: private JCheckBoxOperator _cbSkip;
053: private JLabelOperator _lblWarningMessage;
054: private JButtonOperator _btCopy;
055: private JButtonOperator _btCancel;
056: private JButtonOperator _btHelp;
057:
058: //******************************
059: // Subcomponents definition part
060: //******************************
061:
062: /** Tries to find null JTextArea in this dialog.
063: * @return JTextAreaOperator
064: */
065: public JTextAreaOperator txtJTextArea() {
066: if (_txtJTextArea == null) {
067: _txtJTextArea = new JTextAreaOperator(this );
068: }
069: return _txtJTextArea;
070: }
071:
072: /** Tries to find "Describe the copy purpose:" JLabel in this dialog.
073: * @return JLabelOperator
074: */
075: public JLabelOperator lblDescribeTheCopyPurpose() {
076: if (_lblDescribeTheCopyPurpose == null) {
077: _lblDescribeTheCopyPurpose = new JLabelOperator(this ,
078: "Copy Description");
079: }
080: return _lblDescribeTheCopyPurpose;
081: }
082:
083: /** Tries to find "Repository Folder:" JLabel in this dialog.
084: * @return JLabelOperator
085: */
086: public JRadioButtonOperator rbLocalFolder() {
087: if (_rbLocalFolder == null) {
088: _rbLocalFolder = new JRadioButtonOperator(this ,
089: "Local Folder");
090: }
091: return _rbLocalFolder;
092: }
093:
094: public JRadioButtonOperator rbRemoteFolder() {
095: if (_rbRemoteFolder == null) {
096: _rbRemoteFolder = new JRadioButtonOperator(this ,
097: "Remote Folder");
098: }
099: return _rbRemoteFolder;
100: }
101:
102: /** Tries to find null JComboBox in this dialog.
103: * @return JComboBoxOperator
104: */
105: public JComboBoxOperator cboJComboBox() {
106: if (_cboJComboBox == null) {
107: _cboJComboBox = new JComboBoxOperator(this );
108: }
109: return _cboJComboBox;
110: }
111:
112: /** Tries to find "Browse..." JButton in this dialog.
113: * @return JButtonOperator
114: */
115: public JButtonOperator btBrowse() {
116: if (_btBrowse == null) {
117: _btBrowse = new JButtonOperator(this , "Browse...");
118: }
119: return _btBrowse;
120: }
121:
122: /** Tries to find "Switch to Copy" JCheckBox in this dialog.
123: * @return JCheckBoxOperator
124: */
125: public JCheckBoxOperator cbSwitchToCopy() {
126: if (_cbSwitchToCopy == null) {
127: _cbSwitchToCopy = new JCheckBoxOperator(this ,
128: "Switch to Copy");
129: }
130: return _cbSwitchToCopy;
131: }
132:
133: /** Tries to find "Skip" JCheckBox in this dialog.
134: * @return JCheckBoxOperator
135: */
136: public JCheckBoxOperator cbSkip() {
137: if (_cbSkip == null) {
138: _cbSkip = new JCheckBoxOperator(this , "Skip");
139: }
140: return _cbSkip;
141: }
142:
143: /** Tries to find "Warning - there are localy modified files!" JLabel in this dialog.
144: * @return JLabelOperator
145: */
146: public JLabelOperator lblWarningMessage() {
147: if (_lblWarningMessage == null) {
148: _lblWarningMessage = new JLabelOperator(this , 2);
149: }
150: return _lblWarningMessage;
151: }
152:
153: /** Tries to find "Copy" JButton in this dialog.
154: * @return JButtonOperator
155: */
156: public JButtonOperator btCopy() {
157: if (_btCopy == null) {
158: _btCopy = new JButtonOperator(this , "Copy");
159: }
160: return _btCopy;
161: }
162:
163: /** Tries to find "Cancel" JButton in this dialog.
164: * @return JButtonOperator
165: */
166: public JButtonOperator btCancel() {
167: if (_btCancel == null) {
168: _btCancel = new JButtonOperator(this , "Cancel");
169: }
170: return _btCancel;
171: }
172:
173: /** Tries to find "Help" JButton in this dialog.
174: * @return JButtonOperator
175: */
176: public JButtonOperator btHelp() {
177: if (_btHelp == null) {
178: _btHelp = new JButtonOperator(this , "Help");
179: }
180: return _btHelp;
181: }
182:
183: //****************************************
184: // Low-level functionality definition part
185: //****************************************
186:
187: /** gets text for txtJTextArea
188: * @return String text
189: */
190: public String getCopyPurpose() {
191: return txtJTextArea().getText();
192: }
193:
194: /** sets text for txtJTextArea
195: * @param text String text
196: */
197: public void setCopyPurpose(String text) {
198: txtJTextArea().clearText();
199: txtJTextArea().typeText(text);
200: }
201:
202: /** returns selected item for cboJComboBox
203: * @return String item
204: */
205: public String getSelectedRepositoryFolder() {
206: return cboJComboBox().getSelectedItem().toString();
207: }
208:
209: public String getRepositoryFolder() {
210: return cboJComboBox().getEditor().getItem().toString();
211: }
212:
213: /** selects item for cboJComboBox
214: * @param item String item
215: */
216: public void selectJComboBox(String item) {
217: cboJComboBox().selectItem(item);
218: }
219:
220: /** types text for cboJComboBox
221: * @param text String text
222: */
223: public void setRepositoryFolder(String text) {
224: cboJComboBox().clearText();
225: cboJComboBox().typeText(text);
226: }
227:
228: /** clicks on "Browse..." JButton
229: */
230: public RepositoryBrowserImpOperator browseRepository() {
231: btBrowse().pushNoBlock();
232: return new RepositoryBrowserImpOperator();
233: }
234:
235: /** checks or unchecks given JCheckBox
236: * @param state boolean requested state
237: */
238: public void checkSwitchToCopy(boolean state) {
239: if (cbSwitchToCopy().isSelected() != state) {
240: cbSwitchToCopy().push();
241: }
242: }
243:
244: /** clicks on "Copy" JButton
245: */
246: public void copy() {
247: btCopy().push();
248: }
249:
250: /** clicks on "Cancel" JButton
251: */
252: public void cancel() {
253: btCancel().push();
254: }
255:
256: /** clicks on "Help" JButton
257: */
258: public void help() {
259: btHelp().push();
260: }
261:
262: //*****************************************
263: // High-level functionality definition part
264: //*****************************************
265:
266: /**
267: * Performs verification of CopyToOperator by accessing all its components.
268: */
269: public void verify() {
270: txtJTextArea();
271: lblDescribeTheCopyPurpose();
272: rbLocalFolder();
273: rbRemoteFolder();
274: cboJComboBox();
275: btBrowse();
276: cbSwitchToCopy();
277: cbSkip();
278: btCopy();
279: btCancel();
280: btHelp();
281: }
282: }
|