Search in sources :

Example 11 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 onInsertRow.

public void onInsertRow(InsertRowEvent event) {
    int index = rowMapper.mapToMergedRow(event.getIndex());
    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 12 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 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;
}
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 13 with DynamicDataRow

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

Example 14 with DynamicDataRow

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);
        }
    }
}
Also used : Coordinate(org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.Coordinate) TableRowElement(com.google.gwt.dom.client.TableRowElement) DynamicDataRow(org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.DynamicDataRow) TableCellElement(com.google.gwt.dom.client.TableCellElement)

Example 15 with DynamicDataRow

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);
        }
    }
}
Also used : Coordinate(org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.Coordinate) TableRowElement(com.google.gwt.dom.client.TableRowElement) DynamicDataRow(org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.DynamicDataRow) TableCellElement(com.google.gwt.dom.client.TableCellElement)

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