Changeset 7609


Ignore:
Timestamp:
2004-06-17T14:30:29+12:00 (20 years ago)
Author:
kjdon
Message:

fixed the bug where when you drag a document with existing namespaced metadata into a collection with a different metadata set, the add button would be enabled for metadata with the same name as an existing one. the problem was, the namespace wasn't being removed before testing to see if it existed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/msm/MSMPrompt.java

    r6770 r7609  
    668668    args[0] = name;
    669669
     670    // we ignore any namespaces - if the name was a full match (namespace
     671    // and element name) then we wouldn't be in here
     672    String unqualified_name = name;
     673    int ns_sep = unqualified_name.indexOf(MSMUtils.NS_SEP);
     674    if (ns_sep != -1) {
     675        unqualified_name = unqualified_name.substring(ns_sep+1);
     676    }
     677   
    670678    // Create
    671679    MSMDialog dialog = new MSMDialog();
     
    728736
    729737    // Connect
    730     AddListener add_listener = new AddListener(dialog, name, set);
     738    AddListener add_listener = new AddListener(dialog, unqualified_name, set);
    731739    CancelListener cancel_listener = new CancelListener(dialog);
    732740    IgnoreListener ignore_listener = new IgnoreListener(dialog);
    733741    MergeListener merge_listener = new MergeListener(dialog, element);
    734     SetListener set_listener = new SetListener(set, element, name, add_button, merge_button);
    735 
     742    SetListener set_listener = new SetListener(set, element, unqualified_name, add_button, merge_button);
     743   
    736744    add_button.addActionListener(add_listener);
    737745    cancel_button.addActionListener(cancel_listener);
     
    748756        MetadataSet closest_set = null;
    749757        ElementWrapper closest_element = null;
    750         String base_name = name;
    751         int ns_sep = base_name.indexOf(MSMUtils.NS_SEP);
    752         if (ns_sep != -1) {
    753         base_name = base_name.substring(ns_sep+1);
    754         }
    755758        for(int i = 0; i < set.getItemCount(); i++) {
    756759        MetadataSet mds = (MetadataSet) set.getItemAt(i);
     
    758761            Element mde = mds.getElement(j);
    759762            String new_name = mde.getAttribute("name");
    760             if (base_name.equals(new_name)) {
     763            if (unqualified_name.equals(new_name)) {
    761764            closest_element = new ElementWrapper(mde);
    762765            closest_set = mds;
     
    845848    set_listener = null;
    846849    set = null;
     850    unqualified_name = null;
    847851    button_pane = null;
    848852    dialog.dispose();
     
    862866    private JDialog dialog = null;
    863867    private String name = null;
     868    // the name should have no namespace
    864869    public AddListener(JDialog dialog, String name, JComboBox set) {
    865870        this.dialog = dialog;
     
    870875        // Get the currently selected metadata set.
    871876        MetadataSet mds = (MetadataSet) set.getSelectedItem();
    872         String n = name;
    873         // If we've been forced to go this far then any given namespace is complete bollocks.
    874         while(n.indexOf(".") != -1 && !n.equals(".")) {
    875         n = n.substring(n.indexOf(".") + 1);
    876         }
    877877        // However, before we attempt to add a new element to the set, we should check that none already exists.
    878878        Element element = mds.getElement(name);
    879879        if (element == null) {
    880         result = mds.addElement(n, Gatherer.config.getLanguage());
     880        result = mds.addElement(name, Gatherer.config.getLanguage());
    881881        }
    882882        else {
     
    884884        }
    885885        mds = null;
    886         n = null;
    887886        element = null;
    888887        dialog.setVisible(false);
     
    10421041        // Can only add if the element doesn't already exist in the metadata set
    10431042        add_button.setEnabled(!mds.containsElement(element_name));
    1044 
    10451043        // Can only merge if the metadata set is not empty
    10461044        merge_button.setEnabled(mds.size() > 0);
Note: See TracChangeset for help on using the changeset viewer.