source: trunk/gli/src/org/greenstone/gatherer/gui/metaaudit/HeaderRenderer.java@ 13531

Last change on this file since 13531 was 10011, checked in by mdewsnip, 19 years ago

Moved Utility.getImage into JarTools, as part of tidying up the Utility class.

  • Property svn:keywords set to Author Date Id Revision
File size: 3.5 KB
Line 
1/**
2 *#########################################################################
3 *
4 * A component of the Gatherer application, part of the Greenstone digital
5 * library suite from the New Zealand Digital Library Project at the
6 * University of Waikato, New Zealand.
7 *
8 * <BR><BR>
9 *
10 * Author: John Thompson, Greenstone Digital Library, University of Waikato
11 *
12 * <BR><BR>
13 *
14 * Copyright (C) 1999 New Zealand Digital Library Project
15 *
16 * <BR><BR>
17 *
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 2 of the License, or
21 * (at your option) any later version.
22 *
23 * <BR><BR>
24 *
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
29 *
30 * <BR><BR>
31 *
32 * You should have received a copy of the GNU General Public License
33 * along with this program; if not, write to the Free Software
34 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
35 *########################################################################
36 */
37package org.greenstone.gatherer.gui.metaaudit;
38
39import java.awt.*;
40import javax.swing.*;
41import javax.swing.table.TableCellRenderer;
42import org.greenstone.gatherer.Dictionary;
43import org.greenstone.gatherer.util.JarTools;
44
45/** This custom button renderer replaces the boring old column headers with clickable versions which are based on JToggleButtons.
46 * @author John Thompson, Greenstone Digital Library, University of Waikato
47 * @version 2.3
48 */
49public class HeaderRenderer
50 extends JToggleButton
51 implements TableCellRenderer {
52
53 /** The constructor sets up a margin around the button, and adds the filter icons.
54 */
55 public HeaderRenderer() {
56 setMargin(new Insets(0,0,0,0));
57 setIcon(JarTools.getImage("filter.gif"));
58 setSelectedIcon(JarTools.getImage("filter-on.gif"));
59 }
60
61 /** Called to create the component to be used as the 'rubber-stamp' for the table cell given the follwing arguments.
62 * @param table The <strong>JTable</strong> that is asking the renderer to draw; can be <i>null</i>.
63 * @param value The value of the cell to be rendered as an <strong>Object</strong>. It is up to the specific renderer to interpret and draw the value. For example, if value is the string "true", it could be rendered as a string or it could be rendered as a check box that is checked. null is a valid value.
64 * @param isSelected <i>true</i> if the cell is to be rendered with the selection highlighted; otherwise <i>false</i>.
65 * @param hasFocus If <i>true</i>, render cell appropriately. For example, put a special border on the cell, if the cell can be edited, render in the color used to indicate editing.
66 * @param row The row index of the cell being drawn as an <i>int</i>. When drawing the header, the value of row is -1.
67 * @param column The column index of the cell being drawn as an <i>int</i>.
68 * @see org.greenstone.gatherer.gui.metaaudit.MetaAuditTable
69 */
70 public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
71 setText(value.toString());
72 setToolTipText(Dictionary.get("Autofilter.Table_Header_Tooltip", value.toString()));
73 MetaAuditTable temp = (MetaAuditTable) table;
74 if (temp != null) { // And it may if this is called during table init.
75 setSelected(temp.isFiltered(column));
76 }
77 return this;
78 }
79}
Note: See TracBrowser for help on using the repository browser.