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.properties.editors;
043:
044: /*
045: * FontCustomEditorOperator.java
046: *
047: * Created on 6/13/02 4:29 PM
048: */
049:
050: import javax.swing.JDialog;
051: import org.netbeans.jellytools.Bundle;
052: import org.netbeans.modules.visualweb.gravy.NbDialogOperator;
053: import org.netbeans.jemmy.operators.*;
054:
055: /** Class implementing all necessary methods for handling Font Custom Editor
056: */
057: public class FontCustomEditorOperator extends NbDialogOperator {
058:
059: /** Creates new FontCustomEditorOperator
060: * @throws TimeoutExpiredException when NbDialog not found
061: * @param title String title of custom editor */
062: public FontCustomEditorOperator(String title) {
063: super (title);
064: }
065:
066: /** Creates a new instance of FontCustomEditorOperator
067: * @param wrapper JDialogOperator wrapper for custom editor */
068: public FontCustomEditorOperator(JDialogOperator wrapper) {
069: super ((JDialog) wrapper.getSource());
070: }
071:
072: private JListOperator _lstFontName;
073: private JListOperator _lstFontSize;
074: private JTextFieldOperator _txtFontName;
075: private JTextFieldOperator _txtFontSize;
076: private JTextFieldOperator _txtFontStyle;
077: private JListOperator _lstFontStyle;
078: /** String constant for plain font style */
079: public static final String STYLE_PLAIN = Bundle.getString(
080: "org.netbeans.beaninfo.editors.Bundle", "CTL_Plain");
081: /** String constant for bold font style */
082: public static final String STYLE_BOLD = Bundle.getString(
083: "org.netbeans.beaninfo.editors.Bundle", "CTL_Bold");
084: /** String constant for italic font style */
085: public static final String STYLE_ITALIC = Bundle.getString(
086: "org.netbeans.beaninfo.editors.Bundle", "CTL_Italic");
087: /** String constant for bold italic font style */
088: public static final String STYLE_BOLDITALIC = Bundle.getString(
089: "org.netbeans.beaninfo.editors.Bundle", "CTL_BoldItalic");
090:
091: /** Tries to find null JList in this dialog.
092: * @throws TimeoutExpiredException when component not found
093: * @return JListOperator
094: */
095: public JListOperator lstFontName() {
096: if (_lstFontName == null) {
097: _lstFontName = new JListOperator(this , 0);
098: }
099: return _lstFontName;
100: }
101:
102: /** Tries to find null JList in this dialog.
103: * @throws TimeoutExpiredException when component not found
104: * @return JListOperator
105: */
106: public JListOperator lstFontSize() {
107: if (_lstFontSize == null) {
108: _lstFontSize = new JListOperator(this , 2);
109: }
110: return _lstFontSize;
111: }
112:
113: /** Tries to find null JTextField in this dialog.
114: * @throws TimeoutExpiredException when component not found
115: * @return JTextFieldOperator
116: */
117: public JTextFieldOperator txtFontName() {
118: if (_txtFontName == null) {
119: _txtFontName = new JTextFieldOperator(this , 0);
120: }
121: return _txtFontName;
122: }
123:
124: /** Tries to find null JTextField in this dialog.
125: * @throws TimeoutExpiredException when component not found
126: * @return JTextFieldOperator
127: */
128: public JTextFieldOperator txtFontSize() {
129: if (_txtFontSize == null) {
130: _txtFontSize = new JTextFieldOperator(this , 2);
131: }
132: return _txtFontSize;
133: }
134:
135: /** Tries to find null JTextField in this dialog.
136: * @throws TimeoutExpiredException when component not found
137: * @return JTextFieldOperator
138: */
139: public JTextFieldOperator txtFontStyle() {
140: if (_txtFontStyle == null) {
141: _txtFontStyle = new JTextFieldOperator(this , 1);
142: }
143: return _txtFontStyle;
144: }
145:
146: /** Tries to find null JList in this dialog.
147: * @throws TimeoutExpiredException when component not found
148: * @return JListOperator
149: */
150: public JListOperator lstFontStyle() {
151: if (_lstFontStyle == null) {
152: _lstFontStyle = new JListOperator(this , 1);
153: }
154: return _lstFontStyle;
155: }
156:
157: /** returns edited font name
158: * @return String font name */
159: public String getFontName() {
160: return txtFontName().getText();
161: }
162:
163: /** returns edited font style
164: * @return String font style */
165: public String getFontStyle() {
166: return txtFontStyle().getText();
167: }
168:
169: /** returns edited font size
170: * @return String font size */
171: public String getFontSize() {
172: return txtFontSize().getText();
173: }
174:
175: /** tries to find and set text of txtFontName
176: * @param name String font name */
177: public void setFontName(String name) {
178: lstFontName().selectItem(name);
179: }
180:
181: /** tries to find and set text of txtFontSize
182: * @param size String font size */
183: public void setFontSize(String size) {
184: txtFontSize().setText("");
185: txtFontSize().typeText(size);
186: }
187:
188: /** tries to find and set text of txtFontStyle
189: * @param style String font style */
190: public void setFontStyle(String style) {
191: lstFontStyle().selectItem(style);
192: }
193:
194: /** Performs verification by accessing all sub-components */
195: public void verify() {
196: txtFontName();
197: txtFontSize();
198: txtFontStyle();
199: lstFontName();
200: lstFontSize();
201: lstFontStyle();
202: }
203:
204: }
|