diff --git a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java index cc6f6b8..e844663 100644 --- a/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java +++ b/src/main/java/org/gcube/portlets/user/geoportaldataviewer/client/GeoportalDataViewer.java @@ -88,109 +88,109 @@ public class GeoportalDataViewer implements EntryPoint { mainPanel = new GeonaDataViewMainPanel(applicationBus, getClientHeight()); RootPanel.get(APP_DIV).add(mainPanel); - - Timer t = new Timer() { - + + Scheduler.get().scheduleDeferred(new ScheduledCommand() { + @Override - public void run() { - Scheduler.get().scheduleDeferred(new ScheduledCommand() { + public void execute() { - @Override - public void execute() { - - olMapMng = new OLMapManager(mainPanel.getMapPanel().getElement().getId(),layerManager.getLayerManagerBus()); - layerManager.setOlMap(olMapMng.getOLOSMMap()); - mainPanel.setMap(olMapMng.getOLOSMMap()); - updateSize(); - ScriptInjector.fromUrl("//cdn.jsdelivr.net/npm/nanogallery2@3/dist/jquery.nanogallery2.min.js") + olMapMng = new OLMapManager(mainPanel.getMapPanel().getElement().getId(), + layerManager.getLayerManagerBus()); + layerManager.setOlMap(olMapMng.getOLOSMMap()); + mainPanel.setMap(olMapMng.getOLOSMMap()); + updateSize(); + ScriptInjector.fromUrl("//cdnjs.cloudflare.com/ajax/libs/nanogallery2/3.0.5/jquery.nanogallery2.min.js") .setWindow(ScriptInjector.TOP_WINDOW).inject(); - } - }); + } + }); - Window.addResizeHandler(new ResizeHandler() { - @Override - public void onResize(ResizeEvent event) { - updateSize(); - } - }); + Window.addResizeHandler(new ResizeHandler() { + @Override + public void onResize(ResizeEvent event) { + updateSize(); + } + }); - paramWmsRequest = Window.Location.getParameter(GeoportalDataViewerConstants.GET_WMS_PARAMETER); - paramGeonaItemType = Window.Location.getParameter(GeoportalDataViewerConstants.GET_GEONA_ITEM_TYPE); - //paramUUID = Window.Location.getParameter(GeoportalDataViewerConstants.GET_UUID_PARAMETER); - paramGeonaItemID = Window.Location.getParameter(GeoportalDataViewerConstants.GET_GEONA_ITEM_ID); - paramLayerTitle = Window.Location.getParameter(GeoportalDataViewerConstants.GET_LAYER_TITLE); - GWT.log(GeoportalDataViewerConstants.GET_WMS_PARAMETER + " = " + paramWmsRequest); - GWT.log(GeoportalDataViewerConstants.GET_GEONA_ITEM_TYPE + " = " + paramGeonaItemType); - GWT.log(GeoportalDataViewerConstants.GET_GEONA_ITEM_ID + " = " + paramGeonaItemID); - //GWT.log(GeoportalDataViewerConstants.GET_UUID_PARAMETER + " = " + paramUUID); - GWT.log(GeoportalDataViewerConstants.GET_LAYER_TITLE + " = " + paramLayerTitle); - - //VALIDATING THE LONG FORMAT FOR GID - try { - if(paramGeonaItemID!=null) - Long.parseLong(paramGeonaItemID); - }catch (Exception e) { - Window.alert("Bad format for parameter "+GeoportalDataViewerConstants.GET_GEONA_ITEM_ID+". It must be a Long"); - paramGeonaItemID = null; - } - - Scheduler.get().scheduleDeferred(new ScheduledCommand() { + paramWmsRequest = Window.Location.getParameter(GeoportalDataViewerConstants.GET_WMS_PARAMETER); + paramGeonaItemType = Window.Location.getParameter(GeoportalDataViewerConstants.GET_GEONA_ITEM_TYPE); + // paramUUID = + // Window.Location.getParameter(GeoportalDataViewerConstants.GET_UUID_PARAMETER); + paramGeonaItemID = Window.Location.getParameter(GeoportalDataViewerConstants.GET_GEONA_ITEM_ID); + paramLayerTitle = Window.Location.getParameter(GeoportalDataViewerConstants.GET_LAYER_TITLE); + GWT.log(GeoportalDataViewerConstants.GET_WMS_PARAMETER + " = " + paramWmsRequest); + GWT.log(GeoportalDataViewerConstants.GET_GEONA_ITEM_TYPE + " = " + paramGeonaItemType); + GWT.log(GeoportalDataViewerConstants.GET_GEONA_ITEM_ID + " = " + paramGeonaItemID); + // GWT.log(GeoportalDataViewerConstants.GET_UUID_PARAMETER + " = " + paramUUID); + GWT.log(GeoportalDataViewerConstants.GET_LAYER_TITLE + " = " + paramLayerTitle); - @Override - public void execute() { - GeoportalDataViewerServiceAsync.Util.getInstance().getGeoNaDataViewProfile(new AsyncCallback() { + // VALIDATING THE LONG FORMAT FOR GID + try { + if (paramGeonaItemID != null) + Long.parseLong(paramGeonaItemID); + } catch (Exception e) { + Window.alert("Bad format for parameter " + GeoportalDataViewerConstants.GET_GEONA_ITEM_ID + + ". It must be a Long"); + paramGeonaItemID = null; + } + + Scheduler.get().scheduleDeferred(new ScheduledCommand() { + + @Override + public void execute() { + GeoportalDataViewerServiceAsync.Util.getInstance() + .getGeoNaDataViewProfile(new AsyncCallback() { @Override public void onFailure(Throwable caught) { Window.alert(caught.getMessage()); - + } @Override public void onSuccess(GeoNaDataViewerProfile profile) { geonaDataViewerProfile = profile; - GWT.log("Profile: "+geonaDataViewerProfile); + GWT.log("Profile: " + geonaDataViewerProfile); Iterator it; String theItemType = paramGeonaItemType; - if(theItemType==null) { + if (theItemType == null) { it = geonaDataViewerProfile.getMapLayers().keySet().iterator(); it.hasNext(); - theItemType= it.next(); + theItemType = it.next(); } - + LayerItem layerItem = geonaDataViewerProfile.getMapLayers().get(theItemType); - - if(layerItem==null) { - Window.alert("Not detected any layer with type: "+theItemType); + + if (layerItem == null) { + Window.alert("Not detected any layer with type: " + theItemType); return; } - - GWT.log("The layerItem is: "+layerItem); - layerManager.addLayer(theItemType, null, null, layerItem.getWmsLink(), false, false, null, true); - - if(paramGeonaItemID!=null) { - if(paramGeonaItemType==null) { - Window.alert("Missing parameter "+GeoportalDataViewerConstants.GET_GEONA_ITEM_TYPE +" (GeoNa Data Type) where to search the item id: "+paramGeonaItemID); + + GWT.log("The layerItem is: " + layerItem); + layerManager.addLayer(theItemType, null, null, layerItem.getWmsLink(), false, false, + null, true); + + if (paramGeonaItemID != null) { + if (paramGeonaItemType == null) { + Window.alert( + "Missing parameter " + GeoportalDataViewerConstants.GET_GEONA_ITEM_TYPE + + " (GeoNa Data Type) where to search the item id: " + + paramGeonaItemID); return; } GeoNaItemRef gir = new GeoNaItemRef(new Long(paramGeonaItemID), paramGeonaItemType); applicationBus.fireEvent(new ShowDetailsEvent(gir, null, null)); } - + } }); - } - }); - - bindEvents(); - } - }; - - t.schedule(3000); + }); + bindEvents(); } + + /** * Update window size. diff --git a/src/main/webapp/GeoportalDataViewer.html b/src/main/webapp/GeoportalDataViewer.html index de8e1b3..3452035 100644 --- a/src/main/webapp/GeoportalDataViewer.html +++ b/src/main/webapp/GeoportalDataViewer.html @@ -22,7 +22,7 @@ type="text/javascript"> diff --git a/src/main/webapp/WEB-INF/jsp/GeoPortalDataViewerAppPortlet_view.jsp b/src/main/webapp/WEB-INF/jsp/GeoPortalDataViewerAppPortlet_view.jsp index c2eb463..9242ff9 100644 --- a/src/main/webapp/WEB-INF/jsp/GeoPortalDataViewerAppPortlet_view.jsp +++ b/src/main/webapp/WEB-INF/jsp/GeoPortalDataViewerAppPortlet_view.jsp @@ -29,4 +29,8 @@ + +
\ No newline at end of file