Changeset 2222 for trunk/java-client
- Timestamp:
- 2001-03-24T15:16:44+12:00 (23 years ago)
- Location:
- trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/CSFrame.java
r2197 r2222 91 91 content.add(searchPanel); 92 92 93 93 addWindowListener(new WindowHandler()); 94 94 95 95 pack(); … … 110 110 abstract class CSAction extends AbstractAction { 111 111 int menuItemID; 112 Frame frame;113 114 CSAction( String name, int newMenuItemID, Frame f)112 CSFrame frame; 113 114 CSAction( String name, int newMenuItemID, CSFrame f) 115 115 { 116 116 super(name); … … 125 125 class FileAction extends CSAction 126 126 { 127 FileAction(String name, int newMenuItemID, Frame frame)127 FileAction(String name, int newMenuItemID, CSFrame frame) 128 128 { 129 129 super(name,newMenuItemID, frame ); … … 159 159 class EditAction extends CSAction 160 160 { 161 EditAction(String name, int newMenuItemID, Frame frame)161 EditAction(String name, int newMenuItemID, CSFrame frame) 162 162 { 163 163 super(name,newMenuItemID, frame ); -
trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/CollectionInfoDialog.java
r2210 r2222 55 55 private String fullCollectionName = ""; 56 56 private String descString = ""; 57 private String numOfWordsString, numOfDocsString; 57 58 private NumberFormat numFormat = NumberFormat.getInstance(); 58 59 … … 81 82 contentPanel.add(collectionLabel); 82 83 contentPanel.add(new JLabel("Number of Documents:")); 83 String numOfDocs = numFormat.format( collectionInfo.getNumOfDocs()); 84 contentPanel.add(new JLabel(numOfDocs)); 84 85 long numOfDocs = collectionInfo.getNumOfDocs(); 86 if (numOfDocs == 0) 87 numOfDocsString = "unknown"; 88 else 89 numOfDocsString = numFormat.format(numOfDocs); 90 contentPanel.add(new JLabel(numOfDocsString)); 85 91 contentPanel.add(new JLabel("Number of Words:")); 86 String numOfWords = numFormat.format( collectionInfo.getNumOfWords()); 87 contentPanel.add(new JLabel(numOfWords)); 92 93 long numOfWords = collectionInfo.getNumOfWords(); 94 if (numOfWords == 0) 95 numOfWordsString = "unknown"; 96 else 97 numOfWordsString = numFormat.format(numOfWords); 98 contentPanel.add(new JLabel(numOfWordsString)); 88 99 contentPanel.add(new JLabel("Size:")); 89 100 long numOfBytes = collectionInfo.getNumOfBytes(); 90 101 contentPanel.add(new JLabel(formatByteSize(numOfBytes))); 91 102 contentPanel.add(new JLabel("Last built on:")); 103 // waiting for API to return a correct Date object ... 92 104 Date buildDate = new Date( collectionInfo.getBuildDate()*1000); 93 105 contentPanel.add(new JLabel(DateFormat.getDateTimeInstance().format(buildDate))); -
trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/Constants.java
r2190 r2222 19 19 package org.nzdl.gsdl.SimpleGraphicalClient; 20 20 21 import java.awt. Font;21 import java.awt.*; 22 22 23 23 /** … … 59 59 String SAVE_DOCS = "Save documents"; 60 60 61 /* Cursors */ 62 63 Cursor NORMAL_CURSOR = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR); 64 Cursor WAIT_CURSOR = Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR); 65 66 67 68 61 69 /*Fonts */ 62 70 -
trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/PreferencesDialog.java
r2195 r2222 47 47 public class PreferencesDialog extends JDialog implements ActionListener { 48 48 49 private CSFrame parentFrame; 49 50 private JButton okButton, cancelButton; 50 51 private JPanel buttonPanel, holderPanel; … … 54 55 55 56 56 PreferencesDialog( Frame f, String title, boolean modal) {57 PreferencesDialog(CSFrame f, String title, boolean modal) { 57 58 super(f, title, modal ); 59 parentFrame = f; 58 60 59 61 contentBox = Box.createVerticalBox(); … … 138 140 //System.err.println("ok button pressed!"); 139 141 142 boolean oldRawText = NzdlPreferences.getBoolean(Constants.RAW_TEXT); 143 140 144 NzdlPreferences.setBoolean(Constants.DISPLAY_FIRST_DOC,showFirstDocCheckBox.isSelected()); 141 145 NzdlPreferences.setBoolean(Constants.RAW_TEXT, showAsTextCheckBox.isSelected()); … … 148 152 // update the current display if raw text option has changed ? 149 153 154 boolean newRawText = NzdlPreferences.getBoolean(Constants.RAW_TEXT); 155 156 if (oldRawText != newRawText) { 157 //System.err.println("raw text option changed"); 158 if (newRawText) { 159 // kludgy direct access to instance and method 160 parentFrame.searchPanel.switchToRawText(); 161 } 162 else 163 // kludgy direct access to instance and method 164 parentFrame.searchPanel.switchToHTML(); 165 } // end if oldRawText != newRawTex 166 150 167 dispose(); //close window 151 } 168 } // end if source == okButton 152 169 else 153 170 { -
trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/SearchPanel.java
r2210 r2222 210 210 211 211 nzdl.service( collectionName, request, response ); 212 Date t8 = new Date();213 212 NzdlResultSet results = response.getResultSet(); 214 213 ArrayList docIDs = new ArrayList(results.getDocumentIDs()); … … 225 224 titleMap.put(docID, titleList.get(0)); 226 225 } // end for 227 Date t9 = new Date();228 long sdiff = t9.getTime() - t8.getTime();229 System.err.println("processing results = " + sdiff + " ms");230 226 // update the results list 231 227 csModel.clearResults(); … … 251 247 else { 252 248 if (e.getSource() == collectionInfoButton) { 253 //System.err.println("colllection info button pressed");254 249 CollectionInfoDialog cid = new CollectionInfoDialog(windowParent, collectionList.getSelectedItem().toString(), nzdl); 255 250 } … … 278 273 System.err.println("clicked on fake result"); 279 274 } 280 else { 281 // a real result representing a real document to deal with 282 283 windowParent.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); 284 //trash the old htmlDoc for memory/garbage collection 285 try { 286 if (htmlDoc != null) 287 htmlDoc.remove(0, htmlDoc.getLength()); 288 if (defaultStyledDoc != null) 289 defaultStyledDoc.remove(0, defaultStyledDoc.getLength()); 290 } catch (Exception exception) { 291 throw new Error (exception.toString()); 275 else { // a real result representing a real document to deal with 276 277 windowParent.setCursor(WAIT_CURSOR); 278 279 deleteDocContents(); // for memory/garbage collection 280 281 StringReader sr = new StringReader(nzdl.getDocument(result.getCollectionName(), result.getDocID())); 282 283 if (NzdlPreferences.getInstance().getBoolean(Constants.RAW_TEXT)) 284 // display the document as raw text 285 displayAsRawText(sr); 286 else { 287 // treat as HTML 288 displayAsHTML(sr); 289 htmlDoc.getImageData(nzdl, result.getCollectionName()); 292 290 } 293 defaultStyledDoc = new DefaultStyledDocument(); 294 htmlDoc = new GMLDocument(); 295 296 try { // get the document 297 String docContents = csModel.getNzdlService().getDocument(result.getCollectionName(), result.getDocID()); 298 StringReader sr = new StringReader(docContents); 299 if (NzdlPreferences.getInstance().getBoolean(Constants.RAW_TEXT)) { // display the document as raw text 300 documentPane.setEditorKit(styledEditorKit); 301 styledEditorKit.read( sr, defaultStyledDoc, 0); 302 documentPane.setDocument(defaultStyledDoc); 303 docLength = defaultStyledDoc.getLength(); 304 } 305 else { // treat as HTML 306 documentPane.setEditorKit(htmlEditorKit); 307 htmlEditorKit.read( sr, htmlDoc, 0); 308 documentPane.setStyledDocument( htmlDoc ); 309 docLength = htmlDoc.getLength(); 310 } 311 } // end try 312 catch(BadLocationException badLocException) 313 { 314 System.err.println("Bad Location Exception in creating HTML doc" + badLocException); 315 } 316 catch(IOException ioException) 317 { 318 System.err.println("IO Exception whilst reading doc contents" + ioException); 319 } 320 321 if (docLength > 0) 322 documentPane.setCaretPosition(1); 323 // we might not be using htmlDoc at this point!! 324 htmlDoc.getImageData(nzdl, result.getCollectionName()); 325 windowParent.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); 326 //System.err.println("prefix = " + nzdl.getCollectionInfo(result.getCollectionName()).getHTTPPrefix()); 291 292 windowParent.setCursor(NORMAL_CURSOR); 327 293 } 328 294 } //end valueChanged 329 295 }//end ResultListSelectionHandler 330 296 331 } //end SearchPanel 297 298 299 private void deleteDocContents() { 300 //trash the old htmlDoc for memory/garbage collection 301 try { 302 if (htmlDoc != null) 303 htmlDoc.remove(0, htmlDoc.getLength()); 304 if (defaultStyledDoc != null) 305 defaultStyledDoc.remove(0, defaultStyledDoc.getLength()); 306 } 307 catch (Exception exception) { 308 throw new Error (exception.toString()); 309 } 310 } // end deleteDocContents 311 312 313 public void switchToRawText() { 314 windowParent.setCursor(WAIT_CURSOR); 315 System.err.println("switching to raw text"); 316 displayAsRawText(new StringReader(documentPane.getText())); 317 windowParent.setCursor(NORMAL_CURSOR); 318 } 319 320 public void displayAsRawText(StringReader sr) { 321 defaultStyledDoc = new DefaultStyledDocument(); 322 documentPane.setEditorKit(styledEditorKit); 323 try { 324 styledEditorKit.read( sr, defaultStyledDoc, 0); 325 } 326 catch (Exception e) { 327 System.err.println(e); 328 } 329 documentPane.setDocument(defaultStyledDoc); 330 setCaretToStart(defaultStyledDoc.getLength()); 331 } // end displayAsRawText 332 333 334 public void switchToHTML() { 335 windowParent.setCursor(WAIT_CURSOR); 336 System.err.println("switching to HTML"); 337 displayAsHTML(new StringReader(documentPane.getText())); 338 windowParent.setCursor(NORMAL_CURSOR); 339 } 340 341 public void displayAsHTML(StringReader sr) { 342 htmlDoc = new GMLDocument(); 343 documentPane.setEditorKit(htmlEditorKit); 344 try { 345 htmlEditorKit.read( sr, htmlDoc, 0); 346 } 347 catch (Exception e) { 348 System.err.println(e); 349 } 350 documentPane.setStyledDocument( htmlDoc ); 351 setCaretToStart(htmlDoc.getLength()); 352 } // end displayAsHTML 353 354 355 private void setCaretToStart(int docLength) { 356 // it seems as if they haven't considered 357 // documents with > MAX_INT num of chars ... 358 if (docLength > 0) 359 documentPane.setCaretPosition(1); 360 } 361 362 363 } //end SearchPanel
Note:
See TracChangeset
for help on using the changeset viewer.