added a timer to display the popup

This commit is contained in:
Francesco Mangiacrapa 2020-12-02 18:48:12 +01:00
parent 34ebb8d648
commit f3f98ee632
1 changed files with 68 additions and 15 deletions

View File

@ -27,6 +27,7 @@ import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.event.logical.shared.ResizeEvent;
import com.google.gwt.event.logical.shared.ResizeHandler;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.RootPanel;
@ -73,6 +74,8 @@ public class GeoportalDataViewer implements EntryPoint {
private OLMapManager olMapMng = null;
int attempt = 0;
//https://data.d4science.org/gis-viewer-app/?wmsrequest=https%3A%2F%2Fgeona-proto.d4science.org%2Fgeoserver%2Fconcessioni_conf%2Fwms%3Fservice%3DWMS%26version%3D1.1.0%26request%3DGetMap%26layers%3Dconcessioni_conf%3Acentroids_concessioni%26styles%3D%26bbox%3D8.476%2C39.179%2C17.391%2C45.772%26width%3D768%26height%3D567%26srs%3DEPSG%3A4326%26format%3Dapplication%2Fopenlayers&zoom=6&centermap=12.45%2C42.98
@ -235,8 +238,6 @@ public class GeoportalDataViewer implements EntryPoint {
mainPanel.showAsDetails(concessioneDV, showDetailsEvent.getGeonaItemRef());
}
});
}
}
}
@ -250,22 +251,56 @@ public class GeoportalDataViewer implements EntryPoint {
GWT.log("Fired AddedLayerToMapEvent "+addedLayerToMapEvent.getLayerItem());
GeoportalDataViewerConstants.print("Fired AddedLayerToMapEvent "+addedLayerToMapEvent.getLayerItem());
//the parameter gid has been passed in the query string
if(paramGeonaItemID!=null && mainPanel.getDisplyedRecord()!=null) {
RecordDV record = mainPanel.getDisplyedRecord();
GWT.log("record instanceof ConcessioneDV: " +(record instanceof ConcessioneDV));
GeoportalDataViewerConstants.print("record instanceof ConcessioneDV: " +(record instanceof ConcessioneDV));
if(record instanceof ConcessioneDV) {
ConcessioneDV concessioneDV = (ConcessioneDV) record;
Double x = concessioneDV.getCentroidLong();
Double y = concessioneDV.getCentroidLat();
Coordinate transfCoord = MapUtils.transformCoordiante(new Coordinate(x, y), GeoportalDataViewerConstants.EPSG_4326, GeoportalDataViewerConstants.EPSG_3857);
GeoQuery select = olMapMng.toDataPointQuery(transfCoord);
GeoportalDataViewerConstants.print("fireEvent QueryDataEvent");
layerManager.getLayerManagerBus().fireEvent(new QueryDataEvent(select, transfCoord, record.getId()));
try {
attempt = 0;
if(paramGeonaItemID!=null) {
//waiting for record retrieved by service before calling the WFS
final int MAX_RETRY = 7;
Timer timer = new com.google.gwt.user.client.Timer() {
@Override
public void run() {
attempt++;
GWT.log("waiting got record tenative: "+attempt);
RecordDV record = mainPanel.getDisplyedRecord();
if(record!=null) {
this.cancel();
GWT.log("cancelled timer");
performWFS();
}
if(attempt>MAX_RETRY) {
GWT.log("cancelled timer");
this.cancel();
}
}
};
timer.scheduleRepeating(1000);
}
}catch (Exception e) {
// TODO: handle exception
}
// //the parameter gid has been passed in the query string
// if(paramGeonaItemID!=null && mainPanel.getDisplyedRecord()!=null) {
// RecordDV record = mainPanel.getDisplyedRecord();
// GWT.log("record instanceof ConcessioneDV: " +(record instanceof ConcessioneDV));
// GeoportalDataViewerConstants.print("record instanceof ConcessioneDV: " +(record instanceof ConcessioneDV));
// if(record instanceof ConcessioneDV) {
// ConcessioneDV concessioneDV = (ConcessioneDV) record;
// Double x = concessioneDV.getCentroidLong();
// Double y = concessioneDV.getCentroidLat();
// Coordinate transfCoord = MapUtils.transformCoordiante(new Coordinate(x, y), GeoportalDataViewerConstants.EPSG_4326, GeoportalDataViewerConstants.EPSG_3857);
// GeoQuery select = olMapMng.toDataPointQuery(transfCoord);
// GeoportalDataViewerConstants.print("fireEvent QueryDataEvent");
// layerManager.getLayerManagerBus().fireEvent(new QueryDataEvent(select, transfCoord, record.getId()));
// }
// }
}
});
@ -290,5 +325,23 @@ public class GeoportalDataViewer implements EntryPoint {
});
}
private void performWFS() {
//the parameter gid has been passed in the query string
if(mainPanel.getDisplyedRecord()!=null) {
RecordDV record = mainPanel.getDisplyedRecord();
GWT.log("record instanceof ConcessioneDV: " +(record instanceof ConcessioneDV));
GeoportalDataViewerConstants.print("record instanceof ConcessioneDV: " +(record instanceof ConcessioneDV));
if(record instanceof ConcessioneDV) {
ConcessioneDV concessioneDV = (ConcessioneDV) record;
Double x = concessioneDV.getCentroidLong();
Double y = concessioneDV.getCentroidLat();
Coordinate transfCoord = MapUtils.transformCoordiante(new Coordinate(x, y), GeoportalDataViewerConstants.EPSG_4326, GeoportalDataViewerConstants.EPSG_3857);
GeoQuery select = olMapMng.toDataPointQuery(transfCoord);
GeoportalDataViewerConstants.print("fireEvent QueryDataEvent");
layerManager.getLayerManagerBus().fireEvent(new QueryDataEvent(select, transfCoord, record.getId()));
}
}
}
}