KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > test > subversion > operators > CopyToOperator


1 /*
2  * CopyToOperator.java
3  *
4  * Created on 16/05/06 11:11
5  */

6 package org.netbeans.test.subversion.operators;
7
8 import org.netbeans.jellytools.NbDialogOperator;
9 import org.netbeans.jellytools.nodes.Node;
10 import org.netbeans.jemmy.operators.*;
11 import org.netbeans.test.subversion.operators.actions.CopyAction;
12
13 /** Class implementing all necessary methods for handling "Copy to..." NbDialog.
14  *
15  * @author peter
16  * @version 1.0
17  */

18 public class CopyToOperator extends NbDialogOperator {
19
20     /**
21      * Creates new CopyToOperator that can handle it.
22      */

23     public CopyToOperator() {
24         super("Copy");
25     }
26     
27     /** Selects nodes and call copy action on them.
28      * @param nodes an array of nodes
29      * @return CopyToOperator instance
30      */

31     public static CopyToOperator invoke(Node[] nodes) {
32         new CopyAction().perform(nodes);
33         return new CopyToOperator();
34     }
35     
36     /** Selects node and call copy action on it.
37      * @param node node to be selected
38      * @return CommitOperator instance
39      */

40     public static CopyToOperator invoke(Node node) {
41         return invoke(new Node[] {node});
42     }
43
44     private JTextAreaOperator _txtJTextArea;
45     private JRadioButtonOperator _rbLocalFolder;
46     private JRadioButtonOperator _rbRemoteFolder;
47     private JLabelOperator _lblDescribeTheCopyPurpose;
48     private JLabelOperator _lblRepositoryFolder;
49     private JComboBoxOperator _cboJComboBox;
50     private JButtonOperator _btBrowse;
51     private JCheckBoxOperator _cbSwitchToCopy;
52     private JCheckBoxOperator _cbSkip;
53     private JLabelOperator _lblWarningMessage;
54     private JButtonOperator _btCopy;
55     private JButtonOperator _btCancel;
56     private JButtonOperator _btHelp;
57
58
59     //******************************
60
// Subcomponents definition part
61
//******************************
62

63     /** Tries to find null JTextArea in this dialog.
64      * @return JTextAreaOperator
65      */

66     public JTextAreaOperator txtJTextArea() {
67         if (_txtJTextArea==null) {
68             _txtJTextArea = new JTextAreaOperator(this);
69         }
70         return _txtJTextArea;
71     }
72
73     /** Tries to find "Describe the copy purpose:" JLabel in this dialog.
74      * @return JLabelOperator
75      */

76     public JLabelOperator lblDescribeTheCopyPurpose() {
77         if (_lblDescribeTheCopyPurpose==null) {
78             _lblDescribeTheCopyPurpose = new JLabelOperator(this, "Copy Description");
79         }
80         return _lblDescribeTheCopyPurpose;
81     }
82
83     /** Tries to find "Repository Folder:" JLabel in this dialog.
84      * @return JLabelOperator
85      */

86     public JRadioButtonOperator rbLocalFolder() {
87         if (_rbLocalFolder == null) {
88             _rbLocalFolder = new JRadioButtonOperator(this, "Local Folder");
89         }
90         return _rbLocalFolder;
91     }
92     
93     public JRadioButtonOperator rbRemoteFolder() {
94         if (_rbRemoteFolder == null) {
95             _rbRemoteFolder = new JRadioButtonOperator(this, "Remote Folder");
96         }
97         return _rbRemoteFolder;
98     }
99
100     /** Tries to find null JComboBox in this dialog.
101      * @return JComboBoxOperator
102      */

103     public JComboBoxOperator cboJComboBox() {
104         if (_cboJComboBox==null) {
105             _cboJComboBox = new JComboBoxOperator(this);
106         }
107         return _cboJComboBox;
108     }
109
110     /** Tries to find "Browse..." JButton in this dialog.
111      * @return JButtonOperator
112      */

113     public JButtonOperator btBrowse() {
114         if (_btBrowse==null) {
115             _btBrowse = new JButtonOperator(this, "Browse...");
116         }
117         return _btBrowse;
118     }
119
120     /** Tries to find "Switch to Copy" JCheckBox in this dialog.
121      * @return JCheckBoxOperator
122      */

123     public JCheckBoxOperator cbSwitchToCopy() {
124         if (_cbSwitchToCopy==null) {
125             _cbSwitchToCopy = new JCheckBoxOperator(this, "Switch to Copy");
126         }
127         return _cbSwitchToCopy;
128     }
129     
130     /** Tries to find "Skip" JCheckBox in this dialog.
131      * @return JCheckBoxOperator
132      */

133     public JCheckBoxOperator cbSkip() {
134         if (_cbSkip==null) {
135             _cbSkip = new JCheckBoxOperator(this, "Skip");
136         }
137         return _cbSkip;
138     }
139
140     /** Tries to find "Warning - there are localy modified files!" JLabel in this dialog.
141      * @return JLabelOperator
142      */

143     public JLabelOperator lblWarningMessage() {
144         if (_lblWarningMessage==null) {
145             _lblWarningMessage = new JLabelOperator(this, 2);
146         }
147         return _lblWarningMessage;
148     }
149
150     /** Tries to find "Copy" JButton in this dialog.
151      * @return JButtonOperator
152      */

153     public JButtonOperator btCopy() {
154         if (_btCopy==null) {
155             _btCopy = new JButtonOperator(this, "Copy");
156         }
157         return _btCopy;
158     }
159
160     /** Tries to find "Cancel" JButton in this dialog.
161      * @return JButtonOperator
162      */

163     public JButtonOperator btCancel() {
164         if (_btCancel==null) {
165             _btCancel = new JButtonOperator(this, "Cancel");
166         }
167         return _btCancel;
168     }
169
170     /** Tries to find "Help" JButton in this dialog.
171      * @return JButtonOperator
172      */

173     public JButtonOperator btHelp() {
174         if (_btHelp==null) {
175             _btHelp = new JButtonOperator(this, "Help");
176         }
177         return _btHelp;
178     }
179
180
181     //****************************************
182
// Low-level functionality definition part
183
//****************************************
184

185     /** gets text for txtJTextArea
186      * @return String text
187      */

188     public String JavaDoc getCopyPurpose() {
189         return txtJTextArea().getText();
190     }
191
192     /** sets text for txtJTextArea
193      * @param text String text
194      */

195     public void setCopyPurpose(String JavaDoc text) {
196         txtJTextArea().clearText();
197         txtJTextArea().typeText(text);
198     }
199
200     
201     /** returns selected item for cboJComboBox
202      * @return String item
203      */

204     public String JavaDoc getSelectedRepositoryFolder() {
205         return cboJComboBox().getSelectedItem().toString();
206     }
207     
208     public String JavaDoc getRepositoryFolder() {
209         return cboJComboBox().getEditor().getItem().toString();
210     }
211
212     /** selects item for cboJComboBox
213      * @param item String item
214      */

215     public void selectJComboBox(String JavaDoc item) {
216         cboJComboBox().selectItem(item);
217     }
218
219     /** types text for cboJComboBox
220      * @param text String text
221      */

222     public void setRepositoryFolder(String JavaDoc text) {
223         cboJComboBox().clearText();
224         cboJComboBox().typeText(text);
225     }
226
227     /** clicks on "Browse..." JButton
228      */

229     public RepositoryBrowserImpOperator browseRepository() {
230         btBrowse().pushNoBlock();
231         return new RepositoryBrowserImpOperator();
232     }
233
234     /** checks or unchecks given JCheckBox
235      * @param state boolean requested state
236      */

237     public void checkSwitchToCopy(boolean state) {
238         if (cbSwitchToCopy().isSelected()!=state) {
239             cbSwitchToCopy().push();
240         }
241     }
242
243     /** clicks on "Copy" JButton
244      */

245     public void copy() {
246         btCopy().push();
247     }
248
249     /** clicks on "Cancel" JButton
250      */

251     public void cancel() {
252         btCancel().push();
253     }
254
255     /** clicks on "Help" JButton
256      */

257     public void help() {
258         btHelp().push();
259     }
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 }
283
284
Popular Tags