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

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

updated QueryHistory to include options (stemming) and to display them..
however there is a screen real estate problem :-(
But checking in the underlying support anyway. Will sort out display soon.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 3.4 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 private ArrayList columnTitles;
32
33 private String COLLECTION = "Collection";
34 private String DATE_TIME = "Date/Time";
35 private String TERMS = "Terms";
36 private String HITS = "Hits";
37 private String QUERYTYPE = "Type";
38 private String STEMMED = "Stemmed?";
39 private String CASEMATCHED = "Case match?";
40
41
42 public QueryHistoryModel() {
43 super();
44 historyItems = new ArrayList();
45 columnTitles = new ArrayList();
46 columnTitles.add( DATE_TIME);
47 columnTitles.add( COLLECTION);
48 columnTitles.add( TERMS);
49 columnTitles.add(QUERYTYPE);
50 columnTitles.add(STEMMED);
51 columnTitles.add(CASEMATCHED);
52 columnTitles.add( HITS);
53 }
54
55
56 public void add(QueryHistoryItem queryHistoryItem) {
57 historyItems.add(0,queryHistoryItem); //add at the top!
58 //fireTableDataChanged(); //too general
59 fireTableRowsInserted(0,0);
60 }
61
62 public int getColumnCount() {
63 return columnTitles.size();
64 }
65
66 public Class getColumnClass(int c) {
67 return getValueAt(0, c).getClass();
68 }
69
70 public int getRowCount() {
71 return historyItems.size();
72 }
73
74 public String getColumnName(int column) {
75 return (String) columnTitles.get(column);
76 }
77
78 public Object getValueAt( int row, int column ) {
79 QueryHistoryItem historyItem = (QueryHistoryItem)historyItems.get(row);
80 if (column == columnTitles.indexOf(DATE_TIME)) return historyItem.getDate();
81 if (column == columnTitles.indexOf(COLLECTION)) return new CollectionName(historyItem.getCollectionName());
82 if (column == columnTitles.indexOf(TERMS)) return new Query(historyItem.getQuery().toString());
83 if (column == columnTitles.indexOf(HITS)) return new Long(historyItem.getNumOfHits());
84 if (column == columnTitles.indexOf(QUERYTYPE)) return new String(historyItem.getQueryType());
85 if (column == columnTitles.indexOf(STEMMED)) return new Boolean(historyItem.getStemmed());
86 if (column == columnTitles.indexOf(CASEMATCHED)) return new Boolean( historyItem.getCaseMatched());
87
88 // something has gone wrong if we get here!
89 // but display something anyway...
90 return "row" + row + "col" + column;
91 }
92
93
94
95 public class CollectionName extends Object {
96 String string;
97
98 CollectionName(String newString) {
99 string = newString;
100 }
101
102 public String toString() {
103 return string;
104 }
105
106 } // CollectionName
107
108
109} //QueryHistoryModel
Note: See TracBrowser for help on using the repository browser.