source: trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/QueryHistoryPanel.java@ 2227

Last change on this file since 2227 was 2227, checked in by daven, 23 years ago

Custom cell renderer for the QueryHistoryPanel - with long collection
names as tooltips.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 3.0 KB
Line 
1/*
2 * QueryHistoryPanel.java
3 * Copyright (C) 2001 New Zealand Digital Library Project
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20
21package org.nzdl.gsdl.SimpleGraphicalClient;
22
23import javax.swing.table.AbstractTableModel;
24import javax.swing.table.*;
25import javax.swing.*;
26import javax.swing.border.*;
27import java.awt.*;
28import java.awt.event.*;
29import java.util.*;
30
31
32public class QueryHistoryPanel extends JPanel implements Constants
33{
34
35 QueryHistoryModel personalQueryHistoryModel;
36 CSModel csModel;
37
38 JTable personalQueryHistoryTable;
39 JTabbedPane tabbedPane;
40 JScrollPane personalScrollQueryPane;
41 TableSorter tableSorter;
42
43 public QueryHistoryPanel(CSModel newCSModel) {
44 super();
45 csModel = newCSModel;
46 setLayout( new BorderLayout() );
47 setBorder(BorderFactory.createTitledBorder("Query History"));
48
49 personalQueryHistoryModel = csModel.getQueryHistoryModel();
50 tableSorter = new TableSorter(personalQueryHistoryModel);
51 personalQueryHistoryTable = new JTable(tableSorter);
52 tableSorter.addMouseListenerToHeaderInTable(personalQueryHistoryTable);
53
54
55 personalQueryHistoryTable.setDefaultRenderer(QueryHistoryModel.CollectionName.class, new CollectionNameRenderer());
56
57 personalQueryHistoryTable.setBorder(BorderFactory.createEmptyBorder(3,3,3,3));
58 personalScrollQueryPane = new JScrollPane(personalQueryHistoryTable);
59
60 personalQueryHistoryTable.getColumnModel().getColumn(0).setMaxWidth(100);
61
62
63 tabbedPane= new JTabbedPane();
64 tabbedPane.addTab("Personal", personalScrollQueryPane);
65 add(tabbedPane, BorderLayout.CENTER);
66 } // end constructor
67
68
69
70class CollectionNameRenderer extends JLabel implements TableCellRenderer {
71
72 public Component getTableCellRendererComponent(JTable table,
73 Object value,
74 boolean isSelected,
75 boolean hasFocus,
76 int row,
77 int column) {
78 this.setText(value.toString());
79 this.setFont(queryHistoryFont);
80 this.setToolTipText(csModel.getLongCollectionName(value.toString()));
81 return this;
82 } // end getTableCellRendererComponent
83
84
85
86
87 } // end CollectionNameRenderer
88
89
90
91
92
93} // QueryHistoryPanel
Note: See TracBrowser for help on using the repository browser.