Changeset 12346


Ignore:
Timestamp:
2006-07-31T11:08:56+12:00 (18 years ago)
Author:
kjdon
Message:

moved text outside the source list. select all button is now on mgpp as well, and added a select none button.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/cdm/IndexManager.java

    r12300 r12346  
    634634        NewIndexPrompt new_index_prompt = null;
    635635   
     636        private JCheckBox text_checkbox;
    636637        private CheckList source_list;
    637638        // mg uses a level box
     
    641642
    642643        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;
    644647        //private JButton select_all_button;
    645648        //private JButton replace_button;
     
    667670        JPanel content_pane = (JPanel)this.getContentPane();
    668671        ArrayList new_data = new ArrayList();
    669         new_data.add(CollectionConfiguration.TEXT_STR);
    670672        new_data.addAll(MetadataSetManager.getEveryMetadataSetElement());
    671673
    672674        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            });
    674683        JLabel source_label = new JLabel(Dictionary.get("CDM.IndexManager.Source"));
    675684        source_list = new CheckList(false);
     
    680689        JPanel button_pane = new JPanel();
    681690        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());
    685695        } 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       
    689723        if (existing_index != null) {
    690724            add_or_replace_button = new GLIButton(Dictionary.get("CDM.IndexManager.Replace_Index"), Dictionary.get("CDM.IndexManager.Replace_Index_Tooltip"));
     
    698732        button_pane.add(add_or_replace_button);
    699733       
    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        }
    714740       
    715741        // always have a cancel button
     
    726752        details_pane.setLayout(new BorderLayout(10,10));
    727753        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);
    729755        details_pane.add(new JScrollPane(source_list), BorderLayout.CENTER);
    730756
     
    744770            level_combobox = new JComboBox();
    745771            level_combobox.setPreferredSize(FIELD_SIZE);
     772            // Note the order of these must be the same as the
     773            // level order in Index
    746774            level_combobox.addItem(CollectionConfiguration.DOCUMENT_STR);//Dictionary.get("CDM.IndexManager.Document"));
     775            level_combobox.addItem(CollectionConfiguration.SECTION_STR);//Dictionary.get("CDM.IndexManager.Section"));
    747776            level_combobox.addItem(CollectionConfiguration.PARAGRAPH_STR);//Dictionary.get("CDM.IndexManager.Paragraph"));
    748             level_combobox.addItem(CollectionConfiguration.SECTION_STR);//Dictionary.get("CDM.IndexManager.Section"));
    749777            level_combobox.setEditable(false);
    750778            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            });
    751784            JPanel level_pane = new JPanel();
    752785            level_pane.setLayout(new BorderLayout());
     
    765798            source_list.setTickedObjects(sources.toArray());
    766799            source_list.setEnabled(true);
     800            if (sources.contains(CollectionConfiguration.TEXT_STR)) {
     801                text_checkbox.setSelected(true);
     802            }
    767803            }
    768804            if (!mgpp_enabled) {
     
    772808        }
    773809        content_pane.setLayout(new BorderLayout());
     810        content_pane.add(source_label, BorderLayout.NORTH);
    774811        content_pane.add(details_pane, BorderLayout.CENTER);
    775812        content_pane.add(button_pane, BorderLayout.SOUTH);
     
    804841            index = new Index(sources);
    805842           
    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            }           
    814849            if (mgpp_enabled) {
    815850            index = new Index(sources);
     
    843878            index = new Index(sources);
    844879            }
    845             else if (!source_list.isNothingTicked()) {
     880            else if (text_checkbox.isSelected() ||
     881                 !source_list.isNothingTicked()) {
    846882            ArrayList sources = source_list.getTicked();
     883            if (text_checkbox.isSelected()) {
     884                sources.add(0, CollectionConfiguration.TEXT_STR);
     885            }
    847886            if(mgpp_enabled) {
    848887                index = new Index(sources);
     
    871910        public void actionPerformed(ActionEvent event) {
    872911            ArrayList all_sources = source_list.getAll();
     912            all_sources.add(0, CollectionConfiguration.TEXT_STR);
    873913            ArrayList new_sources = new ArrayList();
    874914            for(int i = 0; i < all_sources.size(); i++) {
     
    915955        }
    916956
    917         private class SelectAllActionListener
    918         implements ActionListener {
    919 
    920         public void actionPerformed(ActionEvent event) {
    921             source_list.setAllTicked();
    922             validateAddOrReplaceButton();
    923         }
    924         }
    925 
    926957        private class SourceListListener
    927958        implements ListSelectionListener {
     
    943974            ArrayList sources;
    944975            Index index = null;
    945             if (!source_list.isNothingTicked()) {
     976            if (text_checkbox.isSelected() || !source_list.isNothingTicked()) {
    946977            sources = source_list.getTicked();
     978            if (text_checkbox.isSelected()) {
     979                sources.add(0, CollectionConfiguration.TEXT_STR);
     980            }
    947981            if (mgpp_enabled) {
    948982                index = new Index(sources);
Note: See TracChangeset for help on using the changeset viewer.