Changeset 4924
- Timestamp:
- 04/08/14 15:34:30 (10 years ago)
- Location:
- vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/pages/FacetedSearchPage.java
r4913 r4924 1 1 package eu.clarin.cmdi.vlo.wicket.pages; 2 2 3 import eu.clarin.cmdi.vlo.wicket.panels.SingleFacetPanel; 3 4 import eu.clarin.cmdi.vlo.config.VloConfig; 4 import eu.clarin.cmdi.vlo.pojo.ExpansionState;5 5 import eu.clarin.cmdi.vlo.wicket.panels.search.FacetsPanel; 6 6 import eu.clarin.cmdi.vlo.pojo.QueryFacetsSelection; … … 10 10 import eu.clarin.cmdi.vlo.wicket.components.SearchForm; 11 11 import eu.clarin.cmdi.vlo.wicket.panels.search.SearchResultsPanel; 12 import eu.clarin.cmdi.vlo.wicket.model.FacetFieldModel;13 12 import eu.clarin.cmdi.vlo.wicket.model.FacetFieldsModel; 14 import eu.clarin.cmdi.vlo.wicket.model.FacetSelectionModel;15 13 import eu.clarin.cmdi.vlo.wicket.panels.BreadCrumbPanel; 16 14 import eu.clarin.cmdi.vlo.wicket.panels.search.FacetValuesPanel; … … 34 32 35 33 private static final long serialVersionUID = 1L; 36 34 37 35 @SpringBean 38 36 private FacetFieldsService facetFieldsService; … … 105 103 106 104 private Panel createCollectionsPanel(final String id) { 107 final IModel<QueryFacetsSelection> queryModel = getModel(); 108 final FacetFieldModel collectionFacetFieldModel = new FacetFieldModel(facetFieldsService, vloConfig.getCollectionFacet(), queryModel, FacetValuesPanel.MAX_NUMBER_OF_FACETS_TO_SHOW); 109 final FacetSelectionModel collectionSelectionModel = new FacetSelectionModel(collectionFacetFieldModel, queryModel); 110 final FacetPanel panel = new FacetPanel(id, collectionSelectionModel, new Model<ExpansionState>(ExpansionState.COLLAPSED)) { 105 final FacetPanel panel = new SingleFacetPanel(id, getModel(), vloConfig.getCollectionFacet(), facetFieldsService) { 111 106 112 107 @Override 113 108 protected void selectionChanged(AjaxRequestTarget target) { 114 109 updateSelection(target); 115 }116 117 @Override118 protected boolean isHideIfNoValues() {119 // collections facets should always be visible, even if no120 // values are present (due to no search results)121 return false;122 110 } 123 111 -
vlo/branches/vlo-3.0/vlo-web-app/src/main/java/eu/clarin/cmdi/vlo/wicket/panels/search/FacetPanel.java
r4872 r4924 29 29 import org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxFallbackLink; 30 30 import org.apache.wicket.markup.html.basic.Label; 31 import org.apache.wicket.markup.html.panel. Panel;31 import org.apache.wicket.markup.html.panel.GenericPanel; 32 32 import org.apache.wicket.model.AbstractReadOnlyModel; 33 33 import org.apache.wicket.model.IModel; … … 42 42 * @author twagoo 43 43 */ 44 public abstract class FacetPanel extends Panel { 45 46 private final IModel<FacetSelection> selectionModel; 44 public abstract class FacetPanel extends GenericPanel<FacetSelection> { 45 47 46 private final IModel<ExpansionState> expansionStateModel; 48 47 … … 53 52 super(id, selectionModel); 54 53 55 this.selectionModel = selectionModel;56 54 this.expansionStateModel = expansionState; 57 55 … … 89 87 90 88 // Facet name becomes title 91 titleLink.add(new Label("title", new SolrFieldNameModel(new PropertyModel( selectionModel, "facetField.name"))));89 titleLink.add(new Label("title", new SolrFieldNameModel(new PropertyModel(getModel(), "facetField.name")))); 92 90 return titleLink; 93 91 } … … 97 95 super.onConfigure(); 98 96 99 final boolean valuesSelected = ! selectionModel.getObject().getFacetValues().isEmpty();97 final boolean valuesSelected = !getModelObject().getFacetValues().isEmpty(); 100 98 facetValuesPanel.setVisible(!valuesSelected); 101 99 selectedFacetPanel.setVisible(valuesSelected); 102 100 103 101 // hide this entire panel is no values are selectable 104 setVisible(!isHideIfNoValues() || valuesSelected || selectionModel.getObject().getFacetField().getValueCount() > 0);102 setVisible(!isHideIfNoValues() || valuesSelected || getModelObject().getFacetField().getValueCount() > 0); 105 103 } 106 104 … … 116 114 private FacetValuesPanel createFacetValuesPanel(String id) { 117 115 return new FacetValuesPanel(id, 118 new PropertyModel<FacetField>( selectionModel, "facetField"),119 new PropertyModel<QueryFacetsSelection>( selectionModel, "selection")) {116 new PropertyModel<FacetField>(getModel(), "facetField"), 117 new PropertyModel<QueryFacetsSelection>(getModel(), "selection")) { 120 118 @Override 121 119 public void onValuesSelected(String facet, Collection<String> value, AjaxRequestTarget target) { 122 120 // A value has been selected on this facet's panel, update the model! 123 selectionModel.getObject().getSelection().selectValues(facet, value);121 FacetPanel.this.getModelObject().getSelection().selectValues(facet, value); 124 122 if (target != null) { 125 123 // reload entire page for now … … 131 129 132 130 private SelectedFacetPanel createSelectedFacetPanel(String id) { 133 return new SelectedFacetPanel(id, selectionModel) {131 return new SelectedFacetPanel(id, getModel()) { 134 132 @Override 135 133 public void onValuesUnselected(String facet, Collection<String> valuesRemoved, AjaxRequestTarget target) { 136 final QueryFacetsSelection selection = selectionModel.getObject().getSelection();134 final QueryFacetsSelection selection = getModelObject().getSelection(); 137 135 138 136 // Values have been removed, calculate remainder
Note: See TracChangeset
for help on using the changeset viewer.