Changeset 12167
- Timestamp:
- 2006-07-12T14:05:55+12:00 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/cdm/IndexManager.java
r12127 r12167 641 641 // mg uses a level box 642 642 private JComboBox level_combobox; 643 644 private JButton add_button; 645 private JButton add_all_button; 646 private JButton select_all_button; 647 private JButton replace_button; 643 // mgpp has a allfields selector 644 private JCheckBox allfields_box; 645 646 private JButton add_or_replace_button; 647 private JButton add_or_select_all_button; 648 //private JButton select_all_button; 649 //private JButton replace_button; 648 650 private JButton cancel_button; 649 650 // some panels that we need to manipulate later on651 private JPanel boxes_pane;652 private JPanel labels_pane;653 private JLabel level_label;654 651 655 652 private boolean mgpp_enabled = false; … … 688 685 689 686 JPanel button_pane = new JPanel(); 687 button_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); 690 688 // three buttons for new index, or replace mg index, two buttons otherwise 691 689 if (existing_index == null || !mgpp_enabled) { … … 696 694 697 695 if (existing_index != null) { 698 replace_button = new GLIButton(Dictionary.get("CDM.IndexManager.Replace_Index"), Dictionary.get("CDM.IndexManager.Replace_Index_Tooltip")); 699 replace_button.setEnabled(false); 700 replace_button.addActionListener(new ReplaceIndexListener()); 701 button_pane.add(replace_button); 696 add_or_replace_button = new GLIButton(Dictionary.get("CDM.IndexManager.Replace_Index"), Dictionary.get("CDM.IndexManager.Replace_Index_Tooltip")); 697 add_or_replace_button.addActionListener(new ReplaceIndexListener()); 702 698 } else { 703 add_button = new GLIButton(Dictionary.get("CDM.IndexManager.Add_Index"), Dictionary.get("CDM.IndexManager.Add_Index_Tooltip")); 704 add_button.setEnabled(false); 705 add_button.addActionListener(new AddIndexListener()); 706 button_pane.add(add_button); 707 } 699 add_or_replace_button = new GLIButton(Dictionary.get("CDM.IndexManager.Add_Index"), Dictionary.get("CDM.IndexManager.Add_Index_Tooltip")); 700 add_or_replace_button.addActionListener(new AddIndexListener()); 701 } 702 703 add_or_replace_button.setEnabled(false); 704 button_pane.add(add_or_replace_button); 708 705 709 706 if (!mgpp_enabled) { 710 select_all_button = new GLIButton(Dictionary.get("CDM.IndexManager.Select_All"), Dictionary.get("CDM.IndexManager.Select_All_Tooltip")); 711 select_all_button.setEnabled(true); 712 select_all_button.addActionListener(new SelectAllActionListener()); 713 button_pane.add(select_all_button); 707 // its select all 708 add_or_select_all_button = new GLIButton(Dictionary.get("CDM.IndexManager.Select_All"), Dictionary.get("CDM.IndexManager.Select_All_Tooltip")); 709 add_or_select_all_button.setEnabled(true); 710 add_or_select_all_button.addActionListener(new SelectAllActionListener()); 711 button_pane.add(add_or_select_all_button); 714 712 } else if (existing_index == null) { 715 713 // mgpp, and new index 716 add_ all_button = new GLIButton(Dictionary.get("CDM.IndexManager.Add_All"), Dictionary.get("CDM.IndexManager.Add_All_Tooltip"));717 add_ all_button.setEnabled(true);718 add_ all_button.addActionListener(new AddAllIndexActionListener());719 button_pane.add(add_ all_button);714 add_or_select_all_button = new GLIButton(Dictionary.get("CDM.IndexManager.Add_All"), Dictionary.get("CDM.IndexManager.Add_All_Tooltip")); 715 add_or_select_all_button.setEnabled(true); 716 add_or_select_all_button.addActionListener(new AddAllIndexActionListener()); 717 button_pane.add(add_or_select_all_button); 720 718 721 719 } 720 722 721 // always have a cancel button 723 722 cancel_button = new GLIButton(Dictionary.get("General.Cancel"), Dictionary.get("General.Cancel")); … … 738 737 739 738 // do type specific stuff 740 if (!mgpp_enabled) { 741 742 level_label = new JLabel(Dictionary.get("CDM.IndexManager.Level")); 739 if (mgpp_enabled) { 740 // allfields 741 allfields_box = new JCheckBox(Dictionary.get("CDM.IndexManager.Allfields_Index")); 742 allfields_box.addItemListener(new AllFieldsBoxListener()); 743 //JLabel allfields_label = new JLabel(Dictionary.get("CDM.IndexManager.Allfields_Index")); 744 details_pane.add(allfields_box, BorderLayout.SOUTH); 745 746 747 } else { 748 // index level 749 JLabel level_label = new JLabel(Dictionary.get("CDM.IndexManager.Level")); 743 750 level_combobox = new JComboBox(); 744 751 level_combobox.setPreferredSize(FIELD_SIZE); … … 758 765 if (existing_index !=null) { 759 766 ArrayList sources = existing_index.getSources(); 760 source_list.setTickedObjects(sources.toArray()); 761 source_list.setEnabled(true); 767 if (mgpp_enabled && sources.get(0).equals(ALLFIELDS)) { 768 allfields_box.setSelected(true); 769 source_list.setEnabled(false); 770 } else { 771 source_list.setTickedObjects(sources.toArray()); 772 source_list.setEnabled(true); 773 } 762 774 if (!mgpp_enabled) { 763 775 level_combobox.setSelectedIndex(existing_index.getLevel()); … … 789 801 } 790 802 803 // Checks that specified index not already in the collection 804 private void validateAddOrReplaceButton() { 805 Index index; 806 ArrayList sources; 807 if (mgpp_enabled && allfields_box.isSelected()) { 808 sources = new ArrayList(); 809 sources.add(ALLFIELDS); 810 index = new Index(sources); 811 812 } else if (!source_list.isNothingTicked()) { 813 Object object[] = source_list.getTicked().toArray(); 814 sources = new ArrayList(); 815 for(int i = 0; i < object.length; i++) { 816 sources.add(object[i]); 817 } 818 object = null; 819 820 if (mgpp_enabled) { 821 index = new Index(sources); 822 } else { 823 index = new Index(level_combobox.getSelectedIndex(), sources); 824 } 825 } else { 826 // nothing selected 827 add_or_replace_button.setEnabled(false); 828 return; 829 } 830 831 sources = null; 832 if (index_model.contains(index)) { 833 add_or_replace_button.setEnabled(false); 834 } 835 else { 836 add_or_replace_button.setEnabled(true); 837 } 838 839 } 791 840 private class AddIndexListener 792 841 implements ActionListener … … 795 844 { 796 845 Index index; 797 if (!source_list.isNothingTicked()) { 846 if (mgpp_enabled && allfields_box.isSelected()) { 847 ArrayList sources = new ArrayList(); 848 sources.add(ALLFIELDS); 849 index = new Index(sources); 850 } 851 else if (!source_list.isNothingTicked()) { 798 852 ArrayList sources = source_list.getTicked(); 799 853 if(mgpp_enabled) { … … 853 907 } 854 908 909 private class AllFieldsBoxListener 910 implements ItemListener { 911 912 public void itemStateChanged(ItemEvent event) { 913 if (event.getStateChange() == ItemEvent.SELECTED) { 914 source_list.setEnabled(false); 915 } else if (event.getStateChange() == ItemEvent.DESELECTED) { 916 source_list.setEnabled(true); 917 } 918 validateAddOrReplaceButton(); 919 } 920 921 } 922 855 923 private class SelectAllActionListener 856 924 implements ActionListener { … … 858 926 public void actionPerformed(ActionEvent event) { 859 927 source_list.setAllTicked(); 860 if (editing) { 861 replace_button.setEnabled(true); 862 } else { 863 add_button.setEnabled(true); 864 } 928 validateAddOrReplaceButton(); 865 929 } 866 930 } … … 873 937 return; 874 938 } 875 boolean enabled = !source_list.isNothingTicked(); 876 if (editing) { 877 replace_button.setEnabled(enabled); 878 } else { 879 add_button.setEnabled(enabled); 880 } 881 939 validateAddOrReplaceButton(); 882 940 } 883 941 }
Note:
See TracChangeset
for help on using the changeset viewer.