Search in sources :

Example 1 with DynamicDataRow

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++;
    }
}
Also used : DynamicDataRow(org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.DynamicDataRow) GroupedDynamicDataRow(org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.GroupedDynamicDataRow)

Example 2 with DynamicDataRow

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;
}
Also used : GroupedDynamicDataRow(org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.GroupedDynamicDataRow) DynamicDataRow(org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.DynamicDataRow) GroupedDynamicDataRow(org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.GroupedDynamicDataRow)

Example 3 with DynamicDataRow

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;
}
Also used : DynamicDataRow(org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.DynamicDataRow) GroupedDynamicDataRow(org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.GroupedDynamicDataRow)

Example 4 with DynamicDataRow

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);
}
Also used : DynamicDataRow(org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.DynamicDataRow) GroupedDynamicDataRow(org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.GroupedDynamicDataRow)

Example 5 with DynamicDataRow

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);
}
Also used : ArrayList(java.util.ArrayList) ToggleMergingEvent(org.kie.workbench.common.widgets.decoratedgrid.client.widget.events.ToggleMergingEvent) DynamicDataRow(org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.DynamicDataRow) GroupedDynamicDataRow(org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.GroupedDynamicDataRow) UpdateModelEvent(org.kie.workbench.common.widgets.decoratedgrid.client.widget.events.UpdateModelEvent) Coordinate(org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.Coordinate) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

DynamicDataRow (org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.DynamicDataRow)16 GroupedDynamicDataRow (org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.GroupedDynamicDataRow)9 TableRowElement (com.google.gwt.dom.client.TableRowElement)6 Coordinate (org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.Coordinate)4 TableCellElement (com.google.gwt.dom.client.TableCellElement)3 DivElement (com.google.gwt.dom.client.DivElement)1 TableSectionElement (com.google.gwt.dom.client.TableSectionElement)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 InterpolationVariable (org.drools.workbench.models.datamodel.rule.InterpolationVariable)1 ToggleMergingEvent (org.kie.workbench.common.widgets.decoratedgrid.client.widget.events.ToggleMergingEvent)1 UpdateModelEvent (org.kie.workbench.common.widgets.decoratedgrid.client.widget.events.UpdateModelEvent)1