in progress

This commit is contained in:
Francesco Mangiacrapa 2022-07-07 18:21:34 +02:00
parent 22713ca924
commit c28170ee91
9 changed files with 177 additions and 107 deletions

View File

@ -67,6 +67,8 @@ import com.github.gwtbootstrap.client.ui.Modal;
import com.github.gwtbootstrap.client.ui.constants.AlertType;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.dom.client.Element;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
@ -489,6 +491,16 @@ public class GeoPortalDataEntryApp implements EntryPoint {
treeItemPanel = new TreeItemPanel(profileID, itemTypeTitle, orderedCards, appManagerBus);
geoNaMainForm.addTree(treeItemPanel);
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
TreeItem firstChild = treeItemPanel.getRoot().getChild(0);
treeItemPanel.getTree().setSelectedItem(firstChild, true);
}
});
}
private void resetUI() {

View File

@ -34,6 +34,7 @@
.display-right {
float: right;
margin-right: 20px;
}
.align-center {
@ -44,10 +45,6 @@
max-height: auto;
}
.margin-bottom-5 {
margin-bottom: 5px !important;
}
.search-field {
padding-top: 6px;
margin-top: 2px;
@ -59,6 +56,7 @@
}
.sub-page-header h1 {
}
.sub-page-header small {
@ -75,7 +73,7 @@
ui:field="tabNewProject">
<g:ScrollPanel>
<g:HTMLPanel ui:field="contTabNewProject">
<b:Navbar addStyleNames="{style.margin-bottom-5}">
<b:Navbar addStyleNames="nav-toolbar-style">
<b:Brand addStyleNames="{style.margin-top-5}">New Project</b:Brand>
<b:Nav>
<b:Dropdown text="Create New Project"

View File

@ -1,10 +1,8 @@
package org.gcube.portlets.user.geoportaldataentry.client.ui.form;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
import org.gcube.portlets.user.geoportaldataentry.client.events.SaveGeonaDataFormsEvent;
import org.gcube.portlets.user.geoportaldataentry.client.events.TreeItemEvent;
import org.gcube.portlets.user.geoportaldataentry.client.events.TreeItemEvent.ACTION;
import org.gcube.portlets.user.geoportaldataentry.client.ui.card.GeoNaFormCardModel;
@ -12,16 +10,13 @@ import org.gcube.portlets.user.geoportaldataentry.client.ui.card.MetadataFormCar
import org.gcube.portlets.user.geoportaldataentry.client.ui.tree.NodeItem;
import org.gcube.portlets.user.geoportaldataentry.client.ui.tree.TreeItemPanel;
import org.gcube.portlets.user.geoportaldataentry.shared.GeoNaFormDataObject;
import org.gcube.portlets.user.geoportaldataentry.shared.TNode;
import org.gcube.portlets.user.geoportaldataentry.shared.Tree_Node;
import org.gcube.portlets.widgets.mpformbuilder.client.form.generic.CreateMetadataForm;
import org.gcube.portlets.widgets.mpformbuilder.shared.GenericDatasetBean;
import com.github.gwtbootstrap.client.ui.AlertBlock;
import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.FormActions;
import com.github.gwtbootstrap.client.ui.NavList;
import com.github.gwtbootstrap.client.ui.Tab;
import com.github.gwtbootstrap.client.ui.TabPanel;
import com.github.gwtbootstrap.client.ui.constants.AlertType;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
@ -58,7 +53,7 @@ public class GeonaDataEntryMainForm extends Composite {
interface GeonaDataEntryMainFormUiBinder extends UiBinder<Widget, GeonaDataEntryMainForm> {
}
private TNode<GeoNaFormCardModel> nodes = new TNode<GeoNaFormCardModel>();
private Tree_Node<GeoNaFormCardModel> nodes = new Tree_Node<GeoNaFormCardModel>();
@UiField
HTMLPanel mainHTMLPanel;
@ -195,18 +190,9 @@ public class GeonaDataEntryMainForm extends Composite {
return;
}
// try {
// node = (NodeItem) root.getWidget();
// boolean isRoot = node.isRoot();
// if(isRoot)
// return true;
// }catch (Exception e) {
// // TODO: handle exception
// }
boolean isValid = node.validateForm();
GWT.log("validateFormsIntoTree called for: " + root.getText() + " is valid: " + isValid);
node.setValidCard(isValid);
if (!isValid) {
canSave = false;
}
@ -224,29 +210,12 @@ public class GeonaDataEntryMainForm extends Composite {
TreeItem root = treeItemPanel.getRoot();
validateFormsIntoTree(root);
// boolean canSave = true;
//
// TreeItem root = treeItemPanel.getRoot();
//
// for (int i=0; i<root.getChildCount(); i++) {
// TreeItem child = root.getChild(i);
// NodeItem node = (NodeItem) child.getWidget();
// boolean isValid = node.validateForm();
// if (isValid == false)
// canSave = false;
// }
//
// for (String metadataType : mapForms.keySet()) {
// MetadataFormCard card = mapForms.get(metadataType);
// boolean isValid = card.validateForm();
// card.setValidCard(isValid);
// if (isValid == false)
// canSave = false;
// }
List<GeoNaFormDataObject> listGeonaFormObjects = new ArrayList<GeoNaFormDataObject>();
if (canSave) {
Tree_Node<GeoNaFormDataObject> listGeonaFormObjects = buildTree(root);
System.out.println(listGeonaFormObjects);
// for (String metadataType : mapForms.keySet()) {
// MetadataFormCard card = mapForms.get(metadataType);
// List<GenericDatasetBean> listGDB = new ArrayList<GenericDatasetBean>(card.getListForms().size());
@ -268,6 +237,48 @@ public class GeonaDataEntryMainForm extends Composite {
}
public <T> void printTree(Tree_Node<T> node) {
if(node==null) {
return;
}
System.out.println(node);
for (Tree_Node<T> children : node.getChildren()) {
printTree(children);
}
}
private Tree_Node<GeoNaFormDataObject> buildTree(TreeItem root) {
GWT.log("buildTree called");
if (root == null) {
GWT.log("buildTree returns, node is null");
return null;
}
GWT.log("buildTree called on: " + root.getText());
// Cloning
NodeItem theRootNode = (NodeItem) root.getWidget();
GeoNaFormCardModel nodeCard = theRootNode.getGeoNaFormCardModel();
GeoNaFormDataObject gfdo = new GeoNaFormDataObject(Arrays.asList(nodeCard.getMetadataForm().getFormDataBean()), nodeCard.getGcubeProfile());
Tree_Node<GeoNaFormDataObject> tNode = new Tree_Node<GeoNaFormDataObject>(nodeCard.getGcubeProfile().getSectionTitle(), gfdo);
// Total children count
int total = root.getChildCount();
// All the children
for (int i = 0; i < total; i++) {
Tree_Node<GeoNaFormDataObject> childCloned = buildTree(root.getChild(i));
tNode.addChild(childCloned);
}
return tNode;
}
/**
* Show alert on save action.
*

View File

@ -12,16 +12,6 @@
width: 100%;
}
.tree-panel {
padding: 5px;
border: 1px solid #e7e7e7;
min-width: 280px;
}
.tree-panel ul {
background: #e7e7e7;
}
.w20 {
width: 20%;
}
@ -42,7 +32,7 @@
</ui:style>
<g:HTMLPanel ui:field="mainHTMLPanel">
<g:HTMLPanel addStyleNames="{style.wrapper}">
<g:HTMLPanel addStyleNames="{style.tree-panel}">
<g:HTMLPanel addStyleNames="tree-panel">
<b:NavList visible=" false " ui:field="navbarTree">
<b:NavHeader>Sections</b:NavHeader>
<g:HTMLPanel addStyleNames="{style.section-toolbar}">

View File

@ -175,12 +175,16 @@ public class NodeItem extends Composite {
public void setValidCard(boolean bool) {
if (bool) {
iconField.setIcon(IconType.OK_SIGN);
htmlNode.asWidget().getElement().removeClassName("red-text");
htmlNode.asWidget().getElement().addClassName("green-text");
iconField.getElement().removeClassName("red-text");
iconField.getElement().addClassName("green-text");
htmlNode.getElement().removeClassName("red-text");
htmlNode.getElement().addClassName("green-text");
} else {
iconField.setIcon(IconType.MINUS_SIGN);
htmlNode.asWidget().getElement().removeClassName("green-text");
htmlNode.asWidget().getElement().addClassName("red-text");
iconField.getElement().removeClassName("green-text");
iconField.getElement().addClassName("red-text");
htmlNode.getElement().removeClassName("green-text");
htmlNode.getElement().addClassName("red-text");
}
}
@ -192,12 +196,16 @@ public class NodeItem extends Composite {
boolean isValid = validateForm();
if (isValid) {
iconField.setIcon(IconType.OK_SIGN);
htmlNode.asWidget().getElement().removeClassName("red-text");
htmlNode.asWidget().getElement().addClassName("green-text");
iconField.getElement().removeClassName("red-text");
iconField.getElement().addClassName("green-text");
htmlNode.getElement().removeClassName("red-text");
htmlNode.getElement().addClassName("green-text");
} else {
iconField.setIcon(IconType.MINUS_SIGN);
htmlNode.asWidget().getElement().removeClassName("red-text");
htmlNode.asWidget().getElement().addClassName("red-text");
iconField.getElement().removeClassName("green-text");
iconField.getElement().addClassName("red-text");
htmlNode.getElement().removeClassName("green-text");
htmlNode.getElement().addClassName("red-text");
}
}

View File

@ -12,12 +12,12 @@
margin-left: 10px;
}
.margin-left-10 {
margin-left: 10px;
.padding-right-5 {
padding-right: 5px;
}
</ui:style>
<g:HorizontalPanel>
<g:HTMLPanel addStyleNames="margin-left-10">
<g:HTMLPanel addStyleNames="{style.padding-right-5}">
<b:Icon type="OK_SIGN" ui:field="iconField"></b:Icon>
</g:HTMLPanel>
<g:HTML ui:field="htmlNode">Node</g:HTML>

View File

@ -41,12 +41,7 @@ public class TreeItemPanel {
root = new TreeItem(rootNode);
root.setHTML(itemTypeTitle);
// TreeMap<String, List<TreeItem>> mapParentSections = new TreeMap<String,
// List<TreeItem>>();
treeItemParents.put(JSON_ROOT_PATH, Arrays.asList(root));
// mapParentSections.put(JSON_ROOT_PATH, Arrays.asList(root));
for (GeoNaFormCardModel geoNaFormCardModel : gnaCardsModels) {
@ -217,4 +212,8 @@ public class TreeItemPanel {
return treeItemParents;
}
public void selectItem(TreeItem item){
item.setSelected(true);
}
}

View File

@ -5,44 +5,39 @@ import java.util.ArrayList;
import java.util.List;
/**
* The Class TNode.
* The Class Tree_Node.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Jul 6, 2022
* Jul 7, 2022
* @param <T> the generic type
*/
public class TNode<T> implements Serializable {
public class Tree_Node<T> implements Serializable {
/**
*
*/
private static final long serialVersionUID = -7319055031988865761L;
private String name;
private T data;
private List<TNode<T>> children;
private TNode<T> parent;
private List<Tree_Node<T>> children = new ArrayList<Tree_Node<T>>();
private Tree_Node<T> parent;
public TNode() {
/**
* Instantiates a new tree node.
*/
public Tree_Node() {
}
/**
* Instantiates a new node.
* Instantiates a new tree node.
*
* @param name the name
* @param data the data
*/
public TNode(T data) {
public Tree_Node(String name, T data) {
this.name = name;
this.data = data;
this.children = new ArrayList<TNode<T>>();
}
/**
* Instantiates a new node.
*
* @param node the node
*/
public TNode(TNode<T> node) {
this.data = (T) node.getData();
children = new ArrayList<TNode<T>>();
}
/**
@ -50,11 +45,29 @@ public class TNode<T> implements Serializable {
*
* @param child the child
*/
public void addChild(TNode<T> child) {
public void addChild(Tree_Node<T> child) {
child.setParent(this);
children.add(child);
}
/**
* Gets the name.
*
* @return the name
*/
public String getName() {
return name;
}
/**
* Sets the name.
*
* @param name the new name
*/
public void setName(String name) {
this.name = name;
}
/**
* Gets the data.
*
@ -78,7 +91,7 @@ public class TNode<T> implements Serializable {
*
* @return the parent
*/
public TNode<T> getParent() {
public Tree_Node<T> getParent() {
return this.parent;
}
@ -87,7 +100,7 @@ public class TNode<T> implements Serializable {
*
* @param parent the new parent
*/
public void setParent(TNode<T> parent) {
public void setParent(Tree_Node<T> parent) {
this.parent = parent;
}
@ -96,7 +109,20 @@ public class TNode<T> implements Serializable {
*
* @return the children
*/
public List<TNode<T>> getChildren() {
public List<Tree_Node<T>> getChildren() {
return this.children;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("Tree_Node [name=");
builder.append(name);
builder.append(", data=");
builder.append(data);
builder.append("]");
return builder.toString();
}
}

View File

@ -37,11 +37,11 @@ h1 {
margin: 15px 6px 6px;
}
.red-text a {
.red-text {
color: red !important;
}
.green-text a {
.green-text {
color: green !important;
}
@ -120,14 +120,6 @@ h1 {
width: 95%;
}
.nav-toolbar-style {
margin-bottom: 5px;
}
.nav-toolbar-style .container {
padding-top: 5px;
}
.search-textbox {
padding: 4px 14px !important;
margin-bottom: 0 !important;
@ -146,3 +138,37 @@ h1 {
margin-top: 8px !important;
margin-bottom: 10px !important;
}
.tree-panel {
padding: 5px;
border: 1px solid #e7e7e7;
min-width: 280px;
}
.tree-panel .gwt-TreeItem {
padding: 5px !important;
border: 1px solid #dee2e6 !important;
min-width: 270px;
font-size: 16px;
}
.tree-panel .gwt-TreeItem div {
font-size: 16px;
}
.tree-panel ul {
background: #e7e7e7;
}
.nav-toolbar-style {
margin-bottom: 5px !important;
}
.nav-toolbar-style .navbar-inner {
background-image: none !important;
box-shadow: none !important;
}
.nav-toolbar-style .container {
padding-top: 5px;
}