Source code: com/voytechs/html/component/TableContainer.java
1 /*
2 * File: TableContainer.java
3 * Auth: Mark Bednarczyk
4 * Date: DATE
5 * Id: $Id: TableContainer.java,v 1.1.1.1 2002/01/23 23:52:48 voytechs Exp $
6 ********************************************
7 * $Log: TableContainer.java,v $
8 * Revision 1.1.1.1 2002/01/23 23:52:48 voytechs
9 * Initial public release, BETA 1.0 - voytechs
10 *
11 */
12 package com.voytechs.html.component;
13
14 import com.voytechs.html.event.EventException;
15 import com.voytechs.html.event.HtmlDispatcher;
16 import com.voytechs.html.io.HtmlWriter;
17 import com.voytechs.html.util.LogFacility;
18
19 import java.lang.*;
20 import java.util.*;
21 import java.io.IOException;
22
23 /**
24 * A generic container object is a component that can
25 * contain other components.
26 * <BR>
27 * Components added to a container are tracked in a list. The order of the list will define the
28 * components' front-to-back stacking order within the container. If no index is specified
29 * when adding a component to a container, it will be added to the end of the list (and hence
30 * to the bottom of the stacking order).
31 */
32 public class TableContainer
33 extends Component {
34
35 /* Internal attributes */
36
37 private ComponentVector children = null;
38
39 /**
40 *
41 * @param
42 * @exception
43 */
44 public TableContainer() {
45 children = new ComponentVector(this);
46 }
47
48 /**
49 * Function that initializes the object relationships. Late bindings,
50 * adding delayed listeners, etc. Called after the full component tree
51 * is built.
52 */
53 protected void init(Frame root, HtmlDispatcher dispatcher)
54 throws com.voytechs.html.event.EventException {
55
56 super.init(root, dispatcher);
57
58 children.init(root, dispatcher);
59 }
60
61 /**
62 * Add a child component to the list of children to manage.
63 * Components are displayed in the order they were added.
64 */
65 protected void addChild(Component child) throws EventException {
66 LogFacility.log.println(this + "::TableContainer::addChild() - adding a child=" + child);
67
68 children.addElement(child);
69
70 child.setParent(this);
71
72 if(areFlagsSet(Component.COMPONENT_FLAG_INIT))
73 child.init(getRootFrame(), getRootFrame().getDispatcher());
74 }
75
76 /**
77 * Removes a previously added Component from the tree.
78 */
79 public void removeElement(Component child)
80 throws EventException {
81
82 if(children.removeElement(child) == false)
83 throw new EventException(this + "Container::removeElement() - trying to remove an unexistent element: " + child);
84 }
85
86
87 /**
88 * Calls the paint method for all is children components.
89 * @param htmlOut HtmlWriter where output should be sent to.
90 * @exception Any stream output errors.
91 */
92 protected void paint(HtmlWriter htmlOut) throws IOException {
93 LogFacility.log.println(this + "::TableContainer::paint() - show=" + show());
94
95 if(show() == false)
96 return;
97
98 paintChildren(htmlOut);
99 }
100
101 /**
102 * Calls the paint method for all its children conponents.
103 * @param htmlOut HtmlWriter where output should be sent to.
104 * @exception Any stream output errors.
105 */
106 protected void paintChildren(HtmlWriter htmlOut) throws IOException {
107
108 children.paintElements(htmlOut);
109 }
110
111 /**
112 * A debuging function to print out the component tree.
113 */
114 public String toStringTree(String prefix) {
115 String s = "";
116
117 s += super.toStringTree(prefix);
118
119 s += children.toStringTree(prefix);
120
121 return(s);
122 }
123
124 /**
125 * Test function for TableContainer
126 * @param args command line arguments
127 */
128 public static void main(String [] args) {
129 }
130
131 } /* END OF: TableContainer */