geoportal-data-entry-app/src/main/java/org/gcube/portlets/user/geoportaldataentry/client/ui/tree/NodeItem.java

134 lines
3.9 KiB
Java
Raw Normal View History

package org.gcube.portlets.user.geoportaldataentry.client.ui.tree;
2022-07-05 15:51:43 +02:00
import org.gcube.portlets.user.geoportaldataentry.client.ui.card.GeoNaFormCardModel;
2022-07-04 16:34:15 +02:00
import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.constants.IconType;
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.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.TreeItem;
import com.google.gwt.user.client.ui.Widget;
public class NodeItem extends Composite {
private static NodeItemUiBinder uiBinder = GWT.create(NodeItemUiBinder.class);
interface NodeItemUiBinder extends UiBinder<Widget, NodeItem> {
}
@UiField
HTML htmlNode;
@UiField
Button buttonAdd;
@UiField
Button buttonRemove;
2022-07-05 15:51:43 +02:00
private GeoNaFormCardModel geoNaFormCardModel;
private TreeItem parentTreeItem;
private String jsonSectionFullPath;
// public NodeItem(TreeItem parent, GcubeProfileDV profile, CreateMetadataForm baseForm, Integer minOccurs,
// Integer maxOccurs, boolean canBeDuplicated, boolean canBeDeleted) {
// initWidget(uiBinder.createAndBindUi(this));
// this.profile = profile;
// this.baseForm = baseForm;
// htmlNode.setHTML(profile.getSectionTitle());
// buttonAdd.setVisible(false);
// buttonRemove.setVisible(false);
//
// if (canBeDuplicated) {
// buttonAdd.setIcon(IconType.COPY);
// buttonAdd.getElement().getStyle().setProperty("pointerEvents", "none");
// buttonAdd.getElement().getStyle().setProperty("textDecoration", "none");
// buttonAdd.getElement().getStyle().setColor("#555");
// buttonAdd.setVisible(true);
//
// }
//
// if (canBeDeleted) {
// buttonRemove.setIcon(IconType.TRASH);
// buttonRemove.getElement().getStyle().setProperty("pointerEvents", "none");
// buttonRemove.getElement().getStyle().setProperty("textDecoration", "none");
// buttonRemove.getElement().getStyle().setColor("#555");
// buttonRemove.setVisible(true);
// }
//
// htmlNode.addClickHandler(new ClickHandler() {
//
// @Override
// public void onClick(ClickEvent event) {
// // TODO Auto-generated method stub
//
// }
// });
//
// }
public NodeItem(TreeItem parent, GeoNaFormCardModel geoNaFormCardModel, boolean canBeDeleted,
String jsonSectionFullPath) {
initWidget(uiBinder.createAndBindUi(this));
2022-07-05 15:51:43 +02:00
this.geoNaFormCardModel = geoNaFormCardModel;
this.parentTreeItem = parent;
this.jsonSectionFullPath = jsonSectionFullPath;
htmlNode.setHTML(geoNaFormCardModel.getGcubeProfile().getSectionTitle());
buttonAdd.setVisible(false);
buttonRemove.setVisible(false);
boolean canBeDuplicated = geoNaFormCardModel.getFormCard().isInternalRepeatibleForm();
if (canBeDuplicated) {
buttonAdd.setIcon(IconType.COPY);
buttonAdd.getElement().getStyle().setProperty("pointerEvents", "none");
buttonAdd.getElement().getStyle().setProperty("textDecoration", "none");
buttonAdd.getElement().getStyle().setColor("#555");
buttonAdd.setVisible(true);
}
if (canBeDeleted) {
buttonRemove.setIcon(IconType.TRASH);
buttonRemove.getElement().getStyle().setProperty("pointerEvents", "none");
buttonRemove.getElement().getStyle().setProperty("textDecoration", "none");
buttonRemove.getElement().getStyle().setColor("#555");
buttonRemove.setVisible(true);
}
htmlNode.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
// TODO Auto-generated method stub
}
});
}
2022-07-05 15:51:43 +02:00
public TreeItem getParentTreeItem() {
return parentTreeItem;
}
public GeoNaFormCardModel getGeoNaFormCardModel() {
return geoNaFormCardModel;
}
/**
* Gets the json section full path.
*
* @return the json section full path
*/
public String getJsonSectionFullPath() {
return jsonSectionFullPath;
}
}