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 AbstractMergableGridWidget method cloneDynamicDataRow.
@SuppressWarnings({ "rawtypes", "unchecked" })
private DynamicDataRow cloneDynamicDataRow(GroupedDynamicDataRow sourceRowData) {
GroupedDynamicDataRow rowData = new GroupedDynamicDataRow();
for (int iCol = 0; iCol < sourceRowData.size(); iCol++) {
CellValue<? extends Comparable<?>> sourceCell = sourceRowData.get(iCol);
CellValue.GroupedCellValue cell = sourceCell.convertToGroupedCell();
if (sourceCell instanceof CellValue.GroupedCellValue) {
CellValue.GroupedCellValue groupedSourceCell = (CellValue.GroupedCellValue) sourceCell;
if (groupedSourceCell.isGrouped()) {
cell.addState(CellValue.CellState.GROUPED);
}
if (groupedSourceCell.isOtherwise()) {
cell.addState(CellValue.CellState.OTHERWISE);
}
}
rowData.add(cell);
}
for (DynamicDataRow childRow : sourceRowData.getChildRows()) {
rowData.addChildRow(cloneRow(childRow));
}
return rowData;
}
use of org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.DynamicDataRow in project kie-wb-common by kiegroup.
the class AbstractMergableGridWidget method findMaxRedrawRow.
// Given a base row find the maximum row that needs to be re-rendered based
// upon each columns merged cells; where each merged cell passes through the
// base row
private int findMaxRedrawRow(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 maxRedrawRow = 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 < data.size() - 1) {
iRow++;
DynamicDataRow row = data.get(iRow);
cell = row.get(iCol);
}
maxRedrawRow = (iRow > maxRedrawRow ? iRow : maxRedrawRow);
}
return maxRedrawRow;
}
use of org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.DynamicDataRow in project kie-wb-common by kiegroup.
the class AbstractMergableGridWidget method onAppendRow.
public void onAppendRow(AppendRowEvent event) {
int index = data.size();
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 onSortData.
public void onSortData(SortDataEvent event) {
// Remove grouping, if applicable
if (data.isGrouped()) {
ToggleMergingEvent tme = new ToggleMergingEvent(false);
eventBus.fireEvent(tme);
}
// Sort data
List<SortConfiguration> sortConfiguration = event.getSortConfiguration();
data.sort(sortConfiguration);
redraw();
// Copy data and raise event for underlying model to update itself
List<List<CellValue<? extends Comparable<?>>>> changedData = new ArrayList<List<CellValue<? extends Comparable<?>>>>();
for (DynamicDataRow row : data) {
List<CellValue<? extends Comparable<?>>> changedRow = new ArrayList<CellValue<? extends Comparable<?>>>();
changedData.add(changedRow);
for (int iCol = 0; iCol < row.size(); iCol++) {
CellValue<? extends Comparable<?>> changedCell = row.get(iCol);
changedRow.add(changedCell);
}
}
UpdateModelEvent dce = new UpdateModelEvent(new Coordinate(0, 0), changedData);
eventBus.fireEvent(dce);
}
Aggregations