Changeset 10396


Ignore:
Timestamp:
2005-08-02T15:35:54+12:00 (19 years ago)
Author:
mdewsnip
Message:

Tidied up the Gatherer and GUIManager exit() functions to make sure the loaded collection is saved when the user closes the GLI applet window.

Location:
trunk/gli/src/org/greenstone/gatherer
Files:
3 edited

Legend:

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

    r10387 r10396  
    470470    public void exit()
    471471    {
     472    System.err.println("In Gatherer.exit()...");
    472473    exit = true;
    473 
    474     // If we have an open collection remember it for next time, then save it and close it
    475     if (c_man.ready()) {
    476         Configuration.setString("general.open_collection", true, c_man.getCollectionFilePath());
    477         g_man.saveThenCloseCurrentCollection();
    478     }
    479     else {
    480         Configuration.setString("general.open_collection", true, null);
    481     }
    482474
    483475    // Save the file associations
     
    487479    }
    488480
    489     // Store the current position and size (if reasonable) of the Gatherer for next time
    490     Rectangle bounds = g_man.getBounds();
    491     Configuration.setBounds("general.bounds", true, bounds);
    492 
    493     // Save configuration.
    494     Configuration.save();
    495 
    496481    // Get the gui to deallocate
    497     g_man.setVisible(false);
    498482    g_man.destroy();
    499483    g_man_built = false;
     
    509493    // Make sure we haven't started up any processes that are still running
    510494    if (apps.size() == 0) {
    511         if (Gatherer.isApplet) {
    512         // If we're running as an applet we don't actually quit, just delete the main GLI window
    513         g_man = null;
    514         }
    515         else {
     495        // If we're running as an applet we don't actually quit (just hide the main GLI window)
     496        if (!Gatherer.isApplet) {
    516497        // This is the end...
    517498        System.exit(0);
  • trunk/gli/src/org/greenstone/gatherer/GathererApplet.java

    r10372 r10396  
    185185
    186186    // If there was an open collection last session, reopen it
    187     if (Gatherer.open_collection_file_path != null) {
     187    Gatherer.open_collection_file_path = Configuration.getString("general.open_collection", true);
     188    if (Gatherer.open_collection_file_path != null && !Gatherer.open_collection_file_path.equals("")) {
    188189        Gatherer.c_man.loadCollection(Gatherer.open_collection_file_path);
    189190    }
  • trunk/gli/src/org/greenstone/gatherer/gui/GUIManager.java

    r10387 r10396  
    174174    }
    175175    else if (esrc == menu_bar.file_exit) {
    176         returnToInitialPane();
    177176        exit();
    178177    }
     
    291290
    292291
    293     public void destroy() {
     292    /** This is called when we're absolutely finished with the GLI. It is *not* called when the applet is suspended.
     293     */
     294    public void destroy()
     295    {
    294296    // Destroying create pane ensures the latest log has been closed
    295297    if (create_pane != null) {
    296298        create_pane.destroy();
     299    }
     300
     301    // Deal to help
     302    if (help != null) {
     303        help.destroy();
     304        help = null;
    297305    }
    298306    }
     
    409417    /** This method ensures that all the things needing saving are saved before Gatherer.exit() is called.
    410418     */
    411     public void exit() {
    412     // Tell everyone who cares that they are losing focus
    413     DebugStream.println("**** GUIManager exit called!");
    414 
    415     if (!Gatherer.c_man.ready() || design_pane.canSave()) {
    416         // If we're running as an applet we don't actually quit, just hide the main GLI window
    417         if (Gatherer.isApplet) {
    418         // consider saving???
    419         setVisible(false);
    420         }
    421         else {
    422         if (Gatherer.c_man.ready() && !Gatherer.c_man.saved()) {
    423             Gatherer.c_man.saveCollection();
    424         }
    425 
    426         // Deal to help
    427         if (help != null) {
    428             help.destroy();
    429             help = null;
    430         }
    431         DebugStream.println("**** Calling Gatherer.self.exit");
    432         Gatherer.self.exit();
    433         }
     419    public void exit()
     420    {
     421    // If we have a collection open remember it for next time, then save it and close it
     422    if (Gatherer.c_man.ready()) {
     423        Configuration.setString("general.open_collection", true, Gatherer.c_man.getCollectionFilePath());
     424        saveThenCloseCurrentCollection();
     425    }
     426    else {
     427        Configuration.setString("general.open_collection", true, null);
     428    }
     429
     430    // Store the current position and size of the GLI for next time
     431    Configuration.setBounds("general.bounds", true, getBounds());
     432
     433    // Save configuration
     434    Configuration.save();
     435
     436    // Hide the main window
     437    setVisible(false);
     438
     439    // If we're running as an applet we don't quit here (we quit when the browser calls GathererApplet.destroy())
     440    if (!Gatherer.isApplet) {
     441        Gatherer.self.exit();
    434442    }
    435443    }
Note: See TracChangeset for help on using the changeset viewer.