Added code to opening the collection in input or all the collections

This commit is contained in:
Francesco Mangiacrapa 2022-11-09 14:35:37 +01:00
parent 59fcd5db9d
commit 6950ce8c2f
3 changed files with 51 additions and 14 deletions

View File

@ -224,7 +224,7 @@ public class GeoportalDataViewer implements EntryPoint {
GWT.log("Loading collections, count " + result.getAvailableCollections().size());
mainPanel.setAvailableCollections(result.getAvailableCollections().values());
mainPanel.setAvailableCollections(result.getAvailableCollections().values(), paramGeonaItemType);
if (paramGeonaItemID != null) {
if (paramGeonaItemType == null) {

View File

@ -2,6 +2,7 @@ package org.gcube.portlets.user.geoportaldataviewer.client.ui;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences;
@ -139,6 +140,8 @@ public class GeonaDataViewMainPanel extends Composite {
private HandlerManager applicationBus;
private HashMap<String, List<CheckBox>> mapCollectionCheckBoxes;
public GeonaDataViewMainPanel(HandlerManager applicationBus, int mapHeight,
List<ItemFieldsResponse> itemFieldsReponse) {
initWidget(uiBinder.createAndBindUi(this));
@ -268,6 +271,15 @@ public class GeonaDataViewMainPanel extends Composite {
}
}, ClickEvent.getType());
openCollectionDropDown.addDomHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
// event.preventDefault();
event.stopPropagation();
}
}, ClickEvent.getType());
}
/**
@ -478,18 +490,20 @@ public class GeonaDataViewMainPanel extends Composite {
* @param listBaseLayers the new base layers
*/
public void setAvailableCollections(Collection<GCubeCollection> collection) {
public void setAvailableCollections(Collection<GCubeCollection> collection, String openCollectionID) {
GWT.log("Init Available collections menu");
if (collection == null || collection.isEmpty())
GWT.log("!!! No Available collections");
mapCollectionCheckBoxes = new HashMap<String, List<CheckBox>>();
for (GCubeCollection coll : collection) {
GWT.log("Found available collection " + coll);
String label = coll.getUcd().getName();
String id = coll.getUcd().getId();
final String collectionID = coll.getUcd().getId(); // collectionID == UCD_Id
CheckBox checkbox = new CheckBox(label);
checkbox.setId("gcubeCollectionSelector_" + id);
checkbox.setId("gcubeCollectionSelector_" + collectionID);
checkbox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
@ -497,8 +511,8 @@ public class GeonaDataViewMainPanel extends Composite {
public void onValueChange(ValueChangeEvent<Boolean> event) {
GWT.log("Collection selector flag changed to value : " + event.toDebugString());
String collectionID = ((CheckBox) event.getSource()).getId().replace("gcubeCollectionSelector_",
"");
// String collectionID = ((CheckBox) event.getSource()).getId().replace("gcubeCollectionSelector_",
// "");
GWT.log("Collection ID is : " + collectionID + ", event value: " + event.getValue());
if (event.getValue()) {
@ -512,16 +526,39 @@ public class GeonaDataViewMainPanel extends Composite {
});
openCollectionPanel.add(checkbox);
List<CheckBox> listCollections = mapCollectionCheckBoxes.get(collectionID);
if (listCollections == null)
listCollections = new ArrayList<CheckBox>();
listCollections.add(checkbox);
mapCollectionCheckBoxes.put(collectionID, listCollections);
// Opening All Collections if openCollectionID is null
if (openCollectionID == null) {
checkbox.setValue(true, true);
// String collectionID = checkbox.getId().replace("gcubeCollectionSelector_",
// "");
GWT.log("Opening the collection: " + collectionID);
applicationBus.fireEvent(new OpenCollectionEvent(collectionID));
}
}
// Open the first collection as default
if (collection != null && collection.size() > 0) {
CheckBox checkbox = (CheckBox) openCollectionPanel.getWidget(0);
checkbox.setValue(true, true);
String collectionID = checkbox.getId().replace("gcubeCollectionSelector_", "");
applicationBus.fireEvent(new OpenCollectionEvent(collectionID));
}
// Opening All Collections if openCollectionID is null
if (openCollectionID != null) {
List<CheckBox> listCheckBoxes = mapCollectionCheckBoxes.get(openCollectionID);
if (listCheckBoxes != null) {
for (CheckBox checkBox : listCheckBoxes) {
checkBox.setValue(true, true);
String collectionID = checkBox.getId().replace("gcubeCollectionSelector_", "");
GWT.log("Opening the input collection: " + collectionID);
applicationBus.fireEvent(new OpenCollectionEvent(collectionID));
}
}
}
}
public void openCollectionMenu() {

View File

@ -667,7 +667,7 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
try {
SessionUtil.getCurrentContext(this.getThreadLocalRequest(), true);
new GeoportalServiceIdentityProxy(this.getThreadLocalRequest());
List<ItemFieldsResponse> listIFResponse = new ArrayList<ItemFieldsResponse>();
List<String> handlersIds = Arrays.asList(GEOPORTAL_DATA_HANDLER.geoportal_basic_data_list.getId());