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 abstract class implements test functionality for the dialog "Table Layout".
051: */
052: public abstract class GeneralTableLayoutOperator extends
053: NbDialogOperator {
054: /**
055: * Constructor of this class.
056: */
057: public GeneralTableLayoutOperator() {
058: super (getBundleString("tblLayout"));
059: }
060:
061: private JTabbedPaneOperator _tbpLayout;
062:
063: private JButtonOperator _btApply;
064: private JButtonOperator _btNew;
065: private JButtonOperator _btUp;
066: private JButtonOperator _btDown;
067: private JButtonOperator _btAdd;
068: private JButtonOperator _btRemove;
069: private JButtonOperator _btRemoveAll;
070: private JListOperator _lstAvailable;
071: private JListOperator _lstDisplayed;
072: private JTextFieldOperator _txtHeader;
073: private JTextFieldOperator _txtFooter;
074: private JTextFieldOperator _txtValue;
075: protected JComboBoxOperator _cboSource;
076: protected JComboBoxOperator _cboComponentType;
077:
078: /**
079: * Initializes (if necessary) and returns an object JTabbedPaneOperator
080: * for the dialog tabbed pane.
081: * @return the appropriate object JTabbedPaneOperator
082: */
083: public JTabbedPaneOperator tbpLayout() {
084: if (_tbpLayout == null) {
085: _tbpLayout = new JTabbedPaneOperator(this );
086: }
087: return _tbpLayout;
088: }
089:
090: /**
091: * Initializes (if necessary) and returns an object JButtonOperator
092: * for the dialog button "Apply".
093: * @return the appropriate object JButtonOperator
094: */
095: public JButtonOperator btApply() {
096: if (_btApply == null) {
097: _btApply = new JButtonOperator(this , Bundle
098: .getStringTrimmed("com.sun.jsfcl.binding.Bundle",
099: "apply"));
100: }
101: return _btApply;
102: }
103:
104: /**
105: * Initializes (if necessary) and returns an object JButtonOperator
106: * for the dialog button "New".
107: * @return the appropriate object JButtonOperator
108: */
109: public JButtonOperator btNew() {
110: if (_btNew == null) {
111: _btNew = new JButtonOperator(this , getBundleString("new"));
112: }
113: return _btNew;
114: }
115:
116: /**
117: * Initializes (if necessary) and returns an object JButtonOperator
118: * for the dialog button "Up".
119: * @return the appropriate object JButtonOperator
120: */
121: public JButtonOperator btUp() {
122: if (_btUp == null) {
123: _btUp = new JButtonOperator(this , getBundleString("up"));
124: }
125: return _btUp;
126: }
127:
128: /**
129: * Initializes (if necessary) and returns an object JButtonOperator
130: * for the dialog button "Down".
131: * @return the appropriate object JButtonOperator
132: */
133: public JButtonOperator btDown() {
134: if (_btDown == null) {
135: _btDown = new JButtonOperator(this , getBundleString("down"));
136: }
137: return _btDown;
138: }
139:
140: /**
141: * Initializes (if necessary) and returns an object JButtonOperator
142: * for the dialog button "Add".
143: * @return the appropriate object JButtonOperator
144: */
145: public JButtonOperator btAdd() {
146: if (_btAdd == null) {
147: _btAdd = new JButtonOperator(this , ">");
148: }
149: return _btAdd;
150: }
151:
152: /**
153: * Initializes (if necessary) and returns an object JButtonOperator
154: * for the dialog button "<".
155: * @return the appropriate object JButtonOperator
156: */
157: public JButtonOperator btRemove() {
158: if (_btRemove == null) {
159: _btRemove = new JButtonOperator(this , "<");
160: }
161: return _btRemove;
162: }
163:
164: /**
165: * Initializes (if necessary) and returns an object JButtonOperator
166: * for the dialog button "<<".
167: * @return the appropriate object JButtonOperator
168: */
169: public JButtonOperator btRemoveAll() {
170: if (_btRemoveAll == null) {
171: _btRemoveAll = new JButtonOperator(this , "<<");
172: }
173: return _btRemoveAll;
174: }
175:
176: /**
177: * Initializes (if necessary) and returns an object JListOperator
178: * for the dialog list "Available".
179: * @return the appropriate object JListOperator
180: */
181: public JListOperator lstAvailable() {
182: if (_lstAvailable == null) {
183: _lstAvailable = new JListOperator(this , 0);
184: }
185: return _lstAvailable;
186: }
187:
188: /**
189: * Initializes (if necessary) and returns an object JListOperator
190: * for the dialog list "Displayed".
191: * @return the appropriate object JListOperator
192: */
193: public JListOperator lstDisplayed() {
194: if (_lstDisplayed == null) {
195: _lstDisplayed = new JListOperator(this , 1);
196: }
197: return _lstDisplayed;
198: }
199:
200: /**
201: * Initializes (if necessary) and returns an object JTextFieldOperator
202: * for the dialog text field "Header".
203: * @return the appropriate object JTextFieldOperator
204: */
205: public JTextFieldOperator txtHeader() {
206: if (_txtHeader == null) {
207: _txtHeader = new JTextFieldOperator(this , 0);
208: }
209: return _txtHeader;
210: }
211:
212: /**
213: * Initializes (if necessary) and returns an object JTextFieldOperator
214: * for the dialog text field "Footer".
215: * @return the appropriate object JTextFieldOperator
216: */
217: public JTextFieldOperator txtFooter() {
218: if (_txtFooter == null) {
219: _txtFooter = new JTextFieldOperator(this , 1);
220: }
221: return _txtFooter;
222: }
223:
224: /**
225: * Initializes (if necessary) and returns an object JTextFieldOperator
226: * for the dialog text field "Value".
227: * @return the appropriate object JTextFieldOperator
228: */
229: public JTextFieldOperator txtValue() {
230: if (_txtValue == null) {
231: _txtValue = new JTextFieldOperator(this , 2);
232: }
233: return _txtValue;
234: }
235:
236: /**
237: * Initializes (if necessary) and returns an object JComboBoxOperator
238: * for the dialog drop-down list "Source".
239: * @return the appropriate object JComboBoxOperator
240: */
241: public JComboBoxOperator cboSource() {
242: if (_cboSource == null) {
243: _cboSource = new JComboBoxOperator(this , 0);
244: }
245: return _cboSource;
246: }
247:
248: /**
249: * Initializes (if necessary) and returns an object JComboBoxOperator
250: * for the dialog drop-down list "Component Type".
251: * @return the appropriate object JComboBoxOperator
252: */
253: public JComboBoxOperator cboComponentType() {
254: if (_cboComponentType == null) {
255: _cboComponentType = new JComboBoxOperator(this , 1);
256: }
257: return _cboComponentType;
258: }
259:
260: /**
261: * Select the tab "Columns" in the tabbed pane.
262: */
263: public void selectColumnsTab() {
264: tbpLayout().selectPage(getBundleString("cols"));
265: }
266:
267: /**
268: * Finds in a bundle file and returns an actual text of control component.
269: * @param p_text string-key corresponding to required control component.
270: * @return actual text of control component
271: */
272: public static String getBundleString(String p_text) {
273: System.out.println("Getting bundle for " + p_text);
274: try {
275: return Bundle.getStringTrimmed(
276: "com.sun.jsfcl.std.table.Bundle", p_text);
277: } catch (JemmyException e) {
278: }
279: return null;
280: }
281:
282: /**
283: * Initializes all necessary controls.
284: */
285: public void verify() {
286: btOK();
287: btApply();
288: btCancel();
289: btHelp();
290:
291: selectColumnsTab();
292:
293: btUp();
294: btDown();
295: btNew();
296: btAdd();
297: btRemove();
298: btRemoveAll();
299: lstAvailable();
300: lstDisplayed();
301: txtFooter();
302: txtValue();
303: cboSource();
304: cboComponentType();
305: }
306:
307: /**
308: * Adds new column to the table.
309: * @param column a column name
310: */
311: public void addColumn(String column) {
312: lstAvailable().selectItem(column);
313: btAdd().push();
314: }
315:
316: /**
317: * Removes a column from the table.
318: * @param column a column name
319: */
320: public void removeColumn(String column) {
321: lstDisplayed().selectItem(column);
322: btRemove().push();
323: }
324:
325: /**
326: * Removes all columns from the table.
327: */
328: public void removeAllColumns() {
329: btRemoveAll().push();
330: }
331: }
|