feature_22518
#5
feature_22518
into master
2 years ago
@ -1,4 +1,4 @@
|
||||
eclipse.preferences.version=1
|
||||
lastWarOutDir=/home/francescomangiacrapa/git/geoportal-data-viewer-app/target/geoportal-data-viewer-app-2.1.0-SNAPSHOT
|
||||
lastWarOutDir=/home/francescomangiacrapa/git/geoportal-data-viewer-app/target/geoportal-data-viewer-app-2.2.0-SNAPSHOT
|
||||
warSrcDir=src/main/webapp
|
||||
warSrcDirIsOutput=false
|
||||
|
@ -1,41 +1,54 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
|
||||
|
||||
|
||||
|
||||
|
||||
<wb-module deploy-name="geoportal-data-viewer-app-2.1.0-SNAPSHOT">
|
||||
|
||||
|
||||
<wb-module deploy-name="geoportal-data-viewer-app-2.2.0-SNAPSHOT">
|
||||
|
||||
|
||||
|
||||
|
||||
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
||||
|
||||
<dependent-module archiveName="geoportal-data-common-1.3.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/geoportal-data-common/geoportal-data-common">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
|
||||
|
||||
|
||||
|
||||
<property name="java-output-path" value="/geoportal-data-viewer-app/target/geoportal-data-viewer-app-0.0.1-SNAPSHOT/WEB-INF/classes"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<property name="context-root" value="geoportal-data-viewer-app"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</wb-module>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</project-modules>
|
||||
|
@ -0,0 +1,83 @@
|
||||
package org.gcube.portlets.user.geoportaldataviewer.client.events;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.RECORD_TYPE;
|
||||
|
||||
import com.google.gwt.event.shared.GwtEvent;
|
||||
|
||||
/**
|
||||
* The Class GetListOfRecordsEvent.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Dec 7, 2021
|
||||
*/
|
||||
public class GetListOfRecordsEvent extends GwtEvent<GetListOfRecordsEventHandler> {
|
||||
|
||||
/** The type. */
|
||||
public static Type<GetListOfRecordsEventHandler> TYPE = new Type<GetListOfRecordsEventHandler>();
|
||||
private RECORD_TYPE recordType;
|
||||
private SearchingFilter sortFilter;
|
||||
|
||||
/**
|
||||
* Instantiates a new cancel upload event.
|
||||
*
|
||||
* @param recordType the record type
|
||||
* @param sortFilter the sort filter
|
||||
*/
|
||||
public GetListOfRecordsEvent(RECORD_TYPE recordType, SearchingFilter sortFilter) {
|
||||
this.recordType = recordType;
|
||||
this.sortFilter = sortFilter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the associated type.
|
||||
*
|
||||
* @return the associated type
|
||||
*/
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.google.gwt.event.shared.GwtEvent#getAssociatedType()
|
||||
*/
|
||||
@Override
|
||||
public Type<GetListOfRecordsEventHandler> getAssociatedType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch.
|
||||
*
|
||||
* @param handler the handler
|
||||
*/
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared.
|
||||
* EventHandler)
|
||||
*/
|
||||
@Override
|
||||
protected void dispatch(GetListOfRecordsEventHandler handler) {
|
||||
handler.onGetList(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the record type.
|
||||
*
|
||||
* @return the record type
|
||||
*/
|
||||
public RECORD_TYPE getRecordType() {
|
||||
return recordType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the sort filter.
|
||||
*
|
||||
* @return the sort filter
|
||||
*/
|
||||
public SearchingFilter getSortFilter() {
|
||||
return sortFilter;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package org.gcube.portlets.user.geoportaldataviewer.client.events;
|
||||
|
||||
import com.google.gwt.event.shared.EventHandler;
|
||||
|
||||
|
||||
/**
|
||||
* The Interface GetListOfRecordsEventHandler.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Aug 4, 2021
|
||||
*/
|
||||
public interface GetListOfRecordsEventHandler extends EventHandler {
|
||||
|
||||
|
||||
/**
|
||||
* On get list.
|
||||
*
|
||||
* @param getListOfRecordsEvent the get list of records event
|
||||
*/
|
||||
void onGetList(GetListOfRecordsEvent getListOfRecordsEvent);
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
package org.gcube.portlets.user.geoportaldataviewer.client.events;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
|
||||
|
||||
import com.google.gwt.event.shared.GwtEvent;
|
||||
|
||||
/**
|
||||
* The Class SearchPerformedEvent.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Dec 14, 2021
|
||||
*/
|
||||
public class SearchPerformedEvent extends GwtEvent<SearchPerformedEventHandler> {
|
||||
public static Type<SearchPerformedEventHandler> TYPE = new Type<SearchPerformedEventHandler>();
|
||||
private List<ConcessioneDV> data;
|
||||
private boolean searchReset;
|
||||
|
||||
/**
|
||||
* Instantiates a new search performed event.
|
||||
*
|
||||
* @param data the data
|
||||
* @param searchReset the search reset
|
||||
*/
|
||||
public SearchPerformedEvent(List<ConcessioneDV> data, boolean searchReset) {
|
||||
this.data = data;
|
||||
this.searchReset = searchReset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the associated type.
|
||||
*
|
||||
* @return the associated type
|
||||
*/
|
||||
@Override
|
||||
public Type<SearchPerformedEventHandler> getAssociatedType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch.
|
||||
*
|
||||
* @param handler the handler
|
||||
*/
|
||||
@Override
|
||||
protected void dispatch(SearchPerformedEventHandler handler) {
|
||||
handler.onSearchDone(this);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the data.
|
||||
*
|
||||
* @return the data
|
||||
*/
|
||||
public List<ConcessioneDV> getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is search reset.
|
||||
*
|
||||
* @return true, if is search reset
|
||||
*/
|
||||
public boolean isSearchReset() {
|
||||
return searchReset;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package org.gcube.portlets.user.geoportaldataviewer.client.events;
|
||||
|
||||
import com.google.gwt.event.shared.EventHandler;
|
||||
|
||||
/**
|
||||
* The Interface SearchPerformedEventHandler.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Dec 14, 2021
|
||||
*/
|
||||
public interface SearchPerformedEventHandler extends EventHandler {
|
||||
|
||||
/**
|
||||
* On search done.
|
||||
*
|
||||
* @param searchPerformedEvent the search performed event
|
||||
*/
|
||||
void onSearchDone(SearchPerformedEvent searchPerformedEvent);
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package org.gcube.portlets.user.geoportaldataviewer.client.events;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.products.model.RecordDV;
|
||||
|
||||
import com.google.gwt.event.shared.GwtEvent;
|
||||
|
||||
|
||||
/**
|
||||
* The Class ShowDetailsEvent.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Jul 30, 2021
|
||||
*/
|
||||
public class ShowPopupOnCentroiEvent extends GwtEvent<ShowPopupOnCentroiEventHandler> {
|
||||
public static Type<ShowPopupOnCentroiEventHandler> TYPE = new Type<ShowPopupOnCentroiEventHandler>();
|
||||
private RecordDV record;
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new show details event.
|
||||
*
|
||||
* @param geonaItemType the geona item type
|
||||
* @param geonaMongoID the geona mongo ID
|
||||
* @param itemName the item name
|
||||
* @param featureRow the feature row
|
||||
*/
|
||||
public ShowPopupOnCentroiEvent(RecordDV record) {
|
||||
this.record = record;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the associated type.
|
||||
*
|
||||
* @return the associated type
|
||||
*/
|
||||
@Override
|
||||
public Type<ShowPopupOnCentroiEventHandler> getAssociatedType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatch.
|
||||
*
|
||||
* @param handler the handler
|
||||
*/
|
||||
@Override
|
||||
protected void dispatch(ShowPopupOnCentroiEventHandler handler) {
|
||||
handler.onShowPopup(this);
|
||||
|
||||
}
|
||||
|
||||
public RecordDV getRecord() {
|
||||
return record;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package org.gcube.portlets.user.geoportaldataviewer.client.events;
|
||||
|
||||
import com.google.gwt.event.shared.EventHandler;
|
||||
|
||||
|
||||
/**
|
||||
* The Interface ShowPopupOnCentroiEventHandler.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Dec 10, 2021
|
||||
*/
|
||||
public interface ShowPopupOnCentroiEventHandler extends EventHandler {
|
||||
|
||||
/**
|
||||
* On show popup.
|
||||
*
|
||||
* @param showPopupOnCentroiEvent the show popup on centroi event
|
||||
*/
|
||||
void onShowPopup(ShowPopupOnCentroiEvent showPopupOnCentroiEvent);
|
||||
}
|
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 650 B |
Before Width: | Height: | Size: 465 B After Width: | Height: | Size: 810 B |
After Width: | Height: | Size: 465 B |
Before Width: | Height: | Size: 500 B After Width: | Height: | Size: 693 B |
After Width: | Height: | Size: 500 B |
After Width: | Height: | Size: 744 B |
Before Width: | Height: | Size: 683 B After Width: | Height: | Size: 599 B |
@ -0,0 +1,498 @@
|
||||
package org.gcube.portlets.user.geoportaldataviewer.client.ui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
|
||||
import org.gcube.application.geoportalcommon.shared.ItemField;
|
||||
import org.gcube.application.geoportalcommon.shared.ResultSetPaginatedData;
|
||||
import org.gcube.application.geoportalcommon.shared.SearchingFilter;
|
||||
import org.gcube.application.geoportalcommon.shared.SearchingFilter.LOGICAL_OP;
|
||||
import org.gcube.application.geoportalcommon.shared.SearchingFilter.ORDER;
|
||||
import org.gcube.application.geoportalcommon.shared.WhereClause;
|
||||
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerServiceAsync;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.events.SearchPerformedEvent;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowDetailsEvent;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowPopupOnCentroiEvent;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.util.LoaderIcon;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.util.StringUtil;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.Alert;
|
||||
import com.github.gwtbootstrap.client.ui.Button;
|
||||
import com.github.gwtbootstrap.client.ui.DropdownButton;
|
||||
import com.github.gwtbootstrap.client.ui.ListBox;
|
||||
import com.github.gwtbootstrap.client.ui.NavLink;
|
||||
import com.github.gwtbootstrap.client.ui.TextBox;
|
||||
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
||||
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
|
||||
import com.github.gwtbootstrap.client.ui.constants.IconType;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.event.dom.client.ChangeEvent;
|
||||
import com.google.gwt.event.dom.client.ChangeHandler;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
import com.google.gwt.event.dom.client.KeyPressEvent;
|
||||
import com.google.gwt.event.dom.client.KeyPressHandler;
|
||||
import com.google.gwt.event.shared.HandlerManager;
|
||||
import com.google.gwt.uibinder.client.UiBinder;
|
||||
import com.google.gwt.uibinder.client.UiField;
|
||||
import com.google.gwt.user.client.Window;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.Composite;
|
||||
import com.google.gwt.user.client.ui.FlexTable;
|
||||
import com.google.gwt.user.client.ui.HTML;
|
||||
import com.google.gwt.user.client.ui.HTMLPanel;
|
||||
import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
|
||||
|
||||
/**
|
||||
* The Class SearchFacilityUI.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Dec 14, 2021
|
||||
*/
|
||||
public class SearchFacilityUI extends Composite {
|
||||
|
||||
private static SearchFacilityPanelUiBinder uiBinder = GWT.create(SearchFacilityPanelUiBinder.class);
|
||||
|
||||
protected static final int MIN_LENGHT_SERCHING_STRING = 3;
|
||||
|
||||
@UiField
|
||||
ListBox listBoxSortBy;
|
||||
|
||||
@UiField
|
||||
ListBox listBoxSearchFor;
|
||||
|
||||
@UiField
|
||||
TextBox searchField;
|
||||
|
||||
@UiField
|
||||
NavLink sortByToogle;
|
||||
|
||||
@UiField
|
||||
Button resetSearch;
|
||||
|
||||
@UiField
|
||||
HTMLPanel panelResults;
|
||||
|
||||
@UiField
|
||||
HorizontalPanel toogleSortBy;
|
||||
|
||||
private List<ItemField> searchForFields;
|
||||
|
||||
private List<ItemField> sortByFields;
|
||||
|
||||
private SearchingFilter currentSortFilter;
|
||||
|
||||
private HandlerManager appManagerBus;
|
||||
|
||||
private static final String LABEL_FILTER_SEPARATOR = " - ";
|
||||
|
||||
private ResultSetPaginatedData latestResult;
|
||||
|
||||
private DropdownButton searchFacilityButton;
|
||||
|
||||
/**
|
||||
* The Interface SearchFacilityPanelUiBinder.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Dec 14, 2021
|
||||
*/
|
||||
interface SearchFacilityPanelUiBinder extends UiBinder<Widget, SearchFacilityUI> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new search facility UI.
|
||||
*
|
||||
* @param appManagerBus the app manager bus
|
||||
* @param sortByFields the sort by fields
|
||||
* @param searchForFields the search for fields
|
||||
* @param initialSortFilter the initial sort filter
|
||||
*/
|
||||
public SearchFacilityUI(HandlerManager appManagerBus, List<ItemField> sortByFields, List<ItemField> searchForFields,
|
||||
SearchingFilter initialSortFilter) {
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
this.searchForFields = searchForFields;
|
||||
this.currentSortFilter = initialSortFilter;
|
||||
this.sortByFields = sortByFields;
|
||||
this.appManagerBus = appManagerBus;
|
||||
|
||||
resetSearch.setType(ButtonType.LINK);
|
||||
|
||||
listBoxSortBy.setWidth("180px");
|
||||
listBoxSearchFor.setWidth("140px");
|
||||
|
||||
bindEvents();
|
||||
}
|
||||
|
||||
/**
|
||||
* To label filter.
|
||||
*
|
||||
* @param itemField the item field
|
||||
* @param direction the direction
|
||||
* @return the string
|
||||
*/
|
||||
private String toLabelFilter(ItemField itemField, ORDER direction) {
|
||||
String labelFilter = itemField.getDisplayName() + LABEL_FILTER_SEPARATOR + direction.name();
|
||||
return labelFilter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bind events.
|
||||
*/
|
||||
private void bindEvents() {
|
||||
|
||||
for (ItemField record_FIELD : sortByFields) {
|
||||
if(record_FIELD.isSortable()) {
|
||||
String labelASC = toLabelFilter(record_FIELD, ORDER.ASC);
|
||||
String labelDESC = toLabelFilter(record_FIELD, ORDER.DESC);
|
||||
listBoxSortBy.addItem(labelASC);
|
||||
listBoxSortBy.addItem(labelDESC);
|
||||
}
|
||||
}
|
||||
|
||||
listBoxSortBy.addChangeHandler(new ChangeHandler() {
|
||||
|
||||
@Override
|
||||
public void onChange(ChangeEvent event) {
|
||||
if(latestResult!=null && latestResult.getData().size()>0) {
|
||||
doSearchEvent();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
for (ItemField record_FIELD : searchForFields) {
|
||||
GWT.log("search for: "+record_FIELD);
|
||||
if(record_FIELD.isSearchable()) {
|
||||
listBoxSearchFor.addItem(record_FIELD.getDisplayName());
|
||||
}
|
||||
}
|
||||
|
||||
listBoxSearchFor.addChangeHandler(new ChangeHandler() {
|
||||
|
||||
@Override
|
||||
public void onChange(ChangeEvent event) {
|
||||
if (searchField.getText().length() >= MIN_LENGHT_SERCHING_STRING) {
|
||||
doSearchEvent();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
sortByToogle.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
if (toogleSortBy.isVisible())
|
||||
toogleSortBy.setVisible(false);
|
||||
else
|
||||
toogleSortBy.setVisible(true);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
searchField.addKeyPressHandler(new KeyPressHandler() {
|
||||
|
||||
@Override
|
||||
public void onKeyPress(KeyPressEvent event) {
|
||||
if (com.google.gwt.event.dom.client.KeyCodes.KEY_ENTER == event.getCharCode()) {
|
||||
GWT.log(searchField.getText());
|
||||
doSearchEvent();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
resetSearch.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
searchField.setText("");
|
||||
resetSearch.setVisible(false);
|
||||
panelResults.clear();
|
||||
latestResult = null;
|
||||
appManagerBus.fireEvent(new SearchPerformedEvent(null,true));
|
||||
setSearchEnabled(false);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void setSearchEnabled(boolean bool) {
|
||||
if(bool) {
|
||||
searchFacilityButton.getElement().addClassName("highlight-button");
|
||||
}
|
||||
else {
|
||||
searchFacilityButton.getElement().removeClassName("highlight-button");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Search concessioni.
|
||||
*/
|
||||
private void searchConcessioni() {
|
||||
|
||||
SearchingFilter filter = getCurrentSortFilter();
|
||||
panelResults.clear();
|
||||
panelResults.add(new HTML("<hr>"));
|
||||
panelResults.add(new LoaderIcon("Searching..."));
|
||||
GeoportalDataViewerServiceAsync.Util.getInstance().getListConcessioni(0, 30, filter, false,
|
||||
new AsyncCallback<ResultSetPaginatedData>() {
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
// showLoading(false);
|
||||
// Window.alert(caught.getMessage());
|
||||
panelResults.clear();
|
||||
panelResults.add(new HTML("<hr>"));
|
||||
Alert alert = new Alert("Error on searching. Please, refresh or change the search");
|
||||
alert.setType(AlertType.ERROR);
|
||||
alert.setClose(false);
|
||||
panelResults.add(alert);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(ResultSetPaginatedData result) {
|
||||
|
||||
appManagerBus.fireEvent(new SearchPerformedEvent(result.getData(),false));
|
||||
setSearchEnabled(true);
|
||||
latestResult = result;
|
||||
|
||||
panelResults.clear();
|
||||
panelResults.add(new HTML("<hr>"));
|
||||
|
||||
if (result.getData().size() == 0) {
|
||||
panelResults.add(new HTML("No result found"));
|
||||
return;
|
||||
}
|
||||
|
||||
FlexTable ft = new FlexTable();
|
||||
ft.getElement().setClassName("table-results");
|
||||
int i = 1;
|
||||
ft.setWidget(0, i, new HTML("Nome Progetto"));
|
||||
|
||||
String selValue = listBoxSearchFor.getSelectedValue().toLowerCase();
|
||||
|
||||
boolean addIntroduction = false;
|
||||
if(selValue.startsWith("proj") || selValue.startsWith("any")) {
|
||||
ft.setWidget(0, ++i, new HTML("Introduzione"));
|
||||
addIntroduction = true;
|
||||
}
|
||||
|
||||
boolean addStaff = false;
|
||||
if(selValue.startsWith("director")) {
|
||||
ft.setWidget(0, ++i, new HTML("Autori"));
|
||||
ft.setWidget(0, ++i, new HTML("Responsabile"));
|
||||
ft.setWidget(0, ++i, new HTML("Editore"));
|
||||
ft.setWidget(0, ++i, new HTML("Titolari"));
|
||||
ft.setWidget(0, ++i, new HTML("Contributore"));
|
||||
addStaff = true;
|
||||
}
|
||||
boolean addParole = false;
|
||||
if(selValue.startsWith("keyword")) {
|
||||
ft.setWidget(0, ++i, new HTML("Parole Libere"));
|
||||
ft.setWidget(0, ++i, new HTML("Parole Cronologia"));
|
||||
addParole = true;
|
||||
}
|
||||
|
||||
i = 1;
|
||||
for (ConcessioneDV concessione : result.getData()) {
|
||||
int j = -1;
|
||||
|
||||
NavLink locateOnMap = new NavLink("Show");
|
||||
locateOnMap.setTitle("Locate on the Map and show details");
|
||||
locateOnMap.setIcon(IconType.MAP_MARKER);
|
||||
|
||||
locateOnMap.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
GeoNaItemRef gir = new GeoNaItemRef(concessione.getItemId(), GeoportalDataViewerConstants.RECORD_TYPE.CONCESSIONE.toString());
|
||||
appManagerBus.fireEvent(new ShowDetailsEvent(gir, null, null));
|
||||
appManagerBus.fireEvent(new ShowPopupOnCentroiEvent(concessione));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
ft.setWidget(i, ++j, locateOnMap);
|
||||
|
||||
|
||||
ft.setWidget(i, ++j, new HTML(concessione.getNome()));
|
||||
if(addIntroduction)
|
||||
ft.setWidget(i, ++j, new HTML(StringUtil.ellipsize(concessione.getIntroduzione(), 200)));
|
||||
|
||||
if(addStaff) {
|
||||
ft.setWidget(i, ++j, new HTML(toDisplayList(concessione.getAuthors())));
|
||||
ft.setWidget(i, ++j, new HTML(toDisplayList(Arrays.asList(concessione.getResponsabile()))));
|
||||
ft.setWidget(i, ++j, new HTML(toDisplayList(Arrays.asList(concessione.getEditore()))));
|
||||
ft.setWidget(i, ++j, new HTML(toDisplayList(concessione.getTitolari())));
|
||||
ft.setWidget(i, ++j, new HTML(toDisplayList(Arrays.asList(concessione.getContributore()))));
|
||||
}
|
||||
|
||||
if(addParole) {
|
||||
ft.setWidget(i, ++j, new HTML(toDisplayList(concessione.getParoleChiaveLibere())));
|
||||
ft.setWidget(i, ++j, new HTML(toDisplayList(concessione.getParoleChiaveICCD())));
|
||||
}
|
||||
|
||||
|
||||
// List<UploadedImageDV> listImg = concessione.getImmaginiRappresentative();
|
||||
// GWT.log(listImg.toString());
|
||||
// boolean imagePreviewFound = false;
|
||||
// if (listImg != null && listImg.size() > 0) {
|
||||
//
|
||||
// UploadedImageDV uImg = listImg.get(0);
|
||||
//
|
||||
// if (uImg != null && uImg.getListWsContent() != null
|
||||
// && uImg.getListWsContent().size() > 0) {
|
||||
// WorkspaceContentDV wsc = uImg.getListWsContent().get(0);
|
||||
// String image = "<img style=\"width:50px;height:50px;\" src='" + wsc.getLink()
|
||||
// + "' alt='" + wsc.getName() + "'>";
|
||||
// ft.setWidget(i, 2, new HTML(image));
|
||||
// imagePreviewFound = true;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (!imagePreviewFound) {
|
||||
// ft.setWidget(i, 2, new Image(GNAImages.ICONS.italyIcon()));
|
||||
// }
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
panelResults.add(ft);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* To display authors.
|
||||
*
|
||||
* @param listValues the list values
|
||||
* @return the string
|
||||
*/
|
||||
private String toDisplayList(List<String> listValues) {
|
||||
String toDisplay = "";
|
||||
if (listValues == null)
|
||||
return toDisplay;
|
||||
|
||||
for (String author : listValues) {
|
||||
toDisplay += author + "; ";
|
||||
}
|
||||
return toDisplay;
|
||||
}
|
||||
|
||||
/**
|
||||
* Do search event.
|
||||
*/
|
||||
private void doSearchEvent() {
|
||||
String searchText = searchField.getText();
|
||||
if (searchText.length() < MIN_LENGHT_SERCHING_STRING) {
|
||||
Window.alert("Please enter at least " + MIN_LENGHT_SERCHING_STRING + " characters");
|
||||
return;
|
||||
}
|
||||
|
||||
resetSearch.setVisible(true);
|
||||
// appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE,
|
||||
// getCurrentSortFilter()));
|
||||
|
||||
searchConcessioni();
|
||||
}
|
||||
|
||||
/**
|
||||
* To sort filter.
|
||||
*
|
||||
* @param labelFilter the label filter
|
||||
* @return the searching filter
|
||||
*/
|
||||
public SearchingFilter toSortFilter(String labelFilter) {
|
||||
GWT.log("toSortFilter for label " + labelFilter);
|
||||
String[] array = labelFilter.split(LABEL_FILTER_SEPARATOR);
|
||||
|
||||
SearchingFilter sortFilter = null;
|
||||
try {
|
||||
ItemField recordField = null;
|
||||
for (ItemField value : sortByFields) {
|
||||
if (array[0].equalsIgnoreCase(value.getDisplayName())) {
|
||||
recordField = value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ORDER orderField = ORDER.valueOf(array[1]);
|
||||
sortFilter = new SearchingFilter(Arrays.asList(recordField), orderField);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
GWT.log("toSortFilter Got " + sortFilter);
|
||||
return sortFilter;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Built searching filter.
|
||||
*
|
||||
* @return the searching filter
|
||||
*/
|
||||
private SearchingFilter builtSearchingFilter() {
|
||||
SearchingFilter searchingFilter = toSortFilter(listBoxSortBy.getSelectedValue());
|
||||
String searchText = searchField.getText();
|
||||
if (searchText != null && !searchText.isEmpty()) {
|
||||
Map<String, Object> searchInto = new HashMap<String, Object>();
|
||||
|
||||
List<String> listOfSeachingFields = new ArrayList<String>();
|
||||
|
||||
for (ItemField recordField : searchForFields) {
|
||||
if (recordField.getDisplayName().equals(listBoxSearchFor.getSelectedValue())) {
|
||||
listOfSeachingFields = recordField.getJsonFields();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if(listOfSeachingFields.size()==0) {
|
||||
listOfSeachingFields.add("nome");
|
||||
}
|
||||
for (String fieldname : listOfSeachingFields) {
|
||||
searchInto.put(fieldname, searchText);
|
||||
}
|
||||
|
||||
WhereClause where = new WhereClause();
|
||||
where.setSearchInto(searchInto);
|
||||
where.setOperator(LOGICAL_OP.OR);
|
||||
|
||||
//THIS CLAUSE IS ADDED IN ORDER TO SEARCH ONLY PUBLISHED PRODUCT (WITH SUCCESS)
|
||||
Map<String, Object> searchInto2 = new HashMap<String, Object>();
|
||||
searchInto2.put("report.status", "PASSED");
|
||||
WhereClause where2 = new WhereClause(LOGICAL_OP.AND, searchInto2);
|
||||
|
||||
searchingFilter.setConditions(Arrays.asList(where, where2));
|
||||
}
|
||||
return searchingFilter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current sort filter.
|
||||
*
|
||||
* @return the current sort filter
|
||||
*/
|
||||
public SearchingFilter getCurrentSortFilter() {
|
||||
currentSortFilter = builtSearchingFilter();
|
||||
GWT.log("currentSortFilter: " + currentSortFilter);
|
||||
return currentSortFilter;
|
||||
}
|
||||
|
||||
public void setSearchButton(DropdownButton searchFacilityButton) {
|
||||
this.searchFacilityButton = searchFacilityButton;
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
|
||||
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
|
||||
xmlns:g="urn:import:com.google.gwt.user.client.ui"
|
||||
xmlns:b="urn:import:com.github.gwtbootstrap.client.ui"
|
||||
xmlns:c="urn:import:org.gcube.portlets.user.geoportaldataviewer.client.ui">
|
||||
<ui:style>
|
||||
.important {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.container-panel {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.add-margin-right {
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.add-margin-right-23 {
|
||||
margin-right: 23px;
|
||||
}
|
||||
|
||||
.margin-top-5 {
|
||||
margin-top: 5px;
|
||||
}
|
||||
.font-size-12 {
|
||||
font-size: 12px;
|
||||
}
|
||||
</ui:style>
|
||||
<g:HTMLPanel addStyleNames="{style.container-panel}">
|
||||
<g:FlowPanel>
|
||||
<g:FlowPanel>
|
||||
<g:FlowPanel>
|
||||
<g:HorizontalPanel>
|
||||
<g:Label addStyleNames="{style.add-margin-right}">Search for: </g:Label>
|
||||
<b:ListBox title="Search for"
|
||||
ui:field="listBoxSearchFor"
|
||||
addStyleNames="{style.add-margin-right}">
|
||||
</b:ListBox>
|
||||
<b:TextBox ui:field="searchField"
|
||||
addStyleNames="search-textbox" placeholder="type a text..."></b:TextBox>
|
||||
<b:Button icon="REMOVE_CIRCLE" ui:field="resetSearch"
|
||||
title="Reset the search" visible="false">Reset</b:Button>
|
||||
</g:HorizontalPanel>
|
||||
</g:FlowPanel>
|
||||
<g:FlowPanel>
|
||||
<b:NavLink ui:field="sortByToogle" addStyleNames="{style.font-size-12}">Sort Results</b:NavLink>
|
||||
<g:HorizontalPanel ui:field="toogleSortBy"
|
||||
addStyleNames="{style.margin-top-5}" visible="false">
|
||||
<g:Label addStyleNames="{style.add-margin-right-23}">Sort by: </g:Label>
|
||||
<b:ListBox ui:field="listBoxSortBy">
|
||||
</b:ListBox>
|
||||
</g:HorizontalPanel>
|
||||
</g:FlowPanel>
|
||||
</g:FlowPanel>
|
||||
<g:HTMLPanel ui:field="panelResults">
|
||||
</g:HTMLPanel>
|
||||
</g:FlowPanel>
|
||||
</g:HTMLPanel>
|
||||
</ui:UiBinder>
|