Changeset 4961


Ignore:
Timestamp:
04/14/14 07:29:20 (10 years ago)
Author:
Twan Goosen
Message:

apply minimal occurence selection after change (automatically check checkbox)

File:
1 edited

Legend:

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

    r4958 r4961  
    5656 */
    5757public abstract class AllFacetValuesPanel extends GenericPanel<FacetField> {
    58 
     58   
    5959    private final FacetFieldValuesProvider valuesProvider;
    6060    private final WebMarkupContainer valuesContainer;
     
    7878    public AllFacetValuesPanel(String id, IModel<FacetField> model, IModel<FieldValuesFilter> filterModel) {
    7979        super(id, model);
    80 
     80       
    8181        if (filterModel != null) {
    8282            this.filterModel = filterModel;
     
    8787        // create a provider that shows all values and is sorted by name by default
    8888        valuesProvider = new FacetFieldValuesProvider(model, Integer.MAX_VALUE, FieldValueOrderSelector.NAME_SORT) {
    89 
     89           
    9090            @Override
    9191            protected IModel<FieldValuesFilter> getFilterModel() {
     
    9393                return AllFacetValuesPanel.this.filterModel;
    9494            }
    95 
     95           
    9696        };
    9797
     
    110110        add(optionsForm);
    111111    }
    112 
     112   
    113113    private DataView<FacetField.Count> createValuesView(String id) {
    114114        return new DataView<FacetField.Count>(id, valuesProvider) {
    115 
     115           
    116116            @Override
    117117            protected void populateItem(final Item<FacetField.Count> item) {
     
    120120                // link to select an individual facet value
    121121                final Link selectLink = new AjaxFallbackLink("facetSelect") {
    122 
     122                   
    123123                    @Override
    124124                    public void onClick(AjaxRequestTarget target) {
     
    141141        };
    142142    }
    143 
     143   
    144144    private Form createOptionsForm(String id) {
    145145        final Form options = new Form(id);
    146 
     146       
    147147        final DropDownChoice<SortParam<FieldValuesOrder>> sortSelect
    148148                = new FieldValueOrderSelector("sort", new PropertyModel<SortParam<FieldValuesOrder>>(valuesProvider, "sort"));
    149149        sortSelect.add(new UpdateOptionsFormBehavior(options));
    150150        options.add(sortSelect);
    151 
     151       
    152152        final TextField filterField = new TextField<String>("filter", new PropertyModel(filterModel, "name"));
    153153        filterField.add(new AjaxFormComponentUpdatingBehavior("keyup") {
    154 
     154           
    155155            @Override
    156156            protected void onUpdate(AjaxRequestTarget target) {
     
    159159        });
    160160        options.add(filterField);
    161 
     161       
    162162        addOccurenceOptions(options);
    163 
     163       
    164164        return options;
    165165    }
     
    197197        // Dropdown to select a value (which is applied to the filter if the 'bridge' is open)
    198198        final DropDownChoice<Integer> minOccurence = new DropDownChoice<Integer>("minOccurences", minOccurenceSelectModel, ImmutableList.of(2, 5, 10, 100, 1000));
    199         minOccurence.add(new UpdateOptionsFormBehavior(options));
     199        minOccurence.add(new UpdateOptionsFormBehavior(options) {
     200           
     201            @Override
     202            protected void onUpdate(AjaxRequestTarget target) {
     203                super.onUpdate(target);
     204                // on change, apply to inner model ('open bridge')
     205                if (!minOccurenceCheckBoxModel.getObject()) {
     206                    minOccurenceCheckBoxModel.setObject(true);
     207                }
     208            }
     209           
     210        });
    200211        options.add(minOccurence);
    201212    }
    202 
     213   
    203214    private class UpdateOptionsFormBehavior extends OnChangeAjaxBehavior {
    204 
     215       
    205216        private final Form options;
    206 
     217       
    207218        public UpdateOptionsFormBehavior(Form options) {
    208219            this.options = options;
    209220        }
    210 
     221       
    211222        @Override
    212223        protected void onUpdate(AjaxRequestTarget target) {
     
    214225            target.add(valuesContainer);
    215226        }
    216 
    217     }
    218 
     227       
     228    }
     229   
    219230    @Override
    220231    public void detachModels() {
     
    232243     */
    233244    protected abstract void onValuesSelected(String facet, Collection<String> values, AjaxRequestTarget target);
    234 
     245   
    235246}
Note: See TracChangeset for help on using the changeset viewer.