use of org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.DynamicDataRow in project kie-wb-common by kiegroup.
the class AbstractMergableGridWidget method onPasteRows.
public void onPasteRows(PasteRowsEvent event) {
if (copiedRows == null || copiedRows.size() == 0) {
return;
}
int iRow = rowMapper.mapToMergedRow(event.getTargetRowIndex());
for (DynamicDataRow sourceRowData : copiedRows) {
// Clone the row, other than RowNumber column
insertRow(iRow, cloneRow(sourceRowData));
iRow++;
}
}
use of org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.DynamicDataRow in project kie-wb-common by kiegroup.
the class AbstractVerticalMergableGridWidget method redraw.
@Override
protected void redraw() {
TableSectionElement nbody = Document.get().createTBodyElement();
for (int iRow = 0; iRow < data.size(); iRow++) {
DynamicDataRow rowData = data.get(iRow);
TableRowElement tre = Document.get().createTRElement();
tre.setClassName(getRowStyle(iRow));
populateTableRowElement(tre, rowData);
nbody.appendChild(tre);
}
// Update table to DOM
table.replaceChild(nbody, tbody);
tbody = nbody;
}
use of org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.DynamicDataRow in project kie-wb-common by kiegroup.
the class AbstractVerticalMergableGridWidget method redrawColumns.
@Override
void redrawColumns(int startRedrawIndex, int endRedrawIndex) {
if (startRedrawIndex < 0) {
throw new IllegalArgumentException("startRedrawIndex cannot be less than zero.");
}
if (startRedrawIndex > columns.size()) {
throw new IllegalArgumentException("startRedrawIndex cannot be greater than the number of defined columns.");
}
if (endRedrawIndex < 0) {
throw new IllegalArgumentException("endRedrawIndex cannot be less than zero.");
}
if (endRedrawIndex > columns.size()) {
throw new IllegalArgumentException("endRedrawIndex cannot be greater than the number of defined columns.");
}
if (startRedrawIndex > endRedrawIndex) {
throw new IllegalArgumentException("startRedrawIndex cannot be greater than endRedrawIndex.");
}
for (int iRow = 0; iRow < data.size(); iRow++) {
TableRowElement tre = tbody.getRows().getItem(iRow);
DynamicDataRow rowData = data.get(iRow);
redrawTableRowElement(rowData, tre, startRedrawIndex, endRedrawIndex);
}
}
use of org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.DynamicDataRow in project kie-wb-common by kiegroup.
the class AbstractVerticalMergableGridWidget method resizeColumn.
@Override
public void resizeColumn(DynamicColumn<?> col, int width) {
if (col == null) {
throw new IllegalArgumentException("col cannot be null");
}
if (width < 0) {
throw new IllegalArgumentException("width cannot be less than zero");
}
col.setWidth(width);
int iCol = col.getColumnIndex();
for (DynamicDataRow row : data) {
CellValue<? extends Comparable<?>> cell = row.get(iCol);
Coordinate c = cell.getHtmlCoordinate();
TableRowElement tre = tbody.getRows().getItem(c.getRow());
TableCellElement tce = tre.getCells().getItem(c.getCol());
DivElement div = tce.getFirstChild().<DivElement>cast();
DivElement divText = tce.getFirstChild().getFirstChild().<DivElement>cast();
// Set widths
tce.getStyle().setWidth(width, Unit.PX);
div.getStyle().setWidth(width, Unit.PX);
divText.getStyle().setWidth(width, Unit.PX);
}
}
use of org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.DynamicDataRow in project kie-wb-common by kiegroup.
the class AbstractMergableGridWidget method onUpdateColumnData.
public void onUpdateColumnData(UpdateColumnDataEvent event) {
int iRowIndex = 0;
int iColIndex = event.getIndex();
List<CellValue<? extends Comparable<?>>> columnData = event.getColumnData();
for (int iRow = 0; iRow < data.size(); iRow++) {
DynamicDataRow row = data.get(iRow);
CellValue<? extends Comparable<?>> cell = columnData.get(iRowIndex);
if (row instanceof GroupedDynamicDataRow) {
GroupedDynamicDataRow groupedRow = (GroupedDynamicDataRow) row;
// Setting value on a GroupedCellValue causes all children to assume the same value
groupedRow.get(iColIndex).setValue(cell.getValue());
// So set the children's values accordingly
for (int iGroupedRow = 0; iGroupedRow < groupedRow.getChildRows().size(); iGroupedRow++) {
cell = columnData.get(iRowIndex);
groupedRow.getChildRows().get(iGroupedRow).get(iColIndex).setValue(cell.getValue());
iRowIndex++;
}
} else {
row.get(iColIndex).setValue(cell.getValue());
iRowIndex++;
}
}
data.assertModelMerging();
redrawColumns(iColIndex, columns.size() - 1);
}
Aggregations