org.dominokit.domino.ui.datatable.RowCell Maven / Gradle / Ivy
package org.dominokit.domino.ui.datatable;
import elemental2.dom.HTMLTableCellElement;
import org.dominokit.domino.ui.style.Style;
import org.dominokit.domino.ui.utils.ElementUtil;
import org.jboss.gwt.elemento.core.IsElement;
import static java.util.Objects.nonNull;
public class RowCell {
private final ColumnConfig columnConfig;
private final CellRenderer.CellInfo cellInfo;
public RowCell(CellRenderer.CellInfo cellInfo, ColumnConfig columnConfig) {
this.columnConfig = columnConfig;
this.cellInfo = cellInfo;
}
public ColumnConfig getColumnConfig() {
return columnConfig;
}
public void updateCell() {
ElementUtil.clear(cellInfo.getElement());
Style> style = Style.of(cellInfo.getElement());
if (nonNull(columnConfig.getMinWidth())) {
style.setMinWidth(columnConfig.getMinWidth());
columnConfig.getHeadElement().style().setMinWidth(columnConfig.getMinWidth());
}
if (nonNull(columnConfig.getMaxWidth())) {
style.setMaxWidth(columnConfig.getMaxWidth());
columnConfig.getHeadElement().style().setMaxWidth(columnConfig.getMaxWidth());
}
if (nonNull(columnConfig.getTextAlign())) {
style.setTextAlign(columnConfig.getTextAlign());
columnConfig.getHeadElement().style().setTextAlign(columnConfig.getTextAlign());
}
cellInfo.getElement().appendChild(columnConfig.getCellRenderer().asElement(cellInfo));
}
public CellRenderer.CellInfo getCellInfo() {
return cellInfo;
}
}