Changeset 12739


Ignore:
Timestamp:
2006-09-14T12:46:05+12:00 (18 years ago)
Author:
mdewsnip
Message:

Changed the "creating collection" progress dialog to be consistent with the "loading collection" dialog.

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

Legend:

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

    r12646 r12739  
    332332    public void createCollection(String description, String email, String name, String title, File base_collection_directory, ArrayList metadata_sets)
    333333    {
     334    // Display a modal progress popup to indicate that the collection is being loaded
     335    ModalProgressPopup create_collection_progress_popup = new ModalProgressPopup(Dictionary.get("CollectionManager.Creating_Collection"), Dictionary.get("CollectionManager.Creating_Collection_Please_Wait"));
     336    create_collection_progress_popup.display();
     337
     338    // Create the collection on a separate thread so the progress bar updates correctly
     339    (new CreateCollectionTask(description, email, name, title, base_collection_directory, metadata_sets, create_collection_progress_popup)).start();
     340    }
     341
     342
     343    private class CreateCollectionTask
     344    extends Thread
     345    {
     346    private String description = null;
     347    private String email = null;
     348    private String name = null;
     349    private String title = null;
     350    private File base_collection_directory = null;
     351    private ArrayList metadata_sets = null;
     352    private ModalProgressPopup create_collection_progress_popup = null;
     353
     354    public CreateCollectionTask(String description, String email, String name, String title, File base_collection_directory, ArrayList metadata_sets, ModalProgressPopup create_collection_progress_popup)
     355    {
     356        this.description = description;
     357        this.email = email;
     358        this.name = name;
     359        this.title = title;
     360        this.base_collection_directory = base_collection_directory;
     361        this.metadata_sets = metadata_sets;
     362        this.create_collection_progress_popup = create_collection_progress_popup;
     363    }
     364
     365    public void run()
     366    {
     367        createCollectionInternal(description, email, name, title, base_collection_directory, metadata_sets);
     368        create_collection_progress_popup.close();
     369    }
     370    }
     371
     372
     373    private void createCollectionInternal(String description, String email, String name, String title, File base_collection_directory, ArrayList metadata_sets)
     374    {
    334375    try {
    335376        // first make sure that the collect directory exists
     
    339380        }
    340381
    341         // Create a progress monitor
    342         ProgressMonitor progress = new ProgressMonitor(Gatherer.g_man, Dictionary.get("CollectionManager.Creating_New"), "mkcol.pl", 0, 4);
    343 
    344382        // Create the new collection
    345383        makeCollection(name, email);
    346         progress.setProgress(1);
    347384
    348385        // Check that the collection has been created successfully
     
    351388        // If there is no collection directory then the creation was unsuccessful, or cancelled
    352389        System.err.println("No collection directory...");
    353         progress.close();
    354390        return;
    355391        }
     
    360396        System.err.println("Error: no collect.cfg file has been created!");
    361397        JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CollectionManager.Cannot_Create_Collection_With_Reason", Dictionary.get("CollectionManager.No_Config_File")), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE);
    362         progress.close();
    363398        return;
    364399        }
     
    367402        File log_dir = new File(collection_directory_path + "log");
    368403        log_dir.mkdirs();
    369         progress.setNote(Dictionary.get("CollectionManager.Log_Created"));
    370404
    371405        // Make sure an import folder exists
     
    374408        import_directory.mkdirs();
    375409        }
    376 
    377         progress.setProgress(2);
    378410
    379411        // Now create the collection object around the directory.
     
    465497
    466498        collection.cdm.save(true);
    467         progress.setProgress(3);
    468499
    469500        // Create a lock file
    470501        createLockFile(new File(collection_directory_path, LOCK_FILE));
    471502
    472         progress.setProgress(4);
    473         progress.setNote(Dictionary.get("CollectionManager.Session_Ready", name));
    474         progress.close();
     503        // We're done. Let everyone know.
     504        Gatherer.refresh(Gatherer.COLLECTION_OPENED);
    475505    }
    476506    catch (Exception error) {
  • trunk/gli/src/org/greenstone/gatherer/gui/GUIManager.java

    r12609 r12739  
    786786        Gatherer.c_man.createCollection(ncd_prompt.getDescription(), Configuration.getEmail(), ncd_prompt.getName(), ncd_prompt.getTitle(), ncd_prompt.getBase(), metadata_sets);
    787787        ncd_prompt.dispose();
    788 
    789         // Return to some initial pane (Gather)
    790         returnToInitialPane();
    791 
    792         // Refresh the workspace tree to allow for the new collection
    793         refreshWorkspaceTree(WorkspaceTree.LIBRARY_CONTENTS_CHANGED);
    794 
    795         // Refresh the rest of the GLI
    796         Gatherer.refresh(Gatherer.COLLECTION_OPENED);
    797788        }
    798789
Note: See TracChangeset for help on using the changeset viewer.