source: trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/QueryHistoryModel.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: 2.3 KB
Line 
1/*
2 * QueryHistoryModel.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 java.util.*;
24import javax.swing.event.*;
25import javax.swing.*;
26import javax.swing.table.*;
27
28class QueryHistoryModel extends AbstractTableModel implements Constants {
29
30 private ArrayList historyItems;
31
32 public QueryHistoryModel() {
33 super();
34 historyItems = new ArrayList();
35 }
36
37
38 public void add(QueryHistoryItem queryHistoryItem) {
39 historyItems.add(0,queryHistoryItem); //add at the top!
40 //fireTableDataChanged(); //too general
41 fireTableRowsInserted(0,0);
42 }
43
44 public int getColumnCount() {
45 return QUERY_HISTORY_COLUMN_TITLES.length;
46 }
47
48 public Class getColumnClass(int c) {
49 return getValueAt(0, c).getClass();
50 }
51
52 public int getRowCount() {
53 return historyItems.size();
54 }
55
56 public String getColumnName(int column) {
57 return QUERY_HISTORY_COLUMN_TITLES[column];
58 }
59
60 public Object getValueAt( int row, int column ) {
61 // column resolution is a bit awkward
62 // Collection = 0
63 // Terms = 1
64
65 if (column == 0) return new CollectionName(((QueryHistoryItem)historyItems.get(row)).getCollectionName());
66
67 if (column == 1) return ((QueryHistoryItem)historyItems.get(row)).getQuery();
68 return "row" + row + "col" + column;
69 }
70
71
72
73 public class CollectionName extends Object {
74 String string;
75
76 CollectionName(String newString) {
77 string = newString;
78 }
79
80 public String toString() {
81 return string;
82 }
83
84 } // CollectionName
85
86
87} //QueryHistoryModel
Note: See TracBrowser for help on using the repository browser.