Changeset 4400


Ignore:
Timestamp:
2003-05-29T11:09:36+12:00 (21 years ago)
Author:
jmt12
Message:

2030084: Fixed problem where preview pane was incorrectly attempting to reload the displayed page during GLI exit.

File:
1 edited

Legend:

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

    r4367 r4400  
    5757    private JLabel status      = null;
    5858    private Observer observer = null;
    59     private String args[]      = null;
    60     private String current_url = null;
    61     private String page_showing = null;
    62     private URL homepage       = null;
     59    private URL homepage = null;
     60
     61    static final public String BLANK_PAGE = "<html><head><title>No Page</title></head><body></body></html>";
    6362
    6463    public PreviewPane() {
     
    8382    observer = new Observer();
    8483    view = new CalHTMLPane(prefs, observer, "Default");
    85     //view.setSize(new Dimension(770, 440));
    8684
    8785    status = new JLabel(get("Ready"));
     
    8987
    9088    public void collectionChanged(boolean ready) {
     89    // If we were showing a page, but that page is no longer available, then return to a blank page
     90    if(!ready && homepage != null) {
     91        homepage = null;
     92        view.showHTMLDocument(BLANK_PAGE);
     93    }
    9194    }
    9295
     
    115118    public void gainFocus() {
    116119    if(Gatherer.c_man.ready() && Gatherer.c_man.built()) {
    117                 // Now load the collection
    118         String url = Gatherer.config.exec_address.toString() + "?a=p&p=about&c=" + Gatherer.c_man.getCollection().getName();
    119         Gatherer.println("Loading " + url);
    120         args = new String[1];
    121         args[0] = url;
    122         status.setText(get("Loading", args));
    123         args = null;
    124         view.showHTMLDocument((new GURL(url)).getURL());
    125         page_showing = url;
    126         homepage = (new GURL(url)).getURL();
    127         url = null;
     120        if(homepage == null) {
     121        try {
     122            // Now load the collection
     123            homepage = new URL(Gatherer.config.exec_address.toString() + "?a=p&p=about&c=" + Gatherer.c_man.getCollection().getName());
     124            ///atherer.println("Loading " + url);
     125            status.setText(get("Loading", homepage.toString()));
     126            view.showHTMLDocument(homepage);
     127        }
     128        catch (MalformedURLException exception) {
     129            Gatherer.printStackTrace(exception);
     130        }
     131        }
    128132    }
    129133    validate();
     
    136140    }
    137141
    138     public String get(String key, String args[]) {
     142    public String get(String key, String arg) {
    139143    if(key.indexOf(".") == -1) {
    140144        key = "Browser." + key;
    141145    }
    142     return Gatherer.dictionary.get(key, args);
     146    return Gatherer.dictionary.get(key, arg);
    143147    }
    144148
     
    146150    try {
    147151        String url = Gatherer.config.exec_address.toString() + command;
    148         System.err.println("Action: " + url);
     152        ///ystem.err.println("Action: " + url);
    149153        view.setLoadSynchronously(true);
    150154        view.showHTMLDocument(new URL(url));
    151155        view.setLoadSynchronously(false);
    152         System.err.println("Complete.");
     156        ///ystem.err.println("Complete.");
    153157        url = null;       
    154158    }
    155159    catch(MalformedURLException error) {
    156         System.err.println("Bad URL.");
     160        ///ystem.err.println("Bad URL.");
    157161    }
    158162    }
    159163
    160164    public void validate() {
    161     if(back_count > 0) {
    162         back.setEnabled(true);
    163     }
    164     else {
    165         back.setEnabled(false);
    166     }
    167     if(homepage != null) {
    168         home.setEnabled(true);
    169     }
    170     else {
    171         home.setEnabled(false);
    172     }
    173     if(forward_count > 0) {
    174         forward.setEnabled(true);
    175     }
    176     else {
    177         forward.setEnabled(false);
    178     }
    179     reload.setEnabled(true);
     165    back.setEnabled(back_count > 0);
     166    home.setEnabled(homepage != null);
     167    forward.setEnabled(forward_count > 0);
     168    reload.setEnabled(homepage != null);
    180169    }
    181170
     
    203192    implements ActionListener {
    204193    public void actionPerformed(ActionEvent event) {
    205         if(homepage != null) {
    206         view.showHTMLDocument(homepage);
    207         back_count++;
    208         validate();
    209         }
     194        view.showHTMLDocument(homepage);
     195        back_count++;
     196        forward_count = 0;
     197        validate();
    210198    }
    211199    }
     
    222210    public int state = CalCons.DOC_LOADED;
    223211    public void linkActivatedUpdate(CalHTMLPane pane, URL url, String target_frame, String j_name) {
    224         if(!url.toString().equals(current_url)) {
    225         back_count++;
    226         forward_count = 0;
    227         validate();
    228         }
     212        back_count++;
     213        forward_count = 0;
     214        validate();
    229215    }
    230216    public void linkFocusUpdate(CalHTMLPane pane, URL url) {
    231                 ///ystem.err.println("Link in focus " + url.toString());
    232         args = new String[1];
    233         args[0] = url.toString();
    234         status.setText(get("Follow"));
    235         args = null;
     217        ///ystem.err.println("Link in focus " + url.toString());
     218        status.setText(get("Follow", url.toString()));
    236219    }
    237220    public void statusUpdate(CalHTMLPane pane, int state, URL url, int value, String message) {
     
    245228        case CalCons.PARSE_FAILED:
    246229        ///ystem.err.println("Parse Failed: " + state + " - " + message);
    247         status.setText(get("CannotConnect") + message);
     230        status.setText(get("CannotConnect", url.toString()));
    248231        break;
    249232        // The Pane has established a connection to the given URL and is receiving any content.
    250233        case CalCons.CONNECTED:
    251234        ///ystem.err.println("Connected: " + state + " - " + message);
    252         args = new String[1];
    253         args[0] = url.toString();
    254         status.setText(get("Loading", args));
    255         args = null;
     235        status.setText(get("Loading", url.toString()));
    256236        break;
    257237        // The size of the content at the given URL is known and is contained in the value argument.
     
    266246        case CalCons.PARSE_FAILED_POST_CONNECT:
    267247        ///ystem.err.println("Parse Failed Post Connect: " + state + " - " + message);
    268         status.setText(get("TimedOut") + message);
     248        status.setText(get("TimedOut", url.toString()));
    269249        break;
    270250        // 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.
    271251        case CalCons.WAITING_FOR_IMAGES:
    272         ///ystem.err.println("Waiting For Images: " + state + " - " + message);
     252        ///ystem.err.println("Waiting For Images: " + state + " - " + message + " - " + url.toString());
    273253        break;
    274254        // All text and image data has been received, parsed and the document structure determined.
Note: See TracChangeset for help on using the changeset viewer.