ckan-metadata-publisher-widget/src/main/java/org/gcube/portlets/widgets/ckandatapublisherwidget/client/ui/TwinColumnSelection/ResourceCellLeft.java

38 lines
1.3 KiB
Java

package org.gcube.portlets.widgets.ckandatapublisherwidget.client.ui.TwinColumnSelection;
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.ResourceElementBean;
import com.github.gwtbootstrap.client.ui.Icon;
import com.github.gwtbootstrap.client.ui.constants.IconType;
import com.google.gwt.cell.client.AbstractCell;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
/**
* Cell that renders left side panel objects
* @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it)
*/
public class ResourceCellLeft extends AbstractCell<ResourceElementBean>{
private static final String HTML_FILE = new Icon(IconType.FILE_ALT).toString();
private static final String HTML_FOLDER = new Icon(IconType.FOLDER_CLOSE_ALT).toString();
@Override
public void render(com.google.gwt.cell.client.Cell.Context context,
ResourceElementBean value, SafeHtmlBuilder sb) {
if (value == null || value.isToBeAdded()) {
return;
}
sb.appendHtmlConstant("<div style='width:100%; padding:2px'>");
sb.appendHtmlConstant(value.isFolder() ? HTML_FOLDER : HTML_FILE);
sb.appendHtmlConstant("<span style='margin-left:5px'>");
sb.appendHtmlConstant("<b>");
sb.appendEscaped(value.getName());
sb.appendHtmlConstant("</b>");
sb.appendHtmlConstant("</span>");
sb.appendHtmlConstant("</div>");
}
}