Changeset 39021


Ignore:
Timestamp:
2024-05-14T13:25:56+12:00 (2 weeks ago)
Author:
kjdon
Message:

added a custom field box into new index prompt (used for search indexes, sortfields and facets). If you are extracting metadata that doesn't end up in the lists of metadata, you can use this to specify those metadata items.

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  
    8383    protected String nip_source_label_key = null;
    8484    protected String nip_source_tooltip_key = null;
     85    protected String nip_custom_label_key = null;
     86    protected String nip_custom_tooltip_key = null;
    8587    protected String nip_add_index_button_key = null;
    8688    protected String nip_add_index_tooltip_key = null;
     
    571573
    572574        protected CheckList source_list;
     575        protected JTextField custom_field;
    573576        protected JButton add_or_replace_button;
    574577        protected JButton add_all_button;
     
    577580        protected JPanel content_pane;
    578581        protected JPanel details_pane;
     582        protected JPanel extra_pane;
    579583        protected JPanel button_pane;
    580584        protected boolean editing = false;
     
    636640        source_list.setToolTipText(Dictionary.get(nip_source_tooltip_key));
    637641        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));
    638656
    639657        button_pane = new JPanel();
     
    677695
    678696        //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
    679705        details_pane.setLayout(new BorderLayout(10,10));
    680706        details_pane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
    681707        details_pane.add(new JScrollPane(source_list), BorderLayout.CENTER);
     708        details_pane.add(extra_pane, BorderLayout.SOUTH);
    682709
    683710        // if we are editing, fill in the controls
     
    686713            source_list.setTickedObjects(sources.toArray());
    687714            source_list.setEnabled(true);
    688         }
     715            custom_field.setText(getCustomItemsFromSources(sources));
     716        }
     717        custom_field.getDocument().addDocumentListener(new CustomFieldListener());
    689718        content_pane.setLayout(new BorderLayout());
    690719        content_pane.add(source_label, BorderLayout.NORTH);
     
    698727        Index index = null;
    699728        ArrayList sources;
    700 
    701         if (!source_list.isNothingTicked()) {
     729        String custom_text = custom_field.getText();
     730        if (!source_list.isNothingTicked() || !custom_text.equals("")) {
    702731            sources = source_list.getTicked();
     732            addCustomItemsToSources(sources, custom_text);
     733       
    703734            index = createIndex(sources);
    704735        }
     
    706737        }
    707738
     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        }
    708761        // add/replace is only active if something is specified AND the specified index is not in the list already.
    709762        protected void validateAddOrReplaceButton() {
     
    793846        }
    794847   
     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        }
    795865
    796866        protected class ReplaceIndexListener
  • main/trunk/gli/src/org/greenstone/gatherer/cdm/FacetManager.java

    r36250 r39021  
    4242    this.nip_source_label_key = "CDM.FacetManager.Source";
    4343        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     
    4547    this.nip_add_index_button_key = "CDM.FacetManager.Add";
    4648    this.nip_add_index_tooltip_key = "CDM.FacetManager.Add_Tooltip";
  • main/trunk/gli/src/org/greenstone/gatherer/cdm/SearchIndexManager.java

    r36301 r39021  
    6868      this.nip_source_label_key = "CDM.IndexManager.Source";
    6969      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
    7073      this.nip_add_index_button_key = "CDM.IndexManager.Add_Index";
    7174      this.nip_add_index_tooltip_key = "CDM.IndexManager.Add_Index_Tooltip";
     
    383386              allfields_box.setComponentOrientation(Dictionary.getOrientation());
    384387              //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);
    386389             
    387390             
     
    412415              level_pane.add(level_label, BorderLayout.LINE_START);
    413416              level_pane.add(level_combobox, BorderLayout.CENTER);
    414               details_pane.add(level_pane, BorderLayout.SOUTH);
     417              extra_pane.add(level_pane);
    415418
    416419            }
     
    421424                allfields_box.setSelected(true);
    422425                source_list.setEnabled(false);
     426        custom_field.setEnabled(false);
    423427              } else {
    424                 source_list.setTickedObjects(sources.toArray());
    425                 source_list.setEnabled(true);
     428          source_list.setTickedObjects(sources.toArray());
     429          source_list.setEnabled(true);
    426430                if (sources.contains(StaticStrings.TEXT_STR)) {
    427431                  text_checkbox.setSelected(true);
     
    435439               
    436440          }
     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
    437455        // 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() {
    439458        Index index;
    440459        ArrayList sources;
     
    474493        Index index = null;
    475494        ArrayList sources;
     495        String custom_text = custom_field.getText();
    476496        if (mgpp_enabled && allfields_box.isSelected()) {
    477497            sources = new ArrayList();
     
    479499            index = new Index(sources);
    480500        }
    481         else if (text_checkbox.isSelected() || !source_list.isNothingTicked()) {
     501        else if (text_checkbox.isSelected() || !source_list.isNothingTicked() || !custom_text.equals("")) {
    482502            sources = source_list.getTicked();
    483503            if (text_checkbox.isSelected()) {
    484504            sources.add(0, StaticStrings.TEXT_STR);
    485505            }
     506            addCustomItemsToSources(sources, custom_text);
    486507            if(mgpp_enabled) {
    487508            index = new Index(sources);
     
    501522            if (event.getStateChange() == ItemEvent.SELECTED) {
    502523            source_list.setEnabled(false);
     524            custom_field.setEnabled(false);
    503525                        text_checkbox.setEnabled(false);
    504526            } else if (event.getStateChange() == ItemEvent.DESELECTED) {
    505527            source_list.setEnabled(true);
     528            custom_field.setEnabled(true);
    506529                        text_checkbox.setEnabled(true);
    507530            }
  • main/trunk/gli/src/org/greenstone/gatherer/cdm/SortFieldManager.java

    r36260 r39021  
    5252    this.nip_source_label_key = "CDM.SortFieldManager.Source";
    5353        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";
    5456
    5557    this.nip_add_index_button_key = "CDM.SortFieldManager.Add";
     
    123125              rank_checkbox.setEnabled(false);
    124126              source_list.setEnabled(false);
     127              custom_field.setEnabled(false);
    125128          } else if (sources.contains(RANK)) {
    126129              rank_checkbox.setSelected(true);
    127130              none_checkbox.setEnabled(false);
    128131              source_list.setEnabled(false);
     132              custom_field.setEnabled(false);
    129133          }
    130134         
    131135          }
    132136
    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);
    142139
    143140      }
    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        }
    145154        // override this to take into account none/rank options
    146155        protected Index generateNewIndex() {
    147156        ArrayList sources;
    148157
     158        String custom_text = custom_field.getText();
    149159        if (none_checkbox.isSelected()) {
    150160            sources = new ArrayList();
     
    153163            sources = new ArrayList();
    154164            sources.add(RANK);
    155         } else if (!source_list.isNothingTicked()) {
     165        } else if (!source_list.isNothingTicked() || !custom_text.equals("")) {
    156166            sources = source_list.getTicked();
     167            addCustomItemsToSources(sources, custom_text);
    157168        } else {
    158169            // nothing selected
     
    172183            source_list.setEnabled(false);
    173184            rank_checkbox.setEnabled(false);
     185            custom_field.setEnabled(false);
    174186            } else if (rank_checkbox.isSelected()) {
    175187            source_list.setEnabled(false);
    176188            none_checkbox.setEnabled(false);
     189            custom_field.setEnabled(false);
    177190            } else {
    178191            // neither button is selected
     
    180193            rank_checkbox.setEnabled(true);
    181194            source_list.setEnabled(true);
     195            custom_field.setEnabled(true);
    182196            }
    183197            validateAddOrReplaceButton();
Note: See TracChangeset for help on using the changeset viewer.