Changeset 6539 for trunk/gli/src/org/greenstone/gatherer/cdm
- Timestamp:
- 2004-01-16T16:04:59+13:00 (20 years ago)
- Location:
- trunk/gli/src/org/greenstone/gatherer/cdm
- Files:
-
- 10 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);
Note:
See TracChangeset
for help on using the changeset viewer.