Added Comparable for sorting the UCD names

This commit is contained in:
Francesco Mangiacrapa 2023-01-16 14:08:23 +01:00
parent f9ea07ee00
commit 9a7edeada1
5 changed files with 74 additions and 26 deletions

View File

@ -1,5 +1,7 @@
package org.gcube.portlets.user.geoportaldataviewer.client; package org.gcube.portlets.user.geoportaldataviewer.client;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@ -231,10 +233,20 @@ public class GeoportalDataViewer implements EntryPoint {
"//cdnjs.cloudflare.com/ajax/libs/nanogallery2/3.0.5/jquery.nanogallery2.min.js") "//cdnjs.cloudflare.com/ajax/libs/nanogallery2/3.0.5/jquery.nanogallery2.min.js")
.setWindow(ScriptInjector.TOP_WINDOW).inject(); .setWindow(ScriptInjector.TOP_WINDOW).inject();
if (result.getAvailableCollections() == null
|| result.getAvailableCollections().size() == 0) {
RootPanel.get(APP_DIV).remove(loaderApp);
Window.alert("No available collection in this context");
RootPanel.get(APP_DIV).add(getGeneralErrorPanel());
return;
}
GWT.log("Loading collections, count " + result.getAvailableCollections().size()); GWT.log("Loading collections, count " + result.getAvailableCollections().size());
mainPanel.setAvailableCollections(result.getAvailableCollections().values(), ArrayList<GCubeCollection> listColl = new ArrayList<GCubeCollection>();
paramGeonaItemType); listColl.addAll(result.getAvailableCollections().values());
Collections.sort(listColl);
mainPanel.setAvailableCollections(listColl, paramGeonaItemType);
if (paramGeonaItemID != null) { if (paramGeonaItemID != null) {
if (paramGeonaItemType == null) { if (paramGeonaItemType == null) {
@ -592,17 +604,17 @@ public class GeoportalDataViewer implements EntryPoint {
@Override @Override
public void onShowPopup(ShowPopupOnCentroidEvent showPopupOnCentroiEvent) { public void onShowPopup(ShowPopupOnCentroidEvent showPopupOnCentroiEvent) {
GWT.log("ShowPopupOnCentroidEvent: " + showPopupOnCentroiEvent); GWT.log("ShowPopupOnCentroidEvent: " + showPopupOnCentroiEvent);
//Showing popup after clicking on map // Showing popup after clicking on map
if (showPopupOnCentroiEvent.getProfileID() != null && showPopupOnCentroiEvent.getProjectID() != null) { if (showPopupOnCentroiEvent.getProfileID() != null && showPopupOnCentroiEvent.getProjectID() != null) {
Coordinate transfCoord = MapUtils Coordinate transfCoord = MapUtils
.geoJSONTToBBoxCenter(showPopupOnCentroiEvent.getSpatialReference(), null, null); .geoJSONTToBBoxCenter(showPopupOnCentroiEvent.getSpatialReference(), null, null);
performWFSQueryOnCentroid(showPopupOnCentroiEvent.getProjectID(), transfCoord.getX(), performWFSQueryOnCentroid(showPopupOnCentroiEvent.getProjectID(), transfCoord.getX(),
transfCoord.getY()); transfCoord.getY());
//Showing popup after locate on Map // Showing popup after locate on Map
}else if(showPopupOnCentroiEvent.getProjectView()!=null) { } else if (showPopupOnCentroiEvent.getProjectView() != null) {
layerManager.showPopupInfoForCentroidLayer(showPopupOnCentroiEvent.getProjectView()); layerManager.showPopupInfoForCentroidLayer(showPopupOnCentroiEvent.getProjectView());
} }

View File

@ -187,6 +187,14 @@ public class GeonaDataViewMainPanel extends Composite {
navListSearch.addItem(PLACEHOLDER_SELECT_SEARCH_IN, PLACEHOLDER_SELECT_SEARCH_IN); navListSearch.addItem(PLACEHOLDER_SELECT_SEARCH_IN, PLACEHOLDER_SELECT_SEARCH_IN);
navListSearch.getElement().getFirstChildElement().setAttribute("disabled", "disabled"); navListSearch.getElement().getFirstChildElement().setAttribute("disabled", "disabled");
// List<UseCaseDescriptorDV> listUCDs = new ArrayList<UseCaseDescriptorDV>();
//
// for (ItemFieldsResponse itemFieldsResponse : itemFieldsReponse) {
// listUCDs.add(itemFieldsResponse.getUseCaseDescriptorDV());
// }
//
// Collections.sort(listUCDs);
for (final ItemFieldsResponse itemFieldResp : itemFieldsReponse) { for (final ItemFieldsResponse itemFieldResp : itemFieldsReponse) {

View File

@ -52,7 +52,7 @@
<b:DropdownButton type="LINK" <b:DropdownButton type="LINK"
text="Open Collection" ui:field="openCollectionDropDown"> text="Open Collection" ui:field="openCollectionDropDown">
<g:HTMLPanel ui:field="openCollectionPanel" <g:HTMLPanel ui:field="openCollectionPanel"
addStyleNames="{style.open-collection-style}"> addStyleNames="open-collection-style">
</g:HTMLPanel> </g:HTMLPanel>
</b:DropdownButton> </b:DropdownButton>
<b:DropdownButton type="LINK" <b:DropdownButton type="LINK"

View File

@ -1,40 +1,37 @@
package org.gcube.portlets.user.geoportaldataviewer.shared; package org.gcube.portlets.user.geoportaldataviewer.shared;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.IndexLayerDV; import org.gcube.application.geoportalcommon.shared.geoportal.materialization.IndexLayerDV;
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.UseCaseDescriptorDV; import org.gcube.application.geoportalcommon.shared.geoportal.ucd.UseCaseDescriptorDV;
public class GCubeCollection implements Serializable, Comparable<GCubeCollection> {
public class GCubeCollection implements Serializable { /**
/**
* *
*/ */
private static final long serialVersionUID = -3915546050671671465L; private static final long serialVersionUID = -3915546050671671465L;
private UseCaseDescriptorDV ucd; private UseCaseDescriptorDV ucd;
private List<IndexLayerDV> indexes; private List<IndexLayerDV> indexes;
public GCubeCollection() { public GCubeCollection() {
} }
public UseCaseDescriptorDV getUcd() { public UseCaseDescriptorDV getUcd() {
return ucd; return ucd;
} }
public List<IndexLayerDV> getIndexes() { public List<IndexLayerDV> getIndexes() {
return indexes; return indexes;
} }
public void setUcd(UseCaseDescriptorDV ucd) {
public void setUcd(UseCaseDescriptorDV ucd) {
this.ucd = ucd; this.ucd = ucd;
} }
public void setIndexes(List<IndexLayerDV> indexes) { public void setIndexes(List<IndexLayerDV> indexes) {
this.indexes = indexes; this.indexes = indexes;
} }
@ -42,6 +39,24 @@ public class GCubeCollection implements Serializable {
public String toString() { public String toString() {
return "GCubeCollection [ucd=" + ucd + ", indexes=" + indexes + "]"; return "GCubeCollection [ucd=" + ucd + ", indexes=" + indexes + "]";
} }
@Override
public int compareTo(GCubeCollection o) {
if (this == null || this.ucd == null)
return 1;
if (o == null || o.getUcd() == null)
return -1;
if (this.ucd.getName() == null)
return 1;
if (o.getUcd().getName() == null)
return -1;
return this.getUcd().getName().compareTo(o.getUcd().getName());
}
} }

View File

@ -771,6 +771,19 @@ RESPONSIVE
} }
/* OPEN COLLECTION UI */ /* OPEN COLLECTION UI */
.open-collection-style {
padding-left: 10px;
padding-right: 10px;
}
.open-collection-style > div {
border: 1px solid #ccc !important;
border-radius: 5px;
padding: 10px;
margin-bottom: 10px;
margin-top: 5px;
}
.layer-style-panel { .layer-style-panel {
margin-left: 25px; margin-left: 25px;
font-size: 13px; font-size: 13px;