Changeset 1093


Ignore:
Timestamp:
01/25/11 16:35:35 (13 years ago)
Author:
patdui
Message:
  • fixed tests
Location:
vlo/trunk/vlo_webapp/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • vlo/trunk/vlo_webapp/src/main/java/eu/clarin/cmdi/vlo/pages/FacetBoxPanel.java

    r1083 r1093  
    2929    private FacetHeaderPanel facetHeaderPanel;
    3030    private FacetModel facetModel;
     31    private int maxNrOfFacetValues;
    3132
    3233    public FacetBoxPanel(String id, IModel<FacetField> model) {
    3334        super(id, model);
    3435        setOutputMarkupId(true);
     36        setMaxNrOfFacetValues(MAX_NR_OF_FACET_VALUES);
    3537    }
    36 
     38   
    3739    @SuppressWarnings("serial")
    3840    public FacetBoxPanel create(final SearchPageQuery query) {
     
    4850            add(new WebMarkupContainer("facetHeaderPanel"));
    4951        }
    50         final boolean showMore = facetField.getValueCount() > MAX_NR_OF_FACET_VALUES + 1;
     52        final boolean showMore = facetField.getValueCount() > maxNrOfFacetValues + 1;
    5153        List<Count> values = getFacetListForBox(facetField, showMore);
    5254        ListView<Count> facetList = new ListView<Count>("facetList", values) {
     
    7880        List<Count> values = new ArrayList<Count>();
    7981        if (showMore) {
    80             if (facetField.getValueCount() == MAX_NR_OF_FACET_VALUES || facetField.getValueCount() == MAX_NR_OF_FACET_VALUES + 1) { //Show all values, the "more" link can be used as the extra facet
     82            if (facetField.getValueCount() == maxNrOfFacetValues || facetField.getValueCount() == maxNrOfFacetValues + 1) { //Show all values, the "more" link can be used as the extra facet
    8183                values = allValues;
    8284            } else {// make a sublist
    8385                //IGNORABLE_VALUES (like "unknown") are move to the back of the list and should only be shown when you click "more...", unless the list is too small then whe can just show them.
    8486                List<Count> ignorables = new ArrayList<Count>();
    85                 for (int i = 0; values.size() < MAX_NR_OF_FACET_VALUES && i < allValues.size(); i++) {
     87                for (int i = 0; values.size() < maxNrOfFacetValues && i < allValues.size(); i++) {
    8688                    Count count = allValues.get(i);
    8789                    if (!IGNORABLE_VALUES.contains(count.getName().toLowerCase())) {
     
    9193                    }
    9294                }
    93                 int stillToAdd = MAX_NR_OF_FACET_VALUES - values.size();
     95                int stillToAdd = maxNrOfFacetValues - values.size();
    9496                for (int i = 0; i < stillToAdd && i < ignorables.size(); i++) {
    9597                    values.add(ignorables.get(i));
     
    113115    }
    114116
     117    void setMaxNrOfFacetValues(int maxNrOfFacetValues) {
     118        this.maxNrOfFacetValues = maxNrOfFacetValues;
     119    }
     120
    115121}
  • vlo/trunk/vlo_webapp/src/test/java/eu/clarin/cmdi/vlo/pages/FacetBoxPanelTest.java

    r1048 r1093  
    2323    public void testCalculateFacetBoxPanel() throws Exception {
    2424        FacetBoxPanel panel = new FacetBoxPanel("test", null);
     25        panel.setMaxNrOfFacetValues(5);
    2526        FacetField facetField = new FacetField("test");
    2627        facetField.add("name5", 5);
Note: See TracChangeset for help on using the changeset viewer.