Changeset 2143


Ignore:
Timestamp:
2001-03-09T12:44:21+13:00 (23 years ago)
Author:
say1
Message:

added Makefile for dave"s stuff. added a few comments ...

Location:
trunk/java-client/org/nzdl/gsdl
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/java-client/org/nzdl/gsdl/Makefile

    r2121 r2143  
    66
    77subdirs :
     8    (cd SimpleGraphicalClient && $(MAKE) all)
    89    (cd util && $(MAKE) all)
    910    (cd service && $(MAKE) all)
     
    1112
    1213clean:
     14    (cd SimpleGraphicalClient && $(MAKE) clean)
    1315    (cd util && $(MAKE) clean)
    1416    (cd service && $(MAKE) clean)
  • trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/CSFrame.java

    r2142 r2143  
     1/*
     2 *    SimpleGraphicalClient.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 */
    119package org.nzdl.gsdl.SimpleGraphicalClient;
    220
     
    725import java.awt.event.*;
    826import java.util.*;
     27/**
     28 * Class
     29 *
     30 * A class to
     31 *
     32 * @author Dave Nichols ([email protected])
     33 * @author stuart yeates ([email protected])
     34 * @version $Revision$
     35 * @see org.nzdl.gsdl.service.SimpleGraphicalClient.SimpleGraphicalClient
     36 */
    937
    1038public class CSFrame extends JFrame implements Observer, Constants
  • trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/CSModel.java

    r2142 r2143  
     1/*
     2 *    SimpleGraphicalClient.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 */
    119package org.nzdl.gsdl.SimpleGraphicalClient;
    220
     
    927import org.nzdl.gsdl.service.NzdlService;
    1028
     29/**
     30 * Class
     31 *
     32 * A class to
     33 *
     34 * @author Dave Nichols ([email protected])
     35 * @author stuart yeates ([email protected])
     36 * @version $Revision$
     37 * @see org.nzdl.gsdl.service.SimpleGraphicalClient.SimpleGraphicalClient
     38 */
    1139
    1240class CSModel extends Object
  • trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/Constants.java

    r2142 r2143  
     1/*
     2 *    SimpleGraphicalClient.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 */
    119package org.nzdl.gsdl.SimpleGraphicalClient;
    220
    3 import java.awt.*;
     21import java.awt.Font;
     22
     23/**
     24 * Class
     25 *
     26 * A class to
     27 *
     28 * @author Dave Nichols ([email protected])
     29 * @author stuart yeates ([email protected])
     30 * @version $Revision$
     31 * @see org.nzdl.gsdl.service.SimpleGraphicalClient.SimpleGraphicalClient
     32 */
     33
    434
    535public interface Constants
  • trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/Result.java

    r2142 r2143  
     1/*
     2 *    SimpleGraphicalClient.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 */
    119package org.nzdl.gsdl.SimpleGraphicalClient;
    220
    321import java.io.*;
     22/**
     23 * Class
     24 *
     25 * A class to
     26 *
     27 * @author Dave Nichols ([email protected])
     28 * @author stuart yeates ([email protected])
     29 * @version $Revision$
     30 * @see org.nzdl.gsdl.service.SimpleGraphicalClient.SimpleGraphicalClient
     31 */
    432
    533public class Result extends Object
  • trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/ResultModel.java

    r2142 r2143  
     1/*
     2 *    ResultModel.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 */
    119package org.nzdl.gsdl.SimpleGraphicalClient;
    220
     
    523import javax.swing.*;
    624
     25/**
     26 * Class ResultModel
     27 *
     28 * A class to
     29 *
     30 * @author Dave Nichols ([email protected])
     31 * @author stuart yeates ([email protected])
     32 * @version $Revision$
     33 * @see org.nzdl.gsdl.service.SimpleGraphicalClient.SimpleGraphicalClient
     34 */
    735
    836class ResultModel extends DefaultListModel
  • trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/SearchPanel.java

    r2142 r2143  
     1/*
     2 *    SimpleGraphicalClient.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 */
    119package org.nzdl.gsdl.SimpleGraphicalClient;
    2 
    320
    421import javax.swing.*;
     
    2138
    2239
     40/**
     41 * A Class representing the Panel in which the Queryign action happens.
     42 *
     43 * Does most of the actual `work' in the package.
     44 *
     45 * @author Dave Nichols ([email protected])
     46 * @author stuart yeates ([email protected])
     47 * @version $Revision$
     48 * @see org.nzdl.gsdl.service.SimpleGraphicalClient.SimpleGraphicalClient
     49 * @see org.nzdl.gsdl.service.SimpleGraphicalClient.CSModel
     50 * @see javax.swing.JPanel
     51 */
    2352
    2453public class SearchPanel extends JPanel implements ActionListener, Constants
    2554{
    2655
    27 CSModel csModel;
    28 JLabel collectionLabel;
    29 JTextField searchTextField;
    30 JButton searchButton;
    31 JComboBox collectionList;  // can we search multiple collections at once?
    32 JPanel queryFormulationPanel, resultsPanel, dataPanel;
    33 JPanel collectionListPanel, searchTextFieldPanel, searchButtonPanel;
    34 JList   resultsList;    // where the ranked results are displayed
    35 JScrollPane scrollResultsPane;
    36 JTextArea dataTextArea;  // where the doc contents are displayed
    37 JScrollPane scrollDataPane;
     56  CSModel csModel;
     57  JLabel collectionLabel;
     58  JTextField searchTextField;
     59  JButton searchButton;
     60  JComboBox collectionList;  // can we search multiple collections at once?
     61  JPanel queryFormulationPanel, resultsPanel, dataPanel;
     62  JPanel collectionListPanel, searchTextFieldPanel, searchButtonPanel;
     63  /** where the ranked results are displayed */
     64  JList   resultsList;   
     65  JScrollPane scrollResultsPane;
     66  /** where the doc contents are displayed */
     67  JTextArea dataTextArea; 
     68  JScrollPane scrollDataPane;
     69
     70  /**
     71   * Construct and initialise a new SearchPanel
     72   */
    3873
    3974  public SearchPanel( CSModel newCsModel, JFrame parent)
    4075  {
    4176    super();
    42     csModel = newCsModel;
     77    csModel = newCsModel;
    4378    setLayout( new BoxLayout(this, BoxLayout.Y_AXIS));
    44     setBorder(BorderFactory.createTitledBorder("Search"));
    45    
    46    
    47     searchTextField = new JTextField("Enter search terms here", 35) {
    48               public boolean isRequestFocusEnabled(){
    49                    return true;
    50               }
    51     };
    52 
    53 
    54     searchTextField.setText("Enter search terms here");
    55     searchTextField.setFont(searchTextFieldFont);
    56     searchTextField.setColumns(35);
    57     searchTextField.setBorder(BorderFactory.createEmptyBorder(0,2,0,2));
    58     searchButton = new JButton("Search");
    59    
    60     searchButton.addActionListener(this);
    61     //searchButton.setBorder(BorderFactory.createEmptyBorder(2,2,2,2));
    62     searchButton.setPreferredSize(new Dimension(80, 20));
    63    
    64     collectionListPanel = new JPanel();
    65     collectionListPanel.setBorder(BorderFactory.createEmptyBorder(2,2,2,2));
    66     collectionListPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
    67     collectionLabel = new JLabel("Collection: ");
    68     /*collectionList = new JComboBox(csModel.getCollectionList()){
    69           public boolean isFocusTraversable() {
    70               return false;
    71           }
    72       }; */
    73     //System.err.println("size is " + csModel.getCollectionListSize());
    74     //Collection coll = csModel.getCollectionList();
    75     //System.err.println("coll size is " + coll.size());
    76     //Vector vec = new Vector(coll);
    77     //System.err.println("vector size is " + vec.size());
    78     collectionList = new JComboBox(csModel.getCollectionList()){
    79           public boolean isFocusTraversable() {
    80               return false;
    81           }
    82         };
    83 
    84 
    85 
    86 
    87 
    88     //collectionList.setSelectedIndex(0); // only if there is content
    89     collectionListPanel.add(collectionLabel);
    90     collectionListPanel.add(collectionList);
    91 
    92    
    93     searchTextFieldPanel = new JPanel();
    94     searchTextFieldPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
    95     searchTextFieldPanel.add(searchTextField);
    96    
    97     searchButtonPanel = new JPanel();
    98     searchButtonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
    99     searchButtonPanel.add(searchButton);
    100    
    101     queryFormulationPanel = new JPanel();
    102     queryFormulationPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
    103     queryFormulationPanel.setLayout(new BoxLayout(queryFormulationPanel, BoxLayout.Y_AXIS));
    104     queryFormulationPanel.add(Box.createHorizontalStrut(100));
    105     queryFormulationPanel.add(collectionListPanel);
    106     queryFormulationPanel.add(searchTextFieldPanel);
    107     queryFormulationPanel.add(searchButtonPanel);
    108    
    109    
    110     resultsPanel = new JPanel();
    111     resultsPanel.setLayout(new BorderLayout());
    112     resultsPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
    113     ResultModel resultListModel = csModel.getResultsModel();
    114     resultsList = new JList(resultListModel);
    115     resultsList.setFont(resultsFont);
    116     resultsList.setBorder(BorderFactory.createEmptyBorder(3,3,3,3));
    117     resultsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    118     scrollResultsPane = new JScrollPane(resultsList);
    119     resultsPanel.add(scrollResultsPane, BorderLayout.CENTER);
    120     csModel.addResult(new Result("Search results will appear here", "", ""));
    121    
    122     dataPanel = new JPanel();
    123     dataPanel.setLayout(new BorderLayout());
    124     dataPanel.setBorder(BorderFactory.createEmptyBorder(3,3,3,3));
    125     dataTextArea = new JTextArea("Document details will appear here", 10, 0);
    126     dataTextArea.setEditable(false);
    127     dataTextArea.setLineWrap(true);
    128     dataTextArea.setFont(docFont);
    129     dataTextArea.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
    130     scrollDataPane = new JScrollPane(dataTextArea);
    131     dataPanel.add(scrollDataPane, BorderLayout.CENTER);
     79    setBorder(BorderFactory.createTitledBorder("Search"));
     80   
     81   
     82    searchTextField = new JTextField("Enter search terms here", 35) {
     83    public boolean isRequestFocusEnabled(){
     84      return true;
     85    }
     86      };
     87
     88
     89    searchTextField.setText("Enter search terms here");
     90    searchTextField.setFont(searchTextFieldFont);
     91    searchTextField.setColumns(35);
     92    searchTextField.setBorder(BorderFactory.createEmptyBorder(0,2,0,2));
     93    searchButton = new JButton("Search");
     94   
     95    searchButton.addActionListener(this);
     96    //searchButton.setBorder(BorderFactory.createEmptyBorder(2,2,2,2));
     97    searchButton.setPreferredSize(new Dimension(80, 20));
     98   
     99    collectionListPanel = new JPanel();
     100    collectionListPanel.setBorder(BorderFactory.createEmptyBorder(2,2,2,2));
     101    collectionListPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
     102    collectionLabel = new JLabel("Collection: ");
     103    /*collectionList = new JComboBox(csModel.getCollectionList()){
     104      public boolean isFocusTraversable() {
     105      return false;
     106      }
     107      }; */
     108    //System.err.println("size is " + csModel.getCollectionListSize());
     109    //Collection coll = csModel.getCollectionList();
     110    //System.err.println("coll size is " + coll.size());
     111    //Vector vec = new Vector(coll);
     112    //System.err.println("vector size is " + vec.size());
     113    collectionList = new JComboBox(csModel.getCollectionList()){
     114    public boolean isFocusTraversable() {
     115      return false;
     116    }
     117      };
     118
     119
     120
     121
     122
     123    //collectionList.setSelectedIndex(0); // only if there is content
     124    collectionListPanel.add(collectionLabel);
     125    collectionListPanel.add(collectionList);
     126
     127   
     128    searchTextFieldPanel = new JPanel();
     129    searchTextFieldPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
     130    searchTextFieldPanel.add(searchTextField);
     131   
     132    searchButtonPanel = new JPanel();
     133    searchButtonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
     134    searchButtonPanel.add(searchButton);
     135   
     136    queryFormulationPanel = new JPanel();
     137    queryFormulationPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
     138    queryFormulationPanel.setLayout(new BoxLayout(queryFormulationPanel, BoxLayout.Y_AXIS));
     139    queryFormulationPanel.add(Box.createHorizontalStrut(100));
     140    queryFormulationPanel.add(collectionListPanel);
     141    queryFormulationPanel.add(searchTextFieldPanel);
     142    queryFormulationPanel.add(searchButtonPanel);
     143   
     144   
     145    resultsPanel = new JPanel();
     146    resultsPanel.setLayout(new BorderLayout());
     147    resultsPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
     148    ResultModel resultListModel = csModel.getResultsModel();
     149    resultsList = new JList(resultListModel);
     150    resultsList.setFont(resultsFont);
     151    resultsList.setBorder(BorderFactory.createEmptyBorder(3,3,3,3));
     152    resultsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
     153    scrollResultsPane = new JScrollPane(resultsList);
     154    resultsPanel.add(scrollResultsPane, BorderLayout.CENTER);
     155    csModel.addResult(new Result("Search results will appear here", "", ""));
     156   
     157    dataPanel = new JPanel();
     158    dataPanel.setLayout(new BorderLayout());
     159    dataPanel.setBorder(BorderFactory.createEmptyBorder(3,3,3,3));
     160    dataTextArea = new JTextArea("Document details will appear here", 10, 0);
     161    dataTextArea.setEditable(false);
     162    dataTextArea.setLineWrap(true);
     163    dataTextArea.setFont(docFont);
     164    dataTextArea.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
     165    scrollDataPane = new JScrollPane(dataTextArea);
     166    dataPanel.add(scrollDataPane, BorderLayout.CENTER);
    132167   
    133     parent.getRootPane().setDefaultButton(searchButton);
    134    
    135     //resultsList.getSelectionModel().addListSelectionListener(new ResultListSelectionHandler() );
    136     resultsList.addListSelectionListener(new ResultListSelectionHandler() );
    137    
    138     add(Box.createHorizontalStrut(400));
    139    
    140     add(queryFormulationPanel);
    141         add(resultsPanel);
    142     add(dataPanel);
    143     searchTextField.requestFocus();
     168    parent.getRootPane().setDefaultButton(searchButton);
     169   
     170    //resultsList.getSelectionModel().addListSelectionListener(new ResultListSelectionHandler() );
     171    resultsList.addListSelectionListener(new ResultListSelectionHandler() );
     172   
     173    add(Box.createHorizontalStrut(400));
     174   
     175    add(queryFormulationPanel);
     176    add(resultsPanel);
     177    add(dataPanel);
     178    searchTextField.requestFocus();
    144179  }
    145180
    146     public void setCollectionIndex(int index) {
    147 
    148     collectionList.setSelectedIndex(index);
    149 
     181  public void setCollectionIndex(int index) {
     182
     183    collectionList.setSelectedIndex(index);
     184
     185  }
     186
     187
     188  /** respond to the user pressing the Search button */
     189
     190  public void actionPerformed(ActionEvent e) {
     191    Object source = e.getSource();
     192    if (source == searchButton ) { //assume only searchButton generates events
     193      System.out.println("Search button pressed in SearchPanel");
     194      //send query to collection
     195      NzdlQuery nzdlQuery = new NzdlQuery( searchTextField.getText() );
     196      // return the first numResults that match
     197      //query.setEndResults( 15 );
     198      // "-1" means consider all the documents that match
     199      nzdlQuery.setMaxDocs( -1 );
     200      String collectionName = collectionList.getSelectedItem().toString();
     201      NzdlRequest request = new NzdlRequest( nzdlQuery );
     202      NzdlResponse response = new NzdlResponse( );
     203      csModel.getNzdlService().service( collectionName, request, response ); //nzdl object ????
     204      NzdlResultSet results = response.getResultSet();
     205      java.util.List docIDs = results.getDocumentIDs();
     206      // paired collection of docIDs and Titles - but as Sets!
     207      Map titleMetaData = csModel.getNzdlService().getMetaData( collectionName, docIDs, "Title" );
     208      // created a paired collection of docIDs and Titles - as simple Strings!
     209      HashMap titleMap = new HashMap();
     210      for (ListIterator i = docIDs.listIterator(); i.hasNext(); ) {
     211    String docID = (String) i.next();
     212    Set titleSet = (Set) titleMetaData.get( docID );
     213    ArrayList titleList = new ArrayList(titleSet);
     214    // String documentContents = csModel.getNzdlService().getDocument(collectionName, docID);
     215    //titleMap.put(docID, titleSet.toString()); //
     216    titleMap.put(docID, titleList.get(0)); // use the first title as *the* title
     217      } // end for
     218      // update resultsListModel
     219      // empty previous results List
     220      csModel.clearResults();
     221      System.err.println("Size of docIDs = " + docIDs.size());
     222      Iterator docIDsIterator = docIDs.iterator();
     223      while (docIDsIterator.hasNext()) {
     224    String resultDocID =  (String) docIDsIterator.next();
     225    Result result = new Result( (String)titleMap.get(resultDocID), resultDocID, collectionName );
     226    System.err.println("Adding result");
     227    csModel.addResult(result);
     228      } //end while
     229      // default to showing the top ranked document
     230      resultsList.setSelectedIndex(0);
     231    } // end if
     232    else {
     233      System.out.println("unknown Action event in SearchPanel");
    150234    }
    151 
    152 
    153     /* respond to the user pressing the Search button */
    154 
    155 public void actionPerformed(ActionEvent e) {
    156       Object source = e.getSource();
    157       if (source == searchButton ) { //assume only searchButton generates events
    158        System.out.println("Search button pressed in SearchPanel");
    159        //send query to collection
    160        NzdlQuery nzdlQuery = new NzdlQuery( searchTextField.getText() );
    161        // return the first numResults that match
    162        //query.setEndResults( 15 );
    163        // "-1" means consider all the documents that match
    164        nzdlQuery.setMaxDocs( -1 );
    165        String collectionName = collectionList.getSelectedItem().toString();
    166        NzdlRequest request = new NzdlRequest( nzdlQuery );
    167        NzdlResponse response = new NzdlResponse( );
    168        csModel.getNzdlService().service( collectionName, request, response ); //nzdl object ????
    169            NzdlResultSet results = response.getResultSet();
    170        java.util.List docIDs = results.getDocumentIDs();
    171        // paired collection of docIDs and Titles - but as Sets!
    172        Map titleMetaData = csModel.getNzdlService().getMetaData( collectionName, docIDs, "Title" );
    173        // created a paired collection of docIDs and Titles - as simple Strings!
    174        HashMap titleMap = new HashMap();
    175        for (ListIterator i = docIDs.listIterator(); i.hasNext(); ) {
    176            String docID = (String) i.next();
    177            Set titleSet = (Set) titleMetaData.get( docID );
    178            ArrayList titleList = new ArrayList(titleSet);
    179            // String documentContents = csModel.getNzdlService().getDocument(collectionName, docID);
    180            //titleMap.put(docID, titleSet.toString()); //
    181            titleMap.put(docID, titleList.get(0)); // use the first title as *the* title
    182        } // end for
    183        // update resultsListModel
    184        // empty previous results List
    185        csModel.clearResults();
    186        System.err.println("Size of docIDs = " + docIDs.size());
    187        Iterator docIDsIterator = docIDs.iterator();
    188        while (docIDsIterator.hasNext()) {
    189         String resultDocID =  (String) docIDsIterator.next();
    190         Result result = new Result( (String)titleMap.get(resultDocID), resultDocID, collectionName );
    191         System.err.println("Adding result");
    192         csModel.addResult(result);
    193        } //end while
    194        // default to showing the top ranked document
    195        resultsList.setSelectedIndex(0);
    196       } // end if
    197       else {
    198        System.out.println("unknown Action event in SearchPanel");
    199       }
    200  } //end actionPerformed
    201 
    202 
    203 
    204     /* handles selection events in the results list so that when the
    205        user selects a new title (say) the document contents is
    206        automatically displayed in the main panel */
    207 
    208  class ResultListSelectionHandler implements ListSelectionListener {
     235  } //end actionPerformed
     236
     237
     238
     239  /**
     240   * handles selection events in the results list so that when
     241   * the user selects a new title (say) the document contents
     242   * is automatically displayed in the main panel
     243   */
     244
     245  class ResultListSelectionHandler implements ListSelectionListener {
    209246    public void valueChanged(ListSelectionEvent e) {
    210             //get the result object from the SelectedIndex
    211         Result result = (Result) resultsList.getSelectedValue();
    212         // should check here to see if anything was actually selected !
    213         //get the document content from the result object
    214         // use a String for the moment to hold the contents
    215         String documentContents = csModel.getNzdlService().getDocument(result.getCollectionName(),  result.getDocID());
    216         dataTextArea.setText(documentContents);
    217         dataTextArea.setCaretPosition(0);
     247      //get the result object from the SelectedIndex
     248      Result result = (Result) resultsList.getSelectedValue();
     249      // should check here to see if anything was actually selected !
     250      //get the document content from the result object
     251      // use a String for the moment to hold the contents
     252      String documentContents = csModel.getNzdlService().getDocument(result.getCollectionName(),  result.getDocID());
     253      dataTextArea.setText(documentContents);
     254      dataTextArea.setCaretPosition(0);
    218255    } //end valueChanged
    219 }//end ResultListSelectionHandler
     256  }//end ResultListSelectionHandler
    220257
    221258
  • trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/SimpleGraphicalClient.java

    r2142 r2143  
    8181  int verbosity = 2;
    8282   
    83    
    84    SimpleGraphicalClient() {
     83  /**
     84   * Basic constructor
     85   */
     86  SimpleGraphicalClient() {
    8587    System.err.println("in constructor");
    8688    init(null);
    8789  }
    8890
     91  /**
     92   * Normal constructor
     93   * @param args the command line arguments
     94   */
    8995  public SimpleGraphicalClient(String [] args) {
    9096   
     
    9298  }
    9399
     100  /**
     101   * Do initialisation, including finding a server to connect to and
     102   * setting up all the GUI stuff
     103   * @param args the command line arguments
     104   */
    94105    void init(String [] args)  {
    95106    nzdl = NzdlIORs.findIOR(null, null,
     
    130141
    131142
    132    
     143  /**
     144   * Start the SimpleGraphicalClient
     145   * @param commandline arguments (only used in ORB initialisation).
     146   */
    133147   
    134148  public static void main(String args[])
     
    143157   
    144158} // class GraphicalClient
     159
     160
     161
     162
     163
     164
Note: See TracChangeset for help on using the changeset viewer.