first List of Records with pagination
This commit is contained in:
parent
5fbb0fa8a7
commit
b5ccba5551
|
@ -1,29 +1,39 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<wb-module deploy-name="geoportal-data-entry-app-1.3.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="/src/main/java"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -32,25 +42,33 @@
|
|||
<dependent-module archiveName="geoportal-data-common-1.1.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="context-root" value="geoportal-data-entry-app"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<property name="java-output-path" value="/geoportal-data-entry-app/target/geoportal-data-entry-app-1.0.0-SNAPSHOT/WEB-INF/classes"/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</wb-module>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|||
Moved to maven-portal-bom 3.6.3
|
||||
[#21856] Implementing new user feedback
|
||||
[#21890] Passed to mongoID
|
||||
[#20599] Get List of Records
|
||||
|
||||
|
||||
## [v1.2.0] - 2020-12-18
|
||||
|
|
|
@ -12,4 +12,10 @@ public class ConstantsGeoPortalDataEntryApp {
|
|||
|
||||
public static final String ERROR_ON_INIZIALITAION_STAGE_PLEASE_CONTACT_THE_SUPPORT = "Error on inizialization stage, please contact the support!";
|
||||
|
||||
|
||||
public enum RECORD_TYPE {
|
||||
CONCESSIONE
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -8,14 +8,19 @@ import java.util.List;
|
|||
import java.util.TreeMap;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.events.CreateNewProjectEvent;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.events.CreateNewProjectEventHandler;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.events.GetListOfRecordsEvent;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.events.GetListOfRecordsEventHandler;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.events.SaveGeonaDataFormsEvent;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.events.SaveGeonaDataFormsHandler;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ui.GeonaDataEntryMainForm;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ui.GeonaMainPanel;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ui.GeonaRecordsPaginatedView;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ui.card.GeoNaFormCardModel;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ui.form.GeonaDataEntryMainForm;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ui.report.ReportTemplateToHTML;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ui.table.ItemsTable.DISPLAY_FIELD;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.HTMLUtil;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.HTMLUtil.HTML_TAG;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.LoaderIcon;
|
||||
|
@ -57,7 +62,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
|||
/**
|
||||
* Create a remote service proxy to talk to the server-side Greeting service.
|
||||
*/
|
||||
private final GeoportalDataEntryServiceAsync greetingService = GWT.create(GeoportalDataEntryService.class);
|
||||
public static final GeoportalDataEntryServiceAsync greetingService = GWT.create(GeoportalDataEntryService.class);
|
||||
|
||||
private final HandlerManager appManagerBus = new HandlerManager(null);
|
||||
|
||||
|
@ -350,6 +355,21 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
|||
|
||||
}
|
||||
});
|
||||
|
||||
appManagerBus.addHandler(GetListOfRecordsEvent.TYPE, new GetListOfRecordsEventHandler() {
|
||||
|
||||
@Override
|
||||
public void onGetList(GetListOfRecordsEvent getListOfRecordsEvent) {
|
||||
|
||||
|
||||
Modal modal = new Modal(true);
|
||||
modal.setCloseVisible(true);
|
||||
GeonaRecordsPaginatedView grpw = new GeonaRecordsPaginatedView(appManagerBus,RECORD_TYPE.CONCESSIONE,null, DISPLAY_FIELD.NAME);
|
||||
modal.add(grpw.getCellPanel());
|
||||
modal.add(grpw.getPagerPanel());
|
||||
modal.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -6,19 +6,55 @@ import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
|
|||
import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.SearchedData;
|
||||
|
||||
import com.google.gwt.user.client.rpc.RemoteService;
|
||||
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
|
||||
|
||||
/**
|
||||
* The client side stub for the RPC service.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Aug 4, 2021
|
||||
*/
|
||||
@RemoteServiceRelativePath("geoportaldataentryservice")
|
||||
public interface GeoportalDataEntryService extends RemoteService {
|
||||
|
||||
/**
|
||||
* Save geona data forms.
|
||||
*
|
||||
* @param listGeonaFormObjects the list geona form objects
|
||||
* @return the commit report
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
CommitReport saveGeonaDataForms(List<GeoNaFormDataObject> listGeonaFormObjects) throws Exception;
|
||||
|
||||
/**
|
||||
* Gets the geona init config.
|
||||
*
|
||||
* @return the geona init config
|
||||
*/
|
||||
GeonaISConfig getGeonaInitConfig();
|
||||
|
||||
/**
|
||||
* Gets the links for.
|
||||
*
|
||||
* @param itemId the item id
|
||||
* @param recordType the record type
|
||||
* @return the links for
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
GeoNaItemRef getLinksFor(String itemId, String recordType) throws Exception;
|
||||
|
||||
|
||||
/**
|
||||
* Gets the list concessioni.
|
||||
*
|
||||
* @param start the start
|
||||
* @param offset the offset
|
||||
* @return the list concessioni
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
SearchedData getListConcessioni(Integer start, Integer offset) throws Exception;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
|
|||
import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.SearchedData;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
|
@ -43,4 +44,7 @@ public interface GeoportalDataEntryServiceAsync
|
|||
|
||||
|
||||
void getLinksFor(String itemId, String recordType, AsyncCallback<GeoNaItemRef> callback);
|
||||
|
||||
|
||||
void getListConcessioni(Integer start, Integer offset, AsyncCallback<SearchedData> callback);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
package org.gcube.portlets.user.geoportaldataentry.client.events;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gwt.event.shared.GwtEvent;
|
||||
|
||||
/**
|
||||
* The Class ClickItemEvent.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Jun 22, 2021
|
||||
* @param <T> the generic type
|
||||
*/
|
||||
public class ClickItemEvent<T> extends GwtEvent<ClickItemEventHandler> {
|
||||
public static Type<ClickItemEventHandler> TYPE = new Type<ClickItemEventHandler>();
|
||||
private List<T> selectItems;
|
||||
|
||||
/**
|
||||
* Instantiates a new click item event.
|
||||
*
|
||||
* @param selectItems the select items
|
||||
*/
|
||||
public ClickItemEvent(List<T> selectItems) {
|
||||
this.selectItems = selectItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the associated type.
|
||||
*
|
||||
* @return the associated type
|
||||
*/
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.google.gwt.event.shared.GwtEvent#getAssociatedType()
|
||||
*/
|
||||
@Override
|
||||
public Type<ClickItemEventHandler> 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(ClickItemEventHandler handler) {
|
||||
handler.onClick(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the select items.
|
||||
*
|
||||
* @return the select items
|
||||
*/
|
||||
public List<T> getSelectItems() {
|
||||
return selectItems;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package org.gcube.portlets.user.geoportaldataentry.client.events;
|
||||
|
||||
import com.google.gwt.event.shared.EventHandler;
|
||||
|
||||
|
||||
/**
|
||||
* The Interface ClickItemEventHandler.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Jul 6, 2015
|
||||
*/
|
||||
public interface ClickItemEventHandler extends EventHandler {
|
||||
|
||||
/**
|
||||
* On click.
|
||||
*
|
||||
* @param <T> the generic type
|
||||
* @param moreInfoShowEvent the more info show event
|
||||
*/
|
||||
<T> void onClick(ClickItemEvent<T> moreInfoShowEvent);
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package org.gcube.portlets.user.geoportaldataentry.client.events;
|
||||
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE;
|
||||
|
||||
import com.google.gwt.event.shared.GwtEvent;
|
||||
|
||||
/**
|
||||
* The Class CreateNewProjectEvent.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
*
|
||||
* Oct 13, 2020
|
||||
*/
|
||||
public class GetListOfRecordsEvent extends GwtEvent<GetListOfRecordsEventHandler> {
|
||||
|
||||
/** The type. */
|
||||
public static Type<GetListOfRecordsEventHandler> TYPE = new Type<GetListOfRecordsEventHandler>();
|
||||
private RECORD_TYPE recordType;
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new cancel upload event.
|
||||
*/
|
||||
public GetListOfRecordsEvent(ConstantsGeoPortalDataEntryApp.RECORD_TYPE recordType) {
|
||||
this.recordType = recordType;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
public RECORD_TYPE getRecordType() {
|
||||
return recordType;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package org.gcube.portlets.user.geoportaldataentry.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,68 @@
|
|||
package org.gcube.portlets.user.geoportaldataentry.client.events;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gwt.event.shared.GwtEvent;
|
||||
|
||||
/**
|
||||
* The Class ShowItemEvent.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Jun 22, 2021
|
||||
* @param <T> the generic type
|
||||
*/
|
||||
public class ShowItemEvent<T> extends GwtEvent<ShowItemEventHandler> {
|
||||
public static Type<ShowItemEventHandler> TYPE = new Type<ShowItemEventHandler>();
|
||||
private List<T> selectItems;
|
||||
|
||||
/**
|
||||
* Instantiates a new click item event.
|
||||
*
|
||||
* @param selectItems the select items
|
||||
*/
|
||||
public ShowItemEvent(List<T> selectItems) {
|
||||
this.selectItems = selectItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the associated type.
|
||||
*
|
||||
* @return the associated type
|
||||
*/
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see com.google.gwt.event.shared.GwtEvent#getAssociatedType()
|
||||
*/
|
||||
@Override
|
||||
public Type<ShowItemEventHandler> 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(ShowItemEventHandler handler) {
|
||||
handler.onShowItemClicked(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the select items.
|
||||
*
|
||||
* @return the select items
|
||||
*/
|
||||
public List<T> getSelectItems() {
|
||||
return selectItems;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package org.gcube.portlets.user.geoportaldataentry.client.events;
|
||||
|
||||
import com.google.gwt.event.shared.EventHandler;
|
||||
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Interface ShowItemEventHandler.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Jun 22, 2021
|
||||
*/
|
||||
public interface ShowItemEventHandler extends EventHandler {
|
||||
|
||||
/**
|
||||
* On show item clicked.
|
||||
*
|
||||
* @param <T> the generic type
|
||||
* @param showItemEvent the show item event
|
||||
*/
|
||||
<T> void onShowItemClicked(ShowItemEvent<T> showItemEvent);
|
||||
}
|
|
@ -0,0 +1,110 @@
|
|||
@def selectionBorderWidth 1px ; .cellTableWidget {
|
||||
|
||||
}
|
||||
|
||||
.cellTableFirstColumn {
|
||||
|
||||
}
|
||||
|
||||
.cellTableLastColumn {
|
||||
|
||||
}
|
||||
|
||||
.cellTableFooter {
|
||||
|
||||
}
|
||||
|
||||
.cellTableHeader {
|
||||
}
|
||||
|
||||
.cellTableCell {
|
||||
|
||||
}
|
||||
|
||||
.cellTableFirstColumnFooter {
|
||||
|
||||
}
|
||||
|
||||
.cellTableFirstColumnHeader {
|
||||
|
||||
}
|
||||
|
||||
.cellTableLastColumnFooter {
|
||||
|
||||
}
|
||||
|
||||
.cellTableLastColumnHeader {
|
||||
|
||||
}
|
||||
|
||||
.cellTableSortableHeader {
|
||||
|
||||
}
|
||||
|
||||
.cellTableSortableHeader:hover {
|
||||
|
||||
}
|
||||
|
||||
.cellTableSortedHeaderAscending {
|
||||
|
||||
}
|
||||
|
||||
.cellTableSortedHeaderDescending {
|
||||
|
||||
}
|
||||
|
||||
.cellTableEvenRow {
|
||||
|
||||
}
|
||||
|
||||
.cellTableEvenRowCell {
|
||||
|
||||
}
|
||||
|
||||
.cellTableOddRow {
|
||||
|
||||
}
|
||||
|
||||
.cellTableOddRowCell {
|
||||
|
||||
}
|
||||
|
||||
.cellTableHoveredRow {
|
||||
background: #D9EDF7 !important;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.cellTableHoveredRowCell {
|
||||
background: #D9EDF7 !important;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.cellTableKeyboardSelectedRow, .cellTableKeyboardSelectedRow td, .cellTableKeyboardSelectedRow th {
|
||||
background: #3A87AD !important;
|
||||
}
|
||||
|
||||
.cellTableSelectedRow, .cellTableSelectedRow td, .cellTableSelectedRow th
|
||||
{
|
||||
/* background: #D9EDF7 !important; */
|
||||
/* color: white !important; */
|
||||
/* height: auto; */
|
||||
/* overflow: auto; */
|
||||
|
||||
}
|
||||
|
||||
.cellTableSelectedRowCell, .cellTableSelectedRow td.cellTableSelectedRowCell {
|
||||
background: #3A87AD !important;
|
||||
}
|
||||
|
||||
.cellTableKeyboardSelectedRowCell, .cellTableKeyboardSelectedRow td.cellTableKeyboardSelectedRowCell{
|
||||
background: #3A87AD !important;
|
||||
}
|
||||
|
||||
.cellTableKeyboardSelectedCell, .cellTableKeyboardSelectedRow td.cellTableKeyboardSelectedCell{
|
||||
background: #3A87AD !important;
|
||||
color: white !important;
|
||||
}
|
||||
|
||||
.cellTableLoading {
|
||||
margin: 30px;
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.geoportaldataentry.client.resource;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.CellTable;
|
||||
import com.github.gwtbootstrap.client.ui.CellTable.Resources;
|
||||
import com.google.gwt.core.shared.GWT;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Jun 23, 2015
|
||||
*/
|
||||
public interface CellTableResources extends Resources {
|
||||
|
||||
public CellTableResources INSTANCE = GWT.create(CellTableResources.class);
|
||||
|
||||
// The styles used in this widget.
|
||||
@Override
|
||||
@Source("CellTable.css")
|
||||
CellTable.Style cellTableStyle();
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package org.gcube.portlets.user.geoportaldataentry.client.ui;
|
||||
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ui.form.GeonaDataEntryMainForm;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.LoaderIcon;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
|
@ -10,7 +11,6 @@ import com.google.gwt.user.client.ui.Composite;
|
|||
import com.google.gwt.user.client.ui.HTMLPanel;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class GeonaMainPanel.
|
||||
*
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
package org.gcube.portlets.user.geoportaldataentry.client.ui;
|
||||
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.events.CreateNewProjectEvent;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.events.GetListOfRecordsEvent;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.NavLink;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
import com.google.gwt.event.shared.EventBus;
|
||||
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.uibinder.client.UiHandler;
|
||||
import com.google.gwt.user.client.ui.Composite;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
|
||||
|
@ -24,28 +26,42 @@ public class GeonaNavigationBar extends Composite {
|
|||
|
||||
public GeonaNavigationBar() {
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
bindEvents();
|
||||
}
|
||||
|
||||
private void bindEvents() {
|
||||
// TODO Auto-generated method stub
|
||||
linkCreateNewProject.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
appManagerBus.fireEvent(new CreateNewProjectEvent());
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
linkGetListOfRecords.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
appManagerBus.fireEvent(new GetListOfRecordsEvent(RECORD_TYPE.CONCESSIONE));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@UiField
|
||||
NavLink linkCreateNewProject;
|
||||
|
||||
@UiField
|
||||
NavLink linkGetListOfRecords;
|
||||
|
||||
private HandlerManager appManagerBus;
|
||||
|
||||
public GeonaNavigationBar(String firstName) {
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
}
|
||||
|
||||
@UiHandler("linkCreateNewProject")
|
||||
void onClick(ClickEvent e) {
|
||||
appManagerBus.fireEvent(new CreateNewProjectEvent());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the app manager bus.
|
||||
*
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
<b:Nav>
|
||||
<b:NavLink ui:field="linkCreateNewProject"
|
||||
title="Create a new Project">Create new Project</b:NavLink>
|
||||
<b:NavLink ui:field="linkGetListOfRecords"
|
||||
title="Get List of Concessioni">Get List of Concessioni</b:NavLink>
|
||||
</b:Nav>
|
||||
</b:Navbar>
|
||||
</g:HTMLPanel>
|
||||
|
|
|
@ -0,0 +1,310 @@
|
|||
package org.gcube.portlets.user.geoportaldataentry.client.ui;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConstantsGeoPortalDataEntryApp.RECORD_TYPE;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.GeoPortalDataEntryApp;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ui.table.ItemsTable;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ui.table.ItemsTable.DISPLAY_FIELD;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ui.table.SortedCellTable;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ui.utils.LoaderIcon;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.SearchedData;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.event.shared.HandlerManager;
|
||||
import com.google.gwt.user.cellview.client.SimplePager;
|
||||
import com.google.gwt.user.cellview.client.SimplePager.TextLocation;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.FlowPanel;
|
||||
import com.google.gwt.user.client.ui.Label;
|
||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
import com.google.gwt.view.client.AsyncDataProvider;
|
||||
import com.google.gwt.view.client.HasData;
|
||||
import com.google.gwt.view.client.MultiSelectionModel;
|
||||
import com.google.gwt.view.client.Range;
|
||||
import com.google.gwt.view.client.SelectionModel;
|
||||
import com.google.gwt.view.client.SingleSelectionModel;
|
||||
|
||||
|
||||
/**
|
||||
* The Class GeonaRecordsPaginatedView.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Aug 4, 2021
|
||||
*/
|
||||
public class GeonaRecordsPaginatedView {
|
||||
|
||||
private static final int ITEM_START_INDEX = 0;
|
||||
private static final int ITEMS_PER_PAGE = 30;
|
||||
private VerticalPanel vPanel = new VerticalPanel();
|
||||
private FlowPanel pagerPanel = new FlowPanel();
|
||||
private Boolean initClassFirstRangeChanged = false;
|
||||
private ItemsTable<ConcessioneDV> itemsTable;
|
||||
private MyCustomDataProvider<ConcessioneDV> dataProvider = new MyCustomDataProvider<ConcessioneDV>();
|
||||
protected Widget orginalLoadingIndicator = null;
|
||||
private LoaderIcon loadingPanel = new LoaderIcon("Loading data...");
|
||||
private int serverStartIndex;
|
||||
private HandlerManager eventBus;
|
||||
private RECORD_TYPE recordType;
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new geona records paginated view.
|
||||
*
|
||||
* @param eventbus the eventbus
|
||||
* @param recordType the record type
|
||||
* @param displayFields the display fields
|
||||
* @param sortByField the sort by field
|
||||
*/
|
||||
public GeonaRecordsPaginatedView(HandlerManager eventbus, RECORD_TYPE recordType, DISPLAY_FIELD[] displayFields,
|
||||
DISPLAY_FIELD sortByField) {
|
||||
this.recordType = recordType;
|
||||
this.initClassFirstRangeChanged = true;
|
||||
this.eventBus = eventbus;
|
||||
itemsTable = new ItemsTable<ConcessioneDV>(eventbus, displayFields, sortByField);
|
||||
itemsTable.initTable(null, null, dataProvider);
|
||||
|
||||
orginalLoadingIndicator = itemsTable.getCellTable().getLoadingIndicator();
|
||||
initPagination(ITEMS_PER_PAGE);
|
||||
// loadNewPage(ITEM_START_INDEX, ITEMS_PER_PAGE, false);
|
||||
loadItemsForStatus(recordType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the asycn data provider.
|
||||
*
|
||||
* @return the asycn data provider
|
||||
*/
|
||||
public AsyncDataProvider<ConcessioneDV> getAsycnDataProvider() {
|
||||
return (AsyncDataProvider<ConcessioneDV>) getCellTable().getDataProvider();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the cell tale.
|
||||
*
|
||||
* @return the cell tale
|
||||
*/
|
||||
private SortedCellTable<ConcessioneDV> getCellTable() {
|
||||
return itemsTable.getCellTable();
|
||||
}
|
||||
|
||||
/**
|
||||
* Inits the pagination.
|
||||
*
|
||||
* @param itemsPerPage the items per page
|
||||
*/
|
||||
public void initPagination(int itemsPerPage) {
|
||||
|
||||
SimplePager.Resources pagerResources = GWT.create(SimplePager.Resources.class);
|
||||
SimplePager pager = new SimplePager(TextLocation.CENTER, pagerResources, false, 0, true);
|
||||
pager.setDisplay(getCellTable());
|
||||
pager.setPageSize(itemsPerPage);
|
||||
pager.getElement().getStyle().setProperty("margin", "auto");
|
||||
vPanel.add(loadingPanel);
|
||||
vPanel.add(getCellTable());
|
||||
vPanel.getElement().addClassName("vPanel");
|
||||
pagerPanel.add(pager);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the pager panel.
|
||||
*
|
||||
* @return the pager panel
|
||||
*/
|
||||
public VerticalPanel getCellPanel() {
|
||||
return vPanel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the panel in loading mode.
|
||||
*
|
||||
* @param show the show
|
||||
*/
|
||||
protected void showLoading(boolean show) {
|
||||
loadingPanel.setVisible(show);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the pager panel.
|
||||
*
|
||||
* @return the pager panel
|
||||
*/
|
||||
public FlowPanel getPagerPanel() {
|
||||
return pagerPanel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load new page.
|
||||
*
|
||||
* @param startIdx the start idx
|
||||
* @param limit the limit
|
||||
* @param resetStore the reset store
|
||||
*/
|
||||
private void loadNewPage(final int startIdx, final int limit, final boolean resetStore) {
|
||||
// initFirstRangeChanged = resetStore;
|
||||
GWT.log("loadNewPage with parameters [startIdx: " + startIdx + ", limit: " + limit + ", resetStore:"
|
||||
+ resetStore + "]");
|
||||
// showLoading(true);
|
||||
|
||||
int newStartIndex = startIdx;
|
||||
|
||||
if (resetStore) {
|
||||
GWT.log("Cleaning all data...");
|
||||
newStartIndex = 0;
|
||||
serverStartIndex = 0;
|
||||
GWT.log("Store reset performed start index is: " + newStartIndex);
|
||||
getAsycnDataProvider().updateRowCount(ITEMS_PER_PAGE, false);
|
||||
}
|
||||
|
||||
loadItemsForStatus(newStartIndex, limit, serverStartIndex);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Load items for status.
|
||||
*
|
||||
* @param recordType the record type
|
||||
*/
|
||||
public void loadItemsForStatus(RECORD_TYPE recordType) {
|
||||
this.recordType = recordType;
|
||||
getCellTable().setVisibleRangeAndClearData(new Range(ITEM_START_INDEX, ITEMS_PER_PAGE), false);
|
||||
loadNewPage(ITEM_START_INDEX, ITEMS_PER_PAGE, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the new page result.
|
||||
*
|
||||
* @param result the new new page result
|
||||
*/
|
||||
private void setNewPageResult(SearchedData result) {
|
||||
GWT.log("setNewPageResult: " + result);
|
||||
serverStartIndex = result.getServerEndIndex();
|
||||
SelectionModel<? super ConcessioneDV> sm = getCellTable().getSelectionModel();
|
||||
|
||||
if (sm instanceof SingleSelectionModel) {
|
||||
SingleSelectionModel<ConcessioneDV> ssm = (SingleSelectionModel<ConcessioneDV>) sm;
|
||||
ssm.clear();
|
||||
} else if (sm instanceof MultiSelectionModel) {
|
||||
MultiSelectionModel<ConcessioneDV> msm = (MultiSelectionModel<ConcessioneDV>) sm;
|
||||
msm.clear();
|
||||
}
|
||||
|
||||
getAsycnDataProvider().updateRowCount((int) result.getTotalItems(), true);
|
||||
getAsycnDataProvider().updateRowData(result.getClientStartIndex(), result.getData());
|
||||
|
||||
if (result.getData().size() == 0) {
|
||||
getCellTable().setLoadingIndicator(new Label("No data"));
|
||||
} else {
|
||||
getCellTable().setLoadingIndicator(orginalLoadingIndicator);
|
||||
}
|
||||
|
||||
GWT.log("Updating row data startIndex: " + result.getClientStartIndex() + " children size: "
|
||||
+ result.getData().size());
|
||||
GWT.log("getAsycnDataProvider().getDataDisplays().size(): " + getCellTable().getRowCount());
|
||||
|
||||
if (result.isServerSearchFinished()) {
|
||||
GWT.log("Search finished!!!");
|
||||
getAsycnDataProvider().updateRowCount(getCellTable().getRowCount(), true);
|
||||
}
|
||||
// initFirstRangeChanged = false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Load items for status.
|
||||
*
|
||||
* @param <T> the generic type
|
||||
* @param offset the offset
|
||||
* @param limit the limit
|
||||
* @param serverIndex the server index
|
||||
*/
|
||||
private <T> void loadItemsForStatus(int newStartIndex, int limit, int serverIndex) {
|
||||
showLoading(true);
|
||||
|
||||
GWT.log("calling getDataForStatus with parameters [startIndex: " + newStartIndex + ", limit: " + limit
|
||||
+ ", serverIndex:" + serverIndex + "]");
|
||||
|
||||
GeoPortalDataEntryApp.greetingService.getListConcessioni(newStartIndex, limit, new AsyncCallback<SearchedData>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
showLoading(false);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(SearchedData result) {
|
||||
showLoading(false);
|
||||
setNewPageResult(result);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Select items.
|
||||
*
|
||||
* @param select the select
|
||||
* @param limitToPage the limit to page
|
||||
*/
|
||||
public void selectItems(boolean select, boolean limitToPage) {
|
||||
SortedCellTable<ConcessioneDV> table = getCellTable();
|
||||
int rowSize = table.getVisibleItemCount();
|
||||
|
||||
for (int i = 0; i < rowSize; i++) {
|
||||
ConcessioneDV item = table.getVisibleItem(i);
|
||||
itemsTable.getSelectionModel().setSelected(item, select);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the select items.
|
||||
*
|
||||
* @return the select items
|
||||
*/
|
||||
public List<ConcessioneDV> getSelectItems() {
|
||||
return itemsTable.getSelectedItems();
|
||||
}
|
||||
|
||||
/**
|
||||
* A custom {@link AsyncDataProvider}.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Jul 5, 2017
|
||||
* @param <T> the generic type
|
||||
*/
|
||||
public class MyCustomDataProvider<T> extends AsyncDataProvider<T> {
|
||||
|
||||
/**
|
||||
* {@link #onRangeChanged(HasData)} is called when the table requests a new
|
||||
* range of data. You can push data back to the displays using
|
||||
* {@link #updateRowData(int, List)}.
|
||||
*
|
||||
* @param display the display
|
||||
*/
|
||||
@Override
|
||||
public void onRangeChanged(HasData<T> display) {
|
||||
|
||||
// Get the new range.
|
||||
final Range range = display.getVisibleRange();
|
||||
|
||||
int start = range.getStart();
|
||||
int length = range.getLength();
|
||||
|
||||
if (initClassFirstRangeChanged) {
|
||||
GWT.log("initClassFirstRangeChanged is true.. returning");
|
||||
initClassFirstRangeChanged = false;
|
||||
return;
|
||||
}
|
||||
GWT.log("Range changed: " + start + " " + length + " visible count: " + display.getVisibleItemCount());
|
||||
loadNewPage(start, length, false);
|
||||
//eventBus.fireEvent(new TableRangeViewChangedEvent<T>(start, length));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package org.gcube.portlets.user.geoportaldataentry.client.ui;
|
||||
package org.gcube.portlets.user.geoportaldataentry.client.ui.form;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
|
@ -0,0 +1,204 @@
|
|||
package org.gcube.portlets.user.geoportaldataentry.client.ui.table;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.events.ClickItemEvent;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.Pagination;
|
||||
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
|
||||
import com.google.gwt.core.shared.GWT;
|
||||
import com.google.gwt.dom.client.Style.BorderStyle;
|
||||
import com.google.gwt.event.dom.client.ContextMenuEvent;
|
||||
import com.google.gwt.event.dom.client.ContextMenuHandler;
|
||||
import com.google.gwt.event.dom.client.DoubleClickEvent;
|
||||
import com.google.gwt.event.dom.client.DoubleClickHandler;
|
||||
import com.google.gwt.event.shared.HandlerManager;
|
||||
import com.google.gwt.user.cellview.client.SimplePager;
|
||||
import com.google.gwt.user.client.Event;
|
||||
import com.google.gwt.user.client.ui.DialogBox;
|
||||
import com.google.gwt.user.client.ui.MenuBar;
|
||||
import com.google.gwt.user.client.ui.MenuItem;
|
||||
import com.google.gwt.view.client.AbstractDataProvider;
|
||||
import com.google.gwt.view.client.AsyncDataProvider;
|
||||
import com.google.gwt.view.client.DefaultSelectionEventManager;
|
||||
import com.google.gwt.view.client.ListDataProvider;
|
||||
import com.google.gwt.view.client.MultiSelectionModel;
|
||||
import com.google.gwt.view.client.SelectionChangeEvent;
|
||||
import com.google.gwt.view.client.SelectionChangeEvent.Handler;
|
||||
import com.google.gwt.view.client.SelectionModel;
|
||||
import com.google.gwt.view.client.SingleSelectionModel;
|
||||
|
||||
|
||||
/**
|
||||
* The Class AbstractItemsCellTable.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Jul 11, 2017
|
||||
* @param <T> the generic type
|
||||
*/
|
||||
public abstract class AbstractItemsCellTable<T> {
|
||||
|
||||
protected SortedCellTable<T> sortedCellTable;
|
||||
protected T itemContextMenu = null;
|
||||
protected boolean fireEventOnClick = true;
|
||||
protected SelectionModel<T> theSelectionModel;
|
||||
protected HandlerManager eventBus;
|
||||
|
||||
/**
|
||||
* Inits the table.
|
||||
*
|
||||
* @param pager the pager
|
||||
* @param pagination the pagination
|
||||
* @param dataProvider the data provider
|
||||
*/
|
||||
public abstract void initTable(final SimplePager pager, final Pagination pagination,
|
||||
AbstractDataProvider<T> dataProvider);
|
||||
|
||||
/**
|
||||
* Inits the abstract table.
|
||||
*
|
||||
* @param eventBus the event bus
|
||||
* @param fireOnClick the fire on click
|
||||
* @param dataProvider the data provider
|
||||
* @param selectionModel the selection model
|
||||
* @param pageSize the page size
|
||||
*/
|
||||
protected void initAbstractTable(HandlerManager eventBus, boolean fireOnClick, AbstractDataProvider<T> dataProvider,
|
||||
SelectionModel<T> selectionModel, int pageSize) {
|
||||
this.eventBus = eventBus;
|
||||
this.fireEventOnClick = fireOnClick;
|
||||
this.theSelectionModel = selectionModel;
|
||||
sortedCellTable = new SortedCellTable<T>(pageSize, dataProvider);
|
||||
// sortedCellTable.addStyleName("table-cms-widget");
|
||||
// sortedCellTable.addStyleName("table-cms-widget-vertical-middle");
|
||||
sortedCellTable.setStriped(true);
|
||||
sortedCellTable.setCondensed(true);
|
||||
sortedCellTable.setWidth("100%", true);
|
||||
// dataProvider.addDataDisplay(sortedCellTable);
|
||||
// initTable(cellTable, null, null);
|
||||
//sortedCellTable.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);
|
||||
|
||||
DefaultSelectionEventManager<T> checkBoxManager = DefaultSelectionEventManager.<T> createCheckboxManager();
|
||||
sortedCellTable.setSelectionModel(theSelectionModel,checkBoxManager);
|
||||
|
||||
theSelectionModel.addSelectionChangeHandler(new Handler() {
|
||||
@Override
|
||||
public void onSelectionChange(final SelectionChangeEvent event) {
|
||||
|
||||
if (theSelectionModel instanceof SingleSelectionModel) {
|
||||
SingleSelectionModel<T> ssm = (SingleSelectionModel<T>) theSelectionModel;
|
||||
final T selectedObject = ssm.getSelectedObject();
|
||||
if (selectedObject != null) {
|
||||
GWT.log("Clicked: " + selectedObject);
|
||||
// selectedItem(selectedObject);
|
||||
if (fireEventOnClick)
|
||||
AbstractItemsCellTable.this.eventBus.fireEvent(new ClickItemEvent<T>(Arrays.asList(selectedObject)));
|
||||
}
|
||||
}else if (theSelectionModel instanceof MultiSelectionModel) {
|
||||
Set<T> selected = ((MultiSelectionModel<T>) theSelectionModel).getSelectedSet();
|
||||
GWT.log("Selected are:" +selected);
|
||||
if (fireEventOnClick)
|
||||
AbstractItemsCellTable.this.eventBus.fireEvent(new ClickItemEvent<T>(new ArrayList<T>(selected)));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
sortedCellTable.addDomHandler(new DoubleClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onDoubleClick(final DoubleClickEvent event) {
|
||||
if (theSelectionModel instanceof SingleSelectionModel) {
|
||||
SingleSelectionModel<T> ssm = (SingleSelectionModel<T>) theSelectionModel;
|
||||
T selected = ssm.getSelectedObject();
|
||||
if (selected != null) {
|
||||
GWT.log("Double Click: " + selected);
|
||||
// AbstractItemsCellTable.this.eventBus.fireEvent(new
|
||||
// org.gcube.portlets.widgets.wsexplorer.client.event.LoadFolderEvent<T>(selected));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}, DoubleClickEvent.getType());
|
||||
|
||||
MenuBar options = new MenuBar(true);
|
||||
ScheduledCommand openCommand = new ScheduledCommand() {
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
GWT.log("Context menu shown: " + itemContextMenu);
|
||||
// AbstractItemsCellTable.this.eventBus.fireEvent(new
|
||||
// org.gcube.portlets.widgets.wsexplorer.client.event.LoadFolderEvent<T>(itemContextMenu));
|
||||
}
|
||||
};
|
||||
|
||||
MenuItem openItem = new MenuItem("Open", openCommand);
|
||||
options.addItem(openItem);
|
||||
final DialogBox menuWrapper = new DialogBox(true);
|
||||
menuWrapper.getElement().getStyle().setBorderStyle(BorderStyle.NONE);
|
||||
menuWrapper.getElement().getStyle().setZIndex(10000);
|
||||
menuWrapper.add(options);
|
||||
sortedCellTable.sinkEvents(Event.ONCONTEXTMENU);
|
||||
|
||||
sortedCellTable.addHandler(new ContextMenuHandler() {
|
||||
@Override
|
||||
public void onContextMenu(ContextMenuEvent event) {
|
||||
}
|
||||
}, ContextMenuEvent.getType());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the cell tables.
|
||||
*
|
||||
* @return the cell tables
|
||||
*/
|
||||
public SortedCellTable<T> getCellTable() {
|
||||
return sortedCellTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is fire event on click.
|
||||
*
|
||||
* @return the fireEventOnClick
|
||||
*/
|
||||
public boolean isFireEventOnClick() {
|
||||
|
||||
return fireEventOnClick;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the fire event on click.
|
||||
*
|
||||
* @param fireEventOnClick the fireEventOnClick to set
|
||||
*/
|
||||
public void setFireEventOnClick(boolean fireEventOnClick) {
|
||||
|
||||
this.fireEventOnClick = fireEventOnClick;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the items.
|
||||
*
|
||||
* @param items the items
|
||||
*/
|
||||
public void addItems(List<T> items) {
|
||||
|
||||
AbstractDataProvider<T> dataProvider = sortedCellTable.getDataProvider();
|
||||
|
||||
if (dataProvider instanceof ListDataProvider) {
|
||||
List<T> ldp = ((ListDataProvider<T>) dataProvider).getList();
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
ldp.add(i, items.get(i));
|
||||
}
|
||||
|
||||
sortedCellTable.setPageSize(items.size() + 1);
|
||||
sortedCellTable.redraw();
|
||||
} else if (dataProvider instanceof AsyncDataProvider) {
|
||||
|
||||
// TODO ???
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,516 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.geoportaldataentry.client.ui.table;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.gcube.application.geoportalcommon.ConvertToDataViewModel;
|
||||
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.events.ShowItemEvent;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.Pagination;
|
||||
import com.google.gwt.cell.client.ButtonCell;
|
||||
import com.google.gwt.cell.client.DateCell;
|
||||
import com.google.gwt.cell.client.FieldUpdater;
|
||||
import com.google.gwt.core.shared.GWT;
|
||||
import com.google.gwt.dom.client.Style.Unit;
|
||||
import com.google.gwt.event.shared.HandlerManager;
|
||||
import com.google.gwt.i18n.client.DateTimeFormat;
|
||||
import com.google.gwt.safehtml.shared.SafeHtml;
|
||||
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
|
||||
import com.google.gwt.safehtml.shared.SafeHtmlUtils;
|
||||
import com.google.gwt.user.cellview.client.Column;
|
||||
import com.google.gwt.user.cellview.client.ColumnSortEvent;
|
||||
import com.google.gwt.user.cellview.client.ColumnSortList.ColumnSortInfo;
|
||||
import com.google.gwt.user.cellview.client.SimplePager;
|
||||
import com.google.gwt.user.cellview.client.TextColumn;
|
||||
import com.google.gwt.user.client.ui.Image;
|
||||
import com.google.gwt.user.client.ui.Label;
|
||||
import com.google.gwt.view.client.AbstractDataProvider;
|
||||
import com.google.gwt.view.client.ListDataProvider;
|
||||
import com.google.gwt.view.client.MultiSelectionModel;
|
||||
import com.google.gwt.view.client.SelectionModel;
|
||||
import com.google.gwt.view.client.SingleSelectionModel;
|
||||
|
||||
/**
|
||||
* The Class ItemsTable.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Jun 15, 2021
|
||||
* @param <T> the generic type
|
||||
*/
|
||||
public class ItemsTable<T extends ConcessioneDV> extends AbstractItemsCellTable<T> {
|
||||
|
||||
private static final int ITEMS_PER_PAGE = 10;
|
||||
private static final String NO_DATA = "No data";
|
||||
private TextColumn<T> name;
|
||||
private TextColumn<T> introduction;
|
||||
private TextColumn<T> author;
|
||||
public static DateTimeFormat dtformat = DateTimeFormat.getFormat(ConvertToDataViewModel.DATE_FORMAT);
|
||||
|
||||
private AbstractDataProvider<T> dataProvider;
|
||||
|
||||
/**
|
||||
* The Enum DISPLAY_FIELD.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Feb 1, 2016
|
||||
*/
|
||||
public static enum DISPLAY_FIELD {
|
||||
NAME, INTRO, AUTHOR, PROJECT_START_DATE, PROJECT_END_DATE
|
||||
};
|
||||
|
||||
private List<DISPLAY_FIELD> displayFields;
|
||||
private Column<T, Date> startProjectDateColumn;
|
||||
private Column<T, Date> endProjectDateColumn;
|
||||
private DISPLAY_FIELD startSortByColumn;
|
||||
private boolean isAsyncronusTable;
|
||||
|
||||
/**
|
||||
* Instantiates a new items table.
|
||||
*
|
||||
* @param eventBus the event bus
|
||||
* @param fields the fields
|
||||
* @param startSortByColumn the start sort by column
|
||||
*/
|
||||
public ItemsTable(HandlerManager eventBus, DISPLAY_FIELD[] fields, DISPLAY_FIELD startSortByColumn) {
|
||||
this.eventBus = eventBus;
|
||||
this.startSortByColumn = startSortByColumn;
|
||||
setDisplayFields(fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the items.
|
||||
*
|
||||
* @param items the items
|
||||
*/
|
||||
public void addItems(List<T> items) {
|
||||
super.addItems(items);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inits the table.
|
||||
*
|
||||
* @param pager the pager
|
||||
* @param pagination the pagination
|
||||
* @param dataProvider the data provider
|
||||
*/
|
||||
@Override
|
||||
public void initTable(final SimplePager pager, final Pagination pagination, AbstractDataProvider<T> dataProvider) {
|
||||
this.dataProvider = dataProvider;
|
||||
this.theSelectionModel = new SingleSelectionModel<T>();
|
||||
initAbstractTable(eventBus, fireEventOnClick, dataProvider, theSelectionModel, ITEMS_PER_PAGE);
|
||||
this.dataProvider.addDataDisplay(sortedCellTable);
|
||||
|
||||
this.isAsyncronusTable = dataProvider instanceof ListDataProvider ? false : true;
|
||||
setEmptyTableMessage(NO_DATA);
|
||||
|
||||
// final CheckboxCell cellCheckBox = new CheckboxCell(true, false);
|
||||
// Column<T, Boolean> checkColumn = new Column<T, Boolean>(cellCheckBox) {
|
||||
// @Override
|
||||
// public Boolean getValue(T object) {
|
||||
// // Get the value from the selection model.
|
||||
// return theSelectionModel.isSelected(object);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void render(Context context, T object, SafeHtmlBuilder sb) {
|
||||
// super.render(context, object, sb);
|
||||
// GWT.log("added checkbox: " + cellCheckBox + " to object: " + object);
|
||||
// }
|
||||
//
|
||||
// };
|
||||
//
|
||||
// sortedCellTable.addColumn(checkColumn, "", false);
|
||||
// sortedCellTable.setColumnWidth(checkColumn, 40, Unit.PX);
|
||||
|
||||
ButtonCell previewButton = new ButtonCell();
|
||||
Column<T, String> showdItemColumn = new Column<T, String>(previewButton) {
|
||||
public String getValue(T object) {
|
||||
return "Show";
|
||||
}
|
||||
};
|
||||
|
||||
showdItemColumn.setFieldUpdater(new FieldUpdater<T, String>() {
|
||||
@Override
|
||||
public void update(int index, T object, String value) {
|
||||
GWT.log("clicked show");
|
||||
eventBus.fireEvent(new ShowItemEvent<T>(Arrays.asList(object)));
|
||||
}
|
||||
});
|
||||
sortedCellTable.addColumn(showdItemColumn);
|
||||
sortedCellTable.setColumnWidth(showdItemColumn, 80, Unit.PX);
|
||||
|
||||
if (this.displayFields.contains(DISPLAY_FIELD.NAME)) {
|
||||
|
||||
// NAME
|
||||
name = new TextColumn<T>() {
|
||||
@Override
|
||||
public String getValue(T object) {
|
||||
if (object == null)
|
||||
return "";
|
||||
return ((ConcessioneDV) object).getNome();
|
||||
}
|
||||
|
||||
// ADDING TOOLTIP
|
||||
@Override
|
||||
public void render(com.google.gwt.cell.client.Cell.Context context, T object, SafeHtmlBuilder sb) {
|
||||
if (object == null)
|
||||
return;
|
||||
sb.appendHtmlConstant("<div introduction=\"" + ((ConcessioneDV) object).getNome() + "\">");
|
||||
super.render(context, object, sb);
|
||||
sb.appendHtmlConstant("</div>");
|
||||
};
|
||||
};
|
||||
|
||||
sortedCellTable.addColumn(name, "Name", true);
|
||||
|
||||
if (!isAsyncronusTable) {
|
||||
Comparator<T> c = new Comparator<T>() {
|
||||
@Override
|
||||
public int compare(T o1, T o2) {
|
||||
return ((ConcessioneDV) o1).getNome().compareTo(((ConcessioneDV) o2).getNome());
|
||||
}
|
||||
};
|
||||
|
||||
sortedCellTable.setComparator(name, c);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (this.displayFields.contains(DISPLAY_FIELD.INTRO)) {
|
||||
|
||||
introduction = new TextColumn<T>() {
|
||||
@Override
|
||||
public String getValue(T object) {
|
||||
if (object == null)
|
||||
return "";
|
||||
return ((ConcessioneDV) object).getIntroduzione() != null
|
||||
? ((ConcessioneDV) object).getIntroduzione()
|
||||
: "";
|
||||
}
|
||||
};
|
||||
|
||||
sortedCellTable.addColumn(introduction, "Intro", true);
|
||||
|
||||
if (!isAsyncronusTable) {
|
||||
Comparator<T> c = new Comparator<T>() {
|
||||
@Override
|
||||
public int compare(T o1, T o2) {
|
||||
return ((ConcessioneDV) o1).getIntroduzione().compareTo(((ConcessioneDV) o2).getIntroduzione());
|
||||
}
|
||||
};
|
||||
sortedCellTable.setComparator(introduction, c);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (this.displayFields.contains(DISPLAY_FIELD.AUTHOR)) {
|
||||
|
||||
author = new TextColumn<T>() {
|
||||
@Override
|
||||
public String getValue(T object) {
|
||||
if (object == null)
|
||||
return "";
|
||||
|
||||
String toDisplay = toDisplayAuthors(((ConcessioneDV) object).getAuthors());
|
||||
return toDisplay;
|
||||
}
|
||||
};
|
||||
|
||||
sortedCellTable.addColumn(author, "Author/s", true);
|
||||
|
||||
if (!isAsyncronusTable) {
|
||||
Comparator<T> c = new Comparator<T>() {
|
||||
@Override
|
||||
public int compare(T o1, T o2) {
|
||||
String toDisplay1 = toDisplayAuthors(((ConcessioneDV) o1).getAuthors());
|
||||
String toDisplay2 = toDisplayAuthors(((ConcessioneDV) o2).getAuthors());
|
||||
return toDisplay1.compareTo(toDisplay2);
|
||||
}
|
||||
};
|
||||
sortedCellTable.setComparator(author, c);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (this.displayFields.contains(DISPLAY_FIELD.PROJECT_START_DATE)) {
|
||||
|
||||
DateCell date = new DateCell(dtformat);
|
||||
startProjectDateColumn = new Column<T, Date>(date) {
|
||||
|
||||
@Override
|
||||
public Date getValue(T object) {
|
||||
if (object == null)
|
||||
return null;
|
||||
|
||||
return (((ConcessioneDV) object).getDataInizioProgetto());
|
||||
}
|
||||
};
|
||||
sortedCellTable.addColumn(startProjectDateColumn, "Project Start Date", true);
|
||||
|
||||
if (!isAsyncronusTable) {
|
||||
Comparator<T> c = new Comparator<T>() {
|
||||
@Override
|
||||
public int compare(T o1, T o2) {
|
||||
if (o1 == null)
|
||||
return -1;
|
||||
|
||||
if (o2 == null)
|
||||
return 1;
|
||||
|
||||
Date d1 = (((ConcessioneDV) o1).getDataInizioProgetto());
|
||||
Date d2 = (((ConcessioneDV) o2).getDataInizioProgetto());
|
||||
|
||||
// GWT.log(d1.toString() + "is after "+d2.toString() +" ? "+d2.after(d1));
|
||||
|
||||
if (d1.after(d2))
|
||||
return 1;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
};
|
||||
GWT.log("date colum sortable");
|
||||
sortedCellTable.setComparator(startProjectDateColumn, c);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (this.displayFields.contains(DISPLAY_FIELD.PROJECT_END_DATE)) {
|
||||
|
||||
DateCell date = new DateCell(dtformat);
|
||||
endProjectDateColumn = new Column<T, Date>(date) {
|
||||
|
||||
@Override
|
||||
public Date getValue(T object) {
|
||||
if (object == null)
|
||||
return null;
|
||||
|
||||
return (((ConcessioneDV) object).getDataFineProgetto());
|
||||
}
|
||||
};
|
||||
sortedCellTable.addColumn(startProjectDateColumn, "Project End Date", true);
|
||||
|
||||
if (!isAsyncronusTable) {
|
||||
Comparator<T> c = new Comparator<T>() {
|
||||
@Override
|
||||
public int compare(T o1, T o2) {
|
||||
if (o1 == null)
|
||||
return -1;
|
||||
|
||||
if (o2 == null)
|
||||
return 1;
|
||||
|
||||
Date d1 = (((ConcessioneDV) o1).getDataFineProgetto());
|
||||
Date d2 = (((ConcessioneDV) o2).getDataFineProgetto());
|
||||
|
||||
// GWT.log(d1.toString() + "is after "+d2.toString() +" ? "+d2.after(d1));
|
||||
|
||||
if (d1.after(d2))
|
||||
return 1;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
};
|
||||
GWT.log("date colum sortable");
|
||||
sortedCellTable.setComparator(endProjectDateColumn, c);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
GWT.log("startSortByColumn: " + startSortByColumn);
|
||||
|
||||
if (startSortByColumn != null)
|
||||
switch (startSortByColumn) {
|
||||
case NAME:
|
||||
if (this.displayFields.contains(DISPLAY_FIELD.NAME)) {
|
||||
sortedCellTable.setInitialSortColumn(name);
|
||||
}
|
||||
break;
|
||||
case INTRO:
|
||||
if (this.displayFields.contains(DISPLAY_FIELD.INTRO)) {
|
||||
sortedCellTable.setInitialSortColumn(introduction);
|
||||
}
|
||||
break;
|
||||
case AUTHOR:
|
||||
if (this.displayFields.contains(DISPLAY_FIELD.AUTHOR)) {
|
||||
sortedCellTable.setInitialSortColumn(author);
|
||||
}
|
||||
break;
|
||||
case PROJECT_START_DATE:
|
||||
if (this.displayFields.contains(DISPLAY_FIELD.PROJECT_START_DATE)) {
|
||||
sortedCellTable.setDefaultSortOrder(startProjectDateColumn, false); // sorts ascending on first
|
||||
// click
|
||||
sortedCellTable.setInitialSortColumn(startProjectDateColumn);
|
||||
GWT.log("sortedCellTable: " + sortedCellTable);
|
||||
}
|
||||
break;
|
||||
case PROJECT_END_DATE:
|
||||
if (this.displayFields.contains(DISPLAY_FIELD.PROJECT_START_DATE)) {
|
||||
sortedCellTable.setDefaultSortOrder(endProjectDateColumn, false); // sorts ascending on first click
|
||||
sortedCellTable.setInitialSortColumn(endProjectDateColumn);
|
||||
GWT.log("sortedCellTable: " + sortedCellTable);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// /**
|
||||
// * To date format string.
|
||||
// *
|
||||
// * @param dateTime the date time
|
||||
// * @return the string
|
||||
// */
|
||||
// public static Date toDisplayDate(Date dateTime) {
|
||||
//
|
||||
// if(dateTime==null)
|
||||
// return null;
|
||||
//
|
||||
// return new Date(dtformat.format(dateTime));
|
||||
// }
|
||||
|
||||
private String toDisplayAuthors(List<String> authors) {
|
||||
String toDisplay = "";
|
||||
if (authors == null)
|
||||
return toDisplay;
|
||||
|
||||
for (String author : authors) {
|
||||
toDisplay += author + "; ";
|
||||
}
|
||||
return toDisplay;
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays the appropriate sorted icon in the header of the column for the
|
||||
* given index.
|
||||
*
|
||||
* @param columnIndex of the column to mark as sorted
|
||||
* @param ascending <code>true</code> for ascending icon, <code>false</code>
|
||||
* for descending icon
|
||||
*/
|
||||
public void setSortedColumn(int columnIndex, boolean ascending) {
|
||||
GWT.log("Column index: " + columnIndex);
|
||||
GWT.log("ascending: " + ascending);
|
||||
Column<T, ?> column = sortedCellTable.getColumn(columnIndex);
|
||||
if (column != null && column.isSortable()) {
|
||||
ColumnSortInfo info = sortedCellTable.getColumnSortList().push(column);
|
||||
// ColumnSortEvent.fire(cellTable, cellTable.getColumnSortList());
|
||||
GWT.log("info.isAscending(): " + info.isAscending());
|
||||
if (info.isAscending() != ascending) {
|
||||
sortedCellTable.getColumnSortList().push(column);
|
||||
ColumnSortEvent.fire(sortedCellTable, sortedCellTable.getColumnSortList());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the display fields.
|
||||
*
|
||||
* @param fields the new display fields
|
||||
*/
|
||||
public void setDisplayFields(DISPLAY_FIELD[] fields) {
|
||||
this.displayFields = fields != null && fields.length > 0 ? Arrays.asList(fields)
|
||||
: Arrays.asList(DISPLAY_FIELD.values());
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset columns table.
|
||||
*/
|
||||
public void reInitColumnsTable() {
|
||||
int count = sortedCellTable.getColumnCount();
|
||||
for (int i = 0; i < count; i++) {
|
||||
sortedCellTable.removeColumn(0);
|
||||
}
|
||||
initTable(null, null, dataProvider);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the display fields.
|
||||
*
|
||||
* @return the displayFields
|
||||
*/
|
||||
public List<DISPLAY_FIELD> getDisplayFields() {
|
||||
return displayFields;
|
||||
}
|
||||
|
||||
/**
|
||||
* The Class ButtonImageCell.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Feb 1, 2016
|
||||
*/
|
||||
public class ButtonImageCell extends ButtonCell {
|
||||
|
||||
/**
|
||||
* Render.
|
||||
*
|
||||
* @param context the context
|
||||
* @param value the value
|
||||
* @param sb the sb
|
||||
*/
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.google.gwt.cell.client.AbstractSafeHtmlCell#render(com.google.gwt.cell.
|
||||
* client.Cell.Context, java.lang.Object,
|
||||
* com.google.gwt.safehtml.shared.SafeHtmlBuilder)
|
||||
*/
|
||||
@Override
|
||||
public void render(com.google.gwt.cell.client.Cell.Context context, String value, SafeHtmlBuilder sb) {
|
||||
SafeHtml html = SafeHtmlUtils.fromTrustedString(new Image(value).toString());
|
||||
sb.append(html);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the selected item.
|
||||
*
|
||||
* @return the selected item
|
||||
*/
|
||||
public List<T> getSelectedItems() {
|
||||
if (theSelectionModel instanceof SingleSelectionModel) {
|
||||
T selected = ((SingleSelectionModel<T>) theSelectionModel).getSelectedObject();
|
||||
if (selected != null) {
|
||||
return Arrays.asList(selected);
|
||||
}
|
||||
|
||||
} else if (theSelectionModel instanceof MultiSelectionModel) {
|
||||
Set<T> selected = ((MultiSelectionModel<T>) theSelectionModel).getSelectedSet();
|
||||
if (selected != null) {
|
||||
return new ArrayList<T>(selected);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the empty table message.
|
||||
*
|
||||
* @param msg the new empty table message
|
||||
*/
|
||||
public void setEmptyTableMessage(String msg) {
|
||||
msg = msg != null ? msg : NO_DATA;
|
||||
if (sortedCellTable != null)
|
||||
sortedCellTable.setEmptyTableWidget(new Label(msg));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the selection model.
|
||||
*
|
||||
* @return the selection model
|
||||
*/
|
||||
public SelectionModel<T> getSelectionModel() {
|
||||
return theSelectionModel;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
package org.gcube.portlets.user.geoportaldataentry.client.ui.table;
|
||||
|
||||
import com.google.gwt.cell.client.Cell;
|
||||
import com.google.gwt.cell.client.Cell.Context;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.safehtml.client.SafeHtmlTemplates;
|
||||
import com.google.gwt.safehtml.shared.SafeHtml;
|
||||
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
|
||||
import com.google.gwt.user.cellview.client.Column;
|
||||
|
||||
|
||||
/**
|
||||
* The Class MyToolTipColumn.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Jun 15, 2021
|
||||
* @param <T> the generic type
|
||||
* @param <C> the generic type
|
||||
*/
|
||||
public abstract class MyToolTipColumn<T, C> extends Column<T, C> {
|
||||
|
||||
/**
|
||||
* The Interface Templates.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Jun 15, 2021
|
||||
*/
|
||||
interface Templates extends SafeHtmlTemplates {
|
||||
|
||||
/**
|
||||
* Start tool tip.
|
||||
*
|
||||
* @param toolTipText the tool tip text
|
||||
* @return the safe html
|
||||
*/
|
||||
@Template("<div title=\"{0}\">")
|
||||
SafeHtml startToolTip(String toolTipText);
|
||||
|
||||
/**
|
||||
* End tool tip.
|
||||
*
|
||||
* @return the safe html
|
||||
*/
|
||||
@Template("</div>")
|
||||
SafeHtml endToolTip();
|
||||
}
|
||||
|
||||
private static final Templates TEMPLATES = GWT.create(Templates.class);
|
||||
private final String toolTipText;
|
||||
|
||||
/**
|
||||
* Instantiates a new my tool tip column.
|
||||
*
|
||||
* @param cell the cell
|
||||
* @param toolTipText the tool tip text
|
||||
*/
|
||||
public MyToolTipColumn(final Cell<C> cell, final String toolTipText) {
|
||||
|
||||
super(cell);
|
||||
this.toolTipText = toolTipText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render.
|
||||
*
|
||||
* @param context the context
|
||||
* @param object the object
|
||||
* @param sb the sb
|
||||
*/
|
||||
@Override
|
||||
public void render(final Context context, final T object, final SafeHtmlBuilder sb) {
|
||||
|
||||
sb.append(TEMPLATES.startToolTip(toolTipText));
|
||||
super.render(context, object, sb);
|
||||
sb.append(TEMPLATES.endToolTip());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,302 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
package org.gcube.portlets.user.geoportaldataentry.client.ui.table;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.resource.CellTableResources;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.CellTable;
|
||||
import com.google.gwt.user.cellview.client.Column;
|
||||
import com.google.gwt.user.cellview.client.ColumnSortEvent;
|
||||
import com.google.gwt.user.cellview.client.ColumnSortEvent.AsyncHandler;
|
||||
import com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler;
|
||||
import com.google.gwt.user.cellview.client.ColumnSortList.ColumnSortInfo;
|
||||
import com.google.gwt.user.cellview.client.Header;
|
||||
import com.google.gwt.view.client.AbstractDataProvider;
|
||||
import com.google.gwt.view.client.AsyncDataProvider;
|
||||
import com.google.gwt.view.client.ListDataProvider;
|
||||
|
||||
/**
|
||||
* The Class SortedCellTable.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Jun 15, 2021
|
||||
* @param <T> the generic type
|
||||
*/
|
||||
public class SortedCellTable<T> extends CellTable<T> {
|
||||
|
||||
/**
|
||||
* To keep track of the currently sorted column
|
||||
*/
|
||||
private Column<T, ?> currentlySortedColumn;
|
||||
/**
|
||||
* Tells us which way to sort a column initially
|
||||
*/
|
||||
private Map<Column<T, ?>, Boolean> defaultSortOrderMap = new HashMap<Column<T, ?>, Boolean>();
|
||||
/**
|
||||
* Comparators associated with their columns
|
||||
*/
|
||||
private Map<Column<T, ?>, Comparator<T>> comparators = new HashMap<Column<T, ?>, Comparator<T>>();
|
||||
/**
|
||||
* Column to sort when the data provider's list is refreshed using
|
||||
* {@link SortedCellTable#setList(List)}
|
||||
*/
|
||||
private Column<T, ?> initialSortColumn;
|
||||
/**
|
||||
* Data provider we will attach to this table
|
||||
*/
|
||||
private AbstractDataProvider<T> dataProvider;
|
||||
|
||||
/**
|
||||
* Special column sorting handler that will allow us to do more controlled
|
||||
* sorting
|
||||
*/
|
||||
private ColumnSortEvent.Handler columnSortHandler;
|
||||
|
||||
/**
|
||||
* Instantiates a new sorted cell table.
|
||||
*
|
||||
* @param pageSize the page size
|
||||
* @param dataProv the data prov
|
||||
*/
|
||||
public SortedCellTable(int pageSize, AbstractDataProvider<T> dataProv) {
|
||||
super(pageSize, CellTableResources.INSTANCE);
|
||||
this.dataProvider = dataProv;
|
||||
|
||||
if (this.dataProvider instanceof ListDataProvider) {
|
||||
ListDataProvider<T> listDataProvider = (ListDataProvider<T>) this.dataProvider;
|
||||
ListHandler<T> listSortHandler = new ListHandler<T>((listDataProvider).getList()) {
|
||||
|
||||
@Override
|
||||
public void onColumnSort(ColumnSortEvent event) {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Column<T, ?> column = (Column<T, ?>) event.getColumn();
|
||||
if (column == null) {
|
||||
return;
|
||||
}
|
||||
if (column.equals(currentlySortedColumn)) {
|
||||
// Default behavior
|
||||
super.onColumnSort(event);
|
||||
} else {
|
||||
// Initial sort; look up which direction we need
|
||||
final Comparator<T> comparator = comparators.get(column);
|
||||
if (comparator == null) {
|
||||
return;
|
||||
}
|
||||
Boolean ascending = defaultSortOrderMap.get(column);
|
||||
if (ascending == null || ascending) {
|
||||
// Default behavior
|
||||
super.onColumnSort(event);
|
||||
} else {
|
||||
// Sort the column descending
|
||||
Collections.sort(getList(), new Comparator<T>() {
|
||||
|
||||
public int compare(T o1, T o2) {
|
||||
|
||||
return -comparator.compare(o1, o2);
|
||||
}
|
||||
});
|
||||
// Set the proper arrow in the header
|
||||
getColumnSortList().push(new ColumnSortInfo(column, false));
|
||||
}
|
||||
currentlySortedColumn = column;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setComparator(Column<T, ?> column, Comparator<T> comparator) {
|
||||
|
||||
comparators.put(column, comparator);
|
||||
super.setComparator(column, comparator);
|
||||
}
|
||||
};
|
||||
addColumnSortHandler(listSortHandler);
|
||||
columnSortHandler = listSortHandler;
|
||||
} else if (this.dataProvider instanceof AsyncDataProvider) {
|
||||
//AsyncDataProvider asyncDataProvider = ((AsyncDataProvider) this.dataProvider);
|
||||
//asyncDataProvider.get
|
||||
AsyncHandler asyncSortHandler = new AsyncHandler(this) {
|
||||
@Override
|
||||
public void onColumnSort(ColumnSortEvent event) {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Column<T, ?> column = (Column<T, ?>) event.getColumn();
|
||||
if (column == null) {
|
||||
return;
|
||||
}
|
||||
if (column.equals(currentlySortedColumn)) {
|
||||
// Default behavior
|
||||
super.onColumnSort(event);
|
||||
} else {
|
||||
// Initial sort; look up which direction we need
|
||||
final Comparator<T> comparator = comparators.get(column);
|
||||
if (comparator == null) {
|
||||
return;
|
||||
}
|
||||
Boolean ascending = defaultSortOrderMap.get(column);
|
||||
if (ascending == null || ascending) {
|
||||
// Default behavior
|
||||
super.onColumnSort(event);
|
||||
} else {
|
||||
// Sort the column descending
|
||||
Collections.sort(getVisibleItems(), new Comparator<T>() {
|
||||
|
||||
public int compare(T o1, T o2) {
|
||||
|
||||
return -comparator.compare(o1, o2);
|
||||
}
|
||||
});
|
||||
// Set the proper arrow in the header
|
||||
getColumnSortList().push(new ColumnSortInfo(column, false));
|
||||
}
|
||||
currentlySortedColumn = column;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// addColumnSortHandler(asyncSortHandler);
|
||||
// columnSortHandler = asyncSortHandler;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a column to the table and sets its sortable state.
|
||||
*
|
||||
* @param column the column
|
||||
* @param headerName the header name
|
||||
* @param sortable the sortable
|
||||
*/
|
||||
public void addColumn(Column<T, ?> column, String headerName, boolean sortable) {
|
||||
|
||||
addColumn(column, headerName);
|
||||
column.setSortable(sortable);
|
||||
if (sortable) {
|
||||
defaultSortOrderMap.put(column, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the column.
|
||||
*
|
||||
* @param column the column
|
||||
* @param headerName the header name
|
||||
*/
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* com.google.gwt.user.cellview.client.AbstractCellTable#addColumn(com.google.
|
||||
* gwt.user.cellview.client.Column, java.lang.String)
|
||||
*/
|
||||
public void addColumn(Column<T, ?> column, String headerName) {
|
||||
|
||||
super.addColumn(column, headerName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a column to the table and sets its sortable state.
|
||||
*
|
||||
* @param column the column
|
||||
* @param header the header
|
||||
* @param sortable the sortable
|
||||
*/
|
||||
public void addColumn(Column<T, ?> column, Header<?> header, boolean sortable) {
|
||||
|
||||
addColumn(column, header);
|
||||
column.setSortable(sortable);
|
||||
if (sortable) {
|
||||
defaultSortOrderMap.put(column, true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the column to sort when the data list is reset using
|
||||
* {@link SortedCellTable#setList(List)}.
|
||||
*
|
||||
* @param column the column
|
||||
*/
|
||||
public void setInitialSortColumn(Column<T, ?> column) {
|
||||
|
||||
initialSortColumn = column;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the comparator used to sort the specified column in ascending order.
|
||||
*
|
||||
* @param column the {@link Column}
|
||||
* @param comparator the {@link Comparator} to use for the {@link Column}
|
||||
*/
|
||||
public void setComparator(Column<T, ?> column, Comparator<T> comparator) {
|
||||
comparators.put(column, comparator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the sort order to use when this column is clicked and it was not
|
||||
* previously sorted.
|
||||
*
|
||||
* @param column the column
|
||||
* @param ascending the ascending
|
||||
*/
|
||||
public void setDefaultSortOrder(Column<T, ?> column, boolean ascending) {
|
||||
|
||||
defaultSortOrderMap.put(column, ascending);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the table's data provider list and sorts the table based on the column
|
||||
* given in {@link SortedCellTable#setInitialSortColumn(Column)}.
|
||||
*
|
||||
* @param list the new list
|
||||
*/
|
||||
public void setList(List<T> list) {
|
||||
|
||||
if (dataProvider instanceof ListDataProvider) {
|
||||
List<T> myData = ((ListDataProvider) dataProvider).getList();
|
||||
myData.clear();
|
||||
if (list != null) {
|
||||
/*
|
||||
* for (T t : list) { dataProvider.getList().add(t); }
|
||||
*/
|
||||
myData.addAll(list);
|
||||
}
|
||||
// Do a first-time sort based on which column was set in
|
||||
// setInitialSortColumn()
|
||||
if (initialSortColumn != null) {
|
||||
Collections.sort(myData, new Comparator<T>() {
|
||||
|
||||
@Override
|
||||
public int compare(T o1, T o2) {
|
||||
|
||||
return (defaultSortOrderMap.get(initialSortColumn) ? 1 : -1)
|
||||
* comparators.get(initialSortColumn).compare(o1, o2);
|
||||
}
|
||||
});
|
||||
// Might as well get the little arrow on the header to make it
|
||||
// official
|
||||
getColumnSortList().push(new ColumnSortInfo(initialSortColumn, defaultSortOrderMap.get(initialSortColumn)));
|
||||
|
||||
currentlySortedColumn = initialSortColumn;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the data provider.
|
||||
*
|
||||
* @return the data provider
|
||||
*/
|
||||
public AbstractDataProvider<T> getDataProvider() {
|
||||
|
||||
return dataProvider;
|
||||
}
|
||||
}
|
|
@ -14,14 +14,17 @@ import org.gcube.application.geoportal.common.model.legacy.report.ValidationRepo
|
|||
import org.gcube.application.geoportal.common.rest.AddSectionToConcessioneRequest;
|
||||
import org.gcube.application.geoportal.common.rest.MongoConcessioni;
|
||||
import org.gcube.application.geoportal.common.rest.TempFile;
|
||||
import org.gcube.application.geoportalcommon.ConvertToDataViewModel;
|
||||
import org.gcube.application.geoportalcommon.GeoportalCommon;
|
||||
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
|
||||
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.ConcessioniFormCardTitle;
|
||||
import org.gcube.portlets.user.geoportaldataentry.client.GeoportalDataEntryService;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.CommitReport.STATE;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.GeonaISConfig;
|
||||
import org.gcube.portlets.user.geoportaldataentry.shared.SearchedData;
|
||||
import org.gcube.portlets.widgets.mpformbuilder.shared.GenericDatasetBean;
|
||||
import org.gcube.portlets.widgets.mpformbuilder.shared.upload.FileUploaded;
|
||||
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
||||
|
@ -393,50 +396,83 @@ public class GeoportalDataEntryServiceImpl extends RemoteServiceServlet implemen
|
|||
|
||||
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
|
||||
GeoportalCommon gc = new GeoportalCommon();
|
||||
GeoNaItemRef item = new GeoNaItemRef(itemId, recordType);
|
||||
GeoNaItemRef item = new GeoNaItemRef(itemId, recordType.toLowerCase());
|
||||
item = gc.getPublicLinksFor(item);
|
||||
LOG.info("Returning: " + item);
|
||||
return item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the links for.
|
||||
* Gets the list concessioni.
|
||||
*
|
||||
* @param itemId the item id
|
||||
* @param recordType the record type
|
||||
* @return the links for
|
||||
* @param start the start
|
||||
* @param offset the offset
|
||||
* @return the list concessioni
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
// @Override
|
||||
public void getListConcessioni(Integer start, Integer offset) throws Exception {
|
||||
LOG.info("getListConcessioni called");
|
||||
@Override
|
||||
public SearchedData getListConcessioni(Integer start, Integer limit) throws Exception {
|
||||
LOG.info("getListConcessioni called wit start: "+start + ", limit: "+limit);
|
||||
|
||||
try {
|
||||
List<Concessione> listOfConcessioni = SessionUtil.getListOfConcessioni(getThreadLocalRequest());
|
||||
int maxOffset = listOfConcessioni.size();
|
||||
int listConcessioniSize = listOfConcessioni.size();
|
||||
|
||||
List<Concessione> toReturn = new ArrayList<Concessione>();
|
||||
if(start==null && offset==null) {
|
||||
int startIndex;
|
||||
int limitIndex = 0;
|
||||
if (start == null && limit == null) {
|
||||
toReturn.addAll(listOfConcessioni);
|
||||
}
|
||||
if(start<0)
|
||||
start=0;
|
||||
|
||||
if(offset>maxOffset)
|
||||
offset = maxOffset;
|
||||
|
||||
toReturn.subList(start, offset);
|
||||
|
||||
for (Concessione concessione : toReturn) {
|
||||
startIndex = 0;
|
||||
limitIndex = listConcessioniSize;
|
||||
}else {
|
||||
// if (start < 0)
|
||||
// start = 0;
|
||||
//
|
||||
// if (start > listConcessioniSize)
|
||||
// start = listConcessioniSize;
|
||||
//
|
||||
// if (limit > listConcessioniSize)
|
||||
// limit = listConcessioniSize;
|
||||
|
||||
startIndex = start;
|
||||
limitIndex = start + limit;
|
||||
if(limitIndex>listConcessioniSize) {
|
||||
limitIndex = listConcessioniSize;
|
||||
}
|
||||
}
|
||||
// TODO
|
||||
//LOG.info("Returning: " + concessioni);
|
||||
}catch (Exception e) {
|
||||
|
||||
SearchedData searchedData = new SearchedData(start, limit, startIndex, false);
|
||||
searchedData.setTotalItems(listConcessioniSize);
|
||||
|
||||
|
||||
toReturn = listOfConcessioni.subList(startIndex, limitIndex);
|
||||
|
||||
List<ConcessioneDV> toReturnList = new ArrayList<ConcessioneDV>(toReturn.size());
|
||||
|
||||
for (Concessione concessione : toReturn) {
|
||||
ConcessioneDV concessioneDV = ConvertToDataViewModel.toBaseConcessione(concessione);
|
||||
toReturnList.add(concessioneDV);
|
||||
}
|
||||
|
||||
searchedData.setData(toReturnList);
|
||||
|
||||
if (listConcessioniSize == limit || listConcessioniSize == 0) {
|
||||
LOG.debug("Page completed returning " + listConcessioniSize + " items");
|
||||
int newOffset = startIndex + start;
|
||||
searchedData.setServerSearchFinished(newOffset > listConcessioniSize || listConcessioniSize == 0);
|
||||
LOG.debug("is Search finished: " + searchedData.isServerSearchFinished());
|
||||
return searchedData;
|
||||
}
|
||||
|
||||
LOG.debug("Returning: " + toReturnList);
|
||||
LOG.info("Returning list of concessioni with size: " + toReturnList.size());
|
||||
return searchedData;
|
||||
} catch (Exception e) {
|
||||
LOG.error("Error on loading list of concessioni: ", e);
|
||||
throw new Exception("Error occurred on loading list of Concessioni. Error: " + e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
package org.gcube.portlets.user.geoportaldataentry.server;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
@ -130,24 +131,27 @@ public class SessionUtil {
|
|||
public static List<Concessione> getListOfConcessioni(HttpServletRequest httpServletRequest) throws Exception {
|
||||
HttpSession session = httpServletRequest.getSession();
|
||||
List<Concessione> listOfConcessioni = (List<Concessione>) session.getAttribute(LIST_OF_CONCESSIONI);
|
||||
List<Concessione> result = new ArrayList<Concessione>();
|
||||
|
||||
if (listOfConcessioni == null) {
|
||||
listOfConcessioni = new ArrayList<Concessione>();
|
||||
LOG.info("Loading list of concessione from client mongo");
|
||||
SessionUtil.getCurrentContext(httpServletRequest, true);
|
||||
ServiceUtil serviceUtil = new ServiceUtil();
|
||||
MongoConcessioni clientMongo = serviceUtil.getInstanceMongoConcessioni();
|
||||
Iterable<Concessione> concessioni = clientMongo.getList();
|
||||
Iterator<Concessione> concessioni = clientMongo.getList();
|
||||
if (concessioni != null) {
|
||||
for (Concessione conc : concessioni) {
|
||||
result.add(conc);
|
||||
while (concessioni.hasNext()) {
|
||||
Concessione concessione = (Concessione) concessioni.next();
|
||||
listOfConcessioni.add(concessione);
|
||||
|
||||
}
|
||||
}
|
||||
LOG.debug("Got list of concessione from client mongo: "+result);
|
||||
session.setAttribute(LIST_OF_CONCESSIONI, result);
|
||||
LOG.info("Saved in session list of concessione from client mongo with size: "+result.size());
|
||||
}
|
||||
LOG.info("returning list of concessioni with size: "+result.size());
|
||||
return result;
|
||||
LOG.debug("Got list of concessioni from client mongo: "+listOfConcessioni);
|
||||
session.setAttribute(LIST_OF_CONCESSIONI, listOfConcessioni);
|
||||
LOG.info("Saved in session list of concessioni from client mongo with size: "+listOfConcessioni.size());
|
||||
}else
|
||||
LOG.info("list of concessioni presents in session");
|
||||
|
||||
LOG.info("read list of concessioni with size: "+listOfConcessioni.size());
|
||||
return listOfConcessioni;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,183 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.geoportaldataentry.shared;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
|
||||
|
||||
|
||||
/**
|
||||
* The Class SearchedFolder.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Jun 16, 2021
|
||||
*/
|
||||
public class SearchedData implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 6800997954077785719L;
|
||||
private List<ConcessioneDV> data;
|
||||
private int clientStartIndex = 0;
|
||||
private int limit;
|
||||
private int serverEndIndex = 0;
|
||||
private boolean isServerSearchFinished = false;
|
||||
private long totalItems;
|
||||
|
||||
/**
|
||||
* Instantiates a new searched folder.
|
||||
*/
|
||||
public SearchedData() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new searched data.
|
||||
*
|
||||
* @param clientStartIndex the client start index
|
||||
* @param limit the limit
|
||||
* @param serverEndIndex the server end index
|
||||
* @param isServerSearchFinished the is server search finished
|
||||
*/
|
||||
public SearchedData(int clientStartIndex, int limit, int serverEndIndex, boolean isServerSearchFinished) {
|
||||
|
||||
this.clientStartIndex = clientStartIndex;
|
||||
this.limit = limit;
|
||||
this.serverEndIndex = serverEndIndex;
|
||||
this.isServerSearchFinished = isServerSearchFinished;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the data.
|
||||
*
|
||||
* @return the data
|
||||
*/
|
||||
public List<ConcessioneDV> getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the client start index.
|
||||
*
|
||||
* @return the client start index
|
||||
*/
|
||||
public int getClientStartIndex() {
|
||||
return clientStartIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the limit.
|
||||
*
|
||||
* @return the limit
|
||||
*/
|
||||
public int getLimit() {
|
||||
return limit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the server end index.
|
||||
*
|
||||
* @return the server end index
|
||||
*/
|
||||
public int getServerEndIndex() {
|
||||
return serverEndIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is server search finished.
|
||||
*
|
||||
* @return true, if is server search finished
|
||||
*/
|
||||
public boolean isServerSearchFinished() {
|
||||
return isServerSearchFinished;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the data.
|
||||
*
|
||||
* @param data the new data
|
||||
*/
|
||||
public void setData(List<ConcessioneDV> data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the client start index.
|
||||
*
|
||||
* @param clientStartIndex the new client start index
|
||||
*/
|
||||
public void setClientStartIndex(int clientStartIndex) {
|
||||
this.clientStartIndex = clientStartIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the limit.
|
||||
*
|
||||
* @param limit the new limit
|
||||
*/
|
||||
public void setLimit(int limit) {
|
||||
this.limit = limit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the server end index.
|
||||
*
|
||||
* @param serverEndIndex the new server end index
|
||||
*/
|
||||
public void setServerEndIndex(int serverEndIndex) {
|
||||
this.serverEndIndex = serverEndIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the server search finished.
|
||||
*
|
||||
* @param isServerSearchFinished the new server search finished
|
||||
*/
|
||||
public void setServerSearchFinished(boolean isServerSearchFinished) {
|
||||
this.isServerSearchFinished = isServerSearchFinished;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the total items.
|
||||
*
|
||||
* @return the total items
|
||||
*/
|
||||
public long getTotalItems() {
|
||||
return totalItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the total items.
|
||||
*
|
||||
* @param totalItems the new total items
|
||||
*/
|
||||
public void setTotalItems(long totalItems) {
|
||||
this.totalItems = totalItems;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("SearchedData [data=");
|
||||
builder.append(data);
|
||||
builder.append(", clientStartIndex=");
|
||||
builder.append(clientStartIndex);
|
||||
builder.append(", limit=");
|
||||
builder.append(limit);
|
||||
builder.append(", serverEndIndex=");
|
||||
builder.append(serverEndIndex);
|
||||
builder.append(", isServerSearchFinished=");
|
||||
builder.append(isServerSearchFinished);
|
||||
builder.append(", totalItems=");
|
||||
builder.append(totalItems);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,31 +1,58 @@
|
|||
package org.gcube.portlets.user.geoportaldataentry.client;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import static org.gcube.application.geoportal.client.GeoportalAbstractPlugin.mongoConcessioni;
|
||||
|
||||
import org.gcube.portlets.user.geoportaldataentry.server.ConvertToServiceModel;
|
||||
import org.gcube.portlets.user.geoportaldataentry.server.GeoportalDataEntryServiceImpl;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.application.geoportal.common.model.legacy.Concessione;
|
||||
import org.gcube.application.geoportal.common.rest.MongoConcessioni;
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
|
||||
public class TestClass {
|
||||
|
||||
|
||||
private static String TOKEN = "";
|
||||
private static String CONTEXT ="/gcube/devsec/devVRE";
|
||||
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
ScopeProvider.instance.set(CONTEXT);
|
||||
SecurityTokenProvider.instance.set(TOKEN);
|
||||
|
||||
LocalDateTime ldt = ConvertToServiceModel.toLocalDateTime("2020-10-01 10:20");
|
||||
System.out.println(ldt.toString());
|
||||
|
||||
String latitudine = "-899.2986";
|
||||
//System.out.println(latitudine.matches("^[-]?(180(\\.0+)?|((1[0-7]\\d)|([1-9]?\\d))(\\.\\d+)?)$"));
|
||||
|
||||
|
||||
String longitude = "0";
|
||||
System.out.println(longitude.matches("\\s*[-+]?(180(\\.0+)?|((1[0-7]\\d)|([1-9]?\\d))(\\.\\d+)?)$"));
|
||||
|
||||
// LocalDateTime ldt = ConvertToServiceModel.toLocalDateTime("2020-10-01 10:20");
|
||||
// System.out.println(ldt.toString());
|
||||
//
|
||||
// String latitudine = "-899.2986";
|
||||
// // System.out.println(latitudine.matches("^[-]?(180(\\.0+)?|((1[0-7]\\d)|([1-9]?\\d))(\\.\\d+)?)$"));
|
||||
//
|
||||
// String longitude = "0";
|
||||
// System.out.println(longitude.matches("\\s*[-+]?(180(\\.0+)?|((1[0-7]\\d)|([1-9]?\\d))(\\.\\d+)?)$"));
|
||||
//
|
||||
// GeoportalDataEntryServiceImpl g = new GeoportalDataEntryServiceImpl();
|
||||
// g.getLinksFor("", ConstantsGeoPortalDataEntryApp.RECORD_TYPE.CONCESSIONE.toString());
|
||||
|
||||
getListOfConcessioni();
|
||||
|
||||
GeoportalDataEntryServiceImpl g = new GeoportalDataEntryServiceImpl();
|
||||
g.getLinksFor("", "concessione");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void getListOfConcessioni() throws Exception {
|
||||
MongoConcessioni clientMongo = mongoConcessioni().build();
|
||||
Iterator<Concessione> concessioni = clientMongo.getList();
|
||||
List<Concessione> listOfConcessioni = new ArrayList<Concessione>();
|
||||
if (concessioni != null) {
|
||||
while (concessioni.hasNext()) {
|
||||
Concessione concessione = (Concessione) concessioni.next();
|
||||
listOfConcessioni.add(concessione);
|
||||
|
||||
}
|
||||
}
|
||||
int i = 0;
|
||||
for (Concessione concessione : listOfConcessioni) {
|
||||
System.out.println(++i+" "+concessione);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue