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