Search in sources :

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

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

Example 9 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 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);
    }
}
Also used : DivElement(com.google.gwt.dom.client.DivElement) 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 10 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 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);
}
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)

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