Changeset 39021
- Timestamp:
- 2024-05-14T13:25:56+12:00 (2 weeks ago)
- Location:
- main/trunk/gli/src/org/greenstone/gatherer/cdm
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/gli/src/org/greenstone/gatherer/cdm/BaseIndexManager.java
r36303 r39021 83 83 protected String nip_source_label_key = null; 84 84 protected String nip_source_tooltip_key = null; 85 protected String nip_custom_label_key = null; 86 protected String nip_custom_tooltip_key = null; 85 87 protected String nip_add_index_button_key = null; 86 88 protected String nip_add_index_tooltip_key = null; … … 571 573 572 574 protected CheckList source_list; 575 protected JTextField custom_field; 573 576 protected JButton add_or_replace_button; 574 577 protected JButton add_all_button; … … 577 580 protected JPanel content_pane; 578 581 protected JPanel details_pane; 582 protected JPanel extra_pane; 579 583 protected JPanel button_pane; 580 584 protected boolean editing = false; … … 636 640 source_list.setToolTipText(Dictionary.get(nip_source_tooltip_key)); 637 641 source_list.addListSelectionListener(new SourceListListener()); 642 643 extra_pane = new JPanel(); 644 extra_pane.setComponentOrientation(Dictionary.getOrientation()); 645 646 JPanel custom_field_pane = new JPanel(); 647 //custom_field_pane.setPreferredSize(ROW_SIZE); 648 649 650 JLabel custom_label = new JLabel(Dictionary.get(nip_custom_label_key)); 651 custom_label.setComponentOrientation(Dictionary.getOrientation()); 652 custom_field = new JTextField(); 653 custom_field.setComponentOrientation(Dictionary.getOrientation()); 654 custom_field.setCaretPosition(0); 655 custom_field.setToolTipText(Dictionary.get(nip_custom_tooltip_key)); 638 656 639 657 button_pane = new JPanel(); … … 677 695 678 696 //Layout 697 698 custom_field_pane.setLayout(new BorderLayout()); 699 custom_field_pane.add(custom_label,BorderLayout.LINE_END); 700 custom_field_pane.add(custom_field, BorderLayout.CENTER); 701 702 extra_pane.setLayout(new GridLayout(0,1,5,5)); 703 extra_pane.add(custom_field_pane); 704 679 705 details_pane.setLayout(new BorderLayout(10,10)); 680 706 details_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); 681 707 details_pane.add(new JScrollPane(source_list), BorderLayout.CENTER); 708 details_pane.add(extra_pane, BorderLayout.SOUTH); 682 709 683 710 // if we are editing, fill in the controls … … 686 713 source_list.setTickedObjects(sources.toArray()); 687 714 source_list.setEnabled(true); 688 } 715 custom_field.setText(getCustomItemsFromSources(sources)); 716 } 717 custom_field.getDocument().addDocumentListener(new CustomFieldListener()); 689 718 content_pane.setLayout(new BorderLayout()); 690 719 content_pane.add(source_label, BorderLayout.NORTH); … … 698 727 Index index = null; 699 728 ArrayList sources; 700 701 if (!source_list.isNothingTicked() ) {729 String custom_text = custom_field.getText(); 730 if (!source_list.isNothingTicked() || !custom_text.equals("")) { 702 731 sources = source_list.getTicked(); 732 addCustomItemsToSources(sources, custom_text); 733 703 734 index = createIndex(sources); 704 735 } … … 706 737 } 707 738 739 protected void addCustomItemsToSources(ArrayList sources, String custom_text) { 740 if (!custom_text.equals("")) { 741 String[] custom_items = custom_text.split(","); 742 for (int i = 0; i < custom_items.length; i++) { 743 sources.add(custom_items[i]); 744 } 745 746 } 747 } 748 749 protected String getCustomItemsFromSources(ArrayList sources) { 750 ArrayList all_items = source_list.getAll(); 751 String result = ""; 752 for (int i=0; i < sources.size(); i++) { 753 Object item = sources.get(i); 754 if (!all_items.contains(item)) { 755 result += item+","; 756 } 757 } 758 return result; 759 760 } 708 761 // add/replace is only active if something is specified AND the specified index is not in the list already. 709 762 protected void validateAddOrReplaceButton() { … … 793 846 } 794 847 848 protected class CustomFieldListener 849 implements DocumentListener { 850 public void changedUpdate(DocumentEvent e) { 851 validateAddOrReplaceButton(); 852 } 853 854 /** Gives notification that there was an insert into the document. */ 855 public void insertUpdate(DocumentEvent e) { 856 validateAddOrReplaceButton(); 857 } 858 859 /** Gives notification that a portion of the document has been removed. */ 860 public void removeUpdate(DocumentEvent e) { 861 validateAddOrReplaceButton(); 862 } 863 864 } 795 865 796 866 protected class ReplaceIndexListener -
main/trunk/gli/src/org/greenstone/gatherer/cdm/FacetManager.java
r36250 r39021 42 42 this.nip_source_label_key = "CDM.FacetManager.Source"; 43 43 this.nip_source_tooltip_key = "CDM.FacetManager.Source_Tooltip"; 44 44 this.nip_custom_label_key = "CDM.IndexManager.Custom"; 45 this.nip_custom_tooltip_key = "CDM.IndexManager.Custom_Tooltip"; 46 45 47 this.nip_add_index_button_key = "CDM.FacetManager.Add"; 46 48 this.nip_add_index_tooltip_key = "CDM.FacetManager.Add_Tooltip"; -
main/trunk/gli/src/org/greenstone/gatherer/cdm/SearchIndexManager.java
r36301 r39021 68 68 this.nip_source_label_key = "CDM.IndexManager.Source"; 69 69 this.nip_source_tooltip_key = "CDM.IndexManager.Source_Tooltip"; 70 this.nip_custom_label_key = "CDM.IndexManager.Custom"; 71 this.nip_custom_tooltip_key = "CDM.IndexManager.Custom_Tooltip"; 72 70 73 this.nip_add_index_button_key = "CDM.IndexManager.Add_Index"; 71 74 this.nip_add_index_tooltip_key = "CDM.IndexManager.Add_Index_Tooltip"; … … 383 386 allfields_box.setComponentOrientation(Dictionary.getOrientation()); 384 387 //JLabel allfields_label = new JLabel(Dictionary.get("CDM.IndexManager.Allfields_Index")); 385 details_pane.add(allfields_box, BorderLayout.SOUTH);388 extra_pane.add(allfields_box); 386 389 387 390 … … 412 415 level_pane.add(level_label, BorderLayout.LINE_START); 413 416 level_pane.add(level_combobox, BorderLayout.CENTER); 414 details_pane.add(level_pane, BorderLayout.SOUTH);417 extra_pane.add(level_pane); 415 418 416 419 } … … 421 424 allfields_box.setSelected(true); 422 425 source_list.setEnabled(false); 426 custom_field.setEnabled(false); 423 427 } else { 424 425 428 source_list.setTickedObjects(sources.toArray()); 429 source_list.setEnabled(true); 426 430 if (sources.contains(StaticStrings.TEXT_STR)) { 427 431 text_checkbox.setSelected(true); … … 435 439 436 440 } 441 442 protected String getCustomItemsFromSources(ArrayList sources) { 443 ArrayList all_items = source_list.getAll(); 444 String result = ""; 445 for (int i=0; i < sources.size(); i++) { 446 Object item = sources.get(i); 447 if (!all_items.contains(item)&& !item.equals(StaticStrings.TEXT_STR) && !item.equals(ALLFIELDS)) { 448 result += item+","; 449 } 450 } 451 return result; 452 453 } 454 437 455 // Checks that specified index not already in the collection 438 protected void validateAddOrReplaceButton() { 456 // I think base version of this is sufficient 457 protected void validateAddOrReplaceButtonOld() { 439 458 Index index; 440 459 ArrayList sources; … … 474 493 Index index = null; 475 494 ArrayList sources; 495 String custom_text = custom_field.getText(); 476 496 if (mgpp_enabled && allfields_box.isSelected()) { 477 497 sources = new ArrayList(); … … 479 499 index = new Index(sources); 480 500 } 481 else if (text_checkbox.isSelected() || !source_list.isNothingTicked() ) {501 else if (text_checkbox.isSelected() || !source_list.isNothingTicked() || !custom_text.equals("")) { 482 502 sources = source_list.getTicked(); 483 503 if (text_checkbox.isSelected()) { 484 504 sources.add(0, StaticStrings.TEXT_STR); 485 505 } 506 addCustomItemsToSources(sources, custom_text); 486 507 if(mgpp_enabled) { 487 508 index = new Index(sources); … … 501 522 if (event.getStateChange() == ItemEvent.SELECTED) { 502 523 source_list.setEnabled(false); 524 custom_field.setEnabled(false); 503 525 text_checkbox.setEnabled(false); 504 526 } else if (event.getStateChange() == ItemEvent.DESELECTED) { 505 527 source_list.setEnabled(true); 528 custom_field.setEnabled(true); 506 529 text_checkbox.setEnabled(true); 507 530 } -
main/trunk/gli/src/org/greenstone/gatherer/cdm/SortFieldManager.java
r36260 r39021 52 52 this.nip_source_label_key = "CDM.SortFieldManager.Source"; 53 53 this.nip_source_tooltip_key = "CDM.SortFieldManager.Source_Tooltip"; 54 this.nip_custom_label_key = "CDM.IndexManager.Custom"; 55 this.nip_custom_tooltip_key = "CDM.IndexManager.Custom_Tooltip"; 54 56 55 57 this.nip_add_index_button_key = "CDM.SortFieldManager.Add"; … … 123 125 rank_checkbox.setEnabled(false); 124 126 source_list.setEnabled(false); 127 custom_field.setEnabled(false); 125 128 } else if (sources.contains(RANK)) { 126 129 rank_checkbox.setSelected(true); 127 130 none_checkbox.setEnabled(false); 128 131 source_list.setEnabled(false); 132 custom_field.setEnabled(false); 129 133 } 130 134 131 135 } 132 136 133 134 JPanel extra_options_panel = new JPanel(); 135 extra_options_panel.setComponentOrientation(Dictionary.getOrientation()); 136 extra_options_panel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); 137 138 extra_options_panel.setLayout(new GridLayout(2,1,5,5));//** 139 extra_options_panel.add(none_checkbox); 140 extra_options_panel.add(rank_checkbox); 141 details_pane.add(extra_options_panel, BorderLayout.SOUTH); 137 extra_pane.add(none_checkbox); 138 extra_pane.add(rank_checkbox); 142 139 143 140 } 144 141 // override this to take into account RANK/NONE options 142 protected String getCustomItemsFromSources(ArrayList sources) { 143 ArrayList all_items = source_list.getAll(); 144 String result = ""; 145 for (int i=0; i < sources.size(); i++) { 146 Object item = sources.get(i); 147 if (!all_items.contains(item)&& !item.equals(RANK) && !item.equals(NONE)) { 148 result += item+","; 149 } 150 } 151 return result; 152 153 } 145 154 // override this to take into account none/rank options 146 155 protected Index generateNewIndex() { 147 156 ArrayList sources; 148 157 158 String custom_text = custom_field.getText(); 149 159 if (none_checkbox.isSelected()) { 150 160 sources = new ArrayList(); … … 153 163 sources = new ArrayList(); 154 164 sources.add(RANK); 155 } else if (!source_list.isNothingTicked() ) {165 } else if (!source_list.isNothingTicked() || !custom_text.equals("")) { 156 166 sources = source_list.getTicked(); 167 addCustomItemsToSources(sources, custom_text); 157 168 } else { 158 169 // nothing selected … … 172 183 source_list.setEnabled(false); 173 184 rank_checkbox.setEnabled(false); 185 custom_field.setEnabled(false); 174 186 } else if (rank_checkbox.isSelected()) { 175 187 source_list.setEnabled(false); 176 188 none_checkbox.setEnabled(false); 189 custom_field.setEnabled(false); 177 190 } else { 178 191 // neither button is selected … … 180 193 rank_checkbox.setEnabled(true); 181 194 source_list.setEnabled(true); 195 custom_field.setEnabled(true); 182 196 } 183 197 validateAddOrReplaceButton();
Note:
See TracChangeset
for help on using the changeset viewer.