Changeset 4665


Ignore:
Timestamp:
03/10/14 14:35:18 (11 years ago)
Author:
Twan Goosen
Message:

Added a drop down to choose between sort modes for all values display

Location:
vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/panels/AllFacetValuesPanel.html

    r4663 r4665  
    2525        <wicket:panel>
    2626            <p>All values in this facet</p>
    27             <p>Sort by <select><option>name</option><option>count</option></select></p>
    28             <div>Search: <input type="text" /></div>
    29             <div class="sortedFacet">
    30 <!--                <div>
    31                     <div class="anchorpanel"><a href=""></a><span>A</span></div>
    32                 </div>-->
     27            <form wicket:id="options">
     28                <p>Sort by <select wicket:id="sort"><option>name</option><option>count</option></select></p>
     29                <div>Search: <input type="text" /></div>
     30            </form>
     31            <div wicket:id="facetValuesContainer" class="sortedFacet">
     32                <!--               
     33                    <div>
     34                        <div class="anchorpanel"><a href=""></a><span>A</span></div>
     35                    </div>
     36                -->
    3337                <div wicket:id="facetValue">
    3438                    <div class="facetLinkPanel"><a wicket:id="facetSelect" href=""><span wicket:id="name">A Corpus</span></a> (<span wicket:id="count">1</span>)</div>
  • vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/panels/AllFacetValuesPanel.java

    r4663 r4665  
    1717package eu.clarin.cmdi.vlo.wicket.panels;
    1818
     19import eu.clarin.cmdi.vlo.wicket.components.FieldValueOrderSelector;
     20import eu.clarin.cmdi.vlo.pojo.FieldValuesOrder;
    1921import eu.clarin.cmdi.vlo.wicket.provider.FacetFieldValuesProvider;
    2022import java.util.Collection;
     
    2224import org.apache.solr.client.solrj.response.FacetField;
    2325import org.apache.wicket.ajax.AjaxRequestTarget;
     26import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
    2427import org.apache.wicket.ajax.markup.html.AjaxFallbackLink;
     28import org.apache.wicket.extensions.markup.html.repeater.util.SortParam;
     29import org.apache.wicket.markup.html.WebMarkupContainer;
    2530import org.apache.wicket.markup.html.basic.Label;
     31import org.apache.wicket.markup.html.form.DropDownChoice;
     32import org.apache.wicket.markup.html.form.Form;
    2633import org.apache.wicket.markup.html.link.Link;
    2734import org.apache.wicket.markup.html.panel.GenericPanel;
     
    3037import org.apache.wicket.model.CompoundPropertyModel;
    3138import org.apache.wicket.model.IModel;
     39import org.apache.wicket.model.PropertyModel;
    3240
    3341/**
     42 * A panel that shows all available values for a selected facet. Supports two
     43 * ordering modes (by name or result count) and dynamic filtering.
    3444 *
    3545 * @author twagoo
     
    3747public abstract class AllFacetValuesPanel extends GenericPanel<FacetField> {
    3848
     49    private final FacetFieldValuesProvider valuesProvider;
     50    private final WebMarkupContainer valuesContainer;
     51
    3952    public AllFacetValuesPanel(String id, IModel<FacetField> model) {
    4053        super(id, model);
     54        valuesProvider = new FacetFieldValuesProvider(model);
    4155
    42         // provider that extracts values and counts from FacetField
    43         final FacetFieldValuesProvider valuesProvider = new FacetFieldValuesProvider(model);
    44         add(new DataView<FacetField.Count>("facetValue", valuesProvider) {
     56        valuesContainer = new WebMarkupContainer("facetValuesContainer");
     57        valuesContainer.setOutputMarkupId(true);
     58        add(valuesContainer);
     59
     60        final DataView<FacetField.Count> valuesView = createValuesView("facetValue");
     61        valuesContainer.add(valuesView);
     62
     63        final Form optionsForm = createOptionsForm("options");
     64        optionsForm.setOutputMarkupId(true);
     65        add(optionsForm);
     66    }
     67
     68    private DataView<FacetField.Count> createValuesView(String id) {
     69        return new DataView<FacetField.Count>(id, valuesProvider) {
    4570
    4671            @Override
     
    6994                item.add(new Label("count"));
    7095            }
     96        };
     97    }
     98
     99    private Form createOptionsForm(String id) {
     100        final Form options = new Form(id);
     101        final DropDownChoice<SortParam<FieldValuesOrder>> sortSelect
     102                = new FieldValueOrderSelector("sort", new PropertyModel<SortParam<FieldValuesOrder>>(valuesProvider, "sort"));
     103        sortSelect.add(new AjaxFormComponentUpdatingBehavior("onchange") {
     104
     105            @Override
     106            protected void onUpdate(AjaxRequestTarget target) {
     107                target.add(options);
     108                target.add(valuesContainer);
     109            }
    71110        });
     111        options.add(sortSelect);
     112        return options;
    72113    }
    73114
     
    81122     */
    82123    protected abstract void onValuesSelected(String facet, Collection<String> values, AjaxRequestTarget target);
    83 
    84124}
Note: See TracChangeset for help on using the changeset viewer.