Changeset 1093
- Timestamp:
- 01/25/11 16:35:35 (13 years ago)
- 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 29 29 private FacetHeaderPanel facetHeaderPanel; 30 30 private FacetModel facetModel; 31 private int maxNrOfFacetValues; 31 32 32 33 public FacetBoxPanel(String id, IModel<FacetField> model) { 33 34 super(id, model); 34 35 setOutputMarkupId(true); 36 setMaxNrOfFacetValues(MAX_NR_OF_FACET_VALUES); 35 37 } 36 38 37 39 @SuppressWarnings("serial") 38 40 public FacetBoxPanel create(final SearchPageQuery query) { … … 48 50 add(new WebMarkupContainer("facetHeaderPanel")); 49 51 } 50 final boolean showMore = facetField.getValueCount() > MAX_NR_OF_FACET_VALUES+ 1;52 final boolean showMore = facetField.getValueCount() > maxNrOfFacetValues + 1; 51 53 List<Count> values = getFacetListForBox(facetField, showMore); 52 54 ListView<Count> facetList = new ListView<Count>("facetList", values) { … … 78 80 List<Count> values = new ArrayList<Count>(); 79 81 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 facet82 if (facetField.getValueCount() == maxNrOfFacetValues || facetField.getValueCount() == maxNrOfFacetValues + 1) { //Show all values, the "more" link can be used as the extra facet 81 83 values = allValues; 82 84 } else {// make a sublist 83 85 //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. 84 86 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++) { 86 88 Count count = allValues.get(i); 87 89 if (!IGNORABLE_VALUES.contains(count.getName().toLowerCase())) { … … 91 93 } 92 94 } 93 int stillToAdd = MAX_NR_OF_FACET_VALUES- values.size();95 int stillToAdd = maxNrOfFacetValues - values.size(); 94 96 for (int i = 0; i < stillToAdd && i < ignorables.size(); i++) { 95 97 values.add(ignorables.get(i)); … … 113 115 } 114 116 117 void setMaxNrOfFacetValues(int maxNrOfFacetValues) { 118 this.maxNrOfFacetValues = maxNrOfFacetValues; 119 } 120 115 121 } -
vlo/trunk/vlo_webapp/src/test/java/eu/clarin/cmdi/vlo/pages/FacetBoxPanelTest.java
r1048 r1093 23 23 public void testCalculateFacetBoxPanel() throws Exception { 24 24 FacetBoxPanel panel = new FacetBoxPanel("test", null); 25 panel.setMaxNrOfFacetValues(5); 25 26 FacetField facetField = new FacetField("test"); 26 27 facetField.add("name5", 5);
Note: See TracChangeset
for help on using the changeset viewer.