Changeset 9039


Ignore:
Timestamp:
2005-02-15T12:11:37+13:00 (19 years ago)
Author:
mdewsnip
Message:

Added a progress bar for loading collections. This involved changing collection loading to be on a thread, so the progress dialog box is modal to prevent users from messing with anything while the collection is loaded.

Location:
trunk/gli/src/org/greenstone/gatherer
Files:
1 added
4 edited

Legend:

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

    r9034 r9039  
    6969    /** All of the external applications that must exit before we close the Gatherer. */
    7070    public Vector apps = new Vector();
     71    static public String open_collection_file_path = null;
    7172    /** A public reference to the FileAssociationManager. */
    7273    static public FileAssociationManager assoc_man;
     
    310311        }
    311312
    312         // If there was an open collection last session, reopen it.
    313         if (open_collection == null) {
    314         open_collection = Configuration.getString("general.open_collection", true);
    315         }
    316         if (!no_load && open_collection.length() > 0) {
    317         c_man.loadCollection(open_collection);
     313        open_collection_file_path = open_collection;
     314        if (open_collection_file_path == null) {
     315        open_collection_file_path = Configuration.getString("general.open_collection", true);
     316        }
     317        if (no_load || open_collection_file_path.equals("")) {
     318        open_collection_file_path = null;
    318319        }
    319320    }
  • trunk/gli/src/org/greenstone/gatherer/GathererApplet.java

    r8651 r9039  
    171171                    go.servlet_path, go.wget_version_str, go.wget_path);
    172172
    173 
    174173    JButton bttn = new JButton("Launch Greenstone Librarian Interface ...");
    175174    bttn.addActionListener(this);
     
    204203
    205204    gatherer.run(size, splash, g_man);
     205
     206    // If there was an open collection last session, reopen it.
     207    if (Gatherer.open_collection_file_path != null) {
     208        Gatherer.c_man.loadCollection(Gatherer.open_collection_file_path);
     209    }
    206210    }
    207211
  • trunk/gli/src/org/greenstone/gatherer/GathererProg.java

    r8629 r9039  
    9595                 go.servlet_path, go.wget_version_str, go.wget_path);
    9696    gatherer.run(size,splash,g_man);
     97
     98    // If there was an open collection last session, reopen it.
     99    if (Gatherer.open_collection_file_path != null) {
     100        Gatherer.c_man.loadCollection(Gatherer.open_collection_file_path);
     101    }
    97102    }
    98103}
  • trunk/gli/src/org/greenstone/gatherer/collection/CollectionManager.java

    r9036 r9039  
    5353import org.greenstone.gatherer.cdm.CollectionMetaManager;
    5454import org.greenstone.gatherer.cdm.CommandTokenizer;
     55import org.greenstone.gatherer.gui.ExternalCollectionPrompt;
    5556import org.greenstone.gatherer.gui.LockFileDialog;
     57import org.greenstone.gatherer.gui.ModalProgressPopup;
    5658import org.greenstone.gatherer.gui.NewCollectionMetadataPrompt;
    57 import org.greenstone.gatherer.gui.ExternalCollectionPrompt;
    5859import org.greenstone.gatherer.gui.WarningDialog;
    5960import org.greenstone.gatherer.metadata.DocXMLFileManager;
     
    317318        collect_dir.mkdirs();
    318319        }
    319         // Create a progress monitor.
    320         ProgressMonitor progress = new ProgressMonitor(Gatherer.g_man, Dictionary.get("CollectionManager.Creating_New"), "mkcol.pl", 0, 7);
     320
     321        // Create a progress monitor
     322        ProgressMonitor progress = new ProgressMonitor(Gatherer.g_man, Dictionary.get("CollectionManager.Creating_New"), "mkcol.pl", 0, 4);
     323
    321324        // Create the new collection.
    322325        makeCollection(description, email, name, title);
     326        progress.setProgress(1);
    323327       
    324328        // *******************
     
    337341        return;
    338342        }
    339         progress.setProgress(1);
    340343       
    341344        // ACTIVE_DIR/log/
     
    343346        File log_dir = log_dir_temp.getParentFile();
    344347        log_dir.mkdirs();
    345         if(progress != null) {
    346         progress.setNote(Dictionary.get("CollectionManager.Log_Created"));
    347         }
     348        progress.setNote(Dictionary.get("CollectionManager.Log_Created"));
    348349
    349350        // Make sure an import folder exists
     
    369370        ProfileXMLFileManager.loadProfileXMLFile(new File(collection_dir, Utility.META_DIR));
    370371
    371         // Before we create the CollectionDesignManager we have to check if we are basing it upon some other collection.
     372        // Before creating the CollectionDesignManager check if we are basing it upon some other collection
    372373        if (base_collection_directory != null) {
    373374        DebugStream.println("Basing new collection on existing one: " + base_collection_directory);
     
    460461        out = null;
    461462
    462         progress.setProgress(7);
     463        progress.setProgress(4);
    463464        progress.setNote(Dictionary.get("CollectionManager.Session_Ready", name));
    464465        progress.close();
     
    809810    }
    810811
     812
     813    public void loadCollection(String collection_file_path)
     814    {
     815    ModalProgressPopup load_collection_progress_popup = new ModalProgressPopup(Dictionary.get("CollectionManager.Loading_Collection"));
     816    LoadCollectionTask load_collection_task = new LoadCollectionTask(collection_file_path, load_collection_progress_popup);
     817    load_collection_task.start();
     818    load_collection_progress_popup.display();  // Blocks, so must go *after* starting the task!
     819    }
     820
     821
     822    private class LoadCollectionTask
     823    extends Thread
     824    {
     825    private String collection_file_path = null;
     826    private ModalProgressPopup load_collection_progress_popup = null;
     827
     828    public LoadCollectionTask(String collection_file_path, ModalProgressPopup load_collection_progress_popup)
     829    {
     830        this.collection_file_path = collection_file_path;
     831        this.load_collection_progress_popup = load_collection_progress_popup;
     832    }
     833
     834    public void run()
     835    {
     836        loadCollectionInternal(collection_file_path);
     837        load_collection_progress_popup.setVisible(false);
     838    }
     839    }
     840
     841
    811842    /** Attempts to load the given collection. Currently uses simple serialization of the collection class.
    812843     * @param location The path to the collection as a <strong>String</strong>.
     
    816847     * @see org.greenstone.gatherer.util.Utility
    817848     */
    818     public boolean loadCollection(String location)
     849    private void loadCollectionInternal(String location)
    819850    {
    820851    DebugStream.println("Loading collection " + location + "...");
    821     boolean non_gatherer_collection = false;
     852    boolean non_gli_collection = false;
    822853
    823854    // Check we have actually been given a .col file.
     
    825856        JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CollectionManager.Not_Col_File", location), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE);
    826857        DebugStream.println("CollectionManager.loadCollection: Haven't been given a .col file.");
    827         return false;
     858        return;
    828859    }
    829860
     
    835866        // we cant open this
    836867        collection_directory = null;
    837         return false;
     868        return;
    838869    }
    839870    File collection_config_file = new File(collection_directory, Utility.CONFIG_FILE);
     
    842873        collection_directory = null;
    843874        collection_config_file = null;
    844         return false;
     875        return;
    845876    }
    846877
     
    849880    if (!collection_metadata_directory.exists()) {
    850881        DebugStream.println("Loading non-gatherer collection...");
    851         non_gatherer_collection = true;
     882        non_gli_collection = true;
    852883    }
    853884
     
    866897        collection_directory = null;
    867898        collection_config_file = null;
    868         return false;
     899        return;
    869900        }
    870901
     
    872903    }
    873904
    874     boolean result = false;
    875905    try {
    876906        // Create a lock file.
     
    885915        JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CollectionManager.Cannot_Open_With_Reason", args), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE);
    886916        args = null;
    887         return false;
     917        return;
    888918        }
    889919
     
    905935 
    906936        // If this is a non-GLI (legacy) collection, ask the user to choose some metadata sets
    907         if (non_gatherer_collection) {
     937        if (non_gli_collection) {
    908938        if (!addSomeMetadataSets(collection_directory)) {
    909939            lock_file = null;
    910940            collection_directory = null;
    911941            closeCollection();
    912             return false;
     942            return;
    913943        }
    914944
     
    928958
    929959        collection.cdm = new CollectionDesignManager(collection_config_file);
    930         if (non_gatherer_collection) {
     960        if (non_gli_collection) {
    931961        // Change the classifiers to use the namespaced element names
    932962        LegacyCollectionImporter.updateClassifiers(collection.cdm);
    933963        }
    934964
    935         // Tell everyone that it worked.
     965        // We're done. Let everyone know.
    936966        DebugStream.println(Dictionary.get("CollectionManager.Loading_Successful", name));
    937 
    938         // We're done. Let everyone know.
    939967        Gatherer.refresh(Gatherer.COLLECTION_OPENED);
    940         result = true;
    941968    }
    942969    catch (Exception error) {
     
    957984    collection_directory = null;
    958985    collection_config_file = null;
    959 
    960     return result;
    961986    }
    962987
Note: See TracChangeset for help on using the changeset viewer.