Changeset 10559


Ignore:
Timestamp:
2005-08-25T09:19:03+12:00 (19 years ago)
Author:
mdewsnip
Message:

Moved opening a collection onto its own thread, so the progress bar works when using a remote Greenstone.

File:
1 edited

Legend:

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

    r10548 r10559  
    181181    }
    182182    else if (esrc == menu_bar.file_open) {
    183         String collection_file_path = showOpenCollectionDialog();
    184 
    185         // User has selected a collection to open
    186         if (collection_file_path != null) {
    187         // If there is already a collection open, save and close it
    188         if (Gatherer.c_man.ready()) {
    189             saveThenCloseCurrentCollection();
    190         }
    191 
    192         // Open the selected collection
    193         Gatherer.c_man.loadCollection(collection_file_path);
    194         }
     183        new OpenCollectionTask().start();
    195184    }
    196185    else if (esrc == menu_bar.file_options) {
     
    404393        Dictionary.register(tab_pane);
    405394        content_pane.add(tab_pane, BorderLayout.CENTER);
     395
    406396        // Call refresh to update all controls to reflect current collection status.
    407397        refresh(-1, Gatherer.c_man.ready());
     
    645635
    646636
    647     /** When the load collection option is choosen this method is called to produce the modal file load prompt.
     637    private class OpenCollectionTask
     638        extends Thread
     639    {
     640    public void run()
     641    {
     642        // If using a remote Greenstone check if the collection configurations have been downloaded; do so if not
     643        if (Gatherer.isGsdlRemote) {
     644        File collect_directory = new File(Gatherer.getCollectDirectoryPath());
     645        if (!collect_directory.exists() || collect_directory.listFiles().length == 0) {
     646            if (!RemoteGreenstoneServer.downloadCollectionConfigurations()) {
     647            // Something went wrong downloading the collection configurations
     648            return;
     649            }
     650        }
     651        }
     652
     653        String collection_file_path = showOpenCollectionDialog();
     654
     655        // User has selected a collection to open
     656        if (collection_file_path != null) {
     657        // If there is already a collection open, save and close it
     658        if (Gatherer.c_man.ready()) {
     659            saveThenCloseCurrentCollection();
     660        }
     661
     662        // Open the selected collection
     663        Gatherer.c_man.loadCollection(collection_file_path);
     664        }
     665    }
     666    }
     667
     668
     669    /** When the load collection option is chosen this method is called to produce the modal file load prompt.
    648670     */
    649671    private String showOpenCollectionDialog()
    650672    {
    651     // If using a remote Greenstone check if the collection configurations have been downloaded; do so if not
    652     File collect_directory = new File(Gatherer.getCollectDirectoryPath());
    653     if (Gatherer.isGsdlRemote && (!collect_directory.exists() || collect_directory.listFiles().length == 0)) {
    654         if (!RemoteGreenstoneServer.downloadCollectionConfigurations()) {
    655         // Something went wrong downloading the collection configurations
    656         return null;
    657         }
    658     }
    659 
    660673    // We first try the simple open collection dialog
    661674    SimpleOpenCollectionDialog dialog = new SimpleOpenCollectionDialog();
     
    668681
    669682    // Chosen to use the advanced 'browse' dialog
     683    File collect_directory = null;
    670684    if (user_choice == SimpleOpenCollectionDialog.BROWSE_OPTION) {
    671685        if (Gatherer.GS3) {
Note: See TracChangeset for help on using the changeset viewer.