Changeset 6539
- Timestamp:
- 2004-01-16T16:04:59+13:00 (20 years ago)
- 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 47 47 */ 48 48 public 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; 52 54 53 55 static public void main(String[] args) { … … 310 312 /** ************************** Public Data Members ***************************/ 311 313 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) { 319 323 this.self = this; 320 324 this.collect_config_file = collect_config_file; … … 322 326 String collect_config_name = collect_config_file.getName(); 323 327 if(collect_config_name.equals(COLLECTCONFIGURATION_XML)) { 324 325 328 // Parse with Utility but don't use class loader 329 document = Utility.parse(collect_config_file, false); 326 330 } 327 331 // Otherwise if this is a legacy collect.cfg file then read in the template and send to magic parser 328 332 else if(collect_config_name.equals(COLLECT_CFG)) { 329 330 331 } 332 333 334 335 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() { 336 340 JDialog dialog = new JDialog(Gatherer.g_man, "Collection Configuration", false); 337 341 dialog.setSize(400,400); … … 342 346 refresh_button.addActionListener(new ActionListener() { 343 347 public void actionPerformed(ActionEvent event) { 344 345 } 346 348 tree.setDocument(document); 349 } 350 }); 347 351 content_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); 348 352 content_pane.setLayout(new BorderLayout()); … … 350 354 content_pane.add(refresh_button, BorderLayout.SOUTH); 351 355 dialog.show(); 352 353 354 356 } 357 358 public Element getBeta() { 355 359 Element element = getOrCreateElementByTagName(COLLECTIONMETADATA_BETA_ELEMENT, null, null); 356 360 element.setAttribute(NAME_ATTRIBUTE, COLLECTIONMETADATA_BETA_STR); 357 361 element.setAttribute(SPECIAL_ATTRIBUTE, TRUE_STR); 358 362 return element; 359 363 } 360 364 361 365 public Element getCreator() { … … 451 455 } 452 456 453 457 public void save(boolean force_xml) { 454 458 if(collect_config_file.exists()) { 455 456 457 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()) { 458 462 backup_file.delete(); 459 460 463 } 464 if(!original_file.renameTo(backup_file)) { 461 465 Gatherer.println("Can't rename collect.cfg"); 462 466 } 463 467 } 464 468 if(force_xml || collect_config_file.getName().equals(COLLECTCONFIGURATION_XML)) { 465 466 469 ///ystem.err.println("Writing XML"); 470 Utility.export(document, new File(collect_config_file.getParentFile(), COLLECTCONFIGURATION_XML)); 467 471 } 468 472 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); 472 478 BufferedWriter buffered_writer = new BufferedWriter(file_writer); 473 479 // 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). 474 480 // 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' 476 483 Element collect_config_element = document.getDocumentElement(); 477 484 NodeList command_elements = collect_config_element.getChildNodes(); 478 485 boolean just_wrote_newline = false; // Prevent two or more newlines in a row 479 486 for(int i = 0; i < command_elements.getLength(); i++) { 480 481 487 Node command_node = command_elements.item(i); 488 if(command_node instanceof Element) { 482 489 Element command_element = (Element) command_node; 483 490 // The only thing left are NewLine elements 484 491 if(command_element.getNodeName().equals(NEWLINE_ELEMENT) && !just_wrote_newline) { 485 486 492 buffered_writer.newLine(); 493 just_wrote_newline = true; 487 494 } 488 495 // 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) 489 496 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 491 497 String command = toString(command_element, false); 498 if(command != null && command.length() > 0) { 492 499 write(buffered_writer, command); 493 500 buffered_writer.newLine(); 494 501 just_wrote_newline = false; 495 496 } 497 502 } 503 } 504 } 498 505 } 499 506 buffered_writer.close(); 500 known_metadata = null;501 502 507 // known_metadata = null; 'poof' 508 } 509 catch (Exception exception) { 503 510 Gatherer.println("Error in CollectionConfiguration.save(boolean): " + exception); 504 511 Gatherer.printStackTrace(exception); 505 506 } 507 512 } 513 } 514 } 508 515 509 516 /** ************************** Private Methods ***************************/ … … 801 808 } 802 809 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); 827 918 } 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; 832 922 } 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 } 836 934 } 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) { 893 1013 // No-one knows what to do with this command, so we create an Unknown command element 894 1014 command_element = document.createElement(UNKNOWN_ELEMENT); 895 1015 MSMUtils.setValue(command_element, command_str); 896 }1016 } 897 1017 } 898 1018 // Or an empty line to remember for later 899 1019 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 } 905 1088 } 906 1089 catch(Exception exception) { 907 908 909 } 910 911 912 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) { 913 1096 Element command_element = null; 914 1097 try { … … 963 1146 } 964 1147 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 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 } 996 1179 997 1180 private Element parseIndex(String command_str) { … … 1149 1332 } 1150 1333 1151 1152 1153 1154 1155 1156 1157 1158 String language_str = "en"; // By default - why do we assume English???1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 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 } 1189 1372 1190 1373 private Element parseMetadataSpecial(String command_str) { -
trunk/gli/src/org/greenstone/gatherer/cdm/CollectionMeta.java
r6389 r6539 67 67 element = CollectionDesignManager.collect_config.document.createElement(StaticStrings.COLLECTIONMETADATA_ELEMENT); 68 68 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()); 70 70 element.setAttribute(StaticStrings.ASSIGNED_ATTRIBUTE, StaticStrings.FALSE_STR); 71 71 } -
trunk/gli/src/org/greenstone/gatherer/cdm/CollectionMetaManager.java
r5930 r6539 124 124 for(int i = 0; i < size; i++) { 125 125 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())) { 127 127 Gatherer.println("Found '" + metadatum + "'"); 128 128 return metadatum; -
trunk/gli/src/org/greenstone/gatherer/cdm/CommandTokenizer.java
r6139 r6539 119 119 switch(buffer.charAt(0)) { 120 120 case StaticStrings.DOUBLEQUOTE_CHAR: 121 ///ystem.err.println("Building token wrapped by double quotes."); 121 122 result = buildToken(buffer, StaticStrings.DOUBLEQUOTE_CHAR, true); 122 123 break; 123 124 case StaticStrings.SINGLEQUOTE_CHAR: 125 ///ystem.err.println("Building token wrapped by single quotes."); 124 126 result = buildToken(buffer, StaticStrings.SINGLEQUOTE_CHAR, true); 125 127 break; 126 128 case StaticStrings.OPENBRACKET_CHAR: 129 ///ystem.err.println("Building token wrapped by brackets."); 127 130 result = buildToken(buffer, StaticStrings.CLOSEBRACKET_CHAR, false); 128 131 break; 129 132 default: 133 ///ystem.err.println("Returning plain string."); 130 134 result = buffer.toString(); 131 135 } … … 136 140 count = count - 1; 137 141 } 138 /// atherer.println("----- CommandTokenizer -----\ntoken:\t" + result + "\n----------------------------");142 ///ystem.err.println("----- CommandTokenizer -----\ntoken:\t" + result + "\n----------------------------"); 139 143 return result; 140 144 } … … 147 151 */ 148 152 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)) { 150 154 try { 151 155 // 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 … … 159 163 while(!internal_tokenizer.hasMoreTokens() && (line_str = in_stream.readLine()) != null) { 160 164 ///atherer.println("+++++ CommandTokenizer +++++\nappend:\t" + line_str + "\n+++++++++++++++++++++++++++++"); 161 // Its at this stage the our token count becomes completely p atu165 // Its at this stage the our token count becomes completely putu 162 166 internal_tokenizer = new StringTokenizer(line_str); 163 167 buffer.append(StaticStrings.NEW_LINE_CHAR); // A new line in the final token -
trunk/gli/src/org/greenstone/gatherer/cdm/Format.java
r5650 r6539 315 315 } 316 316 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 } 323 328 } 324 329 text = temp.toString(); -
trunk/gli/src/org/greenstone/gatherer/cdm/FormatManager.java
r6318 r6539 349 349 // Connect 350 350 add_button.addActionListener(new AddListener()); 351 //default_button.addActionListener(new DefaultFormatListener());352 351 insert_button.addActionListener(new InsertListener()); 353 352 remove_button.addActionListener(new RemoveListener()); … … 373 372 part_pane.add(part_combobox, BorderLayout.CENTER); 374 373 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); 378 377 379 378 flag_pane.add(enabled_checkbox); … … 382 381 editor_header_pane.setLayout(new GridLayout(1,3)); 383 382 editor_header_pane.add(editor_label); 384 //editor_header_pane.add(new JPanel());385 //editor_header_pane.add(default_button);386 383 387 384 variable_pane.setBorder(BorderFactory.createEmptyBorder(2,0,2,0)); … … 394 391 editor_pane.add(editor_header_pane, BorderLayout.NORTH); 395 392 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); 397 399 398 400 control_pane.setLayout(card_layout); 399 401 control_pane.add(flag_pane, FLAG); 400 control_pane.add( editor_pane, VALUE);402 control_pane.add(selection_pane, VALUE); 401 403 control_pane.add(blank_pane, BLANK); 402 404 … … 408 410 center_pane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(Dictionary.get("CDM.FormatManager.Editing_Controls")), BorderFactory.createEmptyBorder(2,2,2,2))); 409 411 center_pane.setLayout(new BorderLayout()); 410 center_pane.add( selection_pane, BorderLayout.NORTH);412 center_pane.add(feature_pane, BorderLayout.NORTH); 411 413 center_pane.add(control_pane, BorderLayout.CENTER); 412 414 center_pane.add(button_pane, BorderLayout.SOUTH); … … 552 554 ///ystem.err.println("Flag type"); 553 555 // Flags first. 554 selection_pane.remove(part_pane);556 ///election_pane.remove(part_pane); 555 557 card_layout.show(control_pane, FLAG); 556 558 view_type = FLAG; … … 559 561 } 560 562 else { 561 562 selection_pane.add(part_pane);563 ///ystem.err.println("Value type"); 564 ///election_pane.add(part_pane); 563 565 card_layout.show(control_pane, VALUE); 564 566 view_type = VALUE; … … 576 578 ///ystem.err.println("Flag type"); 577 579 // Flags first. 578 selection_pane.remove(part_pane);580 ///election_pane.remove(part_pane); 579 581 card_layout.show(control_pane, FLAG); 580 582 view_type = FLAG; … … 584 586 else { 585 587 ///ystem.err.println("Value type"); 586 selection_pane.add(part_pane);588 ///election_pane.add(part_pane); 587 589 card_layout.show(control_pane, VALUE); 588 590 view_type = VALUE; … … 626 628 ///ystem.err.println("Determine the correct type."); 627 629 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)); 631 633 card_layout.show(control_pane, FLAG); 632 634 view_type = FLAG; … … 636 638 else { 637 639 ///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)); 639 641 card_layout.show(control_pane, VALUE); 640 642 view_type = VALUE; … … 706 708 if(format.isParamType()) { 707 709 // Flags first. 708 selection_pane.remove(part_pane);710 ///election_pane.remove(part_pane); 709 711 card_layout.show(control_pane, FLAG); 710 712 view_type = FLAG; … … 713 715 } 714 716 else { 715 selection_pane.add(part_pane);717 ///election_pane.add(part_pane); 716 718 card_layout.show(control_pane, VALUE); 717 719 view_type = VALUE; … … 726 728 if(Format.isParamType(name)) { 727 729 // Flags first. 728 selection_pane.remove(part_pane);730 ///election_pane.remove(part_pane); 729 731 card_layout.show(control_pane, FLAG); 730 732 view_type = FLAG; … … 733 735 } 734 736 else { 735 selection_pane.add(part_pane);737 ///election_pane.add(part_pane); 736 738 card_layout.show(control_pane, VALUE); 737 739 view_type = VALUE; … … 869 871 } 870 872 871 private class GUIChangeTask 873 /* 874 private class GUIChangeTask 872 875 implements Runnable { 873 876 private boolean to_add; … … 875 878 private JPanel parent; 876 879 private JPanel replacement; 877 880 878 881 public GUIChangeTask(JPanel parent, JPanel child, JPanel replacement, boolean to_add) { 879 880 881 882 883 } 884 882 this.child = child; 883 this.parent = parent; 884 this.replacement = replacement; 885 this.to_add = to_add; 886 } 887 885 888 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 */ 898 902 899 903 /** 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 46 46 implements Comparable, DOMProxyListEntry { 47 47 /** 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}; 49 49 50 50 private ArrayList sources = null; -
trunk/gli/src/org/greenstone/gatherer/cdm/IndexManager.java
r6389 r6539 116 116 CollectionDesignManager.collectionmeta_manager.addMetadatum(metadatum); 117 117 // Retrieve the currently last index 118 if( getSize() > 0) {118 if(levels_model.getSize() > 0) { 119 119 Level last_level = (Level)levels_model.getElementAt(levels_model.getSize() - 1); 120 120 levels_model.addAfter(level, last_level); 121 121 } 122 122 else { 123 add(level);123 levels_model.add(level); 124 124 } 125 125 Gatherer.c_man.configurationChanged(); … … 589 589 Dictionary.registerText(level_label, "CDM.IndexManager.Level"); 590 590 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")); 594 594 level_combobox.setEditable(false); 595 595 Dictionary.registerTooltip(level_combobox, "CDM.IndexManager.Level_Tooltip"); … … 1217 1217 index_combobox.removeAllItems(); 1218 1218 index_combobox.addItem(CollectionConfiguration.ALLFIELDS_STR); 1219 index_combobox.addItem(CollectionConfiguration.METADATA_STR); 1219 1220 index_combobox.addItem(CollectionConfiguration.TEXT_STR); 1220 1221 java.util.List assigned_elements = Gatherer.c_man.getCollection().msm.getAssignedElements(); … … 1224 1225 } 1225 1226 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 } 1226 1237 } 1227 1238 … … 1343 1354 move_level_down_button.setEnabled((levels_model.indexOf(level) < levels_model.getSize() - 1)); 1344 1355 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); 1346 1357 } 1347 1358 else { … … 1578 1589 // Disable remove button 1579 1590 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 } 1580 1601 // Check if add should be reenabled 1581 1602 eal.validateAddButton(); -
trunk/gli/src/org/greenstone/gatherer/cdm/LanguageManager.java
r6389 r6539 47 47 import org.greenstone.gatherer.cdm.LanguageListCellRenderer; 48 48 import org.greenstone.gatherer.gui.GLIButton; 49 import org.greenstone.gatherer.util.Utility; 49 50 import org.w3c.dom.*; 50 51 … … 55 56 public class LanguageManager 56 57 extends DOMProxyListModel { 58 59 static public Document LANGUAGES_DOCUMENT = Utility.parse("xml/languages.xml", true); 57 60 58 61 static final private Dimension LABEL_SIZE = new Dimension(125,25); … … 79 82 default_language = new Language((Element)default_language_elements.item(0)); 80 83 } 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. 82 85 known_languages = new LinkedHashMap(); 83 try { 86 /* 87 try { 84 88 File in_file = new File("languages.dat"); 85 89 FileReader in_reader = new FileReader(in_file); … … 104 108 catch (Exception error) { 105 109 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; 106 121 } 107 122 } -
trunk/gli/src/org/greenstone/gatherer/cdm/MetadataSetView.java
r6389 r6539 191 191 /** The text area of inline instructions. */ 192 192 private JTextArea instructions = null; 193 194 private ListListener list_listener; 193 195 /** The element model for the currently selected set. */ 194 196 private Vector element_model = null; … … 248 250 Dictionary.registerBoth(remove_button, "CDM.MetadataSetManager.Remove", "CDM.MetadataSetManager.Remove_Tooltip"); 249 251 configure_action_listener = new ConfigureActionListener(); 252 list_listener = new ListListener(); 250 253 251 254 // Add listeners … … 253 256 configure_button.addActionListener(configure_action_listener); 254 257 remove_button.addActionListener(new RemoveButtonListener()); 255 set_list.addListSelectionListener( new ListListener());258 set_list.addListSelectionListener(list_listener); 256 259 set_list.addMouseListener(configure_action_listener); 257 260 // Layout … … 330 333 instructions.setCaretPosition(0); 331 334 } 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 } 332 350 } 333 351 … … 400 418 element_model.add(new ElementWrapper(elements.item(i))); 401 419 } 402 Collections.sort(element_model);420 //Collections.sort(element_model); 403 421 element_list.setListData(element_model); 404 422 configure_button.setEnabled(true); -
trunk/gli/src/org/greenstone/gatherer/collection/CollectionManager.java
r6387 r6539 845 845 // Create a lock file. 846 846 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 } 847 857 // Open the collection file 848 858 collection = new Collection(collection_file); … … 1113 1123 } 1114 1124 } 1115 else if(event.getStatus() == GShell.ERROR ) {1125 else if(event.getStatus() == GShell.ERROR || event.getStatus() == GShell.CANCELLED) { 1116 1126 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("CollectionManager.Preview_Ready_Failed"), Dictionary.get("CollectionManager.Preview_Ready_Title"), JOptionPane.ERROR_MESSAGE); 1117 1127 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. 1118 1129 } 1119 1130 } -
trunk/gli/src/org/greenstone/gatherer/file/FileAssociationManager.java
r6314 r6539 105 105 106 106 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 108 118 if(Utility.isWindows()) { 109 119 // we use cmd and start … … 113 123 command = StaticStrings.WIN_OPEN_COMMAND;//"cmd.exe /c start \"\" \""+url+"\""; 114 124 } 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 118 138 // for now uder linux get the fileassoc thing. but eventually want a separate thing. 119 // pretend we are t yring to open an html file139 // pretend we are trying to open an html file 120 140 // Mmmoooo. - jmt12 141 /* 121 142 String extension = "html"; 122 143 Element entry = getCommand(extension); … … 140 161 MSMUtils.setValue(entry, command.replaceAll("temp.html", FILENAME_ARG)); 141 162 } 142 163 */ 143 164 // 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 } 145 169 // Replace %1 with the url in quotes 146 170 command = command.replaceAll(FILENAME_ARG, url); 171 System.err.println("Result = " + command); 147 172 return command; 148 173 } -
trunk/gli/src/org/greenstone/gatherer/file/FileManager.java
r6319 r6539 63 63 return count; 64 64 } 65 66 public boolean complain_if_no_sets = true; 65 67 66 68 /** 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 645 645 completed_folder_mappings.clear(); 646 646 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 647 653 // Now wait if applicable. 648 654 if(return_immediately) { -
trunk/gli/src/org/greenstone/gatherer/gui/FileAssociationDialog.java
r6318 r6539 64 64 extends ModalDialog { 65 65 66 static final private String NORMAL = "normal"; 67 static final private String PREVIEW = "preview"; 68 66 69 /** The default size of a label. */ 67 70 static final private Dimension LABEL_SIZE = new Dimension(150, 25); … … 70 73 71 74 private boolean ignore = false; 75 private boolean preview_type; 76 private CardLayout card_layout; 72 77 private FileAssociationDialog self; 73 78 private FileAssociationManager file_association_manager; … … 77 82 private JButton remove_button; 78 83 private JButton replace_button; 84 private JPanel swap_pane; 79 85 private JTable existing_associations_table; 80 86 private JTextField command_field; … … 111 117 existing_associations_table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 112 118 JPanel lower_pane = new JPanel(); 119 113 120 JPanel details_pane = new JPanel(); 121 122 card_layout = new CardLayout(); 123 swap_pane = new JPanel(card_layout); 114 124 115 125 JPanel extension_pane = new JPanel(); … … 117 127 extension_label.setPreferredSize(LABEL_SIZE); 118 128 extension_field = new NonWhitespaceField(); 129 130 JLabel preview_label = new JLabel(); 131 Dictionary.setText(preview_label, "FileAssociationDialog.Preview"); 119 132 120 133 JLabel command_label = new JLabel(); … … 179 192 command_pane.add(browse_button, BorderLayout.EAST); 180 193 194 swap_pane.add(extension_pane, NORMAL); 195 swap_pane.add(preview_label, PREVIEW); 196 181 197 details_pane.setBorder(BorderFactory.createTitledBorder(Dictionary.get("FileAssociationDialog.Details"))); 182 198 details_pane.setLayout(new GridLayout(3,1)); 183 details_pane.add( extension_pane);199 details_pane.add(swap_pane); 184 200 details_pane.add(command_label); 185 201 details_pane.add(command_pane); … … 226 242 */ 227 243 public String display(String new_extension) { 244 preview_type = false; 245 228 246 // Clear the current selection 229 247 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 230 256 if(new_extension != null) { 231 257 extension_field.setText(new_extension); 232 258 } 259 233 260 setVisible(true); 261 234 262 if(new_extension != null) { 235 263 return file_association_manager.getCommandString(new_extension); 236 264 } 265 237 266 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(); 238 292 } 239 293 … … 251 305 252 306 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); 261 323 } 262 if(index > -1) {263 existing_associations_table.setRowSelectionInterval(index, index);264 }265 // And update buttons266 add_button.setEnabled(false);267 remove_button.setEnabled(true);268 324 } 269 325 } -
trunk/gli/src/org/greenstone/gatherer/gui/GUIManager.java
r6389 r6539 514 514 */ 515 515 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 516 521 boolean cont = true; 517 522 if(Gatherer.c_man.ready() && !Gatherer.c_man.saved()) { -
trunk/gli/src/org/greenstone/gatherer/gui/MetaEditPane.java
r6389 r6539 1101 1101 1102 1102 JPanel value_field_pane = new JPanel(); 1103 TransformCharacterTextField value_init = new TransformCharacterTextField();1103 //TransformCharacterTextField value_init = new TransformCharacterTextField(); 1104 1104 //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; 1107 1107 value.setBackground(Gatherer.config.getColor("coloring.editable_background", false)); 1108 1108 value.setForeground(Gatherer.config.getColor("coloring.editable_foreground", false)); -
trunk/gli/src/org/greenstone/gatherer/gui/ModalDialog.java
r6161 r6539 35 35 import java.awt.*; 36 36 import javax.swing.*; 37 import org.greenstone.gatherer.Gatherer; 37 38 /** 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. 38 39 * 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. */ … … 48 49 public ModalDialog() { 49 50 super((Frame)null, "", false); 51 Gatherer.current_modal = this; 50 52 } 51 53 … … 55 57 public ModalDialog(Dialog parent) { 56 58 super(parent, "", false); 59 Gatherer.current_modal = this; 57 60 } 58 61 … … 64 67 super(parent, "", false); 65 68 this.modal = modal; 69 Gatherer.current_modal = this; 66 70 } 67 71 … … 73 77 super (parent, title, false); 74 78 this.modal = false; 79 Gatherer.current_modal = this; 75 80 } 76 81 … … 83 88 super (parent, title, false); 84 89 this.modal = modal; 90 Gatherer.current_modal = this; 85 91 } 86 92 … … 90 96 public ModalDialog(Frame parent) { 91 97 super(parent, "", false); 98 Gatherer.current_modal = this; 92 99 } 93 100 … … 99 106 super(parent, "", false); 100 107 this.modal = modal; 101 108 Gatherer.current_modal = this; 102 109 } 103 110 … … 108 115 public ModalDialog(Frame parent, String title) { 109 116 super (parent, title, false); 117 Gatherer.current_modal = this; 110 118 } 111 119 … … 118 126 super (parent, title, false); 119 127 this.modal = modal; 128 Gatherer.current_modal = this; 129 } 130 131 public void dispose() { 132 Gatherer.current_modal = null; 133 super.dispose(); 120 134 } 121 135 -
trunk/gli/src/org/greenstone/gatherer/gui/Preferences.java
r6389 r6539 37 37 import org.greenstone.gatherer.Dictionary; 38 38 import org.greenstone.gatherer.Gatherer; 39 import org.greenstone.gatherer.cdm.LanguageManager; 39 40 import org.greenstone.gatherer.checklist.CheckList; 40 41 import org.greenstone.gatherer.checklist.Entry; … … 72 73 private JLabel library_path_label; 73 74 private JLabel predefined_label; 75 private JLabel program_label; 74 76 private JLabel proxy_host_label; 75 77 private JLabel proxy_port_label; … … 85 87 private JTextArea mode_description_textarea; 86 88 private JTextField library_path_field; 89 private JTextField program_field; 87 90 private JTextField proxy_host_field; 88 91 private Preferences self; … … 156 159 157 160 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 158 170 JPanel library_path_pane = new JPanel(); 159 171 library_path_pane.setPreferredSize(ROW_SIZE); … … 200 212 201 213 // Layout 214 program_pane.setLayout(new BorderLayout()); 215 program_pane.add(program_label, BorderLayout.WEST); 216 program_pane.add(program_field, BorderLayout.CENTER); 217 202 218 library_path_pane.setLayout(new BorderLayout()); 203 219 library_path_pane.add(library_path_label, BorderLayout.WEST); … … 214 230 connection_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); 215 231 connection_pane.setLayout(new GridLayout(8,1,0,2)); 232 connection_pane.add(program_pane); 216 233 connection_pane.add(library_path_pane); 217 234 connection_pane.add(use_proxy_checkbox); … … 228 245 ArrayList dictionary_model = new ArrayList(); 229 246 247 // Old method for determining what languages should be available in the combobox 248 /* 230 249 dictionary_model.add(new DictionaryEntry(Locale.ENGLISH)); 231 250 File classes_folder = new File(Utility.BASE_DIR + StaticStrings.CLASSES_FOLDER); … … 267 286 possible_dictionaries = null; 268 287 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; 269 308 270 309 // Users email … … 300 339 language_combobox = new JComboBox(dictionary_model.toArray()); 301 340 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 } 302 349 303 350 // Recursion … … 329 376 general_pane.add(email_pane); 330 377 general_pane.add(language_pane); 331 general_pane.add(recursion_depth_pane);378 //general_pane.add(recursion_depth_pane); 332 379 general_pane.add(view_extracted_metadata_checkbox); 333 380 general_pane.add(show_file_size_checkbox); … … 532 579 533 580 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(); 538 615 } 539 616 … … 547 624 // Submit the various changes. 548 625 // 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 549 632 String library_path_string = library_path_field.getText(); 550 633 Gatherer.config.setString("general.exec_address", true, library_path_string); -
trunk/gli/src/org/greenstone/gatherer/mem/MetadataEditorManager.java
r6394 r6539 1147 1147 if(!current_set.containsElement(name_str)) { 1148 1148 // Add it, 1149 String language_code = Gatherer.config. interface_language;1149 String language_code = Gatherer.config.getLanguage(); 1150 1150 ElementWrapper element = current_set.addElement(name_str, language_code); 1151 1151 // Then update the tree -
trunk/gli/src/org/greenstone/gatherer/msm/GDMDocument.java
r6398 r6539 258 258 public ArrayList getMetadata(String filename, boolean remove, ArrayList metadatum_so_far, File file, boolean append_folder_level, boolean purge) { 259 259 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); 260 261 // 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 //} 266 265 ArrayList metadatum = null; 267 266 ArrayList queued_for_removal = new ArrayList(); … … 409 408 410 409 // 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++) { 412 411 Element metadata_element = (Element) queued_for_removal.get(a); 413 412 description_element.removeChild(metadata_element); -
trunk/gli/src/org/greenstone/gatherer/msm/GreenstoneArchiveParser.java
r6325 r6539 141 141 MetadataSet extracted_mds = Gatherer.c_man.msm.getSet(Utility.EXTRACTED_METADATA_NAMESPACE); 142 142 if(extracted_mds != null) { 143 element = extracted_mds.addElement(name, Gatherer.config. interface_language);143 element = extracted_mds.addElement(name, Gatherer.config.getLanguage()); 144 144 } 145 145 } -
trunk/gli/src/org/greenstone/gatherer/msm/MSMPrompt.java
r6318 r6539 879 879 Element element = mds.getElement(name); 880 880 if (element == null) { 881 result = mds.addElement(n, Gatherer.config. interface_language);881 result = mds.addElement(n, Gatherer.config.getLanguage()); 882 882 } 883 883 else { -
trunk/gli/src/org/greenstone/gatherer/msm/parsers/GreenstoneMetadataParser.java
r6048 r6539 211 211 ///ystem.out.println("GreenstoneMetadataParser:Error: we have been asked to add metadata but there are no existing sets"); 212 212 // 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 } 217 223 } 218 224 return; -
trunk/gli/src/org/greenstone/gatherer/util/AppendLineOnlyFileDocument.java
r6382 r6539 176 176 try { 177 177 writer.finish(); 178 System.err.println("Closing document.");179 178 file.close(); 180 179 } -
trunk/gli/src/org/greenstone/gatherer/util/Codec.java
r6069 r6539 123 123 ">", ">", 124 124 "\\\\\"", """, 125 "\\\\\'", "'" 125 "\\\\\'", "'", 126 "\"", """, 127 "\'", "'" 126 128 }; 127 129 // removed"\\\\n", "\n", added "\\\\", "\\|" -
trunk/gli/src/org/greenstone/gatherer/util/StaticStrings.java
r6381 r6539 47 47 static final public String ASSIGNED_ATTRIBUTE = "assigned"; 48 48 static final public String AT_CHARACTER = "@"; 49 static final public String BUILD _TYPE_STR = "buildtype";49 static final public String BUILDTYPE_STR = "buildtype"; 50 50 static final public String CCS_STR = "ccs"; 51 51 static final public String CLASSES_FOLDER = "classes"; … … 53 53 static final public String CLASSIFY_STR = "classify"; 54 54 static final public String CLOSE_PARENTHESIS_CHARACTER = ")"; 55 static final public String CODE_ATTRIBUTE = "code"; 55 56 static final public String COLNAME_PATTERN = "<col_name>"; 56 57 static final public String COLLECT_CFG = "collect.cfg"; … … 80 81 static final public String CONTENT_ELEMENT = "content"; 81 82 static final public String CUSTOM_ATTRIBUTE = "custom"; 83 static final public String DC_ATTRIBUTE = "dc"; 82 84 static final public String DEBUG_ARGUMENT = "-debug"; 83 85 static final public String DICTIONARY_FILENAME = "dictionary"; 84 86 static final public String DIRECTORY_MAPPINGS_ELEMENT = "DirectoryMappings"; 87 static final public String DOCUMENT_STR = "document"; 85 88 static final public String ETC_FOLDER = "etc"; 86 89 static final public String EMPTY_STR = ""; … … 101 104 static final public String FORMAT_ELEMENT = "Format"; 102 105 static final public String FORMAT_STR = "format"; 106 static final public String GLI_ATTRIBUTE = "gli"; 103 107 static final public String GREATER_THAN_CHARACTER = ">"; 108 static final public String GS_ATTRIBUTE = "gs"; 104 109 static final public String GSDL_ARGUMENT = "-gsdl"; 105 110 static final public String HFILE_ARGUMENT = "-hfile"; … … 163 168 static final public String OPTION_ELEMENT = "Option"; 164 169 static final public String OPTIONS_ATTRIBUTE = "options"; 170 static final public String PARAGRAPH_STR = "paragraph"; 165 171 static final public String PERL_ARGUMENT = "-perl"; 166 172 static final public String PHIND_CLASSIFIER = "Phind"; … … 177 183 static final public String SEARCHTYPE_ELEMENT = "SearchType"; 178 184 static final public String SEARCHTYPE_STR = "searchtype"; 185 static final public String SECTION_STR = "section"; 179 186 static final public String SEPARATOR_ATTRIBUTE = "separator"; 180 187 static final public String SEPARATOR_CHARACTER = "/"; -
trunk/gli/src/org/greenstone/gatherer/util/Utility.java
r6258 r6539 162 162 /** The image for a toggle button whose state is 'off'. */ 163 163 static final public ImageIcon OFF_ICON = new ImageIcon(ClassLoader.getSystemResource("images/cross.gif")); 164 164 165 165 /** Decodes a string of text so its safe to use in a Greenstone configuration file. Esentially replaces "\n" with a newline. 166 166 * @param raw The <strong>String</strong> before decoding, read from the configuration file.. … … 254 254 } 255 255 // 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) { 257 257 if(!file.getName().endsWith(METADATA_XML)) { 258 fnf_exception.printStackTrace();258 Gatherer.printStackTrace(exception); 259 259 return false; 260 260 } 261 261 return true; 262 }263 catch (IOException ioe) {264 ioe.printStackTrace();265 return false;266 262 } 267 263 } … … 804 800 if(noisey) { 805 801 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); 808 808 } 809 809 return document;
Note:
See TracChangeset
for help on using the changeset viewer.