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