KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.test.subversion.operators;
20
21 import org.netbeans.jellytools.NbDialogOperator;
22 import org.netbeans.jellytools.nodes.Node;
23 import org.netbeans.jemmy.operators.JButtonOperator;
24 import org.netbeans.jemmy.operators.JComboBoxOperator;
25 import org.netbeans.jemmy.operators.JLabelOperator;
26 import org.netbeans.jemmy.operators.JTableOperator;
27 import org.netbeans.jemmy.operators.JTextAreaOperator;
28 import org.netbeans.test.subversion.operators.actions.CommitAction;
29
30
31 /** Class implementing all necessary methods for handling "Commit" dialog.
32  * <br>
33  * Usage:<br>
34  * <pre>
35  * new CommitAction().perform(node);
36  * CommitOperator co = new CommitOperator();
37  * co.setCommitMessage("Commit message.");
38  * co.selectCommitAction("MyFile", "Exclude from Commit");
39  * co.commit();
40  * </pre>
41  *
42  * @see VersioningOperator
43  * @see org.netbeans.jellytools.modules.javacvs.actions.CommitAction
44  * @see org.netbeans.jellytools.modules.javacvs.actions.ShowChangesAction
45  *
46  */

47 public class CommitOperator extends NbDialogOperator {
48
49     /** Waits for "Commit" dialog. It can have title "Commit - <object>"
50      * or "Commit files" if there is no file to commit.
51      */

52     public CommitOperator() {
53         super("Commit");
54     }
55
56     /** Selects nodes and call commit action on them.
57      * @param nodes an array of nodes
58      * @return CommitOperator instance
59      */

60     public static CommitOperator invoke(Node[] nodes) {
61         new CommitAction().perform(nodes);
62         return new CommitOperator();
63     }
64     
65     /** Selects node and call commit action on it.
66      * @param node node to be selected
67      * @return CommitOperator instance
68      */

69     public static CommitOperator invoke(Node node) {
70         return invoke(new Node[] {node});
71     }
72     
73     private JLabelOperator _lblCommitMessage;
74     private JTextAreaOperator _txtCommitMessage;
75     private JLabelOperator _lblFilesToCommit;
76     private JTableOperator _tabFiles;
77     private JButtonOperator _btCommit;
78     private JButtonOperator _btCancel;
79     private JButtonOperator _btHelp;
80
81     //******************************
82
// Subcomponents definition part
83
//******************************
84

85     /** Tries to find "Commit Message:" JLabel in this dialog.
86      * @return JLabelOperator
87      */

88     public JLabelOperator lblCommitMessage() {
89         if (_lblCommitMessage==null) {
90             _lblCommitMessage = new JLabelOperator(this, "Commit Message");
91         }
92         return _lblCommitMessage;
93     }
94
95     /** Tries to find "Commit Message:" TextArea in this dialog.
96      * @return JTextAreaOperator
97      */

98     public JTextAreaOperator txtCommitMessage() {
99         if (_txtCommitMessage==null) {
100             _txtCommitMessage = new JTextAreaOperator(this);
101         }
102         return _txtCommitMessage;
103     }
104
105     /** Tries to find "Files to Commit:" JLabel in this dialog.
106      * @return JLabelOperator
107      */

108     public JLabelOperator lblFilesToCommit() {
109         if (_lblFilesToCommit==null) {
110             _lblFilesToCommit = new JLabelOperator(this, "Files to Commit");
111         }
112         return _lblFilesToCommit;
113     }
114
115     /** Tries to find files JTable in this dialog.
116      * @return JTableOperator
117      */

118     public JTableOperator tabFiles() {
119         if (_tabFiles==null) {
120             _tabFiles = new JTableOperator(this);
121         }
122         return _tabFiles;
123     }
124
125     /** Tries to find "Commit" JButton in this dialog.
126      * @return JButtonOperator
127      */

128     public JButtonOperator btCommit() {
129         if (_btCommit==null) {
130             _btCommit = new JButtonOperator(this, "Commit");
131         }
132         return _btCommit;
133     }
134
135     /** Tries to find "Cancel" JButton in this dialog.
136      * @return JButtonOperator
137      */

138     public JButtonOperator btCancel() {
139         if (_btCancel==null) {
140             _btCancel = new JButtonOperator(this, "Cancel");
141         }
142         return _btCancel;
143     }
144     
145     /** Tries to find "Help" JButton in this dialog.
146      * @return JButtonOperator
147      */

148     public JButtonOperator btHelp() {
149         if (_btHelp==null) {
150             _btHelp = new JButtonOperator(this, "Help");
151         }
152         return _btHelp;
153     }
154
155     //****************************************
156
// Low-level functionality definition part
157
//****************************************
158

159     /** gets text for txtCommitMessage
160      * @return String text
161      */

162     public String JavaDoc getCommitMessage() {
163         return txtCommitMessage().getText();
164     }
165
166     /** sets text for txtCommitMessage
167      * @param text String text
168      */

169     public void setCommitMessage(String JavaDoc text) {
170         txtCommitMessage().clearText();
171         txtCommitMessage().typeText(text);
172     }
173
174     /** clicks on "Commit" JButton
175      */

176     public void commit() {
177         btCommit().push();
178     }
179
180     /** Selects specified commit action for given row.
181      * @param rowIndex index of row to be selected
182      * @param action name of action to be selected
183      */

184     public void selectCommitAction(int rowIndex, String JavaDoc action) {
185         tabFiles().clickOnCell(rowIndex, 2);
186         JComboBoxOperator combo = new JComboBoxOperator(tabFiles());
187         combo.selectItem(action);
188     }
189
190     /** Selects specified commit action for given row.
191      * @param filename name of file to be selected
192      * @param action name of action to be selected
193      */

194     public void selectCommitAction(String JavaDoc filename, String JavaDoc action) {
195         selectCommitAction(tabFiles().findCellRow(filename), action);
196     }
197
198     //*****************************************
199
// High-level functionality definition part
200
//*****************************************
201

202     /** Performs verification of CommitOperator by accessing all its components.
203      */

204     public void verify() {
205         lblCommitMessage();
206         txtCommitMessage();
207 // lblFilesToCommit();
208
tabFiles();
209         btCommit();
210         btCancel();
211         btHelp();
212     }
213 }
214
Popular Tags