Changeset 12346
- Timestamp:
- 2006-07-31T11:08:56+12:00 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/cdm/IndexManager.java
r12300 r12346 634 634 NewIndexPrompt new_index_prompt = null; 635 635 636 private JCheckBox text_checkbox; 636 637 private CheckList source_list; 637 638 // mg uses a level box … … 641 642 642 643 private JButton add_or_replace_button; 643 private JButton add_or_select_all_button; 644 private JButton select_all_button; 645 private JButton select_none_button; 646 private JButton add_all_button; 644 647 //private JButton select_all_button; 645 648 //private JButton replace_button; … … 667 670 JPanel content_pane = (JPanel)this.getContentPane(); 668 671 ArrayList new_data = new ArrayList(); 669 new_data.add(CollectionConfiguration.TEXT_STR);670 672 new_data.addAll(MetadataSetManager.getEveryMetadataSetElement()); 671 673 672 674 JPanel details_pane = new JPanel(); 673 675 676 text_checkbox = new JCheckBox(Dictionary.get("CDM.IndexManager.Text_Source")); 677 text_checkbox.setToolTipText(Dictionary.get("CDM.IndexManager.Text_Source_Tooltip")); 678 text_checkbox.addActionListener(new ActionListener() { 679 public void actionPerformed(ActionEvent event) { 680 validateAddOrReplaceButton(); 681 } 682 }); 674 683 JLabel source_label = new JLabel(Dictionary.get("CDM.IndexManager.Source")); 675 684 source_list = new CheckList(false); … … 680 689 JPanel button_pane = new JPanel(); 681 690 button_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); 682 // three buttons for new index, or replace mg index, two buttons otherwise 683 if (existing_index == null || !mgpp_enabled) { 684 button_pane.setLayout(new GridLayout(1,3,5,0)); 691 692 if (existing_index == null && mgpp_enabled) { 693 button_pane.setLayout(new GridLayout(2,3,5,0)); 694 button_pane.add(new JPanel()); 685 695 } else { 686 button_pane.setLayout(new GridLayout(1,2,5,0)); 687 } 688 696 button_pane.setLayout(new GridLayout(2,2,5,0)); 697 } 698 699 select_all_button = new GLIButton(Dictionary.get("CDM.IndexManager.Select_All"), Dictionary.get("CDM.IndexManager.Select_All_Tooltip")); 700 select_all_button.addActionListener(new ActionListener() { 701 702 public void actionPerformed(ActionEvent event) { 703 text_checkbox.setSelected(true); 704 source_list.setAllTicked(); 705 validateAddOrReplaceButton(); 706 } 707 }); 708 709 select_none_button = new GLIButton(Dictionary.get("CDM.IndexManager.Select_None"), Dictionary.get("CDM.IndexManager.Select_None_Tooltip")); 710 select_none_button.addActionListener(new ActionListener() { 711 712 public void actionPerformed(ActionEvent event) { 713 text_checkbox.setSelected(false); 714 source_list.clearTicked(); 715 validateAddOrReplaceButton(); 716 } 717 }); 718 719 720 button_pane.add(select_all_button); 721 button_pane.add(select_none_button); 722 689 723 if (existing_index != null) { 690 724 add_or_replace_button = new GLIButton(Dictionary.get("CDM.IndexManager.Replace_Index"), Dictionary.get("CDM.IndexManager.Replace_Index_Tooltip")); … … 698 732 button_pane.add(add_or_replace_button); 699 733 700 if (!mgpp_enabled) { 701 // its select all 702 add_or_select_all_button = new GLIButton(Dictionary.get("CDM.IndexManager.Select_All"), Dictionary.get("CDM.IndexManager.Select_All_Tooltip")); 703 add_or_select_all_button.setEnabled(true); 704 add_or_select_all_button.addActionListener(new SelectAllActionListener()); 705 button_pane.add(add_or_select_all_button); 706 } else if (existing_index == null) { 707 // mgpp, and new index 708 add_or_select_all_button = new GLIButton(Dictionary.get("CDM.IndexManager.Add_All"), Dictionary.get("CDM.IndexManager.Add_All_Tooltip")); 709 add_or_select_all_button.setEnabled(true); 710 add_or_select_all_button.addActionListener(new AddAllIndexActionListener()); 711 button_pane.add(add_or_select_all_button); 712 713 } 734 if (existing_index == null && mgpp_enabled) { 735 add_all_button = new GLIButton(Dictionary.get("CDM.IndexManager.Add_All"), Dictionary.get("CDM.IndexManager.Add_All_Tooltip")); 736 add_all_button.setEnabled(true); 737 add_all_button.addActionListener(new AddAllIndexActionListener()); 738 button_pane.add(add_all_button); 739 } 714 740 715 741 // always have a cancel button … … 726 752 details_pane.setLayout(new BorderLayout(10,10)); 727 753 details_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); 728 details_pane.add( source_label, BorderLayout.NORTH);754 details_pane.add(text_checkbox, BorderLayout.NORTH); 729 755 details_pane.add(new JScrollPane(source_list), BorderLayout.CENTER); 730 756 … … 744 770 level_combobox = new JComboBox(); 745 771 level_combobox.setPreferredSize(FIELD_SIZE); 772 // Note the order of these must be the same as the 773 // level order in Index 746 774 level_combobox.addItem(CollectionConfiguration.DOCUMENT_STR);//Dictionary.get("CDM.IndexManager.Document")); 775 level_combobox.addItem(CollectionConfiguration.SECTION_STR);//Dictionary.get("CDM.IndexManager.Section")); 747 776 level_combobox.addItem(CollectionConfiguration.PARAGRAPH_STR);//Dictionary.get("CDM.IndexManager.Paragraph")); 748 level_combobox.addItem(CollectionConfiguration.SECTION_STR);//Dictionary.get("CDM.IndexManager.Section"));749 777 level_combobox.setEditable(false); 750 778 level_combobox.setToolTipText(Dictionary.get("CDM.IndexManager.Level_Tooltip")); 779 level_combobox.addActionListener(new ActionListener() { 780 public void actionPerformed(ActionEvent event) { 781 validateAddOrReplaceButton(); 782 } 783 }); 751 784 JPanel level_pane = new JPanel(); 752 785 level_pane.setLayout(new BorderLayout()); … … 765 798 source_list.setTickedObjects(sources.toArray()); 766 799 source_list.setEnabled(true); 800 if (sources.contains(CollectionConfiguration.TEXT_STR)) { 801 text_checkbox.setSelected(true); 802 } 767 803 } 768 804 if (!mgpp_enabled) { … … 772 808 } 773 809 content_pane.setLayout(new BorderLayout()); 810 content_pane.add(source_label, BorderLayout.NORTH); 774 811 content_pane.add(details_pane, BorderLayout.CENTER); 775 812 content_pane.add(button_pane, BorderLayout.SOUTH); … … 804 841 index = new Index(sources); 805 842 806 } else if (!source_list.isNothingTicked()) { 807 Object object[] = source_list.getTicked().toArray(); 808 sources = new ArrayList(); 809 for(int i = 0; i < object.length; i++) { 810 sources.add(object[i]); 811 } 812 object = null; 813 843 } else if (text_checkbox.isSelected() || 844 !source_list.isNothingTicked()) { 845 sources = source_list.getTicked(); 846 if (text_checkbox.isSelected()) { 847 sources.add(0, CollectionConfiguration.TEXT_STR); 848 } 814 849 if (mgpp_enabled) { 815 850 index = new Index(sources); … … 843 878 index = new Index(sources); 844 879 } 845 else if (!source_list.isNothingTicked()) { 880 else if (text_checkbox.isSelected() || 881 !source_list.isNothingTicked()) { 846 882 ArrayList sources = source_list.getTicked(); 883 if (text_checkbox.isSelected()) { 884 sources.add(0, CollectionConfiguration.TEXT_STR); 885 } 847 886 if(mgpp_enabled) { 848 887 index = new Index(sources); … … 871 910 public void actionPerformed(ActionEvent event) { 872 911 ArrayList all_sources = source_list.getAll(); 912 all_sources.add(0, CollectionConfiguration.TEXT_STR); 873 913 ArrayList new_sources = new ArrayList(); 874 914 for(int i = 0; i < all_sources.size(); i++) { … … 915 955 } 916 956 917 private class SelectAllActionListener918 implements ActionListener {919 920 public void actionPerformed(ActionEvent event) {921 source_list.setAllTicked();922 validateAddOrReplaceButton();923 }924 }925 926 957 private class SourceListListener 927 958 implements ListSelectionListener { … … 943 974 ArrayList sources; 944 975 Index index = null; 945 if ( !source_list.isNothingTicked()) {976 if (text_checkbox.isSelected() || !source_list.isNothingTicked()) { 946 977 sources = source_list.getTicked(); 978 if (text_checkbox.isSelected()) { 979 sources.add(0, CollectionConfiguration.TEXT_STR); 980 } 947 981 if (mgpp_enabled) { 948 982 index = new Index(sources);
Note:
See TracChangeset
for help on using the changeset viewer.