01: /*
02: * Copyright 2000,2005 wingS development team.
03: *
04: * This file is part of wingS (http://wingsframework.org).
05: *
06: * wingS is free software; you can redistribute it and/or modify
07: * it under the terms of the GNU Lesser General Public License
08: * as published by the Free Software Foundation; either version 2.1
09: * of the License, or (at your option) any later version.
10: *
11: * Please see COPYING for the complete licence.
12: */
13: package org.wings;
14:
15: import org.wings.io.Device;
16:
17: import java.io.IOException;
18:
19: /**
20: * Internal component (re)used during the rendering process of cell based components
21: * like {@link STree} and {@link STable}s.
22: *
23: * @author <a href="mailto:engels@mercatis.de">Holger Engels</a>
24: */
25: public class SCellRendererPane extends SContainer {
26: private final transient static org.apache.commons.logging.Log log = org.apache.commons.logging.LogFactory
27: .getLog("org.wings");
28:
29: /**
30: * Construct a CellRendererPane object.
31: */
32: public SCellRendererPane() {
33: super ();
34: setLayout(null);
35: setVisible(false);
36: }
37:
38: /**
39: * Shouldn't be called.
40: */
41: public void write(Device d) {
42: }
43:
44: /**
45: * If the specified component is already a child of this then we don't
46: * bother doing anything - stacking order doesn't matter for cell
47: * renderer components (CellRendererPane doesn't paint anyway).
48: */
49: public SComponent addComponent(SComponent c, Object constraints,
50: int index) {
51: if (c.getParent() == this ) {
52: return null;
53: } else {
54: return super .addComponent(c, constraints, index);
55: }
56: }
57:
58: /**
59: * Write a cell renderer component c to device d. Before the component
60: * is drawn it's reparented to this (if that's neccessary).
61: * The Component p is the component we're actually drawing on.
62: */
63: public void writeComponent(Device d, SComponent c, SComponent p)
64: throws IOException {
65: if (getParent() == null)
66: log.warn("SCellRendererPane: parent == null!");
67:
68: if (getParentFrame() == null)
69: log.warn("SCellRendererPane: parentFrame == null!");
70:
71: if (c == null || !c.isVisible()) {
72: return;
73: }
74:
75: addComponent(c);
76:
77: c.write(d);
78:
79: remove(c);
80: }
81: }
|