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-2007 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:
042: package org.netbeans.modules.visualweb.gravy.designer;
043:
044: import org.netbeans.jellytools.Bundle;
045: import org.netbeans.jellytools.NbDialogOperator;
046: import org.netbeans.jemmy.JemmyException;
047: import org.netbeans.jemmy.operators.*;
048:
049: /**
050: * This class implements test functionality for the dialog "Table Layout".
051: */
052: public class TableLayoutOperator extends GeneralTableLayoutOperator {
053: /**
054: * Creates an instance of this class.
055: */
056: public TableLayoutOperator() {
057: super ();
058: }
059:
060: /**
061: * Creates and returns an instance of this class via using
062: * the appropriate item of a poup menu.
063: * @param menu a popup menu, related to a table
064: * @return a new created object TableLayoutOperator
065: */
066: public static TableLayoutOperator invoke(JPopupMenuOperator menu) {
067: menu.pushMenuNoBlock("tblLayoutEllipse");
068: return new TableLayoutOperator();
069: }
070:
071: private JButtonOperator _btBrowseFirst;
072: private JButtonOperator _btBrowsePrevious;
073: private JButtonOperator _btBrowseNext;
074: private JButtonOperator _btBrowseLast;
075: private JTextFieldOperator _txtPageSize;
076: private JTextFieldOperator _txtFirst;
077: private JTextFieldOperator _txtPrevious;
078: private JTextFieldOperator _txtNext;
079: private JTextFieldOperator _txtLast;
080: private JComboBoxOperator _cboPosition;
081: private JComboBoxOperator _cboAlignment;
082: private JComboBoxOperator _cboNavigation;
083: private JCheckBoxOperator _cbEnable;
084: private JCheckBoxOperator _cbFirst;
085: private JCheckBoxOperator _cbPrevious;
086: private JCheckBoxOperator _cbNext;
087: private JCheckBoxOperator _cbLast;
088:
089: /**
090: * Initializes (if necessary) and returns an object JButtonOperator
091: * for the dialog button "<<".
092: * @return the appropriate object JButtonOperator
093: */
094: public JButtonOperator btBrowseFirst() {
095: if (_btBrowseFirst == null) {
096: _btBrowseFirst = new JButtonOperator(this ,
097: getBundleString("browseEllipse"), 0);
098: }
099: return _btBrowseFirst;
100: }
101:
102: /**
103: * Initializes (if necessary) and returns an object JButtonOperator
104: * for the dialog button "<".
105: * @return the appropriate object JButtonOperator
106: */
107: public JButtonOperator btBrowsePrevious() {
108: if (_btBrowsePrevious == null) {
109: _btBrowsePrevious = new JButtonOperator(this ,
110: getBundleString("browseEllipse"), 1);
111: }
112: return _btBrowsePrevious;
113: }
114:
115: /**
116: * Initializes (if necessary) and returns an object JButtonOperator
117: * for the dialog button ">".
118: * @return the appropriate object JButtonOperator
119: */
120: public JButtonOperator btBrowseNext() {
121: if (_btBrowseNext == null) {
122: _btBrowseNext = new JButtonOperator(this ,
123: getBundleString("browseEllipse"), 2);
124: }
125: return _btBrowseNext;
126: }
127:
128: /**
129: * Initializes (if necessary) and returns an object JButtonOperator
130: * for the dialog button ">>".
131: * @return the appropriate object JButtonOperator
132: */
133: public JButtonOperator btBrowseLast() {
134: if (_btBrowseLast == null) {
135: _btBrowseLast = new JButtonOperator(this ,
136: getBundleString("browseEllipse"), 3);
137: }
138: return _btBrowseLast;
139: }
140:
141: /**
142: * Initializes (if necessary) and returns an object JTextFieldOperator
143: * for the dialog text field "Page Size".
144: * @return the appropriate object JTextFieldOperator
145: */
146: public JTextFieldOperator txtPageSize() {
147: if (_txtPageSize == null) {
148: _txtPageSize = new JTextFieldOperator(this , 0);
149: }
150: return _txtPageSize;
151: }
152:
153: /**
154: * Initializes (if necessary) and returns an object JTextFieldOperator
155: * for the dialog text field "First".
156: * @return the appropriate object JTextFieldOperator
157: */
158: public JTextFieldOperator txtFirst() {
159: if (_txtFirst == null) {
160: _txtFirst = new JTextFieldOperator(this , 1);
161: }
162: return _txtFirst;
163: }
164:
165: /**
166: * Initializes (if necessary) and returns an object JTextFieldOperator
167: * for the dialog text field "Previous".
168: * @return the appropriate object JTextFieldOperator
169: */
170: public JTextFieldOperator txtPrevious() {
171: if (_txtPrevious == null) {
172: _txtPrevious = new JTextFieldOperator(this , 2);
173: }
174: return _txtPrevious;
175: }
176:
177: /**
178: * Initializes (if necessary) and returns an object JTextFieldOperator
179: * for the dialog text field "Next".
180: * @return the appropriate object JTextFieldOperator
181: */
182: public JTextFieldOperator txtNext() {
183: if (_txtNext == null) {
184: _txtNext = new JTextFieldOperator(this , 3);
185: }
186: return _txtNext;
187: }
188:
189: /**
190: * Initializes (if necessary) and returns an object JTextFieldOperator
191: * for the dialog text field "Last".
192: * @return the appropriate object JTextFieldOperator
193: */
194: public JTextFieldOperator txtLast() {
195: if (_txtLast == null) {
196: _txtLast = new JTextFieldOperator(this , 4);
197: }
198: return _txtLast;
199: }
200:
201: /**
202: * Initializes (if necessary) and returns an object JCheckBoxOperator
203: * for the dialog check-box "Enable".
204: * @return the appropriate object JCheckBoxOperator
205: */
206: public JCheckBoxOperator cbEnable() {
207: if (_cbEnable == null) {
208: _cbEnable = new JCheckBoxOperator(this ,
209: getBundleString("enablePaging"));
210: }
211: return _cbEnable;
212: }
213:
214: /**
215: * Initializes (if necessary) and returns an object JCheckBoxOperator
216: * for the dialog check-box "First".
217: * @return the appropriate object JCheckBoxOperator
218: */
219: public JCheckBoxOperator cbFirst() {
220: if (_cbFirst == null) {
221: _cbFirst = new JCheckBoxOperator(this ,
222: getBundleString("firstPage"));
223: }
224: return _cbFirst;
225: }
226:
227: /**
228: * Initializes (if necessary) and returns an object JCheckBoxOperator
229: * for the dialog check-box "Previous".
230: * @return the appropriate object JCheckBoxOperator
231: */
232: public JCheckBoxOperator cbPrevious() {
233: if (_cbPrevious == null) {
234: _cbPrevious = new JCheckBoxOperator(this ,
235: getBundleString("prevPage"));
236: }
237: return _cbPrevious;
238: }
239:
240: /**
241: * Initializes (if necessary) and returns an object JCheckBoxOperator
242: * for the dialog check-box "Next".
243: * @return the appropriate object JCheckBoxOperator
244: */
245: public JCheckBoxOperator cbNext() {
246: if (_cbNext == null) {
247: _cbNext = new JCheckBoxOperator(this ,
248: getBundleString("nextPage"));
249: }
250: return _cbNext;
251: }
252:
253: /**
254: * Initializes (if necessary) and returns an object JCheckBoxOperator
255: * for the dialog check-box "Last".
256: * @return the appropriate object JCheckBoxOperator
257: */
258: public JCheckBoxOperator cbLast() {
259: if (_cbLast == null) {
260: _cbLast = new JCheckBoxOperator(this ,
261: getBundleString("lastPage"));
262: }
263: return _cbLast;
264: }
265:
266: /**
267: * Initializes (if necessary) and returns an object JComboBoxOperator
268: * for the dialog drop-down list "Navigation".
269: * @return the appropriate object JComboBoxOperator
270: */
271: public JComboBoxOperator cboNavigation() {
272: if (_cboNavigation == null) {
273: _cboNavigation = new JComboBoxOperator(this , 0);
274: }
275: return _cboNavigation;
276: }
277:
278: /**
279: * Initializes (if necessary) and returns an object JComboBoxOperator
280: * for the dialog drop-down list "Position".
281: * @return the appropriate object JComboBoxOperator
282: */
283: public JComboBoxOperator cboPosition() {
284: if (_cboPosition == null) {
285: _cboPosition = new JComboBoxOperator(this , 1);
286: }
287: return _cboPosition;
288: }
289:
290: /**
291: * Initializes (if necessary) and returns an object JComboBoxOperator
292: * for the dialog drop-down list "Alignment".
293: * @return the appropriate object JComboBoxOperator
294: */
295: public JComboBoxOperator cboAlignment() {
296: if (_cboAlignment == null) {
297: _cboAlignment = new JComboBoxOperator(this , 2);
298: }
299: return _cboAlignment;
300: }
301:
302: /**
303: * Select the tab "Paging" in the tabbed pane.
304: */
305: public void selectPagingTab() {
306: tbpLayout().selectPage(getBundleString("paging"));
307: }
308:
309: /**
310: * Initializes all necessary controls.
311: */
312: public void verify() {
313:
314: super .verify();
315:
316: selectPagingTab();
317:
318: btBrowseFirst();
319: btBrowsePrevious();
320: btBrowseNext();
321: btBrowseLast();
322: cboNavigation();
323: cboPosition();
324: cboAlignment();
325: cbEnable();
326: cbFirst();
327: cbPrevious();
328: cbNext();
329: cbLast();
330: txtPageSize();
331: txtFirst();
332: txtPrevious();
333: txtNext();
334: txtLast();
335:
336: selectColumnsTab();
337: }
338:
339: /**
340: * Finds in a bundle file and returns an actual text of control component.
341: * @param p_text string-key corresponding to required control component.
342: * @return actual text of control component
343: */
344: public static String getBundleString(String p_text) {
345: System.out.println("Getting bundle for " + p_text);
346: try {
347: return Bundle.getStringTrimmed(
348: "com.sun.jsfcl.std.table.Bundle", p_text);
349: } catch (JemmyException e) {
350: }
351: return null;
352: }
353: }
|