Changeset 36153 for main


Ignore:
Timestamp:
2022-05-09T09:51:09+12:00 (2 years ago)
Author:
kjdon
Message:

IndexingManager updated to add in sortfield panel and facet panel if needed

File:
1 edited

Legend:

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

    r18611 r36153  
    5353
    5454    private IndexOptionManager option_manager = null;
    55     private IndexManager index_manager = null;
     55    private SearchIndexManager index_manager = null;
    5656    private BuildTypeManager build_type_manager = null;
    57 
     57    private SortFieldManager sortfield_manager = null;
     58    private FacetManager facet_manager = null;
    5859
    5960    private String build_type = null;
    6061
    6162    private Control controls = null;
    62 
    6363
    6464    public IndexingManager()
     
    6767    build_type = build_type_manager.getBuildType();
    6868    option_manager = new IndexOptionManager(build_type);
    69     if (build_type.equals(BuildTypeManager.BUILD_TYPE_MG)) {
    70         index_manager = new IndexManager(CollectionDesignManager.collect_config.getMGIndexes(), build_type);
     69    if (isMG()) {
     70        index_manager = new SearchIndexManager(CollectionDesignManager.collect_config.getMGIndexes(), build_type);
    7171    } else {
    72         index_manager = new IndexManager(CollectionDesignManager.collect_config.getMGPPIndexes(), build_type);
    73     }
    74     }
    75 
     72        index_manager = new SearchIndexManager(CollectionDesignManager.collect_config.getMGPPIndexes(), build_type);
     73    }
     74    // we always create the managers, but only display the controls if we
     75    // are Lucene/SOLR
     76    sortfield_manager = new SortFieldManager(CollectionDesignManager.collect_config.getSorts(), build_type);
     77    facet_manager = new FacetManager(CollectionDesignManager.collect_config.getFacets(), build_type);
     78
     79    }
    7680    public boolean isMGPP() {
    7781    return build_type_manager.isMGPP();
     
    8488    public boolean isMG() {
    8589    return build_type_manager.isMG();
     90    }
     91
     92    public boolean isSOLR() {
     93    return build_type_manager.isSOLR();
    8694    }
    8795
     
    130138    JPanel main_index_pane = null;
    131139    JPanel index_options_panel = null;
     140
     141    JPanel index_sort_facet_panel = null;
     142    // these get added/removed depending on indexer in use
     143    private JPanel sortfield_panel = null;
     144    private JPanel facet_panel = null;
    132145
    133146    public IndexingControl() {
     
    138151       
    139152        JPanel build_type_panel = (JPanel)build_type_manager.getControls();
    140         JPanel index_panel = (JPanel)index_manager.getControls();
    141153        index_options_panel = (JPanel)option_manager.getControls();
    142                        
    143            
     154
     155        index_sort_facet_panel = new JPanel();
     156       
     157        index_sort_facet_panel.setLayout(new GridLayout(0,1));
     158        JPanel index_panel = (JPanel)index_manager.getControls();
     159        index_sort_facet_panel.add(index_panel);
     160        if (isLucene() || isSOLR() ) {
     161        sortfield_panel = (JPanel)sortfield_manager.getControls();
     162        index_sort_facet_panel.add(sortfield_panel);
     163        }
     164        if (isSOLR()) {
     165        facet_panel = (JPanel)facet_manager.getControls();
     166        index_sort_facet_panel.add(facet_panel);
     167            }
    144168        main_index_pane = new JPanel();
    145169        main_index_pane.setLayout(new BorderLayout());
    146170        main_index_pane.add(build_type_panel, BorderLayout.NORTH);
    147         main_index_pane.add(index_panel, BorderLayout.CENTER);
     171        main_index_pane.add(index_sort_facet_panel, BorderLayout.CENTER);
    148172        main_index_pane.add(index_options_panel, BorderLayout.SOUTH);
    149173        main_index_pane.setComponentOrientation(Dictionary.getOrientation());
     
    156180        build_type_manager.addBuildTypeListener(this);
    157181        build_type_manager.addBuildTypeListener(index_manager);
     182        build_type_manager.addBuildTypeListener(sortfield_manager);
     183        build_type_manager.addBuildTypeListener(facet_manager);
    158184        build_type_manager.addBuildTypeListener(option_manager);
    159185    }
     
    169195        return;
    170196        }
     197        if (hasSorts(new_build_type) && !hasSorts(build_type)) {
     198        sortfield_panel = (JPanel)sortfield_manager.getControls();
     199        index_sort_facet_panel.add(sortfield_panel);
     200        // add sort panel
     201        }
     202        if (hasSorts(build_type) && ! hasSorts(new_build_type)) {
     203        // remove sort panel
     204        index_sort_facet_panel.remove(sortfield_panel);
     205        }
     206        if (hasFacets(new_build_type) && ! hasFacets(build_type)) {
     207        // add facet
     208        facet_panel = (JPanel)facet_manager.getControls();
     209        index_sort_facet_panel.add(facet_panel);
     210        }
     211        if (hasFacets(build_type) && ! hasFacets(new_build_type)) {
     212        // remove facet pane
     213        index_sort_facet_panel.remove(facet_panel);
     214        }
    171215        build_type = new_build_type;
    172216    }
    173217
     218    private boolean hasSorts(String build_type) {
     219        return build_type.equals(BuildTypeManager.BUILD_TYPE_LUCENE) || build_type.equals(BuildTypeManager.BUILD_TYPE_SOLR);
     220    }
     221    private boolean hasFacets(String build_type) {
     222        return build_type.equals(BuildTypeManager.BUILD_TYPE_SOLR);
     223
     224    }
     225
    174226    }
    175227}
Note: See TracChangeset for help on using the changeset viewer.