Changeset 6539


Ignore:
Timestamp:
2004-01-16T16:04:59+13:00 (20 years ago)
Author:
jmt12
Message:

Heres a bunch of other changed files. If it wasn't a Friday afternoon I might be bothered finding out what I actually changed in them. Such changes include: a new option or three on preferences, a bug fix for the GDM classes, several changes to CDM to allow for G2.39 configuration files, a fix to Codec to allow for quotes in format strings and more work on CommandTokenizer to allow for stupid, stupid, stupid collectionextra's starting with speech marks then a new line. Plus other stuff. And things. Peace Out.

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

Legend:

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

    r6318 r6539  
    4747 */
    4848public class CollectionConfiguration
    49     extends StaticStrings {
    50 
    51     static public Document document;
     49    extends StaticStrings {
     50   
     51    static final public String ENCODING = "UTF-8";
     52
     53    static public Document document;
    5254
    5355    static public void main(String[] args) {
     
    310312    /** ************************** Public Data Members ***************************/
    311313
    312     /** ************************** Private Data Members ***************************/
    313 
    314     private File collect_config_file;
    315 
    316     /** ************************** Public Methods ***************************/
    317 
    318     public CollectionConfiguration(File collect_config_file) {
     314    /** ************************** Private Data Members ***************************/
     315   
     316    /** Is the configuration file currently being read in one of the infamous G2.39 ones. */
     317    private boolean is_twopointthreenine = false;
     318    private File collect_config_file;
     319
     320    /** ************************** Public Methods ***************************/
     321
     322    public CollectionConfiguration(File collect_config_file) {
    319323    this.self = this;
    320324    this.collect_config_file = collect_config_file;
     
    322326    String collect_config_name = collect_config_file.getName();
    323327    if(collect_config_name.equals(COLLECTCONFIGURATION_XML)) {
    324         // Parse with Utility but don't use class loader
    325         document = Utility.parse(collect_config_file, false);
     328        // Parse with Utility but don't use class loader
     329        document = Utility.parse(collect_config_file, false);
    326330    }
    327331    // Otherwise if this is a legacy collect.cfg file then read in the template and send to magic parser
    328332    else if(collect_config_name.equals(COLLECT_CFG)) {
    329         document = Utility.parse(PSEUDO_COLLECTCONFIGURATION_XML, true);
    330         parse(collect_config_file);
    331     }
    332     }
    333 
    334     /** This debug facility shows the currently loaded collect.cfg or CollectConfig.xml file as a DOM tree. */
    335     public void display() {
     333        document = Utility.parse(PSEUDO_COLLECTCONFIGURATION_XML, true);
     334        parse(collect_config_file);
     335    }
     336    }
     337
     338    /** This debug facility shows the currently loaded collect.cfg or CollectConfig.xml file as a DOM tree. */
     339    public void display() {
    336340    JDialog dialog = new JDialog(Gatherer.g_man, "Collection Configuration", false);
    337341    dialog.setSize(400,400);
     
    342346    refresh_button.addActionListener(new ActionListener() {
    343347        public void actionPerformed(ActionEvent event) {
    344             tree.setDocument(document);
    345         }
    346         });
     348            tree.setDocument(document);
     349        }
     350        });
    347351    content_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
    348352    content_pane.setLayout(new BorderLayout());
     
    350354    content_pane.add(refresh_button, BorderLayout.SOUTH);
    351355    dialog.show();
    352     }
    353 
    354     public Element getBeta() {
     356    }
     357   
     358    public Element getBeta() {
    355359    Element element = getOrCreateElementByTagName(COLLECTIONMETADATA_BETA_ELEMENT, null, null);
    356360    element.setAttribute(NAME_ATTRIBUTE, COLLECTIONMETADATA_BETA_STR);
    357361    element.setAttribute(SPECIAL_ATTRIBUTE, TRUE_STR);
    358362    return element;
    359     }
     363    }
    360364
    361365    public Element getCreator() {
     
    451455    }
    452456
    453     public void save(boolean force_xml) {
     457    public void save(boolean force_xml) {
    454458    if(collect_config_file.exists()) {
    455         File original_file = new File(collect_config_file.getParentFile(), COLLECT_CFG);
    456         File backup_file = new File(collect_config_file.getParentFile(), "collect.bak");
    457         if(backup_file.exists()) {
     459        File original_file = new File(collect_config_file.getParentFile(), COLLECT_CFG);
     460        File backup_file = new File(collect_config_file.getParentFile(), "collect.bak");
     461        if(backup_file.exists()) {
    458462        backup_file.delete();
    459         }
    460         if(!original_file.renameTo(backup_file)) {
     463        }
     464        if(!original_file.renameTo(backup_file)) {
    461465        Gatherer.println("Can't rename collect.cfg");
    462         }
     466        }
    463467    }
    464468    if(force_xml || collect_config_file.getName().equals(COLLECTCONFIGURATION_XML)) {
    465         ///ystem.err.println("Writing XML");
    466         Utility.export(document, new File(collect_config_file.getParentFile(), COLLECTCONFIGURATION_XML));
     469        ///ystem.err.println("Writing XML");
     470        Utility.export(document, new File(collect_config_file.getParentFile(), COLLECTCONFIGURATION_XML));
    467471    }
    468472    else {
    469         ///ystem.err.println("Writing text");
    470         try {
    471         FileWriter file_writer = new FileWriter(collect_config_file, false);
     473        ///ystem.err.println("Writing text");
     474        try {       
     475        OutputStream ostream = new FileOutputStream(collect_config_file);
     476        Writer file_writer = new OutputStreamWriter(ostream, ENCODING);
     477        //FileWriter file_writer = new FileWriter(collect_config_file, false);
    472478        BufferedWriter buffered_writer = new BufferedWriter(file_writer);
    473479        // In order to write out an old style collect.cfg we have to traverse the model and do several 'cute' tricks to ensure the collect.cfg is valid (for instance while every metadata element has a language attribute, only second or subsequent metadata, for a certain name, needs a language argument - hence the known metadata array. Note that within GLI the language will always be shown, but it doesn't crash and burn like G2 does, te-he).
    474480        // is this still true?? now we are writing all metadata with a lang tag. can we get rid of known_metadata??
    475         known_metadata = new ArrayList();
     481        // Yes we can. Lets see..
     482        // known_metadata = new ArrayList(); 'blamo'
    476483        Element collect_config_element = document.getDocumentElement();
    477484        NodeList command_elements = collect_config_element.getChildNodes();
    478485        boolean just_wrote_newline = false; // Prevent two or more newlines in a row
    479486        for(int i = 0; i < command_elements.getLength(); i++) {
    480             Node command_node = command_elements.item(i);
    481             if(command_node instanceof Element) {
     487            Node command_node = command_elements.item(i);
     488            if(command_node instanceof Element) {
    482489            Element command_element = (Element) command_node;
    483490            // The only thing left are NewLine elements
    484491            if(command_element.getNodeName().equals(NEWLINE_ELEMENT) && !just_wrote_newline) {
    485                 buffered_writer.newLine();
    486                 just_wrote_newline = true;
     492                buffered_writer.newLine();
     493                just_wrote_newline = true;
    487494            }
    488495            // Anything else we write to file, but only if it has been assigned, the exception being the Indexes element which just get commented if unassigned (a side effect of MG && MGPP compatibility)
    489496            else if(!command_element.getAttribute(ASSIGNED_ATTRIBUTE).equals(FALSE_STR) || command_element.getNodeName().equals(INDEXES_ELEMENT) || command_element.getNodeName().equals(INDEX_DEFAULT_ELEMENT) || command_element.getNodeName().equals(LEVELS_ELEMENT)){
    490                 String command = toString(command_element, false);
    491                 if(command != null && command.length() > 0) {
     497                String command = toString(command_element, false);
     498                if(command != null && command.length() > 0) {
    492499                write(buffered_writer, command);
    493500                buffered_writer.newLine();
    494501                just_wrote_newline = false;
    495                 }
    496             }
    497             }
     502                }
     503            }
     504            }
    498505        }
    499506        buffered_writer.close();
    500         known_metadata = null;
    501         }
    502         catch (Exception exception) {
     507        // known_metadata = null; 'poof'
     508        }
     509        catch (Exception exception) {
    503510        Gatherer.println("Error in CollectionConfiguration.save(boolean): " + exception);
    504511        Gatherer.printStackTrace(exception);
    505         }
    506     }
    507     }
     512        }
     513    }
     514    }
    508515
    509516    /** ************************** Private Methods ***************************/
     
    801808    }
    802809
    803     /** Parse a collect.cfg into a DOM model representation. */
    804     private void parse(File collect_config_file) {
    805         try {
    806             Element collect_cfg_element = document.getDocumentElement();
    807             // Read in the file one command at a time.
    808             FileReader in_reader = new FileReader(collect_config_file);
    809             BufferedReader in = new BufferedReader(in_reader);
    810             String command_str = null;
    811             while((command_str = in.readLine()) != null) {
    812                 Element command_element = null;
    813                 // A command may be broken over several lines.
    814                 command_str = command_str.trim();
    815                 boolean eof = false;
    816                 while(!eof && command_str.endsWith(NEWLINE_CHARACTER)) {
    817                     String next_line = in.readLine();
    818                     if(next_line != null) {
    819                         next_line = next_line.trim();
    820                         if(next_line.length() > 0) {
    821                             // Remove the new line character
    822                             command_str = command_str.substring(0, command_str.lastIndexOf(NEWLINE_CHARACTER));
    823                             // And append the next line, which due to the test above must be non-zero length
    824                             command_str = command_str + next_line;
    825                         }
    826                         next_line = null;
     810    /** Parse a collect.cfg into a DOM model representation. */
     811    private void parse(File collect_config_file) {
     812    try {
     813        ArrayList acquired_collectionmeta_names = null;
     814        ArrayList obsolete_collectionmeta_names = null;
     815        HashMap changed_collectionmeta_names = null;
     816       
     817        // Life is made oh-so-more tricky by the existance of G2.39 config files. There are two ways to handle them:
     818        // 1. Notice that the file is G2.39 from the start, then as I parse it magic it into G2.4 standard
     819        // 2. Extend the parsing method to handle reading in G2.39, then afterwards go through the DOM changing it to G2.4 as appropriate.
     820        // As far as I can tell the second option is twice as much work, so I'll try option 1. The problem here is that I have to determine if the 'buildtype' command is somewhere in the collect.cfg file, which means I'm going to have to read the file twice - once seaching for 'buildtype' and the second time to parse it.
     821
     822        // Search for 'buildtype mgpp'
     823        InputStream input_stream_one = new FileInputStream(collect_config_file);
     824        Reader reader_one = new InputStreamReader(input_stream_one, ENCODING);
     825        BufferedReader buffered_reader_one = new BufferedReader(reader_one);
     826        String search_line_str = null;
     827        while(!is_twopointthreenine && (search_line_str = buffered_reader_one.readLine()) != null) {
     828        if(search_line_str.toLowerCase().indexOf(BUILDTYPE_STR) != -1) {
     829            is_twopointthreenine = true;
     830            acquired_collectionmeta_names = new ArrayList();
     831            changed_collectionmeta_names = new HashMap();
     832            obsolete_collectionmeta_names = new ArrayList();
     833        }
     834        }
     835        buffered_reader_one.close();
     836        reader_one.close();
     837        input_stream_one.close();
     838        buffered_reader_one = null;
     839        reader_one = null;
     840        input_stream_one = null;   
     841
     842        Element collect_cfg_element = document.getDocumentElement();
     843        // Read in the file one command at a time.
     844        InputStream istream = new FileInputStream(collect_config_file);
     845        Reader in_reader = new InputStreamReader(istream, ENCODING);
     846        //FileReader in_reader = new FileReader(collect_config_file);
     847        BufferedReader in = new BufferedReader(in_reader);
     848        String command_str = null;
     849        while((command_str = in.readLine()) != null) {
     850        boolean append_element = true;
     851        Element command_element = null;
     852        // A command may be broken over several lines.
     853        command_str = command_str.trim();
     854        boolean eof = false;
     855        while(!eof && command_str.endsWith(NEWLINE_CHARACTER)) {
     856            String next_line = in.readLine();
     857            if(next_line != null) {
     858            next_line = next_line.trim();
     859            if(next_line.length() > 0) {
     860                // Remove the new line character
     861                command_str = command_str.substring(0, command_str.lastIndexOf(NEWLINE_CHARACTER));
     862                // And append the next line, which due to the test above must be non-zero length
     863                command_str = command_str + next_line;
     864            }
     865            next_line = null;
     866            }
     867            // If we've reached the end of the file theres nothing more we can do
     868            else {
     869            eof = true;
     870            }
     871        }
     872        // If there is still a new line character, then we remove it and hope for the best
     873        if(command_str.endsWith(NEWLINE_CHARACTER)) {
     874            command_str = command_str.substring(0, command_str.lastIndexOf(NEWLINE_CHARACTER));
     875        }
     876        // Now we've either got a command to parse...
     877        if(command_str.length() != 0) {
     878            // Start trying to figure out what it is
     879            //StringTokenizer tokenizer = new StringTokenizer(command_str);
     880            // Instead of a standard string tokenizer I'm going to use the new version of CommandTokenizer, which is not only smart enough to correctly notice speech marks and correctly parse them out, but now also takes the input stream so it can rebuild tokens that stretch over several lines.
     881            CommandTokenizer tokenizer = new CommandTokenizer(command_str, in);
     882            String command_type = tokenizer.nextToken().toLowerCase();
     883            // Why can't you switch on strings eh? We pass it to the various subparsers who each have a bash at parsing the command. If none can parse the command, an unknown element is created
     884            if(command_element == null && command_type.equals(BUILDTYPE_STR)) {
     885            Gatherer.println("G2.39 Buildtype command detected. Ignoring.");
     886            command_element = document.createElement(UNKNOWN_ELEMENT);
     887            append_element = false;
     888            }
     889            if(command_element == null && command_type.equals(CLASSIFY_STR)) {
     890            command_element = parseClassify(command_str);
     891            }
     892            if(command_element == null && command_type.equals(FORMAT_STR)) {
     893            command_element = parseFormat(tokenizer); // Revised to handle multiple lines
     894            }
     895            if(command_element == null && (command_type.equals(INDEX_STR)  || command_type.equals(COMMENTED_INDEXES_STR))) {
     896            // If this was a G2.39 config file then we manipulate the command string a bit before we submit it to the parser. We start by adding allfields as the first index. We then space separate the remaining indexes, and remove duplicates when encountered. Of course before we do any of that we record the various space separated indexes so that we can remove the collection meta assigned to them.
     897            if(is_twopointthreenine) {
     898                Gatherer.println("G2.39 Index command detected. Modifying.");
     899                Gatherer.println("Before: " + command_str);
     900                StringBuffer new_command_str = new StringBuffer(command_type);
     901                new_command_str.append(SPACE_CHARACTER);
     902                new_command_str.append(ALLFIELDS_STR);
     903                new_command_str.append(SPACE_CHARACTER);
     904                ArrayList known_indexes = new ArrayList();
     905                while(tokenizer.hasMoreTokens()) {
     906                String old_index_str = tokenizer.nextToken();
     907                // If this index is a combination of sources, then we need to remove the old collectionmeta, split up the compound index, then request new metadata be added for each part
     908                if(old_index_str.indexOf(COMMA_CHARACTER) != -1) {
     909                    obsolete_collectionmeta_names.add(STOP_CHARACTER + old_index_str);
     910                    StringTokenizer string_tokenizer = new StringTokenizer(old_index_str, COMMA_CHARACTER);
     911                    while(string_tokenizer.hasMoreTokens()) {
     912                    String index_fragment_str = string_tokenizer.nextToken();
     913                    if(!known_indexes.contains(index_fragment_str)) {
     914                        known_indexes.add(index_fragment_str);
     915                        new_command_str.append(index_fragment_str);
     916                        new_command_str.append(SPACE_CHARACTER);
     917                        acquired_collectionmeta_names.add(STOP_CHARACTER + index_fragment_str);
    827918                    }
    828                     // If we've reached the end of the file theres nothing more we can do
    829                     else {
    830                         eof = true;
    831                     }
     919                    index_fragment_str = null;
     920                    }
     921                    string_tokenizer = null;
    832922                }
    833                 // If there is still a new line character, then we remove it and hope for the best
    834                 if(command_str.endsWith(NEWLINE_CHARACTER)) {
    835                     command_str = command_str.substring(0, command_str.lastIndexOf(NEWLINE_CHARACTER));
     923                // However if this was just a single index then a little choir of angels sing haleluja because we don't have to do -anything-. Nothing at all. Zip. Well no changes anyway. I obviously had to write this comment, and you can probably see, assuming you are not blind, that there are several lines of code below doing something, which is of course not nothing but something. And if we assume you are blind then you probably can't see the code, but then you probably didn't not see it doing the not nothing I said it would above.
     924                else {
     925                    if(!known_indexes.contains(old_index_str)) {
     926                    known_indexes.add(old_index_str);
     927                    new_command_str.append(old_index_str);
     928                    new_command_str.append(SPACE_CHARACTER);
     929                    }
     930                    else {
     931                    // Use the collectionmeta for the single index instead of generating a default one
     932                    acquired_collectionmeta_names.remove(STOP_CHARACTER + old_index_str);
     933                    }
    836934                }
    837                 // Now we've either got a command to parse...
    838                 if(command_str.length() != 0) {
    839                     // Start trying to figure out what it is
    840                     //StringTokenizer tokenizer = new StringTokenizer(command_str);
    841                     // Instead of a standard string tokenizer I'm going to use the new version of CommandTokenizer, which is not only smart enough to correctly notice speech marks and correctly parse them out, but now also takes the input stream so it can rebuild tokens that stretch over several lines.
    842                     CommandTokenizer tokenizer = new CommandTokenizer(command_str, in);
    843                     String command_type = tokenizer.nextToken().toLowerCase();
    844                     // Why can't you switch on strings eh? We pass it to the various subparsers who each have a bash at parsing the command. If none can parse the command, an unknown element is created
    845                     if(command_element == null && command_type.equals(CLASSIFY_STR)) {
    846                         command_element = parseClassify(command_str);
    847                     }
    848                     if(command_element == null && command_type.equals(FORMAT_STR)) {
    849                         command_element = parseFormat(tokenizer); // Revised to handle multiple lines
    850                     }
    851                     if(command_element == null && (command_type.equals(INDEX_STR)  || command_type.equals(COMMENTED_INDEXES_STR))) {
    852                         command_element = parseIndex(command_str);
    853                     }
    854                     if(command_element == null && (command_type.equals(INDEX_DEFAULT_STR) || command_type.equals(COMMENTED_INDEX_DEFAULT_STR))) {
    855                         command_element = parseIndexDefault(command_str);
    856                     }
    857                     if(command_element == null && command_type.equals(LANGUAGES_STR)) {
    858                         command_element = parseLanguage(command_str);
    859                     }
    860                     if(command_element == null && command_type.equals(LANGUAGE_DEFAULT_STR)) {
    861                         command_element = parseLanguageDefault(command_str);
    862                     }
    863                     if(command_element == null && (command_type.equals(LEVELS_STR) || command_type.equals(COMMENTED_LEVELS_STR))) {
    864                         command_element = parseLevels(command_str);
    865                     }
    866                     if(command_element == null && command_type.equals(COLLECTIONMETADATA_STR)) {
    867                         command_element = parseMetadata(tokenizer); // Revised to handle multiple lines
    868                     }
    869                     if(command_element == null && (command_type.equals(COLLECTIONMETADATA_BETA_STR) || command_type.equals(COLLECTIONMETADATA_PUBLIC_STR) || command_type.equals(COLLECTIONMETADATA_CREATOR_STR) || command_type.equals(COLLECTIONMETADATA_MAINTAINER_STR))) {
    870                         command_element = parseMetadataSpecial(command_str);
    871                     }
    872                     if(command_element == null && command_type.equals(PLUGIN_STR)) {
    873                         command_element = parsePlugIn(command_str);
    874                     }
    875                     if(command_element == null && command_type.equals(SEARCHTYPE_STR)) {
    876                         command_element = parseSearchType(command_str);
    877                     }
    878                     if(command_element == null && command_type.equals(SUBCOLLECTION_STR)) {
    879                         command_element = parseSubCollection(command_str);
    880                     }
    881                     if(command_element == null && command_type.equals(SUBCOLLECTION_DEFAULT_INDEX_STR)) {
    882                         command_element = parseSubCollectionDefaultIndex(command_str);
    883                     }
    884                     if(command_element == null && command_type.equals(SUBCOLLECTION_INDEX_STR)) {
    885                         command_element = parseSubCollectionIndex(command_str);
    886                     }
    887                     if(command_element == null && (command_type.equals(SUPERCOLLECTION_STR) || command_type.equals(CCS_STR))) {
    888                         command_element = parseSuperCollection(command_str);
    889                     }
    890             // Doesn't match any known type
    891             command_type = null;
    892             if(command_element == null) {
     935                old_index_str = null;
     936                }
     937                known_indexes = null;
     938                command_str = new_command_str.toString();
     939                new_command_str = null;
     940                Gatherer.println("After: " + command_str);
     941            }
     942            command_element = parseIndex(command_str);
     943            }
     944            if(command_element == null && (command_type.equals(INDEX_DEFAULT_STR) || command_type.equals(COMMENTED_INDEX_DEFAULT_STR))) {
     945           
     946            command_element = parseIndexDefault(command_str);
     947            // If this was a G2.39 config file then we squelch the default index (no such thing in G2.4)
     948            if(is_twopointthreenine) {
     949                Gatherer.println("G2.39 Default Index command detected. Ignoring.");
     950                append_element = false;
     951            }
     952            }
     953            if(command_element == null && command_type.equals(LANGUAGES_STR)) {
     954            command_element = parseLanguage(command_str);
     955            }
     956            if(command_element == null && command_type.equals(LANGUAGE_DEFAULT_STR)) {
     957            command_element = parseLanguageDefault(command_str);
     958            }
     959            if(command_element == null && (command_type.equals(LEVELS_STR) || command_type.equals(COMMENTED_LEVELS_STR))) {
     960            // Again if this is G2.39 we have to do a tiny bit of magic to the levels command. We need to add document level, and change the remainder to lower case.
     961            if(is_twopointthreenine) {
     962                Gatherer.println("G2.39 Levels command detected. Modifying.");
     963                Gatherer.println("Before: " + command_str);
     964                StringBuffer new_command_str = new StringBuffer(command_type);
     965                new_command_str.append(SPACE_CHARACTER);
     966                new_command_str.append(DOCUMENT_STR);
     967                while(tokenizer.hasMoreTokens()) {
     968                String token = tokenizer.nextToken();
     969                // Generate a lower case version
     970                String token_lc = token.toLowerCase();
     971                // If they are still the same then it is all good baby, otherwise we have to remember to transform their collectionmeta as well
     972                if(!token.equals(token_lc)) {
     973                    changed_collectionmeta_names.put(STOP_CHARACTER + token, STOP_CHARACTER + token_lc);
     974                }
     975                new_command_str.append(SPACE_CHARACTER);
     976                new_command_str.append(token_lc);
     977                token_lc = null;
     978                token = null;
     979                }
     980                command_str = new_command_str.toString();
     981                new_command_str = null;
     982                Gatherer.println("After: " + command_str);
     983            }
     984            command_element = parseLevels(command_str);
     985            }
     986            if(command_element == null && command_type.equals(COLLECTIONMETADATA_STR)) {
     987            command_element = parseMetadata(tokenizer); // Revised to handle multiple lines
     988            }
     989            if(command_element == null && (command_type.equals(COLLECTIONMETADATA_BETA_STR) || command_type.equals(COLLECTIONMETADATA_PUBLIC_STR) || command_type.equals(COLLECTIONMETADATA_CREATOR_STR) || command_type.equals(COLLECTIONMETADATA_MAINTAINER_STR))) {
     990            command_element = parseMetadataSpecial(command_str);
     991            }
     992            if(command_element == null && command_type.equals(PLUGIN_STR)) {
     993            command_element = parsePlugIn(command_str);
     994            }
     995            if(command_element == null && command_type.equals(SEARCHTYPE_STR)) {
     996            command_element = parseSearchType(command_str);
     997            }
     998            if(command_element == null && command_type.equals(SUBCOLLECTION_STR)) {
     999            command_element = parseSubCollection(command_str);
     1000            }
     1001            if(command_element == null && command_type.equals(SUBCOLLECTION_DEFAULT_INDEX_STR)) {
     1002            command_element = parseSubCollectionDefaultIndex(command_str);
     1003            }
     1004            if(command_element == null && command_type.equals(SUBCOLLECTION_INDEX_STR)) {
     1005            command_element = parseSubCollectionIndex(command_str);
     1006            }
     1007            if(command_element == null && (command_type.equals(SUPERCOLLECTION_STR) || command_type.equals(CCS_STR))) {
     1008            command_element = parseSuperCollection(command_str);
     1009            }
     1010            // Doesn't match any known type
     1011            command_type = null;
     1012            if(command_element == null) {
    8931013            // No-one knows what to do with this command, so we create an Unknown command element
    8941014            command_element = document.createElement(UNKNOWN_ELEMENT);
    8951015            MSMUtils.setValue(command_element, command_str);
    896            }
     1016            }
    8971017        }
    8981018        // Or an empty line to remember for later
    8991019        else {
    900             command_element = document.createElement(NEWLINE_ELEMENT);
    901         }
    902         // Now command element shouldn't be null so we append it to the collection config DOM
    903         collect_cfg_element.appendChild(command_element);
    904         }
     1020            command_element = document.createElement(NEWLINE_ELEMENT);
     1021        }
     1022        // Now command element shouldn't be null so we append it to the collection config DOM, but only if we haven't been told not to add it
     1023        if(append_element) {
     1024            collect_cfg_element.appendChild(command_element);
     1025        }
     1026        }
     1027
     1028        // We have completed parsing the collect configuration file. Now, if we are dealing with the G2.39 nightmare scenario, it's time to add the SearchType command and modify the collectionmeta commands as necessary.
     1029        if(is_twopointthreenine) {
     1030        Element search_type_element = getSearchType();
     1031        search_type_element.setAttribute(ASSIGNED_ATTRIBUTE, TRUE_STR);
     1032        while(search_type_element.hasChildNodes()) {
     1033            search_type_element.removeChild(search_type_element.getFirstChild());
     1034        }
     1035        Element plain_search_type_element = document.createElement(CONTENT_ELEMENT);
     1036        plain_search_type_element.setAttribute(NAME_ATTRIBUTE, SearchTypeManager.SEARCH_TYPES[1]);
     1037        search_type_element.appendChild(plain_search_type_element);
     1038        plain_search_type_element = null;
     1039        Element form_search_type_element = document.createElement(CONTENT_ELEMENT);
     1040        form_search_type_element.setAttribute(NAME_ATTRIBUTE, SearchTypeManager.SEARCH_TYPES[0]);
     1041        search_type_element.appendChild(form_search_type_element);
     1042        form_search_type_element = null;
     1043        search_type_element = null;
     1044       
     1045        // Search through the existing collectionmeta
     1046        Element document_element = document.getDocumentElement();
     1047        NodeList collectionmeta_elements = document_element.getElementsByTagName(COLLECTIONMETADATA_ELEMENT);
     1048        Gatherer.println("There are " + obsolete_collectionmeta_names.size() + " collectionmeta to remove.");
     1049        Gatherer.println("There are " + changed_collectionmeta_names.size() + " collectionmeta to change.");
     1050        for(int z = collectionmeta_elements.getLength(); z > 0; z--) {
     1051            Element collectionmeta_element = (Element) collectionmeta_elements.item(z - 1);
     1052            String name = collectionmeta_element.getAttribute(NAME_ATTRIBUTE);
     1053            Gatherer.println("Checking " + name);
     1054            // Remove any obsolete metadata
     1055            if(obsolete_collectionmeta_names.contains(name)) {
     1056            Gatherer.println("G2.39 CollectMeta detected. Removing: " + name);
     1057            document_element.removeChild(collectionmeta_element);
     1058            }
     1059            // We may have been asked to change the index name to lower case
     1060            else if(changed_collectionmeta_names.containsKey(name)) {
     1061            String new_name = (String) changed_collectionmeta_names.get(name);
     1062            Gatherer.println("G2.39 CollectMeta detected. Changing: " + name + " -> " + new_name);
     1063            collectionmeta_element.setAttribute(NAME_ATTRIBUTE, new_name);
     1064            new_name = null;
     1065            }
     1066            name = null;
     1067        }
     1068
     1069        // Finally add any newly acquired collectionmeta. This general defaults to the collectionmeta name less the full stop
     1070        Gatherer.println("There are " + acquired_collectionmeta_names.size() + " collectionmeta to add.");
     1071        for(int y = 0; y < acquired_collectionmeta_names.size(); y++) {
     1072            String name = (String) acquired_collectionmeta_names.get(y);
     1073            String value = name.substring(1);
     1074            Gatherer.println("G2.39 CollectMeta missing. Adding: " + name + " [l=" + Gatherer.config.getLanguage() + "] \"" + value + "\"");
     1075            Element element = document.createElement(COLLECTIONMETADATA_ELEMENT);
     1076            element.setAttribute(NAME_ATTRIBUTE, name);
     1077            element.setAttribute(LANGUAGE_ATTRIBUTE, Gatherer.config.getLanguage());
     1078            element.setAttribute(ASSIGNED_ATTRIBUTE, TRUE_STR);
     1079            MSMUtils.setValue(element, value);
     1080            document_element.appendChild(element);
     1081            element = null;
     1082            value = null;
     1083            name = null;
     1084        }
     1085
     1086        document_element = null;
     1087        }
    9051088    }
    9061089    catch(Exception exception) {
    907         Gatherer.println("Error in CollectionConfiguration.parse(java.io.File): " + exception);
    908         Gatherer.printStackTrace(exception);
    909     }
    910     }
    911 
    912     private Element parseClassify(String command_str) {
     1090        Gatherer.println("Error in CollectionConfiguration.parse(java.io.File): " + exception);
     1091        Gatherer.printStackTrace(exception);
     1092    }
     1093    }
     1094   
     1095    private Element parseClassify(String command_str) {
    9131096    Element command_element = null;
    9141097    try {
     
    9631146    }
    9641147
    965     private Element parseFormat(CommandTokenizer tokenizer) {
    966         Element command_element = null;
    967         try {
    968             command_element = document.createElement(FORMAT_ELEMENT);
    969             String name_str = tokenizer.nextToken();
    970             String value_str = tokenizer.nextToken();
    971             if(name_str != null && value_str != null) {
    972                 command_element.setAttribute(NAME_ATTRIBUTE, name_str);
    973                 // If the value is true or false we add it as an attribute
    974                 if(value_str.equalsIgnoreCase(TRUE_STR) || value_str.equalsIgnoreCase(FALSE_STR)) {
    975                     command_element.setAttribute(VALUE_ATTRIBUTE, value_str.toLowerCase());
    976                 }
    977                 // Otherwise it gets added as a text node
    978                 else {
    979                     // Ready the value str (which can contain all sorts of funky characters) for writing as a DOM value
    980                     value_str = Codec.transform(value_str, Codec.GREENSTONE_TO_DOM);
    981                     MSMUtils.setValue(command_element, value_str);
    982                 }
    983             }
    984             else {
    985                 command_element = null;
    986             }
    987             name_str = null;
    988             value_str = null;
    989         }
    990         catch (Exception exception) {
    991             Gatherer.printStackTrace(exception);
    992             command_element = null;
    993         }
    994         return command_element;
    995     }
     1148    private Element parseFormat(CommandTokenizer tokenizer) {
     1149    Element command_element = null;
     1150    try {
     1151        command_element = document.createElement(FORMAT_ELEMENT);
     1152        String name_str = tokenizer.nextToken();
     1153        String value_str = tokenizer.nextToken();
     1154        if(name_str != null && value_str != null) {
     1155        command_element.setAttribute(NAME_ATTRIBUTE, name_str);
     1156        // If the value is true or false we add it as an attribute
     1157        if(value_str.equalsIgnoreCase(TRUE_STR) || value_str.equalsIgnoreCase(FALSE_STR)) {
     1158            command_element.setAttribute(VALUE_ATTRIBUTE, value_str.toLowerCase());
     1159        }
     1160        // Otherwise it gets added as a text node
     1161        else {
     1162            // Ready the value str (which can contain all sorts of funky characters) for writing as a DOM value
     1163            value_str = Codec.transform(value_str, Codec.GREENSTONE_TO_DOM);
     1164            MSMUtils.setValue(command_element, value_str);
     1165        }
     1166        }
     1167        else {
     1168        command_element = null;
     1169        }
     1170        name_str = null;
     1171        value_str = null;
     1172    }
     1173    catch (Exception exception) {
     1174        Gatherer.printStackTrace(exception);
     1175        command_element = null;
     1176    }
     1177    return command_element;
     1178    }
    9961179
    9971180    private Element parseIndex(String command_str) {
     
    11491332    }
    11501333
    1151     private Element parseMetadata(CommandTokenizer tokenizer) {
    1152         Element command_element = null;
    1153         try {
    1154             command_element = document.createElement(COLLECTIONMETADATA_ELEMENT);
    1155             String name_str = tokenizer.nextToken();
    1156             String value_str = tokenizer.nextToken();
    1157             if(name_str != null && value_str != null) {
    1158                 String language_str = "en"; // By default - why do we assume English???
    1159                 // Check if the value string is actually a language string
    1160                 if(value_str.startsWith(LBRACKET_CHARACTER) && value_str.endsWith(RBRACKET_CHARACTER)) {
    1161                     language_str = value_str.substring(value_str.indexOf(LANGUAGE_ARGUMENT) + 2, value_str.length() - 1);
    1162                     value_str = tokenizer.nextToken();
    1163                 }
    1164                 if(value_str != null) {
    1165                     // Ready the value str (which can contain all sorts of funky characters) for writing as a DOM value
    1166                     value_str = Codec.transform(value_str, Codec.GREENSTONE_TO_DOM);
    1167                     command_element.setAttribute(NAME_ATTRIBUTE, name_str);
    1168                     command_element.setAttribute(LANGUAGE_ATTRIBUTE, language_str);
    1169                     command_element.setAttribute(ASSIGNED_ATTRIBUTE, TRUE_STR);
    1170                     MSMUtils.setValue(command_element, value_str);
    1171                 }
    1172                 else {
    1173                     command_element = null;
    1174                 }
    1175                 language_str = null;
    1176             }
    1177             else {
    1178                 command_element = null;
    1179             }
    1180             name_str = null;
    1181             value_str = null;
    1182         }
    1183         catch (Exception exception) {
    1184             Gatherer.printStackTrace(exception);
    1185             command_element = null;
    1186         }
    1187         return command_element;
    1188     }
     1334    private Element parseMetadata(CommandTokenizer tokenizer) {
     1335    Element command_element = null;
     1336    try {
     1337        command_element = document.createElement(COLLECTIONMETADATA_ELEMENT);
     1338        String name_str = tokenizer.nextToken();
     1339        String value_str = tokenizer.nextToken();
     1340        if(name_str != null && value_str != null) {
     1341        String language_str = Gatherer.config.getLanguage();
     1342        // Check if the value string is actually a language string
     1343        if(value_str.startsWith(LBRACKET_CHARACTER) && value_str.endsWith(RBRACKET_CHARACTER)) {
     1344            language_str = value_str.substring(value_str.indexOf(LANGUAGE_ARGUMENT) + 2, value_str.length() - 1);
     1345            value_str = tokenizer.nextToken();
     1346        }
     1347        if(value_str != null) {
     1348            // Ready the value str (which can contain all sorts of funky characters) for writing as a DOM value
     1349            value_str = Codec.transform(value_str, Codec.GREENSTONE_TO_DOM);
     1350            command_element.setAttribute(NAME_ATTRIBUTE, name_str);
     1351            command_element.setAttribute(LANGUAGE_ATTRIBUTE, language_str);
     1352            command_element.setAttribute(ASSIGNED_ATTRIBUTE, TRUE_STR);
     1353            MSMUtils.setValue(command_element, value_str);
     1354        }
     1355        else {
     1356            command_element = null;
     1357        }
     1358        language_str = null;
     1359        }
     1360        else {
     1361        command_element = null;
     1362        }
     1363        name_str = null;
     1364        value_str = null;
     1365    }
     1366    catch (Exception exception) {
     1367        Gatherer.printStackTrace(exception);
     1368        command_element = null;
     1369    }
     1370    return command_element;
     1371    }
    11891372
    11901373    private Element parseMetadataSpecial(String command_str) {
  • trunk/gli/src/org/greenstone/gatherer/cdm/CollectionMeta.java

    r6389 r6539  
    6767    element = CollectionDesignManager.collect_config.document.createElement(StaticStrings.COLLECTIONMETADATA_ELEMENT);
    6868    element.setAttribute(StaticStrings.NAME_ATTRIBUTE, name);
    69     element.setAttribute(StaticStrings.LANGUAGE_ATTRIBUTE, Gatherer.config.interface_language);
     69    element.setAttribute(StaticStrings.LANGUAGE_ATTRIBUTE, Gatherer.config.getLanguage());
    7070    element.setAttribute(StaticStrings.ASSIGNED_ATTRIBUTE, StaticStrings.FALSE_STR);
    7171    }
  • trunk/gli/src/org/greenstone/gatherer/cdm/CollectionMetaManager.java

    r5930 r6539  
    124124    for(int i = 0; i < size; i++) {
    125125        CollectionMeta metadatum = (CollectionMeta) getElementAt(i);
    126         if(metadatum.getName().equals(name) && metadatum.getLanguage().equals(Gatherer.config.interface_language)) {
     126        if(metadatum.getName().equals(name) && metadatum.getLanguage().equals(Gatherer.config.getLanguage())) {
    127127        Gatherer.println("Found '" + metadatum + "'");
    128128        return metadatum;
  • trunk/gli/src/org/greenstone/gatherer/cdm/CommandTokenizer.java

    r6139 r6539  
    119119        switch(buffer.charAt(0)) {
    120120        case StaticStrings.DOUBLEQUOTE_CHAR:
     121        ///ystem.err.println("Building token wrapped by double quotes.");
    121122        result = buildToken(buffer, StaticStrings.DOUBLEQUOTE_CHAR, true);
    122123        break;
    123124        case StaticStrings.SINGLEQUOTE_CHAR:
     125        ///ystem.err.println("Building token wrapped by single quotes.");
    124126        result = buildToken(buffer, StaticStrings.SINGLEQUOTE_CHAR, true);
    125127        break;
    126128        case StaticStrings.OPENBRACKET_CHAR:
     129        ///ystem.err.println("Building token wrapped by brackets.");
    127130        result = buildToken(buffer, StaticStrings.CLOSEBRACKET_CHAR, false);
    128131        break;
    129132        default:
     133        ///ystem.err.println("Returning plain string.");
    130134        result = buffer.toString();
    131135        }
     
    136140        count = count - 1;
    137141    }
    138     ///atherer.println("----- CommandTokenizer -----\ntoken:\t" + result + "\n----------------------------");
     142    ///ystem.err.println("----- CommandTokenizer -----\ntoken:\t" + result + "\n----------------------------");
    139143    return result;
    140144    }
     
    147151     */
    148152    private String buildToken(StringBuffer buffer, char end_char, boolean strip_characters) {
    149     while(buffer.charAt(buffer.length() - 1) != end_char || (buffer.length() > 3 && buffer.charAt(buffer.length() - 2) == StaticStrings.BACKSLASH_CHAR)) {
     153    while(buffer.length() == 1 || buffer.charAt(buffer.length() - 1) != end_char || (buffer.length() > 3 && buffer.charAt(buffer.length() - 2) == StaticStrings.BACKSLASH_CHAR)) {
    150154        try {
    151155        // The first version is for the basic tokenizer which has no idea of an input stream, so runs out tokens at the same time as the internal tokenizer does
     
    159163            while(!internal_tokenizer.hasMoreTokens() && (line_str = in_stream.readLine()) != null) {
    160164            ///atherer.println("+++++ CommandTokenizer +++++\nappend:\t" + line_str + "\n+++++++++++++++++++++++++++++");
    161             // Its at this stage the our token count becomes completely patu
     165            // Its at this stage the our token count becomes completely putu
    162166            internal_tokenizer = new StringTokenizer(line_str);
    163167            buffer.append(StaticStrings.NEW_LINE_CHAR); // A new line in the final token
  • trunk/gli/src/org/greenstone/gatherer/cdm/Format.java

    r5650 r6539  
    315315        }
    316316        else {
    317            temp.append("\"");
    318            // Retrieve the DOM encoded value, decode and then append
    319            value = MSMUtils.getValue(element);
    320            value = Codec.transform(value, Codec.DOM_TO_TEXT);
    321            temp.append(value);
    322            temp.append("\"");
     317        value = MSMUtils.getValue(element);
     318        if(value.equalsIgnoreCase(CollectionConfiguration.TRUE_STR) || value.equalsIgnoreCase(CollectionConfiguration.FALSE_STR)) {
     319            temp.append(value);
     320        }
     321        else {
     322            temp.append("\"");
     323            // Retrieve the DOM encoded value, decode and then append
     324            value = Codec.transform(value, Codec.DOM_TO_TEXT);
     325            temp.append(value);
     326            temp.append("\"");
     327        }
    323328        }
    324329        text = temp.toString();
  • trunk/gli/src/org/greenstone/gatherer/cdm/FormatManager.java

    r6318 r6539  
    349349        // Connect
    350350        add_button.addActionListener(new AddListener());
    351         //default_button.addActionListener(new DefaultFormatListener());
    352351        insert_button.addActionListener(new InsertListener());
    353352        remove_button.addActionListener(new RemoveListener());
     
    373372        part_pane.add(part_combobox, BorderLayout.CENTER);
    374373
    375         selection_pane.setLayout(new GridLayout(2,1,0,2));
    376         selection_pane.add(feature_pane);
    377         selection_pane.add(part_pane);
     374        //selection_pane.setLayout(new GridLayout(2,1,0,2));
     375        //selection_pane.add(feature_pane);
     376        //selection_pane.add(part_pane);
    378377
    379378        flag_pane.add(enabled_checkbox);
     
    382381        editor_header_pane.setLayout(new GridLayout(1,3));
    383382        editor_header_pane.add(editor_label);
    384         //editor_header_pane.add(new JPanel());
    385         //editor_header_pane.add(default_button);
    386383
    387384        variable_pane.setBorder(BorderFactory.createEmptyBorder(2,0,2,0));
     
    394391        editor_pane.add(editor_header_pane, BorderLayout.NORTH);
    395392        editor_pane.add(new JScrollPane(editor_textarea), BorderLayout.CENTER);
    396         editor_pane.add(variable_pane, BorderLayout.SOUTH);
     393        //editor_pane.add(variable_pane, BorderLayout.SOUTH);
     394
     395        selection_pane.setLayout(new BorderLayout());
     396        selection_pane.add(part_pane, BorderLayout.NORTH);
     397        selection_pane.add(editor_pane, BorderLayout.CENTER);
     398        selection_pane.add(variable_pane, BorderLayout.SOUTH);
    397399
    398400        control_pane.setLayout(card_layout);
    399401        control_pane.add(flag_pane, FLAG);
    400         control_pane.add(editor_pane, VALUE);
     402        control_pane.add(selection_pane, VALUE);
    401403        control_pane.add(blank_pane, BLANK);
    402404
     
    408410        center_pane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(Dictionary.get("CDM.FormatManager.Editing_Controls")), BorderFactory.createEmptyBorder(2,2,2,2)));
    409411        center_pane.setLayout(new BorderLayout());
    410         center_pane.add(selection_pane, BorderLayout.NORTH);
     412        center_pane.add(feature_pane, BorderLayout.NORTH);
    411413        center_pane.add(control_pane, BorderLayout.CENTER);
    412414        center_pane.add(button_pane, BorderLayout.SOUTH);
     
    552554                   ///ystem.err.println("Flag type");
    553555                // Flags first.
    554                 selection_pane.remove(part_pane);
     556                ///election_pane.remove(part_pane);
    555557                card_layout.show(control_pane, FLAG);
    556558                view_type = FLAG;
     
    559561                }
    560562                else {
    561                    ///ystem.err.println("Value type");
    562                 selection_pane.add(part_pane);
     563                ///ystem.err.println("Value type");
     564                ///election_pane.add(part_pane);
    563565                card_layout.show(control_pane, VALUE);
    564566                view_type = VALUE;
     
    576578                   ///ystem.err.println("Flag type");
    577579                // Flags first.
    578                 selection_pane.remove(part_pane);
     580                ///election_pane.remove(part_pane);
    579581                card_layout.show(control_pane, FLAG);
    580582                view_type = FLAG;
     
    584586                else {
    585587                   ///ystem.err.println("Value type");
    586                 selection_pane.add(part_pane);
     588                ///election_pane.add(part_pane);
    587589                card_layout.show(control_pane, VALUE);
    588590                view_type = VALUE;
     
    626628            ///ystem.err.println("Determine the correct type.");
    627629            if(format.isParamType()) {
    628                ///ystem.err.println("Flag type - remove part");
    629                // Flags first.
    630                SwingUtilities.invokeLater(new GUIChangeTask(selection_pane, part_pane, blank_pane, false));
     630                ///ystem.err.println("Flag type - remove part");
     631                // Flags first.
     632                ///SwingUtilities.invokeLater(new GUIChangeTask(/election_pane, part_pane, blank_pane, false));
    631633               card_layout.show(control_pane, FLAG);
    632634               view_type = FLAG;
     
    636638            else {
    637639               ///ystem.err.println("Value type - show part");
    638                SwingUtilities.invokeLater(new GUIChangeTask(selection_pane, part_pane, blank_pane, true));
     640                ///SwingUtilities.invokeLater(new GUIChangeTask(/election_pane, part_pane, blank_pane, true));
    639641               card_layout.show(control_pane, VALUE);
    640642               view_type = VALUE;
     
    706708                if(format.isParamType()) {
    707709                // Flags first.
    708                 selection_pane.remove(part_pane);
     710                ///election_pane.remove(part_pane);
    709711                card_layout.show(control_pane, FLAG);
    710712                view_type = FLAG;
     
    713715                }
    714716                else {
    715                 selection_pane.add(part_pane);
     717                ///election_pane.add(part_pane);
    716718                card_layout.show(control_pane, VALUE);
    717719                view_type = VALUE;
     
    726728                if(Format.isParamType(name)) {
    727729                // Flags first.
    728                 selection_pane.remove(part_pane);
     730                ///election_pane.remove(part_pane);
    729731                card_layout.show(control_pane, FLAG);
    730732                view_type = FLAG;
     
    733735                }
    734736                else {
    735                 selection_pane.add(part_pane);
     737                ///election_pane.add(part_pane);
    736738                card_layout.show(control_pane, VALUE);
    737739                view_type = VALUE;
     
    869871    }
    870872
    871    private class GUIChangeTask
     873    /*
     874      private class GUIChangeTask
    872875      implements Runnable {
    873876      private boolean to_add;
     
    875878      private JPanel parent;
    876879      private JPanel replacement;
    877 
     880     
    878881      public GUIChangeTask(JPanel parent, JPanel child, JPanel replacement, boolean to_add) {
    879     this.child = child;
    880     this.parent = parent;
    881     this.replacement = replacement;
    882     this.to_add = to_add;
    883       }
    884 
     882      this.child = child;
     883      this.parent = parent;
     884      this.replacement = replacement;
     885      this.to_add = to_add;
     886      }
     887     
    885888      public void run() {
    886      if(to_add) {
    887         parent.remove(replacement);
    888         parent.add(child);
    889         parent.updateUI();
    890      }
    891      else {
    892         parent.remove(child);
    893         parent.add(replacement);
    894         parent.updateUI();
    895      }
    896       }
    897    }
     889      if(to_add) {
     890      parent.remove(replacement);
     891      parent.add(child);
     892      parent.updateUI();
     893      }
     894      else {
     895      parent.remove(child);
     896      parent.add(replacement);
     897      parent.updateUI();
     898      }
     899      }
     900      }
     901    */
    898902
    899903   /** This class encapsulates all of the information associated with a certain component part of a feature within a html page returned from the receptioninst. */
  • trunk/gli/src/org/greenstone/gatherer/cdm/Index.java

    r5937 r6539  
    4646    implements Comparable, DOMProxyListEntry {
    4747    /** An values of items in the index level enumeration. */
    48     static public final String LEVEL[] = {"document","paragraph","section"};
     48    static public final String LEVEL[] = {CollectionConfiguration.DOCUMENT_STR, CollectionConfiguration.PARAGRAPH_STR, CollectionConfiguration.SECTION_STR};
    4949
    5050    private ArrayList sources = null;
  • trunk/gli/src/org/greenstone/gatherer/cdm/IndexManager.java

    r6389 r6539  
    116116        CollectionDesignManager.collectionmeta_manager.addMetadatum(metadatum);
    117117        // Retrieve the currently last index
    118         if(getSize() > 0) {
     118        if(levels_model.getSize() > 0) {
    119119        Level last_level = (Level)levels_model.getElementAt(levels_model.getSize() - 1);
    120120        levels_model.addAfter(level, last_level);
    121121        }
    122122        else {
    123         add(level);
     123        levels_model.add(level);
    124124        }
    125125        Gatherer.c_man.configurationChanged();
     
    589589        Dictionary.registerText(level_label, "CDM.IndexManager.Level");
    590590        level_combobox = new JComboBox();
    591         level_combobox.addItem(Dictionary.get("CDM.IndexManager.Document"));
    592         level_combobox.addItem(Dictionary.get("CDM.IndexManager.Paragraph"));
    593         level_combobox.addItem(Dictionary.get("CDM.IndexManager.Section"));
     591        level_combobox.addItem(CollectionConfiguration.DOCUMENT_STR);//Dictionary.get("CDM.IndexManager.Document"));
     592        level_combobox.addItem(CollectionConfiguration.PARAGRAPH_STR);//Dictionary.get("CDM.IndexManager.Paragraph"));
     593        level_combobox.addItem(CollectionConfiguration.SECTION_STR);//Dictionary.get("CDM.IndexManager.Section"));
    594594        level_combobox.setEditable(false);
    595595        Dictionary.registerTooltip(level_combobox, "CDM.IndexManager.Level_Tooltip");
     
    12171217        index_combobox.removeAllItems();
    12181218        index_combobox.addItem(CollectionConfiguration.ALLFIELDS_STR);
     1219        index_combobox.addItem(CollectionConfiguration.METADATA_STR);
    12191220        index_combobox.addItem(CollectionConfiguration.TEXT_STR);
    12201221        java.util.List assigned_elements = Gatherer.c_man.getCollection().msm.getAssignedElements();
     
    12241225        }
    12251226        assigned_elements = null;
     1227        // Ensure the level manager has at least documents assigned
     1228        if(levels_model.getSize() == 0) {
     1229        Level level = new Level(CollectionConfiguration.DOCUMENT_STR);
     1230        // Create new metadatum
     1231        CollectionMeta metadatum = new CollectionMeta(CollectionConfiguration.STOP_CHARACTER + CollectionConfiguration.DOCUMENT_STR);
     1232        metadatum.setValue(CollectionConfiguration.DOCUMENT_STR);
     1233        // Assign new level
     1234        addLevel(level, metadatum);     
     1235        level = null;
     1236        }
    12261237    }
    12271238
     
    13431354            move_level_down_button.setEnabled((levels_model.indexOf(level) < levels_model.getSize() - 1));
    13441355            move_level_up_button.setEnabled((levels_model.indexOf(level) > 0));
    1345             remove_level_button.setEnabled(true);
     1356            remove_level_button.setEnabled(!level.getName().equals(CollectionConfiguration.DOCUMENT_STR) || levels_model.getSize() > 1);
    13461357            }
    13471358            else {
     
    15781589        // Disable remove button
    15791590        remove_level_button.setEnabled(false);
     1591        // If there are no levels left, put document back in
     1592        if(levels_model.getSize() == 0) {
     1593            Level level = new Level(CollectionConfiguration.DOCUMENT_STR);
     1594            // Create new metadatum
     1595            CollectionMeta metadatum = new CollectionMeta(CollectionConfiguration.STOP_CHARACTER + CollectionConfiguration.DOCUMENT_STR);
     1596            metadatum.setValue(CollectionConfiguration.DOCUMENT_STR);
     1597            // Assign new level
     1598            addLevel(level, metadatum);     
     1599            level = null;
     1600        }
    15801601        // Check if add should be reenabled
    15811602        eal.validateAddButton();
  • trunk/gli/src/org/greenstone/gatherer/cdm/LanguageManager.java

    r6389 r6539  
    4747import org.greenstone.gatherer.cdm.LanguageListCellRenderer;
    4848import org.greenstone.gatherer.gui.GLIButton;
     49import org.greenstone.gatherer.util.Utility;
    4950import org.w3c.dom.*;
    5051
     
    5556public class LanguageManager
    5657    extends DOMProxyListModel {
     58
     59    static public Document LANGUAGES_DOCUMENT = Utility.parse("xml/languages.xml", true);
    5760
    5861    static final private Dimension LABEL_SIZE = new Dimension(125,25);
     
    7982        default_language = new Language((Element)default_language_elements.item(0));
    8083    }
    81     // Load a series of code->language mappings into known_languages, by reading from the 'languages.dat' file, which is essentially a subset of the ISO 639 Standard.
     84    // Load a series of code->language mappings into known_languages, by reading from the 'languages.xml' file, which is essentially a subset of the ISO 639 Standard.
    8285    known_languages = new LinkedHashMap();
    83     try {
     86    /*
     87      try {
    8488        File in_file = new File("languages.dat");
    8589        FileReader in_reader = new FileReader(in_file);
     
    104108    catch (Exception error) {
    105109        error.printStackTrace();
     110    }
     111    */
     112    NodeList language_elements = LANGUAGES_DOCUMENT.getDocumentElement().getElementsByTagName(CollectionConfiguration.LANGUAGE_ELEMENT);
     113    for(int i = 0; i < language_elements.getLength(); i++) {
     114        Element language_element = (Element) language_elements.item(i);
     115        String code = language_element.getAttribute(CollectionConfiguration.CODE_ATTRIBUTE);
     116        String name = language_element.getAttribute(CollectionConfiguration.NAME_ATTRIBUTE);
     117        known_languages.put(code.toLowerCase(), name);
     118        name = null;
     119        code = null;
     120        language_element = null;
    106121    }
    107122    }
  • trunk/gli/src/org/greenstone/gatherer/cdm/MetadataSetView.java

    r6389 r6539  
    191191    /** The text area of inline instructions. */
    192192    private JTextArea instructions = null;
     193
     194    private ListListener list_listener;
    193195    /** The element model for the currently selected set. */
    194196    private Vector element_model = null;
     
    248250        Dictionary.registerBoth(remove_button, "CDM.MetadataSetManager.Remove", "CDM.MetadataSetManager.Remove_Tooltip");
    249251        configure_action_listener = new ConfigureActionListener();
     252        list_listener = new ListListener();
    250253
    251254        // Add listeners
     
    253256        configure_button.addActionListener(configure_action_listener);
    254257        remove_button.addActionListener(new RemoveButtonListener());
    255         set_list.addListSelectionListener(new ListListener());
     258        set_list.addListSelectionListener(list_listener);
    256259        set_list.addMouseListener(configure_action_listener);
    257260        // Layout
     
    330333        instructions.setCaretPosition(0);
    331334        }
     335        // If no current selection, select first available set
     336        if(set_list.isSelectionEmpty() && set_list.getModel().getSize() > 0) {
     337        set_list.setSelectedIndex(0);
     338        MetadataSet set = ((SetWrapper)set_list.getSelectedValue()).getSet();
     339        NodeList elements = set.getElements();
     340        element_model = new Vector();
     341        for(int i = 0; i < elements.getLength(); i++) {
     342            element_model.add(new ElementWrapper(elements.item(i)));
     343        }
     344        element_list.setListData(element_model);
     345        configure_button.setEnabled(true);
     346        remove_button.setEnabled(true);
     347        elements = null;
     348        set = null;
     349        }
    332350    }
    333351
     
    400418            element_model.add(new ElementWrapper(elements.item(i)));
    401419            }
    402             Collections.sort(element_model);
     420            //Collections.sort(element_model);
    403421            element_list.setListData(element_model);
    404422            configure_button.setEnabled(true);
  • trunk/gli/src/org/greenstone/gatherer/collection/CollectionManager.java

    r6387 r6539  
    845845        // Create a lock file.
    846846        createLockFile(lock_file);
     847        // This lock file may not have been created so check
     848        if(!lock_file.canWrite()) {
     849        // The lock file cannot be written to. Most likely cause incorrect file permissions.
     850        String args[] = new String[2];
     851        args[0] = args2[0];
     852        args[1] = Dictionary.get("FileActions.Write_Not_Permitted_Title");
     853        JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CollectionManager.Cannot_Open_With_Reason", args), Dictionary.get("General.Error"), JOptionPane.ERROR_MESSAGE);
     854        args = null;
     855        return false;
     856        }
    847857        // Open the collection file
    848858        collection = new Collection(collection_file);
     
    11131123        }
    11141124    }
    1115     else if(event.getStatus() == GShell.ERROR) {
     1125    else if(event.getStatus() == GShell.ERROR || event.getStatus() == GShell.CANCELLED) {
    11161126        JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CollectionManager.Preview_Ready_Failed"), Dictionary.get("CollectionManager.Preview_Ready_Title"), JOptionPane.ERROR_MESSAGE);
    11171127        Gatherer.g_man.collectionChanged(ready());
     1128        Gatherer.g_man.repaint(); // It appears Java's own dialogs have the same not always painting correct area bug that I suffer from. Well I don't suffer from it personally, but my ModalDialog components do.
    11181129    }
    11191130    }
  • trunk/gli/src/org/greenstone/gatherer/file/FileAssociationManager.java

    r6314 r6539  
    105105
    106106    public String getBrowserCommand(String url) {
    107     String command = null;
     107    System.err.println("Get browser command: " + url);
     108    // First off we try to retrieve one from the configuration
     109    String command = Gatherer.config.getPreviewCommand();
     110    // If that worked, substitute in the url and return
     111    if(command != null && command.length() > 0) {
     112        command = command.replaceAll("%1", url);
     113        System.err.println("Result = " + command);
     114        return command;
     115    }
     116    // Failing that we have to prompt the user for what they want to do, but we do our best to provide a sensible default (if available).
     117    // For windows we can have a pretty good guess
    108118    if(Utility.isWindows()) {
    109119        // we use cmd and start
     
    113123        command = StaticStrings.WIN_OPEN_COMMAND;//"cmd.exe /c start \"\" \""+url+"\"";
    114124        }
    115         command = command.replaceAll(FILENAME_ARG, url);
    116         return command;
    117     }
     125    }
     126
     127    // Now prompt the user
     128    FileAssociationDialog dialog = new FileAssociationDialog(this);
     129    command = dialog.display(true, command);
     130    dialog.dispose();
     131    dialog = null;
     132
     133    // Store the result if any
     134    if(command != null) {
     135        Gatherer.config.setPreviewCommand(command);
     136    }
     137
    118138    // for now uder linux get the fileassoc thing. but eventually want a separate thing.
    119     // pretend we are tyring to open an html file
     139    // pretend we are trying to open an html file
    120140    // Mmmoooo. - jmt12
     141    /*
    121142    String extension = "html";
    122143    Element entry = getCommand(extension);
     
    140161        MSMUtils.setValue(entry, command.replaceAll("temp.html", FILENAME_ARG));
    141162    }
    142    
     163    */
    143164    // if we haven't got a command by now, we'll never get one
    144     if (command == null) return null;
     165    if (command == null) {
     166        System.err.println("Result = " + command);
     167        return null;
     168    }
    145169    // Replace %1 with the url in quotes
    146170    command = command.replaceAll(FILENAME_ARG, url);
     171    System.err.println("Result = " + command);
    147172    return command;
    148173    }
  • trunk/gli/src/org/greenstone/gatherer/file/FileManager.java

    r6319 r6539  
    6363    return count;
    6464    }
     65
     66    public boolean complain_if_no_sets = true;
    6567
    6668    /** Not only the queue of files to be moved, but also the object that moves them. */
  • trunk/gli/src/org/greenstone/gatherer/file/FileQueue.java

    r6329 r6539  
    645645            completed_folder_mappings.clear();
    646646            recycle_folder_mappings.clear();
     647           
     648            // Reset whether we complain about no sets.
     649            if(Gatherer.f_man != null) {
     650                Gatherer.f_man.complain_if_no_sets = true;
     651            }
     652
    647653            // Now wait if applicable.
    648654            if(return_immediately) {
  • trunk/gli/src/org/greenstone/gatherer/gui/FileAssociationDialog.java

    r6318 r6539  
    6464    extends ModalDialog {
    6565
     66    static final private String NORMAL = "normal";
     67    static final private String PREVIEW = "preview";
     68
    6669    /** The default size of a label. */
    6770    static final private Dimension LABEL_SIZE = new Dimension(150, 25);
     
    7073
    7174    private boolean ignore = false;
     75    private boolean preview_type;
     76    private CardLayout card_layout;
    7277    private FileAssociationDialog self;
    7378    private FileAssociationManager file_association_manager;
     
    7782    private JButton remove_button;
    7883    private JButton replace_button;
     84    private JPanel swap_pane;
    7985    private JTable existing_associations_table;
    8086    private JTextField command_field;
     
    111117    existing_associations_table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    112118    JPanel lower_pane = new JPanel();
     119   
    113120    JPanel details_pane = new JPanel();
     121
     122    card_layout = new CardLayout();
     123    swap_pane = new JPanel(card_layout);
    114124
    115125    JPanel extension_pane = new JPanel();
     
    117127    extension_label.setPreferredSize(LABEL_SIZE);   
    118128    extension_field = new NonWhitespaceField();
     129
     130    JLabel preview_label = new JLabel();
     131    Dictionary.setText(preview_label, "FileAssociationDialog.Preview");
    119132
    120133    JLabel command_label = new JLabel();
     
    179192    command_pane.add(browse_button, BorderLayout.EAST);
    180193
     194    swap_pane.add(extension_pane, NORMAL);
     195    swap_pane.add(preview_label, PREVIEW);
     196
    181197    details_pane.setBorder(BorderFactory.createTitledBorder(Dictionary.get("FileAssociationDialog.Details")));
    182198    details_pane.setLayout(new GridLayout(3,1));
    183     details_pane.add(extension_pane);
     199    details_pane.add(swap_pane);
    184200    details_pane.add(command_label);
    185201    details_pane.add(command_pane);
     
    226242     */
    227243    public String display(String new_extension) {
     244    preview_type = false;
     245
    228246    // Clear the current selection
    229247    existing_associations_table.clearSelection();
     248
     249    // Now ensable the components that aren't important for the preview collection command
     250    existing_associations_table.setEnabled(true);
     251    Dictionary.setBoth(close_button, "FileAssociationDialog.Close", "FileAssociationDialog.Close_Tooltip");
     252    // And display the extension chooser
     253    card_layout.show(swap_pane, NORMAL);
     254    swap_pane.updateUI();
     255
    230256    if(new_extension != null) {
    231257        extension_field.setText(new_extension);
    232258    }
     259
    233260    setVisible(true);
     261
    234262    if(new_extension != null) {
    235263        return file_association_manager.getCommandString(new_extension);
    236264    }
     265
    237266    return null;
     267    }
     268
     269    public String display(boolean is_preview_type, String command) {
     270    System.err.println("Preview type");
     271
     272    preview_type = true;
     273
     274    if(command != null) {
     275        command_field.setText(command);
     276    }
     277
     278    // Clear the current selection
     279    existing_associations_table.clearSelection();
     280
     281    // Now disable the components that aren't important for the preview collection command
     282    existing_associations_table.setEnabled(false);
     283
     284    Dictionary.setBoth(close_button, "General.OK", "FileAssociationDialog.Close_Tooltip");
     285
     286    // And display the preview collection message
     287    card_layout.show(swap_pane, PREVIEW);
     288    swap_pane.updateUI();
     289
     290    setVisible(true);
     291    return command_field.getText();
    238292    }
    239293
     
    251305   
    252306    public void actionPerformed(ActionEvent event) {
    253         String extension_str = extension_field.getText();
    254         file_association_manager.setCommand(extension_str, command_field.getText());
    255         // Select the appropriate entry in the table
    256         int index = -1;
    257         for(int i = 0; index == -1 && i < file_association_manager.size(); i++) {
    258         if(file_association_manager.getExtension(i).equals(extension_str)) {
    259             index = i;
    260         }
     307        if(!preview_type) {
     308        String extension_str = extension_field.getText();
     309        file_association_manager.setCommand(extension_str, command_field.getText());
     310        // Select the appropriate entry in the table
     311        int index = -1;
     312        for(int i = 0; index == -1 && i < file_association_manager.size(); i++) {
     313            if(file_association_manager.getExtension(i).equals(extension_str)) {
     314            index = i;
     315            }
     316        }
     317        if(index > -1) {
     318            existing_associations_table.setRowSelectionInterval(index, index);
     319        }
     320        // And update buttons
     321        add_button.setEnabled(false);
     322        remove_button.setEnabled(true);
    261323        }
    262         if(index > -1) {
    263         existing_associations_table.setRowSelectionInterval(index, index);
    264         }
    265         // And update buttons
    266         add_button.setEnabled(false);
    267         remove_button.setEnabled(true);
    268324    }
    269325    }
  • trunk/gli/src/org/greenstone/gatherer/gui/GUIManager.java

    r6389 r6539  
    514514     */
    515515    public void exit() {
     516    // 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.
     517    //if(Gatherer.current_modal != null) {
     518    //    return;
     519    //}
     520
    516521    boolean cont = true;
    517522    if(Gatherer.c_man.ready() && !Gatherer.c_man.saved()) {
  • trunk/gli/src/org/greenstone/gatherer/gui/MetaEditPane.java

    r6389 r6539  
    11011101
    11021102        JPanel value_field_pane = new JPanel();
    1103         TransformCharacterTextField value_init = new TransformCharacterTextField();
     1103        //TransformCharacterTextField value_init = new TransformCharacterTextField();
    11041104        //value_init.replaceCharacter(StaticStrings.PIPE_CHAR, StaticStrings.FORWARDSLASH_CHAR);
    1105         value = value_init;
    1106         value_init = null;
     1105        value = new JTextField();
     1106        //value_init = null;
    11071107        value.setBackground(Gatherer.config.getColor("coloring.editable_background", false));
    11081108        value.setForeground(Gatherer.config.getColor("coloring.editable_foreground", false));
  • trunk/gli/src/org/greenstone/gatherer/gui/ModalDialog.java

    r6161 r6539  
    3535import java.awt.*;
    3636import javax.swing.*;
     37import org.greenstone.gatherer.Gatherer;
    3738/** An extension of the JDialog that overrides the JVM's typical modal behaviour. This typical behaviour is that when a modal dialog is opened, all other windows cease to respond to user events until the modal dialog is disposed. However this prevents us opening the help documents property whenever a modal dialog is open. Thus we override the modal behaviour so that only the owner frame or dialog is blocked.
    3839 * Note that because we always call the super constructor with modal set to false, this should be made visible with setVisible(true) rather than show() which will return straight away. */
     
    4849    public ModalDialog() {
    4950    super((Frame)null, "", false);
     51    Gatherer.current_modal = this;
    5052    }
    5153
     
    5557    public ModalDialog(Dialog parent) {
    5658    super(parent, "", false);
     59    Gatherer.current_modal = this;
    5760    }
    5861
     
    6467    super(parent, "", false);
    6568    this.modal = modal;
     69    Gatherer.current_modal = this;
    6670    }
    6771   
     
    7377    super (parent, title, false);
    7478    this.modal = false;
     79    Gatherer.current_modal = this;
    7580    }
    7681
     
    8388    super (parent, title, false);
    8489    this.modal = modal;
     90    Gatherer.current_modal = this;
    8591    }
    8692
     
    9096    public ModalDialog(Frame parent) {
    9197    super(parent, "", false);
     98    Gatherer.current_modal = this;
    9299    }
    93100
     
    99106    super(parent, "", false);
    100107    this.modal = modal;
    101          
     108    Gatherer.current_modal = this;
    102109    }
    103110   
     
    108115    public ModalDialog(Frame parent, String title) {
    109116    super (parent, title, false);
     117    Gatherer.current_modal = this;
    110118    }
    111119
     
    118126    super (parent, title, false);
    119127    this.modal = modal;
     128    Gatherer.current_modal = this;
     129    }
     130
     131    public void dispose() {
     132    Gatherer.current_modal = null;
     133    super.dispose();
    120134    }
    121135
  • trunk/gli/src/org/greenstone/gatherer/gui/Preferences.java

    r6389 r6539  
    3737import org.greenstone.gatherer.Dictionary;
    3838import org.greenstone.gatherer.Gatherer;
     39import org.greenstone.gatherer.cdm.LanguageManager;
    3940import org.greenstone.gatherer.checklist.CheckList;
    4041import org.greenstone.gatherer.checklist.Entry;
     
    7273    private JLabel library_path_label;
    7374    private JLabel predefined_label;
     75    private JLabel program_label;
    7476    private JLabel proxy_host_label;
    7577    private JLabel proxy_port_label;
     
    8587    private JTextArea mode_description_textarea;
    8688    private JTextField library_path_field;
     89    private JTextField program_field;
    8790    private JTextField proxy_host_field;
    8891    private Preferences self;
     
    156159
    157160    private JPanel createConnectionPreferences() {
     161    JPanel program_pane = new JPanel();
     162    program_pane.setPreferredSize(ROW_SIZE);
     163    program_label = new JLabel();
     164    program_label.setPreferredSize(LABEL_SIZE);
     165    Dictionary.registerText(program_label, "Preferences.Connection.ProgramCommand");
     166    program_field = new JTextField(Gatherer.config.getPreviewCommand());
     167    program_field.setCaretPosition(0);
     168    Dictionary.registerTooltip(program_field, "Preferences.Connection.ProgramCommand_Tooltip");
     169
    158170    JPanel library_path_pane = new JPanel();
    159171    library_path_pane.setPreferredSize(ROW_SIZE);
     
    200212
    201213    // Layout
     214    program_pane.setLayout(new BorderLayout());
     215    program_pane.add(program_label, BorderLayout.WEST);
     216    program_pane.add(program_field, BorderLayout.CENTER);
     217
    202218    library_path_pane.setLayout(new BorderLayout());
    203219    library_path_pane.add(library_path_label, BorderLayout.WEST);
     
    214230    connection_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
    215231    connection_pane.setLayout(new GridLayout(8,1,0,2));
     232    connection_pane.add(program_pane);
    216233    connection_pane.add(library_path_pane);
    217234    connection_pane.add(use_proxy_checkbox);
     
    228245    ArrayList dictionary_model = new ArrayList();
    229246
     247    // Old method for determining what languages should be available in the combobox
     248    /*
    230249    dictionary_model.add(new DictionaryEntry(Locale.ENGLISH));
    231250    File classes_folder = new File(Utility.BASE_DIR + StaticStrings.CLASSES_FOLDER);
     
    267286    possible_dictionaries = null;
    268287    classes_folder = null;
     288    */
     289
     290    // The new method makes use of the successor to the languages.dat file, classes/xml/languages.xml
     291    NodeList language_elements = LanguageManager.LANGUAGES_DOCUMENT.getDocumentElement().getElementsByTagName(StaticStrings.LANGUAGE_ELEMENT);
     292    for(int i = 0; i < language_elements.getLength(); i++) {
     293        Element language_element = (Element) language_elements.item(i);
     294        if((language_element.getAttribute(StaticStrings.GLI_ATTRIBUTE)).equalsIgnoreCase(StaticStrings.TRUE_STR) || (language_element.getAttribute(StaticStrings.DC_ATTRIBUTE)).equalsIgnoreCase(StaticStrings.TRUE_STR)) {
     295        Locale locale = new Locale(language_element.getAttribute(StaticStrings.CODE_ATTRIBUTE));
     296        String description = language_element.getAttribute(StaticStrings.NAME_ATTRIBUTE);
     297        DictionaryEntry entry = new DictionaryEntry(description, locale);
     298        if(!dictionary_model.contains(entry)) {
     299            dictionary_model.add(entry);
     300        }
     301        entry = null;
     302        description = null;
     303        locale = null;
     304        }
     305        language_element = null;
     306    }
     307    language_elements = null;
    269308
    270309    // Users email
     
    300339    language_combobox = new JComboBox(dictionary_model.toArray());
    301340    Dictionary.registerTooltip(language_combobox, "Preferences.General.Interface_Language_Tooltip");
     341    // Try to locate and select the current language
     342    String language_code = Gatherer.config.getLanguage();
     343    for(int b = 0; b < language_combobox.getItemCount(); b++) {
     344        DictionaryEntry entry = (DictionaryEntry) language_combobox.getItemAt(b);
     345        if(language_code.equalsIgnoreCase(entry.getLocale().getLanguage())) {
     346        language_combobox.setSelectedIndex(b);
     347        }
     348    }
    302349
    303350    // Recursion
     
    329376    general_pane.add(email_pane);
    330377    general_pane.add(language_pane);
    331     general_pane.add(recursion_depth_pane);
     378    //general_pane.add(recursion_depth_pane);
    332379    general_pane.add(view_extracted_metadata_checkbox);
    333380    general_pane.add(show_file_size_checkbox);
     
    532579
    533580    public void dispose() {
    534         // Where's my code for unregistering all of the components?!?
    535 
    536         // Dispose
    537         super.dispose();
     581    // Unregister component
     582    Dictionary.unregister(this);
     583    Dictionary.unregister(tab_pane);
     584    Dictionary.unregister(ok_button);
     585    Dictionary.unregister(apply_button);
     586    Dictionary.unregister(cancel_button);
     587    Dictionary.unregister(library_path_label);
     588    Dictionary.unregister(library_path_field);
     589    Dictionary.unregister(use_proxy_checkbox);
     590    Dictionary.unregister(program_label);
     591    Dictionary.unregister(proxy_host_label);
     592    Dictionary.unregister(proxy_host_field);
     593    Dictionary.unregister(proxy_port_label);
     594    Dictionary.unregister(proxy_port_field);
     595    Dictionary.unregister(email_label);
     596    Dictionary.unregister(email_field);
     597    Dictionary.unregister(view_extracted_metadata_checkbox);
     598    Dictionary.unregister(show_file_size_checkbox);
     599    Dictionary.unregister(language_label);
     600    Dictionary.unregister(language_combobox);
     601    Dictionary.unregister(recursion_depth_label);
     602    Dictionary.unregister(recursion_depth_spinner);
     603    Dictionary.unregister(title_label);
     604    Dictionary.unregister(workflow_browse);
     605    Dictionary.unregister(workflow_mirror);
     606    Dictionary.unregister(workflow_gather);
     607    Dictionary.unregister(workflow_enrich);
     608    Dictionary.unregister(workflow_design);
     609    Dictionary.unregister(workflow_export);
     610    Dictionary.unregister(workflow_create);
     611    Dictionary.unregister(workflow_preview);
     612    Dictionary.unregister(predefined_label);
     613    // Dispose
     614    super.dispose();
    538615    }
    539616
     
    547624        // Submit the various changes.
    548625        // Connection preferences
     626        String program_str = program_field.getText();
     627        if(program_str.length() > 0 && program_str.indexOf("%1") == -1) {
     628        program_str = program_str + " %1";
     629        }
     630        Gatherer.config.setPreviewCommand(program_str);
     631
    549632        String library_path_string = library_path_field.getText();
    550633        Gatherer.config.setString("general.exec_address", true, library_path_string);
  • trunk/gli/src/org/greenstone/gatherer/mem/MetadataEditorManager.java

    r6394 r6539  
    11471147        if(!current_set.containsElement(name_str)) {
    11481148            // Add it,
    1149             String language_code = Gatherer.config.interface_language;
     1149            String language_code = Gatherer.config.getLanguage();
    11501150            ElementWrapper element = current_set.addElement(name_str, language_code);
    11511151            // Then update the tree
  • trunk/gli/src/org/greenstone/gatherer/msm/GDMDocument.java

    r6398 r6539  
    258258    public ArrayList getMetadata(String filename, boolean remove, ArrayList metadatum_so_far, File file, boolean append_folder_level, boolean purge) {
    259259    Gatherer.println("Get metadata for " + filename);
     260    Gatherer.println("remove = " + remove + ", metadata_so_far = " + (metadatum_so_far != null ? String.valueOf(metadatum_so_far.size()) : "null") + ", file = " + file + ", append_folder_level = " + append_folder_level + ", purge = " + purge);
    260261    // Of course null is not an acceptable filename
    261     if(filename == null) {
    262         return metadatum_so_far;
    263     }
    264     Gatherer.println("append_folder_level: " + append_folder_level);
    265     Gatherer.println("purge: " + purge);
     262    //if(filename == null) {
     263    //    return metadatum_so_far;
     264    //}
    266265    ArrayList metadatum = null;
    267266    ArrayList queued_for_removal = new ArrayList();
     
    409408
    410409                // Now we remove any elements that have been queued for deletion
    411                 for(int a = 0; a < queued_for_removal.size(); a++) {
     410                for(int a = 0; queued_for_removal != null && a < queued_for_removal.size(); a++) {
    412411                Element metadata_element = (Element) queued_for_removal.get(a);
    413412                description_element.removeChild(metadata_element);
  • trunk/gli/src/org/greenstone/gatherer/msm/GreenstoneArchiveParser.java

    r6325 r6539  
    141141                MetadataSet extracted_mds = Gatherer.c_man.msm.getSet(Utility.EXTRACTED_METADATA_NAMESPACE);
    142142                if(extracted_mds != null) {
    143                     element = extracted_mds.addElement(name, Gatherer.config.interface_language);
     143                    element = extracted_mds.addElement(name, Gatherer.config.getLanguage());
    144144                }
    145145                }
  • trunk/gli/src/org/greenstone/gatherer/msm/MSMPrompt.java

    r6318 r6539  
    879879        Element element = mds.getElement(name);
    880880        if (element == null) {
    881         result = mds.addElement(n, Gatherer.config.interface_language);
     881        result = mds.addElement(n, Gatherer.config.getLanguage());
    882882        }
    883883        else {
  • trunk/gli/src/org/greenstone/gatherer/msm/parsers/GreenstoneMetadataParser.java

    r6048 r6539  
    211211        ///ystem.out.println("GreenstoneMetadataParser:Error: we have been asked to add metadata but there are no existing sets");
    212212        // print the warning dialog
    213         WarningDialog dialog = new WarningDialog("warning.MissingMDS", true);
    214         if (dialog.display() == JOptionPane.CANCEL_OPTION) {
    215         // the user has cancelled
    216         dialog_cancelled = true;
     213        if(Gatherer.f_man.complain_if_no_sets) {
     214        WarningDialog dialog = new WarningDialog("warning.MissingMDS", true);
     215        if (dialog.display() == JOptionPane.CANCEL_OPTION) {
     216            // the user has cancelled
     217            dialog_cancelled = true;
     218            Gatherer.f_man.complain_if_no_sets = true;
     219        }
     220        else {
     221            Gatherer.f_man.complain_if_no_sets = false;
     222        }
    217223        }
    218224        return;
  • trunk/gli/src/org/greenstone/gatherer/util/AppendLineOnlyFileDocument.java

    r6382 r6539  
    176176    try {
    177177        writer.finish();
    178         System.err.println("Closing document.");
    179178        file.close();
    180179    }
  • trunk/gli/src/org/greenstone/gatherer/util/Codec.java

    r6069 r6539  
    123123        ">", "&gt;",
    124124        "\\\\\"", "&quot;",
    125         "\\\\\'", "&apos;"
     125        "\\\\\'", "&apos;",
     126        "\"", "&quot;",
     127        "\'", "&apos;"
    126128    };
    127129    // removed"\\\\n", "\n", added "\\\\", "\\|"
  • trunk/gli/src/org/greenstone/gatherer/util/StaticStrings.java

    r6381 r6539  
    4747    static final public String ASSIGNED_ATTRIBUTE                         = "assigned";
    4848    static final public String AT_CHARACTER                               = "@";
    49     static final public String BUILD_TYPE_STR                             = "buildtype";
     49    static final public String BUILDTYPE_STR                             = "buildtype";
    5050    static final public String CCS_STR                                    = "ccs";
    5151    static final public String CLASSES_FOLDER                             = "classes";
     
    5353    static final public String CLASSIFY_STR                               = "classify";
    5454    static final public String CLOSE_PARENTHESIS_CHARACTER                = ")";
     55    static final public String CODE_ATTRIBUTE                             = "code";
    5556    static final public String COLNAME_PATTERN                            = "<col_name>";
    5657    static final public String COLLECT_CFG                                = "collect.cfg";
     
    8081    static final public String CONTENT_ELEMENT                            = "content";
    8182    static final public String CUSTOM_ATTRIBUTE                           = "custom";
     83    static final public String DC_ATTRIBUTE                               = "dc";
    8284    static final public String DEBUG_ARGUMENT                             = "-debug";
    8385    static final public String DICTIONARY_FILENAME                        = "dictionary";
    8486    static final public String DIRECTORY_MAPPINGS_ELEMENT                 = "DirectoryMappings";
     87    static final public String DOCUMENT_STR                               = "document";
    8588    static final public String ETC_FOLDER                                 = "etc";
    8689    static final public String EMPTY_STR                                  = "";
     
    101104    static final public String FORMAT_ELEMENT                             = "Format";
    102105    static final public String FORMAT_STR                                 = "format";
     106    static final public String GLI_ATTRIBUTE                              = "gli";
    103107    static final public String GREATER_THAN_CHARACTER                     = ">";
     108    static final public String GS_ATTRIBUTE                               = "gs";
    104109    static final public String GSDL_ARGUMENT                              = "-gsdl";
    105110    static final public String HFILE_ARGUMENT                             = "-hfile";
     
    163168    static final public String OPTION_ELEMENT                             = "Option";
    164169    static final public String OPTIONS_ATTRIBUTE                          = "options";
     170    static final public String PARAGRAPH_STR                              = "paragraph";
    165171    static final public String PERL_ARGUMENT                              = "-perl";
    166172    static final public String PHIND_CLASSIFIER                           = "Phind";
     
    177183    static final public String SEARCHTYPE_ELEMENT                         = "SearchType";
    178184    static final public String SEARCHTYPE_STR                             = "searchtype";
     185    static final public String SECTION_STR                                = "section";
    179186    static final public String SEPARATOR_ATTRIBUTE                        = "separator";
    180187    static final public String SEPARATOR_CHARACTER                        = "/";
  • trunk/gli/src/org/greenstone/gatherer/util/Utility.java

    r6258 r6539  
    162162    /** The image for a toggle button whose state is 'off'. */
    163163    static final public ImageIcon OFF_ICON = new ImageIcon(ClassLoader.getSystemResource("images/cross.gif"));
    164 
     164   
    165165    /** Decodes a string of text so its safe to use in a Greenstone configuration file. Esentially replaces "\n" with a newline.
    166166     * @param raw The <strong>String</strong> before decoding, read from the configuration file..
     
    254254    }
    255255    // A file not found exception is most likely thrown because the directory the metadata.xml file is attempting to be written to no longer has any files in it. I'll add a test in GDMDocument to test for this, but if it still happens ignore it (a non-existant directory can't really have metadata added to it any way.
    256     catch (FileNotFoundException fnf_exception) {
     256    catch (Exception exception) {
    257257        if(!file.getName().endsWith(METADATA_XML)) {
    258         fnf_exception.printStackTrace();
     258        Gatherer.printStackTrace(exception);
    259259        return false;
    260260        }
    261261        return true;
    262     }
    263     catch (IOException ioe) {
    264         ioe.printStackTrace();
    265         return false;
    266262    }
    267263    }
     
    804800        if(noisey) {
    805801        error.printStackTrace();
    806         Gatherer.printStackTrace(error);
    807         }
     802        Gatherer.println("Exception in Utility.parse() - Unexpected");
     803        }
     804        else {
     805        Gatherer.println("Exception in Utility.parse() - Expected");
     806        }
     807        Gatherer.printStackTrace(error);
    808808    }
    809809    return document;
Note: See TracChangeset for help on using the changeset viewer.