1   package org.wcb.gui.renderer.jtable;
2   
3   
4   import javax.swing.table.JTableHeader;
5   import java.util.Iterator;
6   
7   /**
8    * <small>
9    * <p/>
10   * This library is free software; you can redistribute it and/or
11   * modify it under the terms of the GNU Lesser General Public
12   * License as published by the Free Software Foundation; either
13   * version 2.1 of the License, or (at your option) any later version.
14   *
15   * This library is distributed in the hope that it will be useful,
16   * but WITHOUT ANY WARRANTY; without even the implied warranty of
17   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18   * Lesser General Public License for more details.
19   *
20   * You should have received a copy of the GNU Lesser General Public
21   * License along with this library; if not, write to the Free Software
22   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
23   * <p/>
24   * $File:  $ <br>
25   * $Change:  $ submitted by $Author: wbogaardt $ at $DateTime: Sep 7, 2006 1:51:13 PM $ <br>
26   * </small>
27   *
28   * @author wbogaardt
29   *         Grouping table header wrapper
30   */
31  /**
32   * This is the object which manages the header of the JTable and
33   * also provides functionality for groupable headers.
34   */
35  
36  public class GroupableTableHeader extends JTableHeader {
37  
38      /**
39       * Identifies the UI class which draws the header.
40       */
41      public static final String uiClassID = "GroupableTableHeaderUI";
42  
43      /**
44       * Constructs a GroupableTableHeader which is initialized with cm as the
45       * column model. If cm is null this method will initialize the table header
46       * with a default TableColumnModel.
47       * @param model the column model for the table
48       */
49      public GroupableTableHeader(GroupableTableColumnModel model) {
50          super(model);
51          setUI(new GroupableTableHeaderUI());
52          setReorderingAllowed(false);
53      }
54  
55  
56      /**
57       * Sets the margins correctly for all groups within
58       * the header.
59       */
60      public void setColumnMargin() {
61          int columnMargin = getColumnModel().getColumnMargin();
62          Iterator iter = ((GroupableTableColumnModel)columnModel).columnGroupIterator();
63          while (iter.hasNext()) {
64              ColumnGroup cGroup = (ColumnGroup)iter.next();
65              cGroup.setColumnMargin(columnMargin);
66          }
67      }
68  
69  }