Changeset 2143 for trunk/java-client
- Timestamp:
- 2001-03-09T12:44:21+13:00 (23 years ago)
- 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 6 6 7 7 subdirs : 8 (cd SimpleGraphicalClient && $(MAKE) all) 8 9 (cd util && $(MAKE) all) 9 10 (cd service && $(MAKE) all) … … 11 12 12 13 clean: 14 (cd SimpleGraphicalClient && $(MAKE) clean) 13 15 (cd util && $(MAKE) clean) 14 16 (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 */ 1 19 package org.nzdl.gsdl.SimpleGraphicalClient; 2 20 … … 7 25 import java.awt.event.*; 8 26 import 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 */ 9 37 10 38 public 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 */ 1 19 package org.nzdl.gsdl.SimpleGraphicalClient; 2 20 … … 9 27 import org.nzdl.gsdl.service.NzdlService; 10 28 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 */ 11 39 12 40 class 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 */ 1 19 package org.nzdl.gsdl.SimpleGraphicalClient; 2 20 3 import java.awt.*; 21 import 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 4 34 5 35 public 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 */ 1 19 package org.nzdl.gsdl.SimpleGraphicalClient; 2 20 3 21 import 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 */ 4 32 5 33 public 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 */ 1 19 package org.nzdl.gsdl.SimpleGraphicalClient; 2 20 … … 5 23 import javax.swing.*; 6 24 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 */ 7 35 8 36 class 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 */ 1 19 package org.nzdl.gsdl.SimpleGraphicalClient; 2 3 20 4 21 import javax.swing.*; … … 21 38 22 39 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 */ 23 52 24 53 public class SearchPanel extends JPanel implements ActionListener, Constants 25 54 { 26 55 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 */ 38 73 39 74 public SearchPanel( CSModel newCsModel, JFrame parent) 40 75 { 41 76 super(); 42 77 csModel = newCsModel; 43 78 setLayout( new BoxLayout(this, BoxLayout.Y_AXIS)); 44 45 46 47 48 49 50 51 };52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 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); 132 167 133 134 135 136 137 138 139 140 141 142 143 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(); 144 179 } 145 180 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"); 150 234 } 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 { 209 246 public void valueChanged(ListSelectionEvent e) { 210 211 212 213 214 215 216 217 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); 218 255 } //end valueChanged 219 }//end ResultListSelectionHandler256 }//end ResultListSelectionHandler 220 257 221 258 -
trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/SimpleGraphicalClient.java
r2142 r2143 81 81 int verbosity = 2; 82 82 83 84 SimpleGraphicalClient() { 83 /** 84 * Basic constructor 85 */ 86 SimpleGraphicalClient() { 85 87 System.err.println("in constructor"); 86 88 init(null); 87 89 } 88 90 91 /** 92 * Normal constructor 93 * @param args the command line arguments 94 */ 89 95 public SimpleGraphicalClient(String [] args) { 90 96 … … 92 98 } 93 99 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 */ 94 105 void init(String [] args) { 95 106 nzdl = NzdlIORs.findIOR(null, null, … … 130 141 131 142 132 143 /** 144 * Start the SimpleGraphicalClient 145 * @param commandline arguments (only used in ORB initialisation). 146 */ 133 147 134 148 public static void main(String args[]) … … 143 157 144 158 } // class GraphicalClient 159 160 161 162 163 164
Note:
See TracChangeset
for help on using the changeset viewer.