Changeset 6228
- Timestamp:
- 05/19/15 12:10:09 (9 years ago)
- Location:
- vlo/trunk/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
vlo/trunk/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/pages/FacetedSearchPage.java
r6210 r6228 47 47 private Component collectionsPanel; 48 48 private Component navigation; 49 private Component searchForm; 49 50 50 51 public FacetedSearchPage(IModel<QueryFacetsSelection> queryModel) { … … 65 66 navigation = createNavigation("navigation"); 66 67 add(navigation); 67 68 add(createSearchForm("search")); 68 69 searchForm = createSearchForm("search"); 70 add(searchForm); 69 71 70 72 collectionsPanel = createCollectionsPanel("collections"); … … 118 120 119 121 private SearchForm createSearchForm(String id) { 120 final SearchForm searchForm = new SearchForm(id, getModel()) {122 final SearchForm form = new SearchForm(id, getModel()) { 121 123 122 124 @Override … … 128 130 129 131 }; 130 return searchForm; 132 form.setOutputMarkupId(true); 133 return form; 131 134 } 132 135 … … 172 175 if (target != null) { // null if JavaScript disabled 173 176 target.add(navigation); 177 target.add(searchForm); 174 178 target.add(searchResultsPanel); 175 179 target.add(facetsPanel); -
vlo/trunk/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/panels/BreadCrumbPanel.html
r5224 r6228 30 30 <wicket:container wicket:id="query"> 31 31 > <a wicket:id="leavequery">Search: "<span wicket:id="content"></span>"</a> 32 <a wicket:id="removal" title="Remove query" class="breadcrumbunselect"><span>[Remove]</span></a> 32 33 </wicket:container> 33 34 <wicket:container wicket:id="facets"> 34 35 > <a wicket:id="leaveselection">Selections</a>: 35 36 <wicket:container wicket:id="facet"> 36 <span class="breadcrumbfacet"><wicket:container wicket:id="value">[VALUE]</wicket:container> <a wicket:id="removal" title="Remove selection" class="breadcrumbunselect"><span>[Remove]</span></a></span> 37 <span class="breadcrumbfacet"><wicket:container wicket:id="value">[VALUE]</wicket:container> 38 <a wicket:id="removal" title="Remove selection" class="breadcrumbunselect"><span>[Remove]</span></a></span> 37 39 </wicket:container> 38 40 </wicket:container> -
vlo/trunk/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/panels/BreadCrumbPanel.java
r6012 r6228 53 53 */ 54 54 public class BreadCrumbPanel extends GenericPanel<QueryFacetsSelection> { 55 55 56 56 @SpringBean(name = "queryParametersConverter") 57 57 private PageParametersConverter<QueryFacetsSelection> paramsConverter; 58 58 @SpringBean 59 59 private FieldValueConverterProvider fieldValueConverterProvider; 60 60 61 61 private final WebMarkupContainer query; 62 62 private final WebMarkupContainer facets; 63 63 64 64 public BreadCrumbPanel(String id, IModel<QueryFacetsSelection> model) { 65 65 super(id, model); … … 68 68 add(facets = createFacets(model, "facets")); 69 69 } 70 70 71 71 private WebMarkupContainer createQuery(final IModel<QueryFacetsSelection> selectionModel, String id) { 72 72 final WebMarkupContainer queryContainer = new WebMarkupContainer(id); 73 73 final Link link = new AjaxFallbackLink("leavequery") { 74 74 75 75 @Override 76 76 public void onClick(AjaxRequestTarget target) { … … 82 82 link.add(new Label("content", new PropertyModel(selectionModel, "query"))); 83 83 queryContainer.add(link); 84 85 queryContainer.add(new AjaxFallbackLink("removal") { 86 87 @Override 88 public void onClick(AjaxRequestTarget target) { 89 // get a copy of the current selection 90 final QueryFacetsSelection newSelection = selectionModel.getObject().getCopy(); 91 newSelection.setQuery(null); 92 onSelectionChanged(newSelection, target); 93 } 94 }); 84 95 return queryContainer; 85 96 } 86 97 87 98 private WebMarkupContainer createFacets(final IModel<QueryFacetsSelection> model, String id) { 88 99 final WebMarkupContainer facetsContainer = new WebMarkupContainer(id); 89 100 facetsContainer.add(new AjaxFallbackLink("leaveselection") { 90 101 91 102 @Override 92 103 public void onClick(AjaxRequestTarget target) { … … 98 109 final FacetSelectionProvider facetSelectionProvider = new FacetSelectionProvider(model); 99 110 facetsContainer.add(new DataView<Map.Entry<String, FacetSelection>>("facet", facetSelectionProvider) { 100 111 101 112 @Override 102 113 protected void populateItem(final Item<Map.Entry<String, FacetSelection>> item) { … … 104 115 // add a label for the selected facet value(s) 105 116 final Label valueLabel = new Label("value", new PropertyModel(selectionModel, "value")) { 106 117 107 118 @Override 108 119 public <C> IConverter<C> getConverter(Class<C> type) { … … 111 122 return (IConverter<C>) new SelectionConverter(facet, fieldValueConverterProvider.getConverter(facet)); 112 123 } 113 124 114 125 }; 115 126 // add facet name as title attribute so that it becomes available through a tooltip … … 120 131 // add a link for removal of the facet value selection 121 132 item.add(new AjaxFallbackLink("removal") { 122 133 123 134 @Override 124 135 public void onClick(AjaxRequestTarget target) { … … 133 144 } 134 145 }); 135 146 136 147 return facetsContainer; 137 148 } … … 148 159 setResponsePage(FacetedSearchPage.class, paramsConverter.toParameters(selection)); 149 160 } 150 161 151 162 @Override 152 163 protected void onConfigure() { 153 164 super.onConfigure(); 154 165 155 166 final String queryString = getModelObject().getQuery(); 156 167 final Map<String, FacetSelection> selection = getModelObject().getSelection(); 157 168 158 169 query.setVisible(queryString != null && !queryString.isEmpty()); 159 170 facets.setVisible(selection != null && !selection.isEmpty()); … … 165 176 */ 166 177 private class SelectionConverter implements IConverter<FacetSelection> { 167 178 168 179 private final String facet; 169 180 private final IConverter<String> valueConverter; 170 181 171 182 public SelectionConverter(String facet, IConverter<String> valueConverter) { 172 183 this.facet = facet; 173 184 this.valueConverter = valueConverter; 174 185 } 175 186 176 187 @Override 177 188 public FacetSelection convertToObject(String value, Locale locale) throws ConversionException { 178 189 throw new UnsupportedOperationException("Not supported yet."); 179 190 } 180 191 181 192 @Override 182 193 public String convertToString(FacetSelection selection, Locale locale) { … … 193 204 return facet; 194 205 } 195 196 } 197 206 207 } 208 198 209 private String getAnyValueString() { 199 210 if (FacetConstants.FIELD_SEARCH_SERVICE.equals(facet)) { … … 202 213 return "any " + facet; 203 214 } 204 215 205 216 public String getCollectionString(FacetSelection selection, String valueSeparator, Locale locale) { 206 217 final Collection<String> value = selection.getValues(); … … 219 230 } 220 231 } 221 232 222 233 private String getConvertedValue(String string, Locale locale) { 223 234 if (valueConverter != null) { … … 229 240 return string; 230 241 } 231 242 232 243 }; 233 244 }
Note: See TracChangeset
for help on using the changeset viewer.