KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > wings > SCellRendererPane


1 /*
2  * $Id: SCellRendererPane.java,v 1.4 2004/12/01 07:54:06 hengels Exp $
3  * Copyright 2000,2005 wingS development team.
4  *
5  * This file is part of wingS (http://www.j-wings.org).
6  *
7  * wingS is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU Lesser General Public License
9  * as published by the Free Software Foundation; either version 2.1
10  * of the License, or (at your option) any later version.
11  *
12  * Please see COPYING for the complete licence.
13  */

14 package org.wings;
15
16 import org.wings.io.Device;
17
18 import java.io.IOException JavaDoc;
19
20 /**
21  * @author <a HREF="mailto:engels@mercatis.de">Holger Engels</a>
22  * @version $Revision: 1.4 $
23  */

24 public class SCellRendererPane
25         extends SContainer {
26     private final transient static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory.getLog("org.wings");
27
28     /**
29      * Construct a CellRendererPane object.
30      */

31     public SCellRendererPane() {
32         super();
33         setLayout(null);
34         setVisible(false);
35     }
36
37     /**
38      * Shouldn't be called.
39      */

40     public void write(Device d) {
41     }
42
43     /**
44      * If the specified component is already a child of this then we don't
45      * bother doing anything - stacking order doesn't matter for cell
46      * renderer components (CellRendererPane doesn't paint anyway).
47      */

48     public SComponent addComponent(SComponent c, Object JavaDoc constraints, int index) {
49         if (c.getParent() == this) {
50             return null;
51         } else {
52             return super.addComponent(c, constraints, index);
53         }
54     }
55
56     /**
57      * Write a cell renderer component c to device d. Before the component
58      * is drawn it's reparented to this (if that's neccessary).
59      * The Component p is the component we're actually drawing on.
60      */

61     public void writeComponent(Device d, SComponent c, SComponent p)
62             throws IOException JavaDoc {
63         if (getParent() == null)
64             log.warn("SCellRendererPane: parent == null!");
65
66         if (getParentFrame() == null)
67             log.warn("SCellRendererPane: parentFrame == null!");
68
69         if (c == null) {
70             return;
71         }
72
73         if (c.getParent() != this) {
74             this.addComponent(c);
75         }
76
77         c.write(d);
78     }
79 }
80
81
82
Popular Tags