to debug
This commit is contained in:
parent
8564db4079
commit
6119f81969
|
@ -143,182 +143,187 @@ public class LayerManager {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(List<GeoNaSpatialQueryResult> listGeonaDataObjects) {
|
public void onSuccess(List<GeoNaSpatialQueryResult> listGeonaDataObjects) {
|
||||||
|
|
||||||
try {
|
GWT.log("GeoNaDataObject's: "+listGeonaDataObjects);
|
||||||
|
GeoportalDataViewerConstants.print("GeoNaDataObject's: "+listGeonaDataObjects);
|
||||||
|
|
||||||
GWT.log("GeoNaDataObject's: "+listGeonaDataObjects);
|
if(listGeonaDataObjects==null || listGeonaDataObjects.isEmpty())
|
||||||
GeoportalDataViewerConstants.print("GeoNaDataObject's: "+listGeonaDataObjects);
|
return;
|
||||||
|
|
||||||
if(listGeonaDataObjects==null || listGeonaDataObjects.isEmpty())
|
FlexTable flex = new FlexTable();
|
||||||
return;
|
flex.setCellPadding(1);
|
||||||
|
flex.setCellSpacing(1);
|
||||||
FlexTable flex = new FlexTable();
|
flex.getElement().addClassName("popup-table");
|
||||||
flex.setCellPadding(1);
|
boolean featureFound = false;
|
||||||
flex.setCellSpacing(1);
|
FeatureRow feature = null;
|
||||||
flex.getElement().addClassName("popup-table");
|
|
||||||
boolean featureFound = false;
|
//TODO SWTCH FOR EARCH ITEM TYPE
|
||||||
FeatureRow feature = null;
|
for (GeoNaSpatialQueryResult geoNaDataObject : listGeonaDataObjects) {
|
||||||
|
List<FeatureRow> features = geoNaDataObject.getFeatures();
|
||||||
//TODO SWTCH FOR EARCH ITEM TYPE
|
|
||||||
for (GeoNaSpatialQueryResult geoNaDataObject : listGeonaDataObjects) {
|
//USING ONLY THE FIRST FEATURE IN THE LIST
|
||||||
List<FeatureRow> features = geoNaDataObject.getFeatures();
|
if(features!=null && features.size()>0) {
|
||||||
|
feature = features.get(0);
|
||||||
//USING ONLY THE FIRST FEATURE IN THE LIST
|
Map<String, List<String>> entries = feature.getMapProperties();
|
||||||
if(features!=null && features.size()>0) {
|
|
||||||
feature = features.get(0);
|
String nome = "";
|
||||||
Map<String, List<String>> entries = feature.getMapProperties();
|
String descrizione = "";
|
||||||
|
String date = "";
|
||||||
for (String key : entries.keySet()) {
|
|
||||||
String theValue = entries.get(key).get(0);
|
for (String key : entries.keySet()) {
|
||||||
if(key.equalsIgnoreCase("nome")) {
|
String theValue = entries.get(key).get(0);
|
||||||
flex.setHTML(0, 0, new HTML(theValue).toString());
|
if(key.equalsIgnoreCase("nome")) {
|
||||||
}
|
nome = theValue!=null?theValue:"";
|
||||||
else if(key.equalsIgnoreCase("descrizione")) {
|
|
||||||
String reducedValue = theValue;
|
|
||||||
try {
|
|
||||||
reducedValue = StringUtil.ellipsize(theValue, 300);
|
|
||||||
GWT.log("reduced: "+reducedValue);
|
|
||||||
} catch (Exception e) {
|
|
||||||
GWT.log("error: "+e.getMessage());
|
|
||||||
}
|
|
||||||
flex.setText(1, 0, reducedValue);
|
|
||||||
}else if(key.equalsIgnoreCase("date_scavo")) {
|
|
||||||
flex.setHTML(2, 0, new HTML("<code>"+theValue+"</code>").toString());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else if(key.equalsIgnoreCase("descrizione")) {
|
||||||
/*Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
descrizione = theValue!=null?theValue:"";
|
||||||
|
}else if(key.equalsIgnoreCase("date_scavo")) {
|
||||||
@Override
|
date = theValue!=null?theValue:"";
|
||||||
public void execute() {
|
|
||||||
List<String> listConcessioni = entries.get("product_id");
|
|
||||||
if(listConcessioni!=null && listConcessioni.size()>0) {
|
|
||||||
String concessioneId = listConcessioni.get(0);
|
|
||||||
try {
|
|
||||||
Long theConcessioneId = Long.parseLong(concessioneId);
|
|
||||||
GeoportalDataViewerServiceAsync.Util.getInstance().getUploadedImagesForId("Concessione", theConcessioneId, 1, new AsyncCallback<List<UploadedImageDV>>() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(Throwable caught) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSuccess(List<UploadedImageDV> result) {
|
|
||||||
GWT.log("Loaded images: "+result);
|
|
||||||
|
|
||||||
for (UploadedImageDV img : result) {
|
|
||||||
if(img.getListWsContent()!=null) {
|
|
||||||
WorkspaceContentDV wsContent = img.getListWsContent().get(img.getListWsContent().size()-1);
|
|
||||||
String theImgHTML = "<img src=\""+wsContent.getLink()+"\"></img>";
|
|
||||||
GWT.log("theImgHTML: "+theImgHTML);
|
|
||||||
flex.setHTML(flex.getRowCount()+1, 0, theImgHTML);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}catch (Exception e) {
|
|
||||||
// TODO: handle exception
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
});*/
|
|
||||||
|
|
||||||
|
|
||||||
if(geoNaDataObject.getMapImages()!=null) {
|
|
||||||
for (Long key : geoNaDataObject.getMapImages().keySet()) {
|
|
||||||
List<UploadedImageDV> listUI = geoNaDataObject.getMapImages().get(key);
|
|
||||||
GWT.log("Adding images: "+listUI);
|
|
||||||
if(listUI!=null) {
|
|
||||||
UploadedImageDV img = listUI.get(0);
|
|
||||||
if(img.getListWsContent()!=null) {
|
|
||||||
WorkspaceContentDV wsContent = img.getListWsContent().get(img.getListWsContent().size()-1);
|
|
||||||
String theImgHTML = "<img src=\""+wsContent.getLink()+"\"></img>";
|
|
||||||
GWT.log("theImgHTML: "+theImgHTML);
|
|
||||||
GeoportalDataViewerConstants.print("The row are: "+flex.getRowCount());
|
|
||||||
flex.setHTML(flex.getRowCount()+1, 0, theImgHTML);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
featureFound = true;
|
|
||||||
//break; //Only the first one
|
|
||||||
}
|
|
||||||
|
|
||||||
if(feature==null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
GWT.log("The selected Feature is: "+feature);
|
|
||||||
GeoportalDataViewerConstants.print("The selected Feature is: "+feature);
|
|
||||||
FeatureRow theFeature = feature;
|
|
||||||
Button button = null;
|
|
||||||
if(!featureFound) {
|
|
||||||
flex.setHTML(0, 0, new HTML("No data available").toString());
|
|
||||||
}else {
|
|
||||||
button = new Button("Open Details");
|
|
||||||
button.getElement().setId("open-details");
|
|
||||||
button.setType(ButtonType.LINK);
|
|
||||||
}
|
|
||||||
|
|
||||||
VerticalPanel vpPanel = new VerticalPanel();
|
|
||||||
vpPanel.add(flex);
|
|
||||||
|
|
||||||
if(button!=null) {
|
|
||||||
vpPanel.add(button);
|
|
||||||
button.setType(ButtonType.LINK);
|
|
||||||
button.addClickHandler(new ClickHandler() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onClick(ClickEvent event) {
|
|
||||||
ShowDetailsEvent toEvent = parseGeonaReferences(geoNaDataObject.getSourceLayerObject().getItemType(), theFeature);
|
|
||||||
applicationBus.fireEvent(toEvent);
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
Coordinate centerTo = null;
|
|
||||||
|
|
||||||
if(feature.getGeometry()!=null) {
|
|
||||||
|
|
||||||
PointsPath path = feature.getGeometry().getPath();
|
|
||||||
GWT.log("Points Path: "+path);
|
|
||||||
if(path!=null && path.getCoordinates()!=null && path.getCoordinates().length>0) {
|
|
||||||
org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.Coordinate center = path.getCoordinates()[0];
|
|
||||||
centerTo = new Coordinate(center.getX(), center.getY());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(centerTo==null)
|
GeoportalDataViewerConstants.print("0: "+nome);
|
||||||
centerTo = queryEvent.getoLCoordinate();
|
flex.setHTML(0, 0, new HTML(nome).toString());
|
||||||
|
try {
|
||||||
|
descrizione = StringUtil.ellipsize(descrizione, 100);
|
||||||
|
GWT.log("reduced: "+descrizione);
|
||||||
|
} catch (Exception e) {
|
||||||
|
GWT.log("error: "+e.getMessage());
|
||||||
|
}
|
||||||
|
GeoportalDataViewerConstants.print("1: "+descrizione);
|
||||||
|
flex.setText(1, 0, descrizione);
|
||||||
|
GeoportalDataViewerConstants.print("2: "+date);
|
||||||
|
flex.setHTML(2, 0, new HTML("<code>"+date+"</code>").toString());
|
||||||
|
|
||||||
|
/*Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
||||||
|
|
||||||
olMap.showPopup(vpPanel.toString(), centerTo);
|
|
||||||
|
|
||||||
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
Element buttonElement = DOM.getElementById("open-details");
|
List<String> listConcessioni = entries.get("product_id");
|
||||||
Event.sinkEvents(buttonElement, Event.ONCLICK);
|
if(listConcessioni!=null && listConcessioni.size()>0) {
|
||||||
Event.setEventListener(buttonElement, new EventListener() {
|
String concessioneId = listConcessioni.get(0);
|
||||||
|
try {
|
||||||
@Override
|
Long theConcessioneId = Long.parseLong(concessioneId);
|
||||||
public void onBrowserEvent(Event event) {
|
GeoportalDataViewerServiceAsync.Util.getInstance().getUploadedImagesForId("Concessione", theConcessioneId, 1, new AsyncCallback<List<UploadedImageDV>>() {
|
||||||
if(Event.ONCLICK == event.getTypeInt()) {
|
|
||||||
ShowDetailsEvent toEvent = parseGeonaReferences(geoNaDataObject.getSourceLayerObject().getItemType(), theFeature);
|
@Override
|
||||||
applicationBus.fireEvent(toEvent);
|
public void onFailure(Throwable caught) {
|
||||||
}
|
// TODO Auto-generated method stub
|
||||||
}
|
|
||||||
});
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(List<UploadedImageDV> result) {
|
||||||
|
GWT.log("Loaded images: "+result);
|
||||||
|
|
||||||
|
for (UploadedImageDV img : result) {
|
||||||
|
if(img.getListWsContent()!=null) {
|
||||||
|
WorkspaceContentDV wsContent = img.getListWsContent().get(img.getListWsContent().size()-1);
|
||||||
|
String theImgHTML = "<img src=\""+wsContent.getLink()+"\"></img>";
|
||||||
|
GWT.log("theImgHTML: "+theImgHTML);
|
||||||
|
flex.setHTML(flex.getRowCount()+1, 0, theImgHTML);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}catch (Exception e) {
|
||||||
|
// TODO: handle exception
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});*/
|
||||||
|
|
||||||
|
|
||||||
|
if(geoNaDataObject.getMapImages()!=null) {
|
||||||
|
for (Long key : geoNaDataObject.getMapImages().keySet()) {
|
||||||
|
List<UploadedImageDV> listUI = geoNaDataObject.getMapImages().get(key);
|
||||||
|
GWT.log("Adding images: "+listUI);
|
||||||
|
if(listUI!=null) {
|
||||||
|
UploadedImageDV img = listUI.get(0);
|
||||||
|
if(img.getListWsContent()!=null) {
|
||||||
|
WorkspaceContentDV wsContent = img.getListWsContent().get(img.getListWsContent().size()-1);
|
||||||
|
String theImgHTML = "<img src=\""+wsContent.getLink()+"\"></img>";
|
||||||
|
GWT.log("theImgHTML: "+theImgHTML);
|
||||||
|
GeoportalDataViewerConstants.print("The row are: "+flex.getRowCount());
|
||||||
|
flex.setHTML(flex.getRowCount()+1, 0, theImgHTML);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
featureFound = true;
|
||||||
|
//break; //Only the first one
|
||||||
|
}
|
||||||
|
|
||||||
|
if(feature==null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
GWT.log("The selected Feature is: "+feature);
|
||||||
|
GeoportalDataViewerConstants.print("The selected Feature is: "+feature);
|
||||||
|
FeatureRow theFeature = feature;
|
||||||
|
Button button = null;
|
||||||
|
if(!featureFound) {
|
||||||
|
flex.setHTML(0, 0, new HTML("No data available").toString());
|
||||||
|
}else {
|
||||||
|
button = new Button("Open Details");
|
||||||
|
button.getElement().setId("open-details");
|
||||||
|
button.setType(ButtonType.LINK);
|
||||||
|
}
|
||||||
|
|
||||||
|
VerticalPanel vpPanel = new VerticalPanel();
|
||||||
|
vpPanel.add(flex);
|
||||||
|
|
||||||
|
if(button!=null) {
|
||||||
|
vpPanel.add(button);
|
||||||
|
button.setType(ButtonType.LINK);
|
||||||
|
button.addClickHandler(new ClickHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(ClickEvent event) {
|
||||||
|
ShowDetailsEvent toEvent = parseGeonaReferences(geoNaDataObject.getSourceLayerObject().getItemType(), theFeature);
|
||||||
|
applicationBus.fireEvent(toEvent);
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}catch (Exception e) {
|
|
||||||
GeoportalDataViewerConstants.print(e.getMessage());
|
Coordinate centerTo = null;
|
||||||
|
|
||||||
|
if(feature.getGeometry()!=null) {
|
||||||
|
|
||||||
|
PointsPath path = feature.getGeometry().getPath();
|
||||||
|
GWT.log("Points Path: "+path);
|
||||||
|
if(path!=null && path.getCoordinates()!=null && path.getCoordinates().length>0) {
|
||||||
|
org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.Coordinate center = path.getCoordinates()[0];
|
||||||
|
centerTo = new Coordinate(center.getX(), center.getY());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(centerTo==null)
|
||||||
|
centerTo = queryEvent.getoLCoordinate();
|
||||||
|
|
||||||
|
olMap.showPopup(vpPanel.toString(), centerTo);
|
||||||
|
|
||||||
|
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute() {
|
||||||
|
Element buttonElement = DOM.getElementById("open-details");
|
||||||
|
Event.sinkEvents(buttonElement, Event.ONCLICK);
|
||||||
|
Event.setEventListener(buttonElement, new EventListener() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBrowserEvent(Event event) {
|
||||||
|
if(Event.ONCLICK == event.getTypeInt()) {
|
||||||
|
ShowDetailsEvent toEvent = parseGeonaReferences(geoNaDataObject.getSourceLayerObject().getItemType(), theFeature);
|
||||||
|
applicationBus.fireEvent(toEvent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -22,10 +22,13 @@ public class StringUtil {
|
||||||
* @throws Exception the exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
public static String ellipsize(String input, int maxCharacters) {
|
public static String ellipsize(String input, int maxCharacters) {
|
||||||
|
|
||||||
|
if(input==null)
|
||||||
|
return "";
|
||||||
|
|
||||||
if (input == null || input.length() < maxCharacters) {
|
if (input.length() < maxCharacters)
|
||||||
return input;
|
return input;
|
||||||
}
|
|
||||||
return input.substring(0, maxCharacters)+"...";
|
return input.substring(0, maxCharacters)+"...";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue