Changeset 6662


Ignore:
Timestamp:
2004-01-29T17:34:35+13:00 (20 years ago)
Author:
jmt12
Message:

Worked around stupid collection title clash warning dialog crashes spooty program on exit

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

Legend:

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

    r6389 r6662  
    192192    }
    193193
     194    /** Ensure that saving will actually work. This can return false if there is a collection filename clash for instance. */
     195    public boolean canSave() {
     196    return general_manager.canSave();
     197    }
     198
    194199    /** Cause the current collection configuration to be written out to disk.
    195200     * @see org.greenstone.gatherer.cdm.ClassifierManager
  • trunk/gli/src/org/greenstone/gatherer/cdm/GeneralManager.java

    r6636 r6662  
    9898    }
    9999
     100    public boolean canSave() {
     101    return ((GeneralControl)controls).canSave();
     102    }
     103
    100104    /** Destructor. */
    101105    public void destroy() {
     
    146150    extends JPanel
    147151    implements Control {
     152
     153    private boolean has_been_warned = false;
    148154    private boolean ready = false;
    149155    private CollectionMeta beta_collectionmeta;
     
    365371        ready = true;
    366372    }
     373
     374    public boolean canSave() {
     375        boolean title_clash_warning = true;
     376        // Oh, and if the collection title is already in use warn them about it
     377        String title = name_textfield.getText();
     378        // I just happen to have a handy method in the new details prompt to detect this very thing
     379        if(NewCollectionDetailsPrompt.titleClashes(title, CollectionDesignManager.collect_config.getFile())) {
     380        // Determine if the user wants to be warned about this
     381        WarningDialog dialog = new WarningDialog("warning.TitleClashes", true);
     382        if(dialog.display() == JOptionPane.OK_OPTION) {
     383            // If they have said yes, then carry on with the assignement
     384            collection_name_collectionmeta.setValue(title);
     385            has_been_warned = true;
     386        }
     387        // Otherwise we don't assign anything. In fact we have to restore the frame title back to its original value
     388        else {
     389            title_clash_warning = false;
     390            String collection_title = collection_name_collectionmeta.getValue(CollectionMeta.TEXT);
     391            String collection_name = Gatherer.c_man.getCollection().getName();
     392            Gatherer.g_man.setTitle(collection_title, collection_name);
     393            collection_name = null;
     394            collection_title = null;
     395        }
     396        dialog.dispose();
     397        dialog = null;
     398        }
     399        // No clash, no worries.
     400        else {
     401        collection_name_collectionmeta.setValue(title);
     402        }
     403        return title_clash_warning;
     404    }
     405
    367406    /** Called to store the current value of the components. */
    368407    public void loseFocus() {
     408       
    369409        // String values. Have to test if this component has actually ever recieved focus anyway.
    370410        if(ready) {
     
    386426        String title = name_textfield.getText();
    387427        // I just happen to have a handy method in the new details prompt to detect this very thing
    388         if(NewCollectionDetailsPrompt.titleClashes(title, CollectionDesignManager.collect_config.getFile())) {
     428        if(!has_been_warned && NewCollectionDetailsPrompt.titleClashes(title, CollectionDesignManager.collect_config.getFile())) {
    389429            // Determine if the user wants to be warned about this
    390430            WarningDialog dialog = new WarningDialog("warning.TitleClashes", true);
     
    411451
    412452        ready = false;
     453        has_been_warned = false;
    413454        } 
    414455    }
  • trunk/gli/src/org/greenstone/gatherer/collection/CollectionManager.java

    r6582 r6662  
    12331233    }
    12341234
     1235    public void setClosingThread(boolean set) {
     1236    if(set) {
     1237        closing_thread = Thread.currentThread();
     1238    }
     1239    else {
     1240        closing_thread = null;
     1241    }
     1242    }
     1243
    12351244    /** Updates the given workspace tree model to reference the private cache of the currently loaded collection. */
    12361245    /* private void updatePrivateWorkspace(DefaultTreeModel model) {
  • trunk/gli/src/org/greenstone/gatherer/gui/GConfigPane.java

    r6389 r6662  
    9999   }
    100100
     101    public boolean canSave() {
     102    return cdm.canSave();
     103    }
     104
    101105   public void loseFocus() {
    102106      if(cdm != null) {
  • trunk/gli/src/org/greenstone/gatherer/gui/GUIManager.java

    r6643 r6662  
    209209    }
    210210    else if(esrc == menu_bar.file_exit) {
    211         menu_bar.exit();
     211        //menu_bar.exit();
    212212        exit();
    213213    }
     
    539539     */
    540540    public void exit() {
    541     // First of all an exit can only happen if no modal dialog is currently being displayed. Something is creating a modal dialog but not disposing of it.
    542     if(Gatherer.current_modal != null) {
    543         System.err.println("There is a modal dialog open.");
    544         Gatherer.current_modal.makeVisible();
    545         Gatherer.current_modal.toFront();
    546         return;
    547     }
    548 
    549     boolean cont = true;
    550     if(Gatherer.c_man.ready() && !Gatherer.c_man.saved()) {
    551         cont = showSaveCollectionBox(false, true);
    552     }
    553     else {
    554         // Deal to help
    555         if(help != null) {
    556             help.destroy();
    557             help = null;
    558         }
    559         Gatherer.self.exit();
     541    // Tell everyone who cares that they are losing focus
     542    if(config_pane.canSave()) {
     543        boolean cont = true;
     544        if(Gatherer.c_man.ready() && !Gatherer.c_man.saved()) {
     545        cont = showSaveCollectionBox(false, true);
     546        }
     547        else {
     548        // Deal to help
     549        if(help != null) {
     550            help.destroy();
     551            help = null;
     552        }
     553        Gatherer.self.exit();
     554        }
    560555    }
    561556    }
     
    852847    //switch(result) {
    853848    //case SaveCollectionBox.SAVE_YES:
     849    Gatherer.c_man.setClosingThread(true);
    854850    Gatherer.c_man.saveCollection(close_after, exit_after);
    855851    // Wait until it is closed.
    856852    try {
    857         synchronized(this) {
     853        synchronized(this) {
    858854            while(Gatherer.c_man.reallyReady()) {
    859             wait(10);
     855            wait(10);
    860856            }
    861         }
     857        }
    862858    }
    863859    catch(Exception error) {
     
    865861        Gatherer.printStackTrace(error);
    866862    }
    867 
     863   
     864    Gatherer.c_man.setClosingThread(false);
     865   
    868866    //content_pane.paintImmediately(bounds);
    869867    return true;
  • trunk/gli/src/org/greenstone/gatherer/gui/ModalDialog.java

    r6641 r6662  
    151151            Object src = event.getSource ();
    152152            if (event instanceof ActiveEvent) {
    153                 ///ystem.err.println("ActiveEvent:");
     153                System.err.println("ActiveEvent:");
    154154                ((ActiveEvent) event).dispatch ();
    155155            } else if (src instanceof Component) {
    156                 ///ystem.err.println("Source is component");
     156                System.err.println("Source is component");
    157157                ((Component) src).dispatchEvent (event);
    158158            }
    159159            else {
    160                 ///ystem.err.println("Event blocked");
     160                System.err.println("Event blocked");
    161161            }
    162162            }
Note: See TracChangeset for help on using the changeset viewer.