1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.commons.jelly.tags.swing;
17
18 import java.awt.GridBagLayout;
19 import java.awt.LayoutManager;
20
21 import org.apache.commons.jelly.JellyTagException;
22 import org.apache.commons.jelly.XMLOutput;
23 import org.apache.commons.jelly.tags.swing.impl.Cell;
24 import org.apache.commons.logging.Log;
25 import org.apache.commons.logging.LogFactory;
26
27 /***
28 * A Layout tag which mimicks the table, tr and td tags of HTML.
29 *
30 * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
31 * @version $Revision: 155420 $
32 */
33 public class TableLayoutTag extends LayoutTagSupport {
34
35 /*** The Log to which logging calls will be made. */
36 private static final Log log = LogFactory.getLog(LayoutTagSupport.class);
37
38 private int rowCount;
39
40 public TableLayoutTag() {
41 }
42
43 /***
44 * Adds a new cell to the current grid
45 */
46 public void addCell(Cell cell) throws JellyTagException {
47
48 addLayoutComponent(cell.getComponent(), cell.getConstraints());
49 }
50
51 /***
52 * Creates a new row index for child <tr> tags
53 */
54 public int nextRowIndex() {
55 return rowCount++;
56 }
57
58
59
60 public void doTag(final XMLOutput output) throws JellyTagException {
61 rowCount = 0;
62 super.doTag(output);
63 }
64
65
66
67
68
69 /***
70 * Creates a GridBagLayout
71 */
72 protected LayoutManager createLayoutManager() {
73 return new GridBagLayout();
74 }
75 }