Changeset 2256 for trunk/java-client/org


Ignore:
Timestamp:
2001-04-02T21:22:19+12:00 (23 years ago)
Author:
daven
Message:

added ranked and boolean searching options to the interface.

Location:
trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/Constants.java

    r2251 r2256  
    6666    /* Query History Table Column Titles */
    6767   
    68     String[]  QUERY_HISTORY_COLUMN_TITLES = {"Time/Date", "Collection", "Terms", "Hits"};
     68
    6969
    7070
  • trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/QueryHistoryModel.java

    r2251 r2256  
    2929
    3030    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
    3138
    3239    public QueryHistoryModel() {
    3340    super();
    3441    historyItems = new ArrayList();
     42    columnTitles = new ArrayList();
     43    columnTitles.add( DATE_TIME);
     44    columnTitles.add( COLLECTION);
     45    columnTitles.add( TERMS);
     46    columnTitles.add( HITS);
    3547    }
    3648
     
    4355   
    4456    public int getColumnCount() {
    45     return  QUERY_HISTORY_COLUMN_TITLES.length;
     57    return columnTitles.size();
    4658    }
    4759
     
    5567
    5668    public String getColumnName(int column) {
    57     return QUERY_HISTORY_COLUMN_TITLES[column];
     69    return (String) columnTitles.get(column);
    5870    }
    5971
    6072    public Object getValueAt( int row, int column ) {
    61     // column resolution is a bit awkward
    62     // Collection = 0
    63     // Terms = 1
     73    QueryHistoryItem historyItem = (QueryHistoryItem)historyItems.get(row);
     74    if (column == columnTitles.indexOf(DATE_TIME)) return historyItem.getDate();
     75    if (column == columnTitles.indexOf(COLLECTION)) return new CollectionName(historyItem.getCollectionName());
     76    if (column == columnTitles.indexOf(TERMS)) return new Query(historyItem.getQuery().toString());
     77    if (column == columnTitles.indexOf(HITS)) return new Long(historyItem.getNumOfHits());
    6478
    65     if (column == 0) return ((QueryHistoryItem)historyItems.get(row)).getDate();
    66 
    67 
    68     if (column == 1) return new CollectionName(((QueryHistoryItem)historyItems.get(row)).getCollectionName());
    69 
    70     if (column == 2) return ((QueryHistoryItem)historyItems.get(row)).getQuery();
    71     if (column == 3) return new Long(((QueryHistoryItem)historyItems.get(row)).getNumOfHits());
     79    // something has gone wrong if we get here!
     80    // but display something anyway...
    7281    return "row" + row + "col" + column;
    7382    }
  • trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/SearchPanel.java

    r2254 r2256  
    3838import org.nzdl.gsdl.service.NzdlService;
    3939import org.nzdl.gsdl.service.NzdlServiceClient;
    40 import org.nzdl.gsdl.util.NzdlPreferences;
     40import org.nzdl.gsdl.util.*;
    4141
    4242
     
    6666  JComboBox collectionList; 
    6767  JPanel queryFormulationPanel, resultsPanel, dataPanel, optionsPanel;
     68    JPanel queryTypePanel, searchControlPanel;
    6869  JPanel collectionListPanel, searchTextFieldPanel, searchButtonPanel;
    6970  JList   resultsList;   
    7071    JCheckBox stemCheckBox, caseFoldCheckBox;
     72    JRadioButton rankedRadioButton, booleanRadioButton;
     73    ButtonGroup buttonGroup;
    7174  JScrollPane scrollResultsPane;
    7275  JScrollPane scrollDataPane;
     
    140143
    141144    optionsPanel = new JPanel();
     145
     146    queryTypePanel = new JPanel();
     147    queryTypePanel.setLayout(new GridLayout(2,1));
     148    rankedRadioButton = new JRadioButton("ranked");
     149    rankedRadioButton.setActionCommand(rankedRadioButton.getText());
     150    rankedRadioButton.setSelected(rankedRadioButton.getText() == NzdlConstants.DEFAULT_QUERY_TYPE);
     151    rankedRadioButton.setToolTipText("Display results in a ranked list");
     152   
     153    booleanRadioButton = new JRadioButton("boolean");
     154    booleanRadioButton.setActionCommand(booleanRadioButton.getText());
     155    booleanRadioButton.setSelected(booleanRadioButton.getText() == NzdlConstants.DEFAULT_QUERY_TYPE);
     156    booleanRadioButton.setToolTipText("Allows the use of Boolean operators: AND(&) OR(|) and NOT(!)");
     157    buttonGroup = new ButtonGroup();
     158    buttonGroup.add(rankedRadioButton);
     159    buttonGroup.add(booleanRadioButton);
     160    queryTypePanel.add(rankedRadioButton);
     161    queryTypePanel.add(booleanRadioButton);
     162   
    142163    stemCheckBox = new JCheckBox("Stemming", true);
    143164    stemCheckBox.setToolTipText("Strip endings such as '...ing', '...ed'");
    144165    caseFoldCheckBox = new JCheckBox("Match case", false);
    145166    caseFoldCheckBox.setToolTipText("Only match when the case is the same");
     167
     168    optionsPanel.add(queryTypePanel);
    146169    optionsPanel.add(stemCheckBox);
    147170    optionsPanel.add(caseFoldCheckBox);
     
    149172    searchButtonPanel = new JPanel();
    150173    searchButtonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
    151     searchButtonPanel.add(optionsPanel);
    152174    searchButtonPanel.add(searchButton);
     175
     176    searchControlPanel = new JPanel();
     177    searchControlPanel.setLayout(new BorderLayout());
     178    searchControlPanel.add(optionsPanel, BorderLayout.WEST);
     179    searchControlPanel.add(searchButtonPanel, BorderLayout.EAST);
    153180
    154181    queryFormulationPanel = new JPanel();
     
    158185    queryFormulationPanel.add(collectionListPanel);
    159186    queryFormulationPanel.add(searchTextFieldPanel);
    160     queryFormulationPanel.add(searchButtonPanel);
     187    queryFormulationPanel.add(searchControlPanel);
    161188
    162189    resultsPanel = new JPanel();
     
    219246      //send query to collection
    220247      NzdlQuery nzdlQuery = new NzdlQuery(queryString);
     248      nzdlQuery.setQueryType(buttonGroup.getSelection().getActionCommand());
     249      System.err.println(buttonGroup.getSelection().getActionCommand());
     250      //nzdlQuery.setQueryType("boolean");
    221251      nzdlQuery.setStemming(stemCheckBox.isSelected());
    222252      // interface reverses underlying logic so negate UI element state
Note: See TracChangeset for help on using the changeset viewer.