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;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
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")
.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());
mainPanel.setAvailableCollections(result.getAvailableCollections().values(),
paramGeonaItemType);
ArrayList<GCubeCollection> listColl = new ArrayList<GCubeCollection>();
listColl.addAll(result.getAvailableCollections().values());
Collections.sort(listColl);
mainPanel.setAvailableCollections(listColl, paramGeonaItemType);
if (paramGeonaItemID != null) {
if (paramGeonaItemType == null) {

View File

@ -188,6 +188,14 @@ public class GeonaDataViewMainPanel extends Composite {
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) {
UseCaseDescriptorDV ucd = itemFieldResp.getUseCaseDescriptorDV();

View File

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

View File

@ -1,14 +1,12 @@
package org.gcube.portlets.user.geoportaldataviewer.shared;
import java.io.Serializable;
import java.util.List;
import org.gcube.application.geoportalcommon.shared.geoportal.materialization.IndexLayerDV;
import org.gcube.application.geoportalcommon.shared.geoportal.ucd.UseCaseDescriptorDV;
public class GCubeCollection implements Serializable {
public class GCubeCollection implements Serializable, Comparable<GCubeCollection> {
/**
*
@ -29,7 +27,6 @@ public class GCubeCollection implements Serializable {
return indexes;
}
public void setUcd(UseCaseDescriptorDV ucd) {
this.ucd = ucd;
}
@ -43,5 +40,23 @@ public class GCubeCollection implements Serializable {
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-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 {
margin-left: 25px;
font-size: 13px;