Changeset 4585


Ignore:
Timestamp:
2003-06-11T16:42:00+12:00 (21 years ago)
Author:
mdewsnip
Message:

Fixed problem where sometimes the "view assigned metadata" menu item wasn't disabled correctly when a pane lost/gained focus. Also changed collection saving to happen when a user has confirmed a load/new collection.

File:
1 edited

Legend:

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

    r4561 r4585  
    187187    }
    188188        else if(esrc == menu_bar.file_new) {
    189         if(!Gatherer.c_man.saved()) {
    190         cont = showSaveCollectionBox(false, false);
    191         }
    192         if(cont) {
    193         showNewCollectionPrompt();
    194         }
     189        showNewCollectionPrompt();
    195190    }
    196191    else if(esrc == menu_bar.file_open) {
    197         if(!Gatherer.c_man.saved()) {
    198         cont = showSaveCollectionBox(false, false);
    199         }
    200         if(cont) {
     192        // if(!Gatherer.c_man.saved()) {
     193        // cont = showSaveCollectionBox(false, false);
     194        // }
     195        // if(cont) {
    201196        //if(!
    202197        showLoadCollectionBox();
     
    204199        //collectionChanged(false);
    205200        //}
    206         }
     201        // }
    207202    }
    208203    else if(esrc == menu_bar.file_options) {
     
    606601    // User can cancel action.
    607602    if(filename != null) {
    608         // If there is already a collection open, close it.
     603        // If there is already a collection open, save and close it.
    609604        if(Gatherer.c_man.ready()) {
    610         Gatherer.c_man.closeCollection();
     605        showSaveCollectionBox(true, false);     
    611606        // Wait until it is closed.
    612         try {
    613             while(Gatherer.c_man.ready()) {
    614             wait(10);
    615             }
    616         }
    617         catch(Exception error) {
    618         }
     607//          try {
     608//              while(Gatherer.c_man.ready()) {
     609//              wait(10);
     610//              }
     611//          }
     612//          catch(Exception error) {
     613//              System.err.println("Exception: " + error);
     614//              error.printStackTrace();
     615//          }
    619616        }
    620617        result = Gatherer.c_man.loadCollection(filename);
     
    635632    }
    636633    /** This method is used to open the new collection box on the screen.
    637       */
     634     */
    638635    public void showNewCollectionPrompt() {
    639636    NewCollectionMetadataPrompt ncm_prompt = null;
     
    646643    // Create the new collection (if not cancelled) in a new thread.
    647644    if(!ncd_prompt.isCancelled() && (ncm_prompt == null || !ncm_prompt.isCancelled())) {
    648         // If there is already a collection open, close it.
     645        // If there is already a collection open, save and close it.
    649646        if(Gatherer.c_man.ready()) {
    650         Gatherer.c_man.closeCollection();
     647        showSaveCollectionBox(true, false);
    651648        // Wait until it is closed.
    652         try {
    653             while(Gatherer.c_man.ready()) {
    654             wait(10);
    655             }
    656         }
    657         catch(Exception error) {
    658         }
    659         }
     649//          try {
     650//              synchronized(this) {
     651//              while(Gatherer.c_man.ready()) {
     652//                  wait(10);
     653//              }
     654//              }
     655//          }
     656//          catch(Exception error) {
     657//              System.err.println("Exception: " + error);
     658//              error.printStackTrace();
     659//          }
     660        }
     661
    660662        // Create new collection.
    661663        CreationTask task = new CreationTask(ncd_prompt, ncm_prompt);
    662         SwingUtilities.invokeLater(task);
     664        // SwingUtilities.invokeLater(task);
     665        task.start();
    663666        // Close prompt.
    664667    }
     
    668671    }
    669672    private class CreationTask
    670     implements Runnable {
     673        extends Thread {
    671674    private NewCollectionDetailsPrompt ncd_prompt = null;
    672675    private NewCollectionMetadataPrompt ncm_prompt = null;
     
    677680
    678681    public void run() {
     682        // System.err.println("Running CreationTask...");
    679683        if(ncm_prompt == null) {
    680684        Gatherer.c_man.createCollection(ncd_prompt.getDescription(), ncd_prompt.getEmail(), ncd_prompt.getName(), ncd_prompt.getTitle(), ncd_prompt.getBase(), null);
     
    732736        }
    733737    }
     738    // "View assigned metadata" menu item is disabled by default
     739    menu_bar.metadata_view.setCanEnable(false);
     740    menu_bar.setMetaAuditSuffix(null);
     741
    734742    menu_bar.tabSelected(tab_pane.getSelectedIndex());
    735743    if(tab_pane.getSelectedIndex() == tab_pane.indexOfComponent(collection_pane)) {
     744        collection_pane.gainFocus();
     745        // "View assigned metadata" menu item is enabled for the "Gather" pane
    736746        menu_bar.metadata_view.setCanEnable(true);
    737747    }
    738748    else if(tab_pane.getSelectedIndex() == tab_pane.indexOfComponent(metaedit_pane)) {
    739749        metaedit_pane.gainFocus();
     750        // "View assigned metadata" menu item is enabled for the "Enrich" pane
    740751        menu_bar.metadata_view.setCanEnable(true);
    741752    }
    742753    else if(tab_pane.getSelectedIndex() == tab_pane.indexOfComponent(config_pane)) {
    743754        config_pane.gainFocus();
    744         menu_bar.metadata_view.setCanEnable(false);
    745755    }
    746756    else if(tab_pane.getSelectedIndex() == tab_pane.indexOfComponent(create_pane)) {
    747757        create_pane.gainFocus();
    748         menu_bar.metadata_view.setCanEnable(false);
    749758    }
    750759    else if(tab_pane.getSelectedIndex() == tab_pane.indexOfComponent(preview_pane)) {
    751760        config_pane.saveConfiguration();
    752761        preview_pane.gainFocus();
    753         menu_bar.metadata_view.setCanEnable(false);
    754     }
    755     else {
    756         menu_bar.metadata_view.setCanEnable(false);
    757     }
     762    }
     763
    758764    previous_pane = (JPanel) tab_pane.getSelectedComponent();
    759765    }
Note: See TracChangeset for help on using the changeset viewer.