package org.gcube.portlets.user.geoportaldataentry.client.ui.tree; import org.gcube.portlets.user.geoportaldataentry.client.ui.card.GeoNaFormCardModel; 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 { } @UiField HTML htmlNode; @UiField Button buttonAdd; @UiField Button buttonRemove; 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)); 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 } }); } 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; } }