Changeset 2165
- Timestamp:
- 2001-03-13T11:50:11+13:00 (23 years ago)
- Location:
- trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/Result.java
r2159 r2165 37 37 38 38 39 public final static String FAKE_RESULT = "No results returned";40 39 public final static Result FAKE_RESULT = new Result("No results returned", "", ""); 40 public final static Result INITIAL_FAKE_RESULT = new Result("Search results will appear here", "", ""); 41 41 // related query 42 42 // time, person, collection etc -
trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/SearchPanel.java
r2162 r2165 21 21 import java.awt.*; 22 22 import java.awt.event.*; 23 import java.io. StringReader;23 import java.io.*; 24 24 import java.io.IOException; 25 25 import java.util.*; … … 69 69 JScrollPane scrollDataPane; 70 70 JFrame windowParent; 71 72 JTextPane documentPane;71 //JEditorPane documentPane; 72 JTextPane documentPane; 73 73 HTMLEditorKit htmlEditorKit; 74 HTMLDocument htmlDoc; 74 GMLDocument htmlDoc = new GMLDocument(); 75 final static GMLDocument blankDoc = new GMLDocument(); 75 76 76 77 final static Rectangle TOP_RECT = new Rectangle(0,0,0,0); … … 145 146 scrollResultsPane = new JScrollPane(resultsList); 146 147 resultsPanel.add(scrollResultsPane, BorderLayout.CENTER); 147 csModel.addResult( new Result("Search results will appear here", "", ""));148 csModel.addResult(Result.INITIAL_FAKE_RESULT); 148 149 149 150 dataPanel = new JPanel(); 150 151 dataPanel.setLayout(new BorderLayout()); 151 152 dataPanel.setBorder(BorderFactory.createEmptyBorder(3,3,3,3)); 152 documentPane = new JTextPane(); 153 documentPane = new JTextPane(); 154 //documentPane = new JEditorPane(); 153 155 htmlEditorKit = new HTMLEditorKit(); 154 156 documentPane.setEditorKit(htmlEditorKit); … … 177 179 public void actionPerformed(ActionEvent e) { 178 180 if (e.getSource() == searchButton ) { //assume only searchButton generates events 181 // cursor not set when RETURN pressed, only when button clicked ? 179 182 windowParent.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); 183 //System.err.println("set wait cursor.."); 180 184 String queryString = searchTextField.getText(); 181 185 String collectionName = collectionList.getSelectedItem().toString(); … … 189 193 NzdlRequest request = new NzdlRequest( nzdlQuery ); 190 194 NzdlResponse response = new NzdlResponse(); 195 191 196 nzdl.service( collectionName, request, response ); 197 Date t8 = new Date(); 192 198 NzdlResultSet results = response.getResultSet(); 193 java.util.List docIDs = results.getDocumentIDs(); 199 ArrayList docIDs = new ArrayList(results.getDocumentIDs()); 200 // System.err.println("Size of docIDs = " + docIDs.size()); 194 201 // paired collection of docIDs and Titles - but as Sets! 195 202 Map titleMetaData = csModel.getNzdlService().getMetaData( collectionName, docIDs, "Title" ); … … 203 210 titleMap.put(docID, titleList.get(0)); 204 211 } // end for 212 Date t9 = new Date(); 213 long sdiff = t9.getTime() - t8.getTime(); 214 System.err.println("processing results = " + sdiff + " ms"); 205 215 // update the results list 206 216 csModel.clearResults(); 207 // System.err.println("Size of docIDs = " + docIDs.size());217 208 218 if (docIDs.size() == 0 ) { // give some feedback for 0 results 209 csModel.addResult(new Result(Result.FAKE_RESULT, "", "")); 210 documentPane.setText(""); 219 csModel.addResult(Result.FAKE_RESULT); 220 //documentPane.setText(""); 221 documentPane.setStyledDocument(blankDoc); 211 222 } 212 223 else { // there are some results … … 233 244 234 245 class ResultListSelectionHandler implements ListSelectionListener { 246 247 // private Result previousSelection = null; 248 235 249 public void valueChanged(ListSelectionEvent e) { 236 250 // get the result object from the SelectedIndex 237 251 // assume we only get here with events from resultsList 252 if (e.getValueIsAdjusting()) { return; } 238 253 Result result = (Result) resultsList.getSelectedValue(); 239 if (result.toString() == Result.FAKE_RESULT) { 240 documentPane.setText(""); 254 // System.err.println("result = " + result); 255 // System.err.println("fake result = " + Result.FAKE_RESULT); 256 if ((result == Result.FAKE_RESULT) || (result == Result.INITIAL_FAKE_RESULT)) { 257 //documentPane.setText(""); 258 documentPane.setStyledDocument( blankDoc ); 259 System.err.println("clicked on fake result"); 241 260 } 242 261 else { 262 263 Date startTime = new Date(); 264 Date t1 = new Date(); 265 243 266 windowParent.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); 244 267 … … 251 274 } 252 275 253 htmlDoc = new HTMLDocument(); 254 try 255 { // get the document and read it in as HTML 276 htmlDoc = new GMLDocument(); 277 try { // get the document and read it in as HTML 256 278 htmlEditorKit.read( new StringReader(csModel.getNzdlService().getDocument(result.getCollectionName(), result.getDocID())), htmlDoc, 0); 257 279 } 258 280 catch(BadLocationException badLocException) 259 281 { 260 282 System.err.println("Bad Location Exception in creating HTML doc" + badLocException); 261 283 } 262 284 catch(IOException ioException) 263 285 { 264 286 System.err.println("IO Exception whilst reading doc contents" + ioException); 265 } 287 } 288 Date t2 = new Date(); 289 long diff = t2.getTime() - t1.getTime(); 290 System.err.println("getDocument() = " + diff + " ms"); 291 292 Date t3 = new Date(); 293 266 294 documentPane.setStyledDocument( htmlDoc ); 295 296 Date t4 = new Date(); 297 long diff2 = t4.getTime() - t3.getTime(); 298 System.err.println("documentPane set " + diff2 + " ms"); 299 267 300 documentPane.scrollRectToVisible(TOP_RECT); 301 302 Date t5 = new Date(); 303 long diff7 = t5.getTime() - t4.getTime(); 304 System.err.println("documentPane scroll " + diff7 + " ms"); 305 306 //System.err.println("getting image data..."); 307 // htmlDoc.getImageData(); 268 308 windowParent.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); 309 Date endTime = new Date(); 310 long diff5 = endTime.getTime() - startTime.getTime(); 311 System.err.println("total time " + diff5 + " ms"); 269 312 } 270 313 } //end valueChanged
Note:
See TracChangeset
for help on using the changeset viewer.