Search in sources :

Example 36 with GridRow

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

the class DeleteListRowCommandTest method testCanvasCommandExecuteRemoveMiddle.

@Test
public void testCanvasCommandExecuteRemoveMiddle() {
    final GridRow firstRow = new BaseGridRow();
    final GridRow lastRow = new BaseGridRow();
    uiModel.insertRow(0, firstRow);
    uiModel.appendRow(lastRow);
    list.getExpression().add(0, HasExpression.wrap(list, null));
    list.getExpression().add(HasExpression.wrap(list, null));
    makeCommand(1);
    final Command<AbstractCanvasHandler, CanvasViolation> cc = command.newCanvasCommand(handler);
    assertEquals(CanvasCommandResultBuilder.SUCCESS, cc.execute(handler));
    assertEquals(2, uiModel.getRowCount());
    assertEquals(firstRow, uiModel.getRow(0));
    assertEquals(lastRow, uiModel.getRow(1));
    verify(command).updateRowNumbers();
    verify(command).updateParentInformation();
    verify(canvasOperation).execute();
}
Also used : CanvasViolation(org.kie.workbench.common.stunner.core.client.command.CanvasViolation) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) GridRow(org.uberfire.ext.wires.core.grids.client.model.GridRow) Test(org.junit.Test)

Example 37 with GridRow

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

the class DeleteListRowCommandTest method testCanvasCommandUndo.

@Test
public void testCanvasCommandUndo() {
    final GridRow existingGridRow = uiModel.getRow(0);
    makeCommand(0);
    // Delete row and then undo
    final Command<AbstractCanvasHandler, CanvasViolation> cc = command.newCanvasCommand(handler);
    assertEquals(CanvasCommandResultBuilder.SUCCESS, cc.execute(handler));
    reset(command, canvasOperation);
    assertEquals(CanvasCommandResultBuilder.SUCCESS, cc.undo(handler));
    assertEquals(1, uiModel.getRowCount());
    assertEquals(existingGridRow, uiModel.getRow(0));
    verify(command).updateRowNumbers();
    verify(command).updateParentInformation();
    verify(canvasOperation).execute();
}
Also used : CanvasViolation(org.kie.workbench.common.stunner.core.client.command.CanvasViolation) AbstractCanvasHandler(org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) GridRow(org.uberfire.ext.wires.core.grids.client.model.GridRow) Test(org.junit.Test)

Example 38 with GridRow

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

the class MoveRowsCommandTest method addUiModelRow.

protected void addUiModelRow(final int rowIndex) {
    final GridRow uiRow = new BaseGridRow();
    uiModel.appendRow(uiRow);
    uiModel.setCellValue(rowIndex, 0, new BaseGridCellValue<>(rowIndex + 1));
    uiModel.setCellValue(rowIndex, 1, new BaseGridCellValue<>("name" + rowIndex));
    uiModel.setCellValue(rowIndex, 2, new BaseGridCellValue<>("editor" + rowIndex));
}
Also used : BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) GridRow(org.uberfire.ext.wires.core.grids.client.model.GridRow)

Example 39 with GridRow

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

the class ExpressionEditorGridRowTest method testRowHigherThanDefault.

@Test
@SuppressWarnings("unchecked")
public void testRowHigherThanDefault() {
    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)))).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) 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 40 with GridRow

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

the class ExpressionEditorGridRowTest method testRowLowerThanDefault.

@Test
@SuppressWarnings("unchecked")
public void testRowLowerThanDefault() {
    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)))).build();
    when(row.getCells()).thenReturn(cells);
    assertThat(row.getHeight()).isBetween(0D, DEFAULT_HEIGHT);
}
Also used : BaseGridCell(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCell) 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