- Timestamp:
- 2022-06-13T16:29:22+12:00 (23 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/gli/src/org/greenstone/gatherer/cdm/BaseIndexManager.java
r36190 r36251 75 75 protected String remove_button_key = "CDM.IndexManager.Remove"; 76 76 protected String remove_button_tooltip_key = null; 77 protected String default_indicator_key = null; //"CDM.IndexManager.Default_Index_Indicator"; 78 protected String set_default_tooltip_key = "CDM.IndexManager.Set_Default_Tooltip"; 77 protected String default_indicator_key = null; 78 protected String set_default_tooltip_key = "CDM.IndexManager.Set_Default_Tooltip"; 79 80 79 81 protected String nip_new_index_key = null; 80 82 protected String nip_edit_index_key = null; 81 protected String nip_source_label_key = null; //"CDM.IndexManager.Source" 82 protected String nip_source_tooltip_key = null; //"CDM.IndexManager.Source" 83 84 protected String nip_add_index_button_key = null;//"CDM.IndexManager.Add_Index" 85 protected String nip_add_index_tooltip_key = null; //"CDM.IndexManager.Add_Index_Tooltip" 86 protected String nip_replace_index_button_key = null; //"CDM.IndexManager.Replace_Index" 87 protected String nip_replace_index_tooltip_key = null; //"CDM.IndexManager.Replace_Index_Tooltip" 88 89 static final protected Dimension PROMPT_SIZE = new Dimension(400,400); 83 protected String nip_source_label_key = null; 84 protected String nip_source_tooltip_key = null; 85 protected String nip_add_index_button_key = null; 86 protected String nip_add_index_tooltip_key = null; 87 protected String nip_replace_index_button_key = null; 88 protected String nip_replace_index_tooltip_key = null; 89 protected String nip_add_all_index_button_key = null; 90 protected String nip_add_all_index_tooltip_key = null; 91 92 static final protected Dimension PROMPT_SIZE = new Dimension(500,500); 90 93 91 94 public BaseIndexManager(Element indexes, String current_build_type, String index_element_name, String index_default_element_name, Index class_type) { … … 234 237 protected void removeIndex(Index index) { 235 238 if(index != null) { 236 // Remove any current metadata from this index 237 //CollectionDesignManager.searchmeta_manager.removeMetadata(StaticStrings.STOP_CHARACTER + index.getID()); 239 // Remove any current metadata for this index 238 240 CollectionDesignManager.searchmeta_manager.removeMetadata(index.getID(), SearchMeta.TYPE_INDEX); 239 241 // Remove the index … … 267 269 } 268 270 // Remove the old index coll meta 269 CollectionDesignManager.searchmeta_manager.removeMetadata( /*StaticStrings.STOP_CHARACTER +*/old_index.getID(), old_index.getType());271 CollectionDesignManager.searchmeta_manager.removeMetadata( old_index.getID(), old_index.getType()); 270 272 // Add the new coll meta 271 273 CollectionDesignManager.searchmeta_manager.addMetadatum(coll_meta); … … 565 567 protected class NewIndexPrompt 566 568 extends ModalDialog { 567 569 568 570 NewIndexPrompt new_index_prompt = null; 569 571 570 572 protected CheckList source_list; 571 573 protected JButton add_or_replace_button; 572 573 //protected JButton select_none_button; 574 //protected JButton add_all_button; 575 //protected JButton select_all_button; 576 //protected JButton replace_button; 574 protected JButton add_all_button; 577 575 protected JButton cancel_button; 578 576 579 580 581 577 protected JPanel content_pane; 578 protected JPanel details_pane; 579 protected JPanel button_pane; 582 580 protected boolean editing = false; 583 581 … … 643 641 button_pane.setComponentOrientation(Dictionary.getOrientation()); 644 642 645 button_pane.setLayout(new GridLayout(0,2,5,0)); 646 643 if (editing) { 644 button_pane.setLayout(new GridLayout(0,2,5,0)); 645 } else { 646 button_pane.setLayout(new GridLayout(0,3,5,0)); 647 } 647 648 if (existing_index != null) { 648 add_or_replace_button = new GLIButton(Dictionary.get(nip_add_index_button_key), Dictionary.get(nip_replace_index_tooltip_key)); 649 // replace 650 add_or_replace_button = new GLIButton(Dictionary.get(nip_replace_index_button_key), Dictionary.get(nip_replace_index_tooltip_key)); 649 651 add_or_replace_button.addActionListener(new ReplaceIndexListener()); 650 652 } else { 653 //new 651 654 add_or_replace_button = new GLIButton(Dictionary.get(nip_add_index_button_key), Dictionary.get(nip_add_index_tooltip_key)); 652 655 add_or_replace_button.addActionListener(new AddIndexListener()); 656 // create the add all button, which we only have for "add" 657 add_all_button = new GLIButton(Dictionary.get(nip_add_all_index_button_key), Dictionary.get(nip_add_all_index_tooltip_key)); 658 add_all_button.addActionListener(new AddAllActionListener()); 659 653 660 } 654 661 … … 656 663 add_or_replace_button.setEnabled(false); 657 664 button_pane.add(add_or_replace_button); 658 659 665 if (!editing) { 666 button_pane.add(add_all_button); 667 } 660 668 // always have a cancel button 661 669 cancel_button = new GLIButton(Dictionary.get("General.Cancel"), Dictionary.get("General.Cancel")); … … 686 694 687 695 } 688 // Checks that specified index not already in the collection689 protected void validateAddOrReplaceButton() {690 Index index;691 ArrayList sources;692 if (!source_list.isNothingTicked()) {693 sources = source_list.getTicked();694 index = createIndex(sources);695 } else {696 // nothing selected697 add_or_replace_button.setEnabled(false);698 return;699 }700 701 sources = null;702 if (index_model.contains(index)) {703 add_or_replace_button.setEnabled(false);704 }705 else {706 add_or_replace_button.setEnabled(true);707 }708 709 }710 696 711 697 protected Index generateNewIndex() { … … 719 705 return index; 720 706 } 707 708 // add/replace is only active if something is specified AND the specified index is not in the list already. 709 protected void validateAddOrReplaceButton() { 710 Index index = generateNewIndex(); 711 if (index == null || index_model.contains(index)) { 712 add_or_replace_button.setEnabled(false); 713 } else { 714 add_or_replace_button.setEnabled(true); 715 } 716 // we enable the add_all button if we have 2 or more sources ticked 717 // unless we are in "edit index" 718 if (!editing) { 719 if (source_list.isEnabled() && source_list.numTicked() > 1) { 720 add_all_button.setEnabled(true); 721 } else { 722 add_all_button.setEnabled(false); 723 } 724 } 725 } 726 721 727 722 728 protected SearchMeta generateSearchMeta(Index index) { 723 SearchMeta metadatum = new SearchMeta( /*StaticStrings.STOP_CHARACTER +*/index.getID(), index.getType());729 SearchMeta metadatum = new SearchMeta(index.getID(), index.getType()); 724 730 if (use_macro_as_display_name(index.getID())) { 725 731 metadatum.setValue(get_macro_name(index.getID())); … … 727 733 metadatum.setValue(index.getID()); 728 734 } 729 // is this right? Index vs index730 //metadatum.setType(index_element_name);731 735 return metadatum; 732 736 } … … 749 753 } 750 754 755 /** add all selected sources as separate indexes (fields). */ 756 private class AddAllActionListener 757 implements ActionListener { 758 759 public void actionPerformed(ActionEvent event) { 760 ArrayList sources = source_list.getTicked(); 761 762 ArrayList new_sources = new ArrayList(); 763 for(int i = 0; i < sources.size(); i++) { 764 Object source = sources.get(i); 765 766 // Create new index 767 new_sources.clear(); 768 new_sources.add(source); 769 Index index = createIndex(new_sources); 770 if(!index_model.contains(index)) { 771 SearchMeta metadatum = generateSearchMeta(index); 772 addIndex(index, metadatum); 773 } 774 source = null; 775 index = null; 776 } 777 new_sources = null; 778 new_index_prompt.dispose(); 779 780 } 781 } 782 751 783 752 784 protected class SourceListListener … … 787 819 */ 788 820 protected boolean use_macro_as_display_name(String index_id) { 789 //String metaname = index_id; 821 790 822 if (index_id.indexOf(":") != -1) { 791 823 index_id = index_id.substring(index_id.indexOf(":") + 1);
Note:
See TracChangeset
for help on using the changeset viewer.