source: trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/QueryHistoryModel.java@ 2225

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

added QueryHistory, tooltips on collectionInfoButton. Altered
CSModel to retain CollectionInfo objects and longCollectionNames
for performance. Added files for a BerryBasket - to be turned on
soon. Added sorting of the QueryHistory via the TableMap and TableSorter
files - from the Java Swing tutorial - not sure about GPL status
of these 2.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 2.2 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 int getRowCount() {
49 return historyItems.size();
50 }
51
52 public String getColumnName(int column) {
53 return QUERY_HISTORY_COLUMN_TITLES[column];
54 }
55
56 public Object getValueAt( int row, int column ) {
57 // column resolution is a bit awkward
58 // Collection = 0
59 // Terms = 1
60
61 if (column == 0) return new CollectionName(((QueryHistoryItem)historyItems.get(row)).getCollectionName());
62
63 if (column == 1) return ((QueryHistoryItem)historyItems.get(row)).getQuery();
64 return "row" + row + "col" + column;
65 }
66
67
68
69 class CollectionName extends Object {
70 String string;
71
72 CollectionName(String newString) {
73 string = newString;
74 }
75
76 public String toString() {
77 return string;
78 }
79
80 } // CollectionName
81
82
83} //QueryHistoryModel
Note: See TracBrowser for help on using the repository browser.