Search in sources :

Example 21 with GridRow

use of org.uberfire.ext.wires.core.grids.client.model.GridRow in project kie-wb-common by kiegroup.

the class GridCellTuple method getRequiredParentColumnWidth.

private double getRequiredParentColumnWidth(final double proposedWidth, final Function<BaseExpressionGrid, Double> requiredWidthSupplier) {
    double width = proposedWidth;
    final GridData uiModel = gridWidget.getModel();
    for (GridRow row : uiModel.getRows()) {
        final GridCell<?> cell = row.getCells().get(columnIndex);
        if (cell != null) {
            final GridCellValue<?> value = cell.getValue();
            if (value instanceof ExpressionCellValue) {
                final ExpressionCellValue ecv = (ExpressionCellValue) value;
                final Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> editor = ecv.getValue();
                if (editor.isPresent()) {
                    final BaseExpressionGrid beg = editor.get();
                    width = Math.max(width, requiredWidthSupplier.apply(beg));
                }
            }
        }
    }
    return width;
}
Also used : BaseExpressionGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid) Expression(org.kie.workbench.common.dmn.api.definition.model.Expression) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue) GridRow(org.uberfire.ext.wires.core.grids.client.model.GridRow)

Example 22 with GridRow

use of org.uberfire.ext.wires.core.grids.client.model.GridRow in project kie-wb-common by kiegroup.

the class DMNGridHelperTest method testHighlightHelper.

@Test
public void testHighlightHelper() {
    final int row = 1;
    final int column = 1;
    final GridColumn<?> headerColumn = mock(GridColumn.class);
    final GridColumn<?> currentColumn = mock(GridColumn.class);
    final GridRow headerRow = mock(GridRow.class);
    final GridRow currentRow = mock(GridRow.class);
    final double headerColumnWidth = 2d;
    final double currentColumnWidth = 4d;
    final double headerRowWidth = 8d;
    final double currentRowWidth = 16d;
    doReturn(highlightHelper).when(helper).highlightHelper(gridWidget1);
    when(gridWidget1.getModel()).thenReturn(model);
    when(model.getColumns()).thenReturn(asList(headerColumn, currentColumn));
    when(model.getRows()).thenReturn(asList(headerRow, currentRow));
    when(headerColumn.getWidth()).thenReturn(headerColumnWidth);
    when(currentColumn.getWidth()).thenReturn(currentColumnWidth);
    when(headerRow.getHeight()).thenReturn(headerRowWidth);
    when(currentRow.getHeight()).thenReturn(currentRowWidth);
    when(highlightHelper.withPaddingX(headerColumnWidth + currentColumnWidth)).thenReturn(highlightHelper);
    when(highlightHelper.withPaddingY(headerRowWidth + currentRowWidth)).thenReturn(highlightHelper);
    when(highlightHelper.withPinnedGrid()).thenReturn(highlightHelper);
    helper.highlightCell(row, column, gridWidget1);
    verify(highlightHelper).highlight(row, column);
}
Also used : GridRow(org.uberfire.ext.wires.core.grids.client.model.GridRow) Test(org.junit.Test)

Example 23 with GridRow

use of org.uberfire.ext.wires.core.grids.client.model.GridRow in project kie-wb-common by kiegroup.

the class ExpressionEditorGridRowTest method testRowHigherThanDefaultWithNullCell.

@Test
@SuppressWarnings("unchecked")
public void testRowHigherThanDefaultWithNullCell() {
    when(view.getHeight()).thenReturn(DEFAULT_HEIGHT + 1);
    final GridRow row = spy(ExpressionEditorGridRow.class);
    final Map<Integer, GridCell<?>> cells = new Maps.Builder<Integer, GridCell<?>>().put(0, new BaseGridCell<>(new ExpressionCellValue(Optional.of(view)))).put(1, null).build();
    when(row.getCells()).thenReturn(cells);
    assertThat(row.getHeight()).isGreaterThan(DEFAULT_HEIGHT);
}
Also used : Maps(org.kie.soup.commons.util.Maps) ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue) GridRow(org.uberfire.ext.wires.core.grids.client.model.GridRow) GridCell(org.uberfire.ext.wires.core.grids.client.model.GridCell) BaseGridCell(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCell) Test(org.junit.Test)

Example 24 with GridRow

use of org.uberfire.ext.wires.core.grids.client.model.GridRow in project kie-wb-common by kiegroup.

the class ExpressionEditorGridRowTest method testEmptyRow.

@Test
public void testEmptyRow() {
    final GridRow row = new ExpressionEditorGridRow();
    assertThat(row.getHeight()).isEqualTo(DEFAULT_HEIGHT);
}
Also used : GridRow(org.uberfire.ext.wires.core.grids.client.model.GridRow) Test(org.junit.Test)

Example 25 with GridRow

use of org.uberfire.ext.wires.core.grids.client.model.GridRow in project kie-wb-common by kiegroup.

the class ExpressionEditorGridRowTest method testRowHigherThanDefaultWithNullCellValue.

@Test
@SuppressWarnings("unchecked")
public void testRowHigherThanDefaultWithNullCellValue() {
    when(view.getHeight()).thenReturn(DEFAULT_HEIGHT + 1);
    final GridRow row = spy(ExpressionEditorGridRow.class);
    final Map<Integer, GridCell<?>> cells = new Maps.Builder<Integer, GridCell<?>>().put(0, new BaseGridCell<>(new ExpressionCellValue(Optional.of(view)))).put(1, new BaseGridCell<>(null)).build();
    when(row.getCells()).thenReturn(cells);
    assertThat(row.getHeight()).isGreaterThan(DEFAULT_HEIGHT);
}
Also used : BaseGridCell(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCell) Maps(org.kie.soup.commons.util.Maps) ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue) GridRow(org.uberfire.ext.wires.core.grids.client.model.GridRow) GridCell(org.uberfire.ext.wires.core.grids.client.model.GridCell) BaseGridCell(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCell) Test(org.junit.Test)

Aggregations

GridRow (org.uberfire.ext.wires.core.grids.client.model.GridRow)54 Test (org.junit.Test)31 BaseGridRow (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow)22 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)10 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)10 CanvasViolation (org.kie.workbench.common.stunner.core.client.command.CanvasViolation)10 ExpressionCellValue (org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue)8 GridCell (org.uberfire.ext.wires.core.grids.client.model.GridCell)6 GridData (org.uberfire.ext.wires.core.grids.client.model.GridData)6 BaseGridCell (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCell)6 ArrayList (java.util.ArrayList)4 DecisionRule (org.kie.workbench.common.dmn.api.definition.model.DecisionRule)4 BaseExpressionGrid (org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid)4 Expression (org.kie.workbench.common.dmn.api.definition.model.Expression)3 LiteralExpression (org.kie.workbench.common.dmn.api.definition.model.LiteralExpression)3 HashMap (java.util.HashMap)2 Maps (org.kie.soup.commons.util.Maps)2 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)2 List (org.kie.workbench.common.dmn.api.definition.model.List)2 BaseUIModelMapper (org.kie.workbench.common.dmn.client.widgets.grid.model.BaseUIModelMapper)2