Changeset 38968


Ignore:
Timestamp:
2024-05-01T17:29:55+12:00 (3 weeks ago)
Author:
anupama
Message:

GsdlCollageApplet. 1. On stopRunning, DisplayImages may be looping in the graphics thread and in that case would through an exception when interrupted. I know check isStopped() within the loop to more tidily exit in such a case. 2. Finally remembered to handle the case of if there's no GS3 running server or no internet connection of any kind. It used to be the case that GsdlCollageApplet would display the Downloading message forever, noticeable when run as a commandline application and if I forgot to run the GS3 server. Now if downloading fails it will say so and come to halt instead of waiting for downloads and displaying the message Downloading forever. 3. Some useful local changes of debugging output on an exception in CURL.

Location:
main/trunk/greenstone3/src/java/org/greenstone/applet/GsdlCollageApplet
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/applet/GsdlCollageApplet/CURL.java

    r38935 r38968  
    674674        }
    675675        catch (Exception e) {
     676        System.err.println("**** URL: " + url);
     677        System.err.println("**** url_str: " + url_str);
     678        System.err.println("**** HEAD: " + head);
     679        System.err.println("**** TAIL: " + tail);
    676680        e.printStackTrace();
    677681        }
  • main/trunk/greenstone3/src/java/org/greenstone/applet/GsdlCollageApplet/DisplayImages.java

    r38937 r38968  
    368368    public void paint(Graphics g)
    369369    {
    370 
     370    if(isStopping()) {
     371        return;
     372    }
    371373    screen_graphic_.setColor(bgcolor_);
    372374    screen_graphic_.fillRect(0,0,app_x_dim_,app_y_dim_);
     
    374376    // get each image currently onscreen inturn
    375377   
    376     for (int i=0; i < inuse_.size(); i++)
     378    for (int i=0; i < inuse_.size() && !isStopping(); i++)
    377379        {
    378380         
     
    416418   
    417419        }
    418    
     420
     421    if(isStopping()) {
     422        return;
     423    }
    419424       
    420425    finished_graphic_.drawImage(screen_buffer_,0,0,app_);
     
    427432            g.setColor(Color.white);
    428433            g.setFont(new Font("font",Font.PLAIN+Font.BOLD,30));
    429             g.drawString("Downloading" + dots[(dots_nums++)%dots.length],app_x_dim_/3-20,app_y_dim_/2-2);
     434
     435            if(app_.download_thread_.wasUnableToDownload()) {
     436            //System.err.println("Display loop");
     437            g.drawString("Can't download.", app_x_dim_/5-20,app_y_dim_/2-20);
     438            g.drawString("Stopping.", app_x_dim_/5-20,app_y_dim_/2+20);
     439            // GsdlCollageApplet.start() will handle rest of termination of threads
     440            } else {
     441            g.drawString("Downloading" + dots[(dots_nums++)%dots.length],app_x_dim_/3-20,app_y_dim_/2-2);
     442            }
    430443        }
    431444        }
  • main/trunk/greenstone3/src/java/org/greenstone/applet/GsdlCollageApplet/DownloadUrls.java

    r38930 r38968  
    4747     */
    4848    private boolean stop_downloading = false;
     49
     50    /** Set to true when unable to download perhaps because of no internet connection. */
     51    private boolean unable_to_download = false;
    4952   
    5053    /** CHRIS - Holds the contents of the collection's assoc directory */
     
    601604   
    602605    else {
    603         System.err.println("Unable able to download "+new_url);
     606        System.err.println("Unable to download "+new_url);
     607        unable_to_download = true;
    604608    }
    605609
     
    609613    }
    610614
     615    public boolean wasUnableToDownload() { return unable_to_download; }
     616   
    611617   
    612618    /** Used in cases where the image maps to a url outside of it's original location.
  • main/trunk/greenstone3/src/java/org/greenstone/applet/GsdlCollageApplet/GsdlCollageApplet.java

    r38948 r38968  
    812812
    813813            Thread curr_thread = Thread.currentThread();
    814        
     814           
    815815            while (curr_thread == paint) {
    816          
    817                repaint();
     816               
     817                repaint();
    818818               
    819819                Thread.sleep(2000);
     820                if(download_thread_.wasUnableToDownload()) {
     821                repaint();
     822                Thread.sleep(2000);
     823                String msg = "@@@ GsdlCollageApplet is unable to download. (No internet?) Stopping.";
     824                System.err.println(msg);
     825                if(isWebswing) {
     826                    WebswingUtil.getWebswingApi().sendActionEvent("javaToWebswingJSConsoleLog", msg, null);
     827                }                 
     828                if(!isRunAsApplet) {
     829                    System.exit(-1);
     830                } else {
     831                    stopRunning();
     832                    return;               
     833                }
     834                }
    820835                curr_thread = Thread.currentThread();
    821836            }
Note: See TracChangeset for help on using the changeset viewer.