Ignore:
Timestamp:
2005-05-03T13:28:34+12:00 (19 years ago)
Author:
mdewsnip
Message:

Tidied up opening collections, and showLoadCollectionBox (now showOpenCollectionDialog) in particular. Now switches back to the Gather pane correctly before closing an open collection, as it needs to do to prevent nasty problems.

File:
1 edited

Legend:

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

    r9800 r9801  
    181181    }
    182182    else if (esrc == menu_bar.file_open) {
    183         if (showLoadCollectionBox()) {
    184         tab_pane.setSelectedComponent(gather_pane);
     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            tab_pane.setSelectedComponent(gather_pane);  // Must be done before closing the collection
     190            Gatherer.c_man.saveCollection();
     191            Gatherer.c_man.closeCollection();
     192        }
     193
     194        // Open the selected collection
     195        Gatherer.c_man.loadCollection(collection_file_path);
    185196        }
    186197    }
     
    619630    }
    620631
     632
    621633    /** When the load collection option is choosen this method is called to produce the modal file load prompt.
    622634     */
    623     private boolean showLoadCollectionBox() {
    624     boolean result = false;
     635    private String showOpenCollectionDialog()
     636    {
    625637    // We first try the simple open collection dialog
    626638    SimpleOpenCollectionDialog dialog = new SimpleOpenCollectionDialog();
    627639    int user_choice = dialog.display();
    628     String filename = null;
    629     // The user may choose to go to the advanced 'browse' dialog
    630     if(user_choice == SimpleOpenCollectionDialog.OK_OPTION) {
    631         filename = dialog.getFileName();
    632     }
    633     else if(user_choice == SimpleOpenCollectionDialog.BROWSE_OPTION) {
     640
     641    // Used simple collection list
     642    if (user_choice == SimpleOpenCollectionDialog.OK_OPTION) {
     643        return dialog.getFileName();
     644    }
     645
     646    // Chosen to use the advanced 'browse' dialog
     647    if (user_choice == SimpleOpenCollectionDialog.BROWSE_OPTION) {
    634648        File collect_directory;
    635649        if (Gatherer.GS3) {
     
    640654        }
    641655        OpenCollectionDialog chooser = new OpenCollectionDialog(collect_directory);
    642         filename = chooser.getFileName();
    643         chooser.destroy();
    644         chooser = null;
    645     }
    646     dialog.destroy();
    647     dialog = null;
    648     // User can cancel action.
    649     if(filename != null) {
    650         // If there is already a collection open, save and close it.
    651         if (Gatherer.c_man.ready()) {
    652         Gatherer.c_man.saveCollection();
    653         Gatherer.c_man.closeCollection();
    654         }
    655 
    656         Gatherer.c_man.loadCollection(filename);
    657 
    658         filename = null;
    659     }
    660     return result;
     656        return chooser.getFileName();
     657    }
     658
     659    // User must have cancelled the action
     660    return null;
    661661    }
    662662
Note: See TracChangeset for help on using the changeset viewer.