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 |
|
---|
21 | package org.nzdl.gsdl.SimpleGraphicalClient;
|
---|
22 |
|
---|
23 | import javax.swing.table.AbstractTableModel;
|
---|
24 | import javax.swing.table.*;
|
---|
25 | import javax.swing.*;
|
---|
26 | import javax.swing.border.*;
|
---|
27 | import java.awt.*;
|
---|
28 | import java.awt.event.*;
|
---|
29 | import java.util.*;
|
---|
30 |
|
---|
31 |
|
---|
32 | public class QueryHistoryPanel extends JPanel implements Constants
|
---|
33 | {
|
---|
34 |
|
---|
35 | QueryHistoryModel personalQueryHistoryModel;
|
---|
36 |
|
---|
37 | JTable personalQueryHistoryTable;
|
---|
38 | JTabbedPane tabbedPane;
|
---|
39 | JScrollPane personalScrollQueryPane;
|
---|
40 | TableSorter tableSorter;
|
---|
41 |
|
---|
42 | public QueryHistoryPanel(CSModel csModel) {
|
---|
43 | super();
|
---|
44 | setLayout( new BorderLayout() );
|
---|
45 | setBorder(BorderFactory.createTitledBorder("Query History"));
|
---|
46 |
|
---|
47 | personalQueryHistoryModel = csModel.getQueryHistoryModel();
|
---|
48 | tableSorter = new TableSorter(personalQueryHistoryModel);
|
---|
49 | personalQueryHistoryTable = new JTable(tableSorter);
|
---|
50 | tableSorter.addMouseListenerToHeaderInTable(personalQueryHistoryTable);
|
---|
51 |
|
---|
52 |
|
---|
53 | personalQueryHistoryTable.setDefaultRenderer(QueryHistoryModel.CollectionName.class, new CollectionNameRenderer());
|
---|
54 |
|
---|
55 | personalQueryHistoryTable.setBorder(BorderFactory.createEmptyBorder(3,3,3,3));
|
---|
56 | personalScrollQueryPane = new JScrollPane(personalQueryHistoryTable);
|
---|
57 |
|
---|
58 | tabbedPane= new JTabbedPane();
|
---|
59 | tabbedPane.addTab("Personal", personalScrollQueryPane);
|
---|
60 | add(tabbedPane, BorderLayout.CENTER);
|
---|
61 | } // end constructor
|
---|
62 |
|
---|
63 |
|
---|
64 |
|
---|
65 | class CollectionNameRenderer extends JLabel implements TableCellRenderer {
|
---|
66 |
|
---|
67 | public Component getTableCellRendererComponent(JTable table,
|
---|
68 | Object value,
|
---|
69 | boolean isSelected,
|
---|
70 | boolean hasFocus,
|
---|
71 | int row,
|
---|
72 | int column) {
|
---|
73 | this.setText("**" + value.toString());
|
---|
74 | return this;
|
---|
75 | } // end getTableCellRendererComponent
|
---|
76 |
|
---|
77 |
|
---|
78 |
|
---|
79 |
|
---|
80 | } // end CollectionNameRenderer
|
---|
81 |
|
---|
82 |
|
---|
83 |
|
---|
84 |
|
---|
85 |
|
---|
86 | } // QueryHistoryPanel
|
---|