Built the base tree
This commit is contained in:
parent
93f87145b7
commit
2eeaabc6b4
|
@ -90,7 +90,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
||||||
private static final String SERVER_ERROR = "An error occurred while "
|
private static final String SERVER_ERROR = "An error occurred while "
|
||||||
+ "attempting to contact the server. Please check your network " + "connection and try again.";
|
+ "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
|
public static final GeoportalDataEntryServiceAsync geoportalDataEntryService = GWT
|
||||||
.create(GeoportalDataEntryService.class);
|
.create(GeoportalDataEntryService.class);
|
||||||
|
@ -143,12 +143,39 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
||||||
* This is the entry point method.
|
* This is the entry point method.
|
||||||
*/
|
*/
|
||||||
public void onModuleLoad() {
|
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>() {
|
GeoportalDataEntryServiceAsync.Util.getInstance().getGeonaInitConfig(new AsyncCallback<GeonaISConfig>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -264,7 +291,7 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});*/
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initGUI() {
|
private void initGUI() {
|
||||||
|
@ -311,7 +338,6 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
||||||
}
|
}
|
||||||
|
|
||||||
setListUseCaseDescriptors(listUCDescriptors);
|
setListUseCaseDescriptors(listUCDescriptors);
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -417,8 +443,11 @@ public class GeoPortalDataEntryApp implements EntryPoint {
|
||||||
GWT.log("TreMap values: " + gnaCardsModels);
|
GWT.log("TreMap values: " + gnaCardsModels);
|
||||||
orderedCards.addAll(gnaCardsModels);
|
orderedCards.addAll(gnaCardsModels);
|
||||||
mapGcubeProfilePerItemType.put(handlerDeclarationDV.getItemType(),
|
mapGcubeProfilePerItemType.put(handlerDeclarationDV.getItemType(),
|
||||||
new ArrayList<GeoNaFormCardModel>(gnaCardsModels));
|
new ArrayList<GeoNaFormCardModel>(orderedCards));
|
||||||
buildNewCards(profileID, orderedCards, OPERATION.UPDATE);
|
buildNewCards(profileID, orderedCards, OPERATION.UPDATE);
|
||||||
|
|
||||||
|
TreeItemPanel tip = new TreeItemPanel(handlerDeclarationDV.getItemType(), orderedCards);
|
||||||
|
RootPanel.get(GeoPortalDataEntryApp.DIV_PORTLET_ID).add(tip.getTree());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -564,7 +564,6 @@ public class GeonaMainTabPanel extends Composite {
|
||||||
|
|
||||||
appManagerBus.fireEvent(
|
appManagerBus.fireEvent(
|
||||||
new CreateNewProjectEvent(ucd.getProfileID(), dataEntryHandler, listProfiles));
|
new CreateNewProjectEvent(ucd.getProfileID(), dataEntryHandler, listProfiles));
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,20 +1,16 @@
|
||||||
package org.gcube.portlets.user.geoportaldataentry.client.ui.tree;
|
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.Button;
|
||||||
import com.github.gwtbootstrap.client.ui.constants.IconSize;
|
|
||||||
import com.github.gwtbootstrap.client.ui.constants.IconType;
|
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.core.client.GWT;
|
||||||
import com.google.gwt.event.dom.client.ClickEvent;
|
import com.google.gwt.event.dom.client.ClickEvent;
|
||||||
import com.google.gwt.event.dom.client.ClickHandler;
|
import com.google.gwt.event.dom.client.ClickHandler;
|
||||||
import com.google.gwt.uibinder.client.UiBinder;
|
import com.google.gwt.uibinder.client.UiBinder;
|
||||||
import com.google.gwt.uibinder.client.UiField;
|
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.Composite;
|
||||||
import com.google.gwt.user.client.ui.HTML;
|
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.TreeItem;
|
||||||
import com.google.gwt.user.client.ui.Widget;
|
import com.google.gwt.user.client.ui.Widget;
|
||||||
|
|
||||||
|
@ -38,9 +34,12 @@ public class NodeItem extends Composite {
|
||||||
@UiField
|
@UiField
|
||||||
Button buttonRemove;
|
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));
|
initWidget(uiBinder.createAndBindUi(this));
|
||||||
htmlNode.setHTML(nodeLabel);
|
this.profile = profile;
|
||||||
|
htmlNode.setHTML(profile.getSectionTitle());
|
||||||
|
|
||||||
buttonAdd.setIcon(IconType.COPY);
|
buttonAdd.setIcon(IconType.COPY);
|
||||||
buttonRemove.setIcon(IconType.TRASH);
|
buttonRemove.setIcon(IconType.TRASH);
|
||||||
|
|
|
@ -1,29 +1,91 @@
|
||||||
package org.gcube.portlets.user.geoportaldataentry.client.ui.tree;
|
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.Tree;
|
||||||
import com.google.gwt.user.client.ui.TreeItem;
|
import com.google.gwt.user.client.ui.TreeItem;
|
||||||
|
|
||||||
public class TreeItemPanel {
|
public class TreeItemPanel {
|
||||||
|
|
||||||
|
private static final String JSON_ROOT_PATH = "$.";
|
||||||
private Tree tree = new Tree();
|
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();
|
TreeItem root = new TreeItem();
|
||||||
root.setHTML(projectType);
|
root.setHTML(itemType);
|
||||||
|
|
||||||
TreeItem child1 = addChild(root, "Item 1");
|
// TreeMap<String, List<TreeItem>> mapParentSections = new TreeMap<String,
|
||||||
TreeItem child2 = addChild(root, "Item 2");
|
// List<TreeItem>>();
|
||||||
TreeItem child3 = addChild(root, "Item 2");
|
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");
|
// for (GeoNaFormCardModel geoNaFormCardModel : gnaCardsModels) {
|
||||||
TreeItem child2_1 = addChild(child2, "Item 2.1");
|
//
|
||||||
|
// 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);
|
tree.addItem(root);
|
||||||
}
|
}
|
||||||
// Create a tree with a few items in it.
|
|
||||||
|
|
||||||
public TreeItem addChild(TreeItem parent, String childName) {
|
private TreeItem addChild(TreeItem parent, GcubeProfileDV profile) {
|
||||||
TreeItem child = new TreeItem(new NodeItem(parent, childName, 0, 5));
|
TreeItem child = new TreeItem(new NodeItem(parent, profile));
|
||||||
parent.addItem(child);
|
parent.addItem(child);
|
||||||
return child;
|
return child;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue