Search in sources :

Example 1 with Coordinate

use of org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.Coordinate in project drools-wb by kiegroup.

the class ModelSynchronizerImpl method fireValidateEvent.

protected void fireValidateEvent(final GridData.Range rowRange, final Set<Integer> columnRange) {
    final int minRowIndex = rowRange.getMinRowIndex();
    final int maxRowIndex = rowRange.getMaxRowIndex();
    final List<Coordinate> updates = new ArrayList<>();
    for (final Integer columnIndex : columnRange) {
        for (int rowIndex = minRowIndex; rowIndex <= maxRowIndex; rowIndex++) {
            updates.add(new Coordinate(rowIndex, columnIndex));
        }
    }
    final ValidateEvent event = new ValidateEvent(updates);
    eventBus.fireEvent(event);
}
Also used : Coordinate(org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.Coordinate) ArrayList(java.util.ArrayList) ValidateEvent(org.drools.workbench.screens.guided.dtable.client.widget.analysis.controller.ValidateEvent)

Example 2 with Coordinate

use of org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.Coordinate in project drools-wb by kiegroup.

the class TemplateDataTableWidget method onUpdateModel.

public void onUpdateModel(UpdateModelEvent event) {
    // Copy data into the underlying model
    Map<Coordinate, List<List<CellValue<? extends Comparable<?>>>>> updates = event.getUpdates();
    for (Map.Entry<Coordinate, List<List<CellValue<? extends Comparable<?>>>>> e : updates.entrySet()) {
        // Coordinate of change
        Coordinate originCoordinate = e.getKey();
        int originRowIndex = originCoordinate.getRow();
        int originColumnIndex = originCoordinate.getCol();
        // Changed data
        List<List<CellValue<? extends Comparable<?>>>> data = e.getValue();
        InterpolationVariable[] vars = model.getInterpolationVariablesList();
        for (int iRow = 0; iRow < data.size(); iRow++) {
            List<CellValue<? extends Comparable<?>>> rowData = data.get(iRow);
            int targetRowIndex = originRowIndex + iRow;
            for (int iCol = 0; iCol < rowData.size(); iCol++) {
                int targetColumnIndex = originColumnIndex + iCol;
                CellValue<? extends Comparable<?>> changedCell = rowData.get(iCol);
                InterpolationVariable var = vars[targetColumnIndex];
                TemplateDataColumn col = new TemplateDataColumn(var.getVarName(), var.getDataType(), var.getFactType(), var.getFactField());
                String dcv = cellValueFactory.convertToModelCell(col, changedCell);
                List<String> columnData = model.getTable().get(var.getVarName());
                columnData.set(targetRowIndex, dcv);
            }
        }
    }
}
Also used : InterpolationVariable(org.drools.workbench.models.datamodel.rule.InterpolationVariable) Coordinate(org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.Coordinate) ArrayList(java.util.ArrayList) List(java.util.List) CellValue(org.kie.workbench.common.widgets.decoratedgrid.client.widget.CellValue) Map(java.util.Map)

Aggregations

ArrayList (java.util.ArrayList)2 Coordinate (org.kie.workbench.common.widgets.decoratedgrid.client.widget.data.Coordinate)2 List (java.util.List)1 Map (java.util.Map)1 InterpolationVariable (org.drools.workbench.models.datamodel.rule.InterpolationVariable)1 ValidateEvent (org.drools.workbench.screens.guided.dtable.client.widget.analysis.controller.ValidateEvent)1 CellValue (org.kie.workbench.common.widgets.decoratedgrid.client.widget.CellValue)1