xref: /titanic_41/usr/src/cmd/krb5/kadmin/gui/visualrt/sunsoft/jws/visual/rt/shadow/java/awt/ContainerShadow.java (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
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  * @(#) ContainerShadow.java 1.48 - last change made 08/05/97
34  */
35 
36 package sunsoft.jws.visual.rt.shadow.java.awt;
37 
38 import sunsoft.jws.visual.rt.base.*;
39 import sunsoft.jws.visual.rt.awt.GBLayout;
40 import java.util.Enumeration;
41 import java.awt.Container;
42 import java.awt.Component;
43 import java.awt.SystemColor;
44 
45 /**
46  * Wraps an AWT widget.  The attributes available for this
47  * class are listed below.  In the type column, type names beginning
48  * with "sunsoft.jws.visual.rt" have been abbreviated to begin with "rt".
49  *
50  * <pre>
51 name            type                      default value
52 -----------------------------------------------------------------------
53 none
54 *  < /pre>
55 *
56 * Check the super class for additional attributes.
57 *
58 * @see Container
59 * @version 	1.48, 08/05/97
60 */
61 public class ContainerShadow
62     extends ComponentShadow implements AMContainer
63 {
64     private AMContainerHelper helper = new AMContainerHelper(this);
65 
ContainerShadow()66     ContainerShadow() {
67         attributes.add("enabled", "java.lang.Boolean", Boolean.TRUE, HIDDEN);
68 
69         if (Global.isMotif()) {
70             // Set the Container colors to use the system colors.  In
71             // Motif Components inherit colors from the Container.
72             // ComponentShadow, the bg and fg were set to null so all
73             // components will use these colors.
74             attributes.add(/* NOI18N */"foreground",
75 			   /* NOI18N */"java.awt.Color",
76 			   SystemColor.controlText, DONTFETCH);
77             attributes.add(/* NOI18N */"background",
78 			   /* NOI18N */"java.awt.Color",
79 			   SystemColor.control, DONTFETCH);
80         }
81     }
82 
createBody()83     public void createBody() {};
84 
showGroups()85     void showGroups() {
86         AttributeManager mgr;
87         Enumeration e = getChildList();
88 
89         while (e.hasMoreElements()) {
90             mgr = (AttributeManager)e.nextElement();
91             if (mgr instanceof Group) {
92                 if (((Boolean)mgr.get("visible")).booleanValue())
93 		    DesignerAccess.internalShowGroup((Group)mgr);
94             } else if (mgr instanceof ContainerShadow) {
95                 if (((Boolean)mgr.get("visible")).booleanValue())
96 		    ((ContainerShadow)mgr).showGroups();
97             }
98         }
99     }
100 
hideGroups()101     void hideGroups() {
102         AttributeManager mgr;
103         Enumeration e = getChildList();
104 
105         while (e.hasMoreElements()) {
106             mgr = (AttributeManager)e.nextElement();
107             if (mgr instanceof Group) {
108                 DesignerAccess.internalHideGroup((Group)mgr);
109             } else if (mgr instanceof ContainerShadow) {
110                 ((ContainerShadow)mgr).hideGroups();
111             }
112         }
113     }
114 
115     // AMContainer interfaces
116 
add(AttributeManager child)117     public void add(AttributeManager child) {
118         helper.add(child);
119     }
120 
remove(AttributeManager child)121     public void remove(AttributeManager child) {
122         helper.remove(child);
123     }
124 
addChildBody(Shadow child)125     public void addChildBody(Shadow child) {
126         if (body != null) {
127             Container cntr = (Container)body;
128             Component comp = (Component)child.getBody();
129 
130             if (comp.getParent() != cntr) {
131                 cntr.add(comp);
132                 updateContainerAttributes((AMContainer)this, child);
133             }
134         }
135     }
136 
updateContainerAttribute(AttributeManager child, String key, Object value)137     public void updateContainerAttribute(AttributeManager child,
138 					 String key, Object value) {
139         // Do nothing.  Sub-classes should override this method to deal with
140         // specific layout managers.
141     }
142 
removeChildBody(Shadow child)143     public void removeChildBody(Shadow child) {
144         if (body != null) {
145             ((Container) body).remove((Component) child.getBody());
146         }
147     }
148 
createChildren()149     public void createChildren() {
150         helper.createChildren();
151     }
152 
reparentChildren()153     public void reparentChildren() {
154         helper.reparentChildren();
155     }
156 
destroyChildren()157     public void destroyChildren() {
158         helper.destroyChildren();
159     }
160 
getChild(String name)161     public AttributeManager getChild(String name) {
162         return (helper.getChild(name));
163     }
164 
getChildList()165     public Enumeration getChildList() {
166         return (helper.getChildList());
167     }
168 
getChildCount()169     public int getChildCount() {
170         return (helper.getChildCount());
171     }
172 
layoutMode()173     public void layoutMode() {
174         super.layoutMode();
175         helper.layoutMode();
176     }
177 
previewMode()178     public void previewMode() {
179         super.previewMode();
180         helper.previewMode();
181     }
182 
preValidate()183     public void preValidate() {
184         helper.preValidate();
185     }
186 }
187