Built the base tree

This commit is contained in:
Francesco Mangiacrapa 2022-07-04 16:34:15 +02:00
parent 93f87145b7
commit 2eeaabc6b4
4 changed files with 116 additions and 27 deletions

View File

@ -90,7 +90,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
private static final String SERVER_ERROR = "An error occurred while "
+ "attempting to contact the server. Please check your network " + "connection and try again.";
private static final String DIV_PORTLET_ID = "geoportal-data-entry";
public static final String DIV_PORTLET_ID = "geoportal-data-entry";
public static final GeoportalDataEntryServiceAsync geoportalDataEntryService = GWT
.create(GeoportalDataEntryService.class);
@ -143,12 +143,39 @@ public class GeoPortalDataEntryApp implements EntryPoint {
* This is the entry point method.
*/
public void onModuleLoad() {
/*
ArrayList<GeoNaFormCardModel> gnaCardsModels = new ArrayList<GeoNaFormCardModel>(10);
GcubeProfileDV gprofile = new GcubeProfileDV();
gprofile.setParentName("$.");
gprofile.setSectionTitle("Istruzione");
GeoNaFormCardModel fcm = new GeoNaFormCardModel();
fcm.setGcubeProfile(gprofile);
gnaCardsModels.add(fcm);
for (int i = 0; i < 2; i++) {
GcubeProfileDV gprofile1 = new GcubeProfileDV();
gprofile1.setParentName("$.livello1");
gprofile1.setSectionTitle("Secondaria Superiore "+i);
GeoNaFormCardModel fcm1 = new GeoNaFormCardModel();
fcm1.setGcubeProfile(gprofile1);
gnaCardsModels.add(fcm1);
}
for (int i = 0; i < 3; i++) {
GcubeProfileDV gprofile2 = new GcubeProfileDV();
gprofile2.setParentName("$.livello1.livello2");
gprofile2.setSectionTitle("Alberghiero di Pisa "+i);
GeoNaFormCardModel fcm2 = new GeoNaFormCardModel();
fcm2.setGcubeProfile(gprofile2);
gnaCardsModels.add(fcm2);
}
TreeItemPanel tip = new TreeItemPanel("Concessione", gnaCardsModels);
RootPanel.get(GeoPortalDataEntryApp.DIV_PORTLET_ID).add(tip.getTree());*/
TreeItemPanel tip = new TreeItemPanel("Concessioni");
RootPanel.get(DIV_PORTLET_ID).add(tip.getTree());
/*RootPanel.get(DIV_PORTLET_ID).add(loader);
RootPanel.get(DIV_PORTLET_ID).add(loader);
GeoportalDataEntryServiceAsync.Util.getInstance().getGeonaInitConfig(new AsyncCallback<GeonaISConfig>() {
@Override
@ -264,7 +291,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
}
}
});*/
});
}
private void initGUI() {
@ -311,7 +338,6 @@ public class GeoPortalDataEntryApp implements EntryPoint {
}
setListUseCaseDescriptors(listUCDescriptors);
}
});
}
@ -417,8 +443,11 @@ public class GeoPortalDataEntryApp implements EntryPoint {
GWT.log("TreMap values: " + gnaCardsModels);
orderedCards.addAll(gnaCardsModels);
mapGcubeProfilePerItemType.put(handlerDeclarationDV.getItemType(),
new ArrayList<GeoNaFormCardModel>(gnaCardsModels));
new ArrayList<GeoNaFormCardModel>(orderedCards));
buildNewCards(profileID, orderedCards, OPERATION.UPDATE);
TreeItemPanel tip = new TreeItemPanel(handlerDeclarationDV.getItemType(), orderedCards);
RootPanel.get(GeoPortalDataEntryApp.DIV_PORTLET_ID).add(tip.getTree());
}
}

View File

@ -564,7 +564,6 @@ public class GeonaMainTabPanel extends Composite {
appManagerBus.fireEvent(
new CreateNewProjectEvent(ucd.getProfileID(), dataEntryHandler, listProfiles));
}
});

View File

@ -1,20 +1,16 @@
package org.gcube.portlets.user.geoportaldataentry.client.ui.tree;
import org.gcube.application.geoportalcommon.shared.geoportal.config.GcubeProfileDV;
import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.constants.IconSize;
import com.github.gwtbootstrap.client.ui.constants.IconType;
import com.github.gwtbootstrap.client.ui.resources.ButtonSize;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HasText;
import com.google.gwt.user.client.ui.TreeItem;
import com.google.gwt.user.client.ui.Widget;
@ -38,9 +34,12 @@ public class NodeItem extends Composite {
@UiField
Button buttonRemove;
public NodeItem(TreeItem parent, String nodeLabel, Integer minOccurs, Integer maxOccurs) {
private GcubeProfileDV profile;
public NodeItem(TreeItem parent, GcubeProfileDV profile) {
initWidget(uiBinder.createAndBindUi(this));
htmlNode.setHTML(nodeLabel);
this.profile = profile;
htmlNode.setHTML(profile.getSectionTitle());
buttonAdd.setIcon(IconType.COPY);
buttonRemove.setIcon(IconType.TRASH);

View File

@ -1,29 +1,91 @@
package org.gcube.portlets.user.geoportaldataentry.client.ui.tree;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.TreeMap;
import org.gcube.application.geoportalcommon.shared.geoportal.config.GcubeProfileDV;
import org.gcube.portlets.user.geoportaldataentry.client.ui.card.GeoNaFormCardModel;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.Tree;
import com.google.gwt.user.client.ui.TreeItem;
public class TreeItemPanel {
private static final String JSON_ROOT_PATH = "$.";
private Tree tree = new Tree();
public TreeItemPanel(String projectType) {
// Create a tree with a few items in it.
public TreeItemPanel(String itemType, Collection<GeoNaFormCardModel> gnaCardsModels) {
TreeItem root = new TreeItem();
root.setHTML(projectType);
root.setHTML(itemType);
TreeItem child1 = addChild(root, "Item 1");
TreeItem child2 = addChild(root, "Item 2");
TreeItem child3 = addChild(root, "Item 2");
// TreeMap<String, List<TreeItem>> mapParentSections = new TreeMap<String,
// List<TreeItem>>();
HashMap<String, TreeItem> treeItemParents = new HashMap<String, TreeItem>();
treeItemParents.put(JSON_ROOT_PATH, root);
// mapParentSections.put(JSON_ROOT_PATH, Arrays.asList(root));
TreeItem child1_1 = addChild(child1, "Item 1.1");
TreeItem child2_1 = addChild(child2, "Item 2.1");
// for (GeoNaFormCardModel geoNaFormCardModel : gnaCardsModels) {
//
// GcubeProfileDV profile = geoNaFormCardModel.getGcubeProfile();
// String parentName = profile.getParentName();
//
// if (profile.getSectionName().compareTo("relazioneScavo") == 0) {
// profile.setParentName(JSON_ROOT_PATH + "abstractRelazione");
// }
//
// if (profile.getSectionName().compareTo("posizionamentoScavo") == 0) {
// profile.setParentName(JSON_ROOT_PATH + "immaginiRappresentative");
// }
//
// if (profile.getSectionName().compareTo("pianteFineScavo") == 0) {
// profile.setParentName(JSON_ROOT_PATH + "immaginiRappresentative.posizionamentoScavo");
// }
//
// GWT.log(" print tree parentName: " + parentName + " name: " + profile.getSectionName() + " title: "
// + profile.getSectionTitle());
// }
for (GeoNaFormCardModel geoNaFormCardModel : gnaCardsModels) {
GcubeProfileDV profile = geoNaFormCardModel.getGcubeProfile();
String parentName = profile.getParentName();
GWT.log("finding parentName: " + parentName + " in " + treeItemParents.keySet());
String jsonSectionFullPath = null;
if (parentName == null || parentName.isEmpty()) {
GWT.log("tree parentName is null: " + parentName + " in " + treeItemParents.keySet());
parentName = JSON_ROOT_PATH;
jsonSectionFullPath = profile.getSectionName();
} else {
jsonSectionFullPath = parentName.endsWith(".") ? parentName + profile.getSectionName()
: parentName + "." + profile.getSectionName();
}
// List<TreeItem> sections = mapParentSections.get(jsonSectionFullPath);
GWT.log("tree getting jsonSectionFullPath: " + jsonSectionFullPath + " in " + treeItemParents.keySet());
TreeItem parentItem = treeItemParents.get(parentName);
GWT.log("tree jsonSection: " + jsonSectionFullPath + " parent " + parentName + " name: "
+ profile.getSectionName() + " title: " + profile.getSectionTitle());
TreeItem child = addChild(parentItem, geoNaFormCardModel.getGcubeProfile());
// if the path section is not the root
if (jsonSectionFullPath.compareTo(JSON_ROOT_PATH) != 0) {
treeItemParents.put(jsonSectionFullPath, child);
}
}
tree.addItem(root);
}
// Create a tree with a few items in it.
public TreeItem addChild(TreeItem parent, String childName) {
TreeItem child = new TreeItem(new NodeItem(parent, childName, 0, 5));
private TreeItem addChild(TreeItem parent, GcubeProfileDV profile) {
TreeItem child = new TreeItem(new NodeItem(parent, profile));
parent.addItem(child);
return child;
}