to debug
This commit is contained in:
parent
8564db4079
commit
6119f81969
|
@ -143,182 +143,187 @@ public class LayerManager {
|
|||
@Override
|
||||
public void onSuccess(List<GeoNaSpatialQueryResult> listGeonaDataObjects) {
|
||||
|
||||
try {
|
||||
GWT.log("GeoNaDataObject's: "+listGeonaDataObjects);
|
||||
GeoportalDataViewerConstants.print("GeoNaDataObject's: "+listGeonaDataObjects);
|
||||
|
||||
GWT.log("GeoNaDataObject's: "+listGeonaDataObjects);
|
||||
GeoportalDataViewerConstants.print("GeoNaDataObject's: "+listGeonaDataObjects);
|
||||
|
||||
if(listGeonaDataObjects==null || listGeonaDataObjects.isEmpty())
|
||||
return;
|
||||
|
||||
FlexTable flex = new FlexTable();
|
||||
flex.setCellPadding(1);
|
||||
flex.setCellSpacing(1);
|
||||
flex.getElement().addClassName("popup-table");
|
||||
boolean featureFound = false;
|
||||
FeatureRow feature = null;
|
||||
|
||||
//TODO SWTCH FOR EARCH ITEM TYPE
|
||||
for (GeoNaSpatialQueryResult geoNaDataObject : listGeonaDataObjects) {
|
||||
List<FeatureRow> features = geoNaDataObject.getFeatures();
|
||||
|
||||
//USING ONLY THE FIRST FEATURE IN THE LIST
|
||||
if(features!=null && features.size()>0) {
|
||||
feature = features.get(0);
|
||||
Map<String, List<String>> entries = feature.getMapProperties();
|
||||
|
||||
for (String key : entries.keySet()) {
|
||||
String theValue = entries.get(key).get(0);
|
||||
if(key.equalsIgnoreCase("nome")) {
|
||||
flex.setHTML(0, 0, new HTML(theValue).toString());
|
||||
}
|
||||
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());
|
||||
}
|
||||
if(listGeonaDataObjects==null || listGeonaDataObjects.isEmpty())
|
||||
return;
|
||||
|
||||
FlexTable flex = new FlexTable();
|
||||
flex.setCellPadding(1);
|
||||
flex.setCellSpacing(1);
|
||||
flex.getElement().addClassName("popup-table");
|
||||
boolean featureFound = false;
|
||||
FeatureRow feature = null;
|
||||
|
||||
//TODO SWTCH FOR EARCH ITEM TYPE
|
||||
for (GeoNaSpatialQueryResult geoNaDataObject : listGeonaDataObjects) {
|
||||
List<FeatureRow> features = geoNaDataObject.getFeatures();
|
||||
|
||||
//USING ONLY THE FIRST FEATURE IN THE LIST
|
||||
if(features!=null && features.size()>0) {
|
||||
feature = features.get(0);
|
||||
Map<String, List<String>> entries = feature.getMapProperties();
|
||||
|
||||
String nome = "";
|
||||
String descrizione = "";
|
||||
String date = "";
|
||||
|
||||
for (String key : entries.keySet()) {
|
||||
String theValue = entries.get(key).get(0);
|
||||
if(key.equalsIgnoreCase("nome")) {
|
||||
nome = theValue!=null?theValue:"";
|
||||
}
|
||||
|
||||
/*Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
||||
|
||||
@Override
|
||||
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());
|
||||
else if(key.equalsIgnoreCase("descrizione")) {
|
||||
descrizione = theValue!=null?theValue:"";
|
||||
}else if(key.equalsIgnoreCase("date_scavo")) {
|
||||
date = theValue!=null?theValue:"";
|
||||
}
|
||||
}
|
||||
|
||||
if(centerTo==null)
|
||||
centerTo = queryEvent.getoLCoordinate();
|
||||
GeoportalDataViewerConstants.print("0: "+nome);
|
||||
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
|
||||
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);
|
||||
}
|
||||
}
|
||||
});
|
||||
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);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}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
|
||||
*/
|
||||
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.substring(0, maxCharacters)+"...";
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue