Changeset 2190
- Timestamp:
- 2001-03-18T12:39:16+12:00 (23 years ago)
- Location:
- trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/Constants.java
r2184 r2190 50 50 51 51 52 /* Preference Strings */ 53 54 String DISPLAY_FIRST_DOC = "Automatically display the first document"; 55 String RAW_TEXT = "Always display raw text (don't interpret HTML)"; 56 String MULTIPLE_SERVERS = "Connect to multiple servers"; 57 String LOG_SERVICE = "Log at the NzdlService level"; 58 String CACHE_CORBA = "Cache corba requests"; 59 String SAVE_DOCS = "Save documents"; 60 52 61 /*Fonts */ 53 62 -
trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/PreferencesDialog.java
r2188 r2190 50 50 private JPanel buttonPanel, holderPanel; 51 51 private Box contentBox; 52 private JCheckBox showFirstDocCheckBox, showAsTextCheckBox, connectToMultipleCheckBox, logNetworkLevelCheckBox, useCacheCheckBox, saveDocsCheckBox; 53 52 54 53 55 … … 70 72 71 73 //contentBox.add(); 72 String preferanceName = null;73 74 // the preferences themselves ... 74 75 75 preferanceName = "Automatically display the first document"; 76 JCheckBox showFirstDocCheckBox = 77 new JCheckBox(preferanceName, NzdlPreferences.getBoolean(preferanceName)); 76 showFirstDocCheckBox = 77 new JCheckBox( Constants.DISPLAY_FIRST_DOC, NzdlPreferences.getBoolean( Constants.DISPLAY_FIRST_DOC)); 78 78 showFirstDocCheckBox.setHorizontalAlignment(SwingConstants.LEFT); 79 79 80 preferanceName = "Always display raw text (don't interpret HTML)"; 81 JCheckBox showAsTextCheckBox = 82 new JCheckBox(preferanceName, NzdlPreferences.getBoolean(preferanceName)); 80 showAsTextCheckBox = 81 new JCheckBox( Constants.RAW_TEXT, NzdlPreferences.getBoolean(Constants.RAW_TEXT)); 83 82 showAsTextCheckBox.setHorizontalAlignment(SwingConstants.LEFT); 84 83 85 preferanceName = "Connect to multiple servers"; 86 JCheckBox connectToMultipleCheckBox = 87 new JCheckBox(preferanceName, NzdlPreferences.getBoolean(preferanceName)); 84 connectToMultipleCheckBox = 85 new JCheckBox(Constants.MULTIPLE_SERVERS, NzdlPreferences.getBoolean(Constants.MULTIPLE_SERVERS)); 88 86 connectToMultipleCheckBox.setHorizontalAlignment(SwingConstants.LEFT); 89 87 90 preferanceName = "Log at the NzdlService level"; 91 JCheckBox logNetworkLevelCheckBox = 92 new JCheckBox(preferanceName, NzdlPreferences.getBoolean(preferanceName)); 88 logNetworkLevelCheckBox = 89 new JCheckBox(Constants.LOG_SERVICE, NzdlPreferences.getBoolean(Constants.LOG_SERVICE)); 93 90 logNetworkLevelCheckBox.setHorizontalAlignment(SwingConstants.LEFT); 94 91 95 preferanceName = "Cache corba requests"; 96 JCheckBox useCacheCheckBox = 97 new JCheckBox(preferanceName, NzdlPreferences.getBoolean(preferanceName)); 92 useCacheCheckBox = 93 new JCheckBox(Constants.CACHE_CORBA, NzdlPreferences.getBoolean(Constants.CACHE_CORBA)); 98 94 useCacheCheckBox.setHorizontalAlignment(SwingConstants.LEFT); 99 95 100 preferanceName = "Save documents"; 101 JCheckBox saveDocsCheckBox = 102 new JCheckBox(preferanceName, NzdlPreferences.getBoolean(preferanceName)); 96 saveDocsCheckBox = 97 new JCheckBox(Constants.SAVE_DOCS, NzdlPreferences.getBoolean(Constants.SAVE_DOCS)); 103 98 saveDocsCheckBox.setHorizontalAlignment(SwingConstants.LEFT); 104 105 99 106 100 // add the preferences ... … … 144 138 //System.err.println("ok button pressed!"); 145 139 140 NzdlPreferences.setBoolean(Constants.DISPLAY_FIRST_DOC,showFirstDocCheckBox.isSelected()); 141 NzdlPreferences.setBoolean(Constants.RAW_TEXT, showAsTextCheckBox.isSelected()); 142 NzdlPreferences.setBoolean(Constants.MULTIPLE_SERVERS, connectToMultipleCheckBox.isSelected()); 143 NzdlPreferences.setBoolean(Constants.LOG_SERVICE,logNetworkLevelCheckBox.isSelected()); 144 NzdlPreferences.setBoolean(Constants.CACHE_CORBA, useCacheCheckBox.isSelected()); 145 NzdlPreferences.setBoolean(Constants.SAVE_DOCS, saveDocsCheckBox.isSelected()); 146 146 NzdlPreferences.getInstance().save(); 147 147 dispose(); //close window -
trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/SearchPanel.java
r2184 r2190 38 38 import org.nzdl.gsdl.service.NzdlService; 39 39 import org.nzdl.gsdl.service.NzdlServiceClient; 40 import org.nzdl.gsdl.util.NzdlPreferences; 40 41 41 42 … … 70 71 JFrame windowParent; 71 72 //JEditorPane documentPane; 72 JTextPane documentPane; 73 HTMLEditorKit htmlEditorKit; 73 JTextPane documentPane; // make this a JTextComponent ?? 74 JTextArea documentArea; 75 JTextComponent documentComponent; 76 HTMLEditorKit htmlEditorKit = new HTMLEditorKit(); 77 StyledEditorKit styledEditorKit = new StyledEditorKit(); 74 78 GMLDocument htmlDoc = new GMLDocument(); 79 DefaultStyledDocument defaultStyledDoc = new DefaultStyledDocument(); 75 80 final static GMLDocument blankDoc = new GMLDocument(); 76 81 … … 149 154 dataPanel.setLayout(new BorderLayout()); 150 155 dataPanel.setBorder(BorderFactory.createEmptyBorder(3,3,3,3)); 151 documentPane = new JTextPane(); 152 //documentPane = new JEditorPane(); 153 htmlEditorKit = new HTMLEditorKit(); 154 documentPane.setEditorKit(htmlEditorKit); 156 documentPane = new JTextPane() { // to control scrolling for raw text docs 157 public boolean getScrollableTracksViewportWidth() { 158 if (getSize().width < getParent().getSize().width) 159 return true; 160 else return false; 161 } 162 public void setSize(Dimension d) { 163 if (d.width < getParent().getSize().width) 164 d.width = getParent().getSize().width; 165 super.setSize(d); 166 } 167 }; // end custom JTextPane 155 168 documentPane.setEditable(false); 156 169 documentPane.setFont(docFont); … … 225 238 csModel.addResult(new Result((String)titleMap.get(resultDocID), resultDocID, collectionName )); 226 239 } //end while 240 if (NzdlPreferences.getInstance().getBoolean(Constants.DISPLAY_FIRST_DOC)) 227 241 resultsList.setSelectedIndex(0); // should be under Preference control! 228 242 } // end else … … 258 272 } 259 273 else { 260 261 Date startTime = new Date(); 274 // a real result representing a real document to deal with 275 262 276 windowParent.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); 263 //trash the old htmlDoc ...277 //trash the old htmlDoc for memory/garbage collection 264 278 try { 265 279 if (htmlDoc != null) 266 280 htmlDoc.remove(0, htmlDoc.getLength()); 281 if (defaultStyledDoc != null) 282 defaultStyledDoc.remove(0, defaultStyledDoc.getLength()); 267 283 } catch (Exception exception) { 268 284 throw new Error (exception.toString()); 269 285 } 286 defaultStyledDoc = new DefaultStyledDocument(); 270 287 htmlDoc = new GMLDocument(); 271 Date t1 = new Date(); 272 Date d1 = new Date(); 273 Date d2 = new Date(); 274 Date d21 = new Date(); 275 Date d3 = new Date(); 276 try { // get the document and read it in as HTML 277 d1 = new Date(); 288 289 try { // get the document 278 290 String docContents = csModel.getNzdlService().getDocument(result.getCollectionName(), result.getDocID()); 279 d2 = new Date(); 280 //long ddiff1 = d2.getTime() - d1.getTime(); 281 // System.err.println("getDocument = " + ddiff1 + "ms"); 282 StringReader sr = new StringReader(docContents); 283 d21 = new Date(); 284 htmlEditorKit.read( sr, htmlDoc, 0); // should be under preference control! 285 d3 = new Date(); 286 //long ddiff2 = d3.getTime() - d2.getTime(); 287 //System.err.println("StringReader() = " + ddiff2 + "ms"); 288 289 // htmlEditorKit.read( new StringReader(csModel.getNzdlService().getDocument(result.getCollectionName(), result.getDocID())), htmlDoc, 0); 290 } 291 StringReader sr = new StringReader( docContents); 292 if (NzdlPreferences.getInstance().getBoolean(Constants.RAW_TEXT)) { // display the document as raw text 293 documentPane.setEditorKit(styledEditorKit); 294 styledEditorKit.read( sr, defaultStyledDoc, 0); 295 documentPane.setDocument(defaultStyledDoc); 296 } 297 else { // treat as HTML 298 documentPane.setEditorKit(htmlEditorKit); 299 htmlEditorKit.read( sr, htmlDoc, 0); 300 documentPane.setStyledDocument( htmlDoc ); 301 } 302 // htmlEditorKit.read( new StringReader(csModel.getNzdlService().getDocument(result.getCollectionName(), result.getDocID())), htmlDoc, 0); 303 } 291 304 catch(BadLocationException badLocException) 292 305 { … … 297 310 System.err.println("IO Exception whilst reading doc contents" + ioException); 298 311 } 299 Date t2 = new Date(); 300 long diff = t2.getTime() - t1.getTime(); 301 long ddiff1 = d2.getTime() - d1.getTime(); 302 long ddiff2 = d21.getTime() - d2.getTime(); 303 long ddiff3 = d3.getTime() - d21.getTime(); 304 System.err.println("nzdl.getDocument = " + ddiff1 + "ms"); 305 System.err.println("StringReader() constructor = " + ddiff2 + "ms"); 306 System.err.println("EditorKit.read() = " + ddiff3 + " ms"); 307 System.err.println("getDocument total = " + diff + " ms"); 308 309 Date t3 = new Date(); 310 311 documentPane.setStyledDocument( htmlDoc ); 312 313 Date t4 = new Date(); 314 long diff2 = t4.getTime() - t3.getTime(); 315 System.err.println("documentPane set " + diff2 + " ms"); 316 312 313 //documentPane.setStyledDocument( htmlDoc ); 314 // should check for empty document here 317 315 documentPane.setCaretPosition(1); 318 319 //Date t5 = new Date(); 320 //long diff7 = t5.getTime() - t4.getTime(); 321 //System.err.println("documentPane scroll " + diff7 + " ms"); 322 323 //System.err.println("getting image data..."); 324 htmlDoc.getImageData(nzdl, result.getCollectionName()); 316 // we might not be using htmlDoc at this point!! 317 //htmlDoc.getImageData(nzdl, result.getCollectionName()); 325 318 windowParent.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); 326 Date endTime = new Date();327 long diff5 = endTime.getTime() - startTime.getTime();328 System.err.println("total time " + diff5 + " ms");329 319 //System.err.println("prefix = " + nzdl.getCollectionInfo(result.getCollectionName()).getHTTPPrefix()); 330 320 } -
trunk/java-client/org/nzdl/gsdl/SimpleGraphicalClient/SimpleGraphicalClient.java
r2184 r2190 33 33 import org.nzdl.gsdl.service.NzdlService; 34 34 import org.nzdl.gsdl.service.NzdlServiceClient; 35 import org.nzdl.gsdl.util.NzdlPreferences; 35 36 import org.nzdl.gsdl.util.NzdlServiceFactory; 36 37
Note:
See TracChangeset
for help on using the changeset viewer.