1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License").  You may not use this file except in compliance
7 * with the License.
8 *
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22/*
23 * ident	"%Z%%M%	%I%	%E% SMI"
24 *
25 * Copyright (c) 2000 by Sun Microsystems, Inc.
26 * All rights reserved.
27 */
28
29/*
30 *        Copyright (C) 1996  Active Software, Inc.
31 *                  All rights reserved.
32 *
33 * @(#) @(#) TextComponentShadow.java 1.20 - last change made 07/28/97
34 */
35
36package sunsoft.jws.visual.rt.shadow.java.awt;
37
38import java.awt.TextComponent;
39import sunsoft.jws.visual.rt.base.Global;
40
41/**
42 * Wraps an AWT widget.  The attributes available for this
43 * class are listed below.  In the type column, type names beginning
44 * with "sunsoft.jws.visual.rt" have been abbreviated to begin with "rt".
45 *
46 * <pre>
47name            type                      default value
48-----------------------------------------------------------------------
49editable        java.lang.Boolean         true
50text            java.lang.String          ""
51*  < /pre>
52*
53* Check the super class for additional attributes.
54*
55* @see TextComponent
56* @version 	1.20, 07/28/97
57*/
58public class TextComponentShadow extends ComponentShadow {
59    public TextComponentShadow() {
60        attributes.add(/* NOI18N */"text",
61		       /* NOI18N */"java.lang.String", /* NOI18N */"", 0);
62        attributes.add(/* NOI18N */"editable",
63		       /* NOI18N */"java.lang.Boolean", Boolean.TRUE, 0);
64    }
65
66    protected Object getOnBody(String key) {
67        if (key.equals(/* NOI18N */"text"))
68	    return ((((TextComponent) body).getText()));
69        else if (key.equals(/* NOI18N */"editable"))
70            return (new Boolean(((TextComponent) body).isEditable()));
71        else
72            return (super.getOnBody(key));
73    }
74
75    protected void setOnBody(String key, Object value) {
76        TextComponent textcomp = (TextComponent)body;
77
78        if (key.equals(/* NOI18N */"text")) {
79            String text = textcomp.getText();
80
81            if ((value == null && text != null && !text.equals(/* NOI18N */""))
82		|| (value != null && !value.equals(text))) {
83                textcomp.setText((String) value);
84            }
85        } else if (key.equals(/* NOI18N */"editable")) {
86            textcomp.setEditable(((Boolean) value).booleanValue());
87        } else {
88            super.setOnBody(key, value);
89        }
90    }
91
92    public void createBody() {};
93}
94