use of org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.DynamicDataRow in project kie-wb-common by kiegroup.
the class AbstractMergableGridWidget method onInsertRow.
public void onInsertRow(InsertRowEvent event) {
int index = rowMapper.mapToMergedRow(event.getIndex());
DynamicDataRow rowData = cellValueFactory.makeUIRowData();
insertRow(index, rowData);
}
use of org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.DynamicDataRow in project kie-wb-common by kiegroup.
the class AbstractMergableGridWidget method findMinRedrawRow.
// Given a base row find the minimum row that needs to be re-rendered based
// upon each columns merged cells; where each merged cell passes through the
// base row
private int findMinRedrawRow(int baseRowIndex) {
if (data.size() == 0) {
return 0;
}
// These should never happen, but it's a safe-guard
if (baseRowIndex < 0) {
baseRowIndex = 0;
}
if (baseRowIndex > data.size() - 1) {
baseRowIndex = data.size() - 1;
}
int minRedrawRow = baseRowIndex;
DynamicDataRow baseRow = data.get(baseRowIndex);
for (int iCol = 0; iCol < baseRow.size(); iCol++) {
int iRow = baseRowIndex;
CellValue<? extends Comparable<?>> cell = baseRow.get(iCol);
while (cell.getRowSpan() != 1 && iRow > 0) {
iRow--;
DynamicDataRow row = data.get(iRow);
cell = row.get(iCol);
}
minRedrawRow = (iRow < minRedrawRow ? iRow : minRedrawRow);
}
return minRedrawRow;
}
use of org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.DynamicDataRow in project kie-wb-common by kiegroup.
the class AbstractVerticalMergableGridWidget method redrawRows.
@Override
protected void redrawRows(int startRedrawIndex, int endRedrawIndex) {
if (startRedrawIndex < 0) {
throw new IllegalArgumentException("startRedrawIndex cannot be less than zero.");
}
if (startRedrawIndex > data.size()) {
throw new IllegalArgumentException("startRedrawIndex cannot be greater than the number of rows in the table.");
}
if (endRedrawIndex < 0) {
throw new IllegalArgumentException("endRedrawIndex cannot be less than zero.");
}
if (endRedrawIndex > data.size()) {
throw new IllegalArgumentException("endRedrawIndex cannot be greater than the number of rows in the table.");
}
if (startRedrawIndex > endRedrawIndex) {
throw new IllegalArgumentException("startRedrawIndex cannot be greater than endRedrawIndex.");
}
// Redraw replacement rows
for (int iRow = startRedrawIndex; iRow <= endRedrawIndex; iRow++) {
DynamicDataRow rowData = data.get(iRow);
TableRowElement tre = Document.get().createTRElement();
populateTableRowElement(tre, rowData);
tbody.replaceChild(tre, tbody.getChild(iRow));
}
fixRowStyles(startRedrawIndex);
}
use of org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.DynamicDataRow in project kie-wb-common by kiegroup.
the class AbstractVerticalMergableGridWidget method showColumn.
@Override
void showColumn(int index) {
if (index < 0) {
throw new IllegalArgumentException("index cannot be less than zero");
}
if (index > columns.size()) {
throw new IllegalArgumentException("index cannot be greater than the number of rows");
}
for (int iRow = 0; iRow < data.size(); iRow++) {
DynamicDataRow rowData = data.get(iRow);
TableCellElement tce = makeTableCellElement(index, rowData);
if (tce != null) {
CellValue<? extends Comparable<?>> cell = rowData.get(index);
Coordinate hc = cell.getHtmlCoordinate();
TableRowElement tre = tbody.getRows().getItem(hc.getRow());
TableCellElement ntce = tre.insertCell(hc.getCol());
tre.replaceChild(tce, ntce);
}
}
}
use of org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.DynamicDataRow in project kie-wb-common by kiegroup.
the class AbstractVerticalMergableGridWidget method hideColumn.
@Override
void hideColumn(int index) {
if (index < 0) {
throw new IllegalArgumentException("index cannot be less than zero");
}
if (index > columns.size()) {
throw new IllegalArgumentException("index cannot be greater than the number of rows");
}
for (int iRow = 0; iRow < data.size(); iRow++) {
DynamicDataRow rowData = data.get(iRow);
CellValue<? extends Comparable<?>> cell = rowData.get(index);
if (cell.getRowSpan() > 0) {
Coordinate hc = cell.getHtmlCoordinate();
TableRowElement tre = tbody.getRows().getItem(hc.getRow());
TableCellElement tce = tre.getCells().getItem(hc.getCol());
tre.removeChild(tce);
}
}
}
Aggregations