Changeset 9943


Ignore:
Timestamp:
2005-05-24T17:00:37+12:00 (19 years ago)
Author:
mdewsnip
Message:

Fix to the bug that prevented adding the same attribute to an element in different languages. By Matthew Whyte.

Location:
trunk/gli/src/org/greenstone/gatherer/gems
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/gems/AttributeTableModel.java

    r8270 r9943  
    9797    }
    9898
     99    /**
     100     * Checks to see if the table contains a given value in a given column
     101     *
     102     * @param value the <strong>String</strong> to check for
     103     * @param column the column number to check in, as an <strong>int</strong>
     104     * @return boolean - true if the table contains the value.
     105     */
    99106    public boolean contains(String value, int column) {
    100107    boolean result = false;
     
    107114    } 
    108115    return result;
     116    }
     117
     118    /**
     119     * Checks to see if the table contains a given value in a given language
     120     *
     121     * @param value the <strong>String</strong> to check for
     122     * @param language_code the language code to check for, as a <strong>String</strong>
     123     * @return boolean - true if the table contains the value.
     124     */
     125    public boolean contains(String value, String language_code) {
     126    Iterator iterator = attributes.iterator();
     127    while(iterator.hasNext()) {
     128        Attribute attribute = (Attribute) iterator.next();
     129        String attributeLanguage = attribute.language;
     130        if(attributeLanguage == null) {
     131        attributeLanguage = "";
     132        }       
     133        if(language_code == null) {
     134        language_code = "";
     135        }
     136     
     137        if(value.equals(attribute.name) && language_code.equalsIgnoreCase(attribute.language)) {
     138        return true;
     139        }
     140    }
     141    return false;
    109142    }
    110143
  • trunk/gli/src/org/greenstone/gatherer/gems/GEMS.java

    r9855 r9943  
    10561056        String new_name_str = name.getSelectedItem().toString();
    10571057        String value_str = Codec.transform(Codec.transformUnicode(value.getText()), Codec.TEXT_TO_DOM);
     1058        String language_code = (String) language_box.getSelectedItem();
    10581059        String old_name_str = null;
    10591060        boolean cont = false;
     
    10671068
    10681069        // Check that there isn't already an entry for this attribute
    1069         if (!model.contains(new_name_str, 0) || (edit && new_name_str.equals(old_name_str)))
     1070        if (!model.contains(new_name_str, language_code) || (edit && new_name_str.equals(old_name_str)))
    10701071        {
    10711072            if(edit) //If edit, remove old attribute
     
    10851086        {
    10861087            cont = false;
    1087             JOptionPane.showMessageDialog(self, Dictionary.get("GEMS.Attribute_Already_Exists"), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE);
     1088            JOptionPane.showMessageDialog(self,
     1089                          Dictionary.get("GEMS.Attribute_Already_Exists"),
     1090                          Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE);
    10881091        }
    10891092       
     
    11151118
    11161119        //Check that there isn't already an entry for this attribute
    1117         if (!model.contains(new_name_str, 0) || (edit && new_name_str.equals(old_name_str)))
     1120        if (!model.contains(new_name_str, language_code) || (edit && new_name_str.equals(old_name_str)))
    11181121        {
    11191122            if(edit) //If this is an edit, remove the old attribute
     
    11351138        {
    11361139            cont = false;
    1137             JOptionPane.showMessageDialog(self, Dictionary.get("GEMS.Attribute_Already_Exists"), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE);
     1140            JOptionPane.showMessageDialog(self,
     1141                          Dictionary.get("GEMS.Attribute_Already_Exists"),
     1142                          Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE);
    11381143        }
    11391144   
Note: See TracChangeset for help on using the changeset viewer.