Changeset 12238


Ignore:
Timestamp:
2006-07-17T11:09:28+12:00 (18 years ago)
Author:
kjdon
Message:

need to remove the set from the model before removing it from the collection. also, now we give a warning if adding a set to a collection with the same namespace as an exisitng set

File:
1 edited

Legend:

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

    r12142 r12238  
    132132    public void actionPerformed(ActionEvent event) {
    133133        MetadataSet metadata_set = (MetadataSet) current_set_list.getSelectedValue();
     134        current_metadata_model.removeElement(metadata_set);
    134135        Gatherer.c_man.removeMetadataSet(metadata_set);
    135         current_metadata_model.removeElement(metadata_set);
    136136        sets_changed = true;
    137137       
     
    179179        super(Gatherer.g_man, true);
    180180        add_set_dialog = this;
    181 
    182181        setModal(true);
    183182        setJMenuBar(new SimpleMenuBar("choosingmetadatasets"));
     
    282281        }
    283282        MetadataSet metadata_set = (MetadataSet) available_sets_list.getSelectedValue();
     283        String namespace = metadata_set.getNamespace();
     284        // have we got a variant already in the collection??
     285        MetadataSet existing_set = null;
     286        if ((existing_set = MetadataSetManager.getMetadataSet(namespace)) != null) {
     287            // warn that we are replacing
     288            String [] args = new String [] {metadata_set.toString(), existing_set.toString()};
     289            WarningDialog namespace_clash_dialog = new WarningDialog("warning.MetadataSetNamespaceClash", Dictionary.get("MetadataSetNamespaceClash.Title"), Dictionary.get("MetadataSetNamespaceClash.Message", args), null, true);
     290            if (namespace_clash_dialog.display()==JOptionPane.CANCEL_OPTION) {
     291            namespace_clash_dialog.dispose();
     292            return;
     293            }
     294            // if we have got here, then we remove the old set
     295            current_metadata_model.removeElement(existing_set);
     296            Gatherer.c_man.removeMetadataSet(existing_set);
     297            sets_changed = true;
     298            namespace_clash_dialog.dispose();
     299        }
     300       
     301       
    284302        Gatherer.c_man.importMetadataSet(metadata_set);
     303        metadata_set = MetadataSetManager.getMetadataSet(namespace);
    285304        current_metadata_model.addElement(metadata_set);
     305        sets_changed = true;
    286306        cancelled = false;
    287307        add_set_dialog.dispose();
Note: See TracChangeset for help on using the changeset viewer.