Changeset 4311
- Timestamp:
- 2003-05-23T16:34:59+12:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/gui/PreviewPane.java
r4293 r4311 56 56 private JButton reload = null; 57 57 private JLabel status = null; 58 private Observer observer = null; 58 59 private String args[] = null; 59 60 private String current_url = null; … … 80 81 81 82 CalHTMLPreferences prefs = new CalHTMLPreferences(); 82 Observerobserver = new Observer();83 observer = new Observer(); 83 84 view = new CalHTMLPane(prefs, observer, "Default"); 84 85 //view.setSize(new Dimension(770, 440)); … … 88 89 89 90 public void collectionChanged(boolean ready) { 91 /** 90 92 if(ready && Gatherer.c_man.built()) { 91 String url = Gatherer.config.exec_path + "?a=p&p=about&c=" + Gatherer.c_man.getCollection().getName(); 93 // If no address is set yet then its time to load the local library. 94 95 // Ask library to rebuild if necessary. 96 String url = Gatherer.config.exec_address + "?a=config&cmd=add-collection&c=" + Gatherer.c_man.getCollection().getName(); 97 Gatherer.println("Reset library: " + url); 98 observer.state = CalCons.PRE_CONNECT; 99 view.showHTMLDocument((new GURL(url)).getURL()); 100 // Display page. 101 url = Gatherer.config.exec_path + "?a=p&p=about&c=" + Gatherer.c_man.getCollection().getName(); 92 102 Gatherer.println("Loading " + url); 93 103 args = new String[1]; … … 98 108 } 99 109 validate(); 110 */ 100 111 } 101 112 … … 129 140 } 130 141 else { 142 String url = Gatherer.config.exec_address + "?a=config&cmd=add-collection&c=" + Gatherer.c_man.getCollection().getName(); 143 131 144 Gatherer.println("Loading " + url); 132 145 args = new String[1]; … … 177 190 } 178 191 192 /** This method performs nominally the same as a showHTMLDocument call expect that it blocks until some final loading state is reached, good or bad. */ 193 private void showAndWait(URL url) { 194 try { 195 // Send url to CalPane 196 197 // Wait until state is preconnect 198 while(observer.state != CalCons.PRE_CONNECT) { 199 wait(100); // 10th of a second 200 } 201 // Now wait until state is final state 202 while(observer.state != CalCons.DOC_LOADED) { 203 wait(100); // 10th of a second 204 } 205 } 206 catch (InterruptedException error) { 207 } 208 } 209 179 210 private class BackListener 180 211 implements ActionListener { … … 217 248 private class Observer 218 249 extends DefaultCalHTMLObserver { 250 public int state = CalCons.DOC_LOADED; 219 251 public void linkActivatedUpdate(CalHTMLPane pane, URL url, String target_frame, String j_name) { 220 252 if(!url.toString().equals(current_url)) { … … 232 264 } 233 265 public void statusUpdate(CalHTMLPane pane, int state, URL url, int value, String message) { 266 this.state = state; 234 267 switch(state) { 235 case 11: 268 // The Pane is attempting to connect to the given URL to receive data. 269 case CalCons.PRE_CONNECT: 270 System.err.println("Preconnect: " + value + " - " + message); 271 break; 272 // The Pane was unable to connect to the given URL or was unable to parse the content. Most likely this will be due to an incorrectly specified URL. The message argument may contain further details of the reason for failure. 273 case CalCons.PARSE_FAILED: 274 System.err.println("Parse Failed: " + value + " - " + message); 275 status.setText(get("CannotConnect") + message); 276 break; 277 // The Pane has established a connection to the given URL and is receiving any content. 278 case CalCons.CONNECTED: 279 System.err.println("Connected: " + value + " - " + message); 236 280 args = new String[1]; 237 281 args[0] = url.toString(); … … 239 283 args = null; 240 284 break; 241 case 14: 242 // Rendering complete. 285 // The size of the content at the given URL is known and is contained in the value argument. 286 case CalCons.DOC_LENGTH: 287 System.err.println("Doc Length: " + value + " - " + message); 288 break; 289 // The title of the document for the given URL is known and is contained in the message argument. Only the title of a document in the Pane's top level frame will be sent to this method. If the document has no name, the message will be null, unless the document is a Frameset document in which case the message "Frameset" will be sent. 290 case CalCons.TITLE: 291 System.err.println("Title: " + value + " - " + message); 292 break; 293 // An exception has been thrown during parsing of the data from the URL. This will most likely be an IOException such as a server time-out. 294 case CalCons.PARSE_FAILED_POST_CONNECT: 295 System.err.println("Parse Failed Post Connect: " + value + " - " + message); 296 status.setText(get("TimedOut") + message); 297 break; 298 // The document has been parsed but formatting cannot be completed because the document contains images of unspecified size. The parsing thread is waiting for image updates to give it the information it needs to format and display the document. 299 case CalCons.WAITING_FOR_IMAGES: 300 System.err.println("Waiting For Images: " + value + " - " + message); 301 break; 302 // All text and image data has been received, parsed and the document structure determined. 303 case CalCons.DOC_LOADED: 304 System.err.println("Doc Loaded: " + value + " - " + message); 243 305 status.setText(get("Ready")); 244 306 break;
Note:
See TracChangeset
for help on using the changeset viewer.