Ignore:
Timestamp:
2003-05-23T16:34:59+12:00 (21 years ago)
Author:
jmt12
Message:

modified for new local library stuff

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/gui/PreviewPane.java

    r4293 r4311  
    5656     private JButton reload = null;
    5757     private JLabel status      = null;
     58     private Observer observer = null;
    5859     private String args[]      = null;
    5960     private String current_url = null;
     
    8081
    8182          CalHTMLPreferences prefs = new CalHTMLPreferences();
    82           Observer observer = new Observer();
     83          observer = new Observer();
    8384          view = new CalHTMLPane(prefs, observer, "Default");
    8485          //view.setSize(new Dimension(770, 440));
     
    8889     
    8990     public void collectionChanged(boolean ready) {
     91          /**
    9092          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();
    92102                Gatherer.println("Loading " + url);
    93103                args = new String[1];
     
    98108          }
    99109          validate();
     110          */
    100111     }
    101112
     
    129140                }
    130141                else {
     142                     String url = Gatherer.config.exec_address + "?a=config&cmd=add-collection&c=" + Gatherer.c_man.getCollection().getName();
     143
    131144                     Gatherer.println("Loading " + url);
    132145                     args = new String[1];
     
    177190     }
    178191
     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
    179210     private class BackListener
    180211          implements ActionListener {
     
    217248     private class Observer
    218249          extends DefaultCalHTMLObserver {
     250          public int state = CalCons.DOC_LOADED;
    219251          public void linkActivatedUpdate(CalHTMLPane pane, URL url, String target_frame, String j_name) {
    220252                if(!url.toString().equals(current_url)) {
     
    232264          }
    233265          public void statusUpdate(CalHTMLPane pane, int state, URL url, int value, String message) {
     266                this.state = state;
    234267                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);
    236280                     args = new String[1];
    237281                     args[0] = url.toString();
     
    239283                     args = null;
    240284                     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);
    243305                     status.setText(get("Ready"));
    244306                     break;
Note: See TracChangeset for help on using the changeset viewer.