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