Search in sources :

Example 51 with GridRow

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

the class RowSynchronizerTest method testMoveRowsMoveUp.

@Test
public void testMoveRowsMoveUp() throws VetoException {
    modelSynchronizer.appendRow();
    modelSynchronizer.appendRow();
    modelSynchronizer.appendRow();
    final GridRow uiRow0 = uiModel.getRow(0);
    final GridRow uiRow1 = uiModel.getRow(1);
    final GridRow uiRow2 = uiModel.getRow(2);
    final List<DTCellValue52> row0 = model.getData().get(0);
    final List<DTCellValue52> row1 = model.getData().get(1);
    final List<DTCellValue52> row2 = model.getData().get(2);
    uiModel.moveRowsTo(0, new ArrayList<GridRow>() {

        {
            add(uiRow1);
            add(uiRow2);
        }
    });
    assertEquals(uiRow1, uiModel.getRow(0));
    assertEquals(uiRow2, uiModel.getRow(1));
    assertEquals(uiRow0, uiModel.getRow(2));
    assertEquals(row1, model.getData().get(0));
    assertEquals(row2, model.getData().get(1));
    assertEquals(row0, model.getData().get(2));
}
Also used : DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) GridRow(org.uberfire.ext.wires.core.grids.client.model.GridRow) Test(org.junit.Test)

Example 52 with GridRow

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

the class ScenarioGridTest method testShowContextMenuGivenOrExpect.

@Test
public void testShowContextMenuGivenOrExpect() {
    final String columnGroup = "grp";
    final ScenarioHeaderMetaData scenarioHeaderMetaDataMock = mock(ScenarioHeaderMetaData.class);
    when(scenarioHeaderMetaDataMock.getColumnGroup()).thenReturn(columnGroup);
    final int uiColumnIndex = 0;
    final int uiRowIndex = 0;
    final double columnWidth = 100.0;
    final GridColumn columnMock = mock(ScenarioGridColumn.class);
    when(columnMock.getIndex()).thenReturn(uiColumnIndex);
    when(columnMock.getWidth()).thenReturn(columnWidth);
    when(((ScenarioGridColumn) columnMock).getFactIdentifier()).thenReturn(FactIdentifier.EMPTY);
    when(columnMock.getHeaderMetaData()).thenReturn(Collections.singletonList(scenarioHeaderMetaDataMock));
    when(((ScenarioGridColumn) columnMock).getInformationHeaderMetaData()).thenReturn(scenarioHeaderMetaDataMock);
    when(scenarioGridModelMock.getColumns()).thenReturn(Collections.singletonList(columnMock));
    final double rowHeight = 40.0;
    final GridRow gridRow = mock(ScenarioGridRow.class);
    when(gridRow.getHeight()).thenReturn(rowHeight);
    when(scenarioGridModelMock.getRow(uiRowIndex)).thenReturn(gridRow);
    when(rendererHelperMock.getColumnInformation(50.0)).thenReturn(columnInformationMock);
    when(columnInformationMock.getColumn()).thenReturn(columnMock);
}
Also used : ScenarioHeaderMetaData(org.drools.workbench.screens.scenariosimulation.client.metadata.ScenarioHeaderMetaData) GridColumn(org.uberfire.ext.wires.core.grids.client.model.GridColumn) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) GridRow(org.uberfire.ext.wires.core.grids.client.model.GridRow) Test(org.junit.Test)

Example 53 with GridRow

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

the class ScenarioGridTest method testShowContextMenuDescription.

@Test
public void testShowContextMenuDescription() {
    final int uiColumnIndex = 0;
    final int uiRowIndex = 0;
    final double columnWidth = 100.0;
    final GridColumn columnMock = mock(ScenarioGridColumn.class);
    when(columnMock.getIndex()).thenReturn(uiColumnIndex);
    when(columnMock.getWidth()).thenReturn(columnWidth);
    when(((ScenarioGridColumn) columnMock).getFactIdentifier()).thenReturn(FactIdentifier.DESCRIPTION);
    when(columnMock.getHeaderMetaData()).thenReturn(Collections.singletonList(mock(GridColumn.HeaderMetaData.class)));
    when(scenarioGridModelMock.getColumns()).thenReturn(Collections.singletonList(columnMock));
    final double rowHeight = 40.0;
    final GridRow gridRow = mock(ScenarioGridRow.class);
    when(gridRow.getHeight()).thenReturn(rowHeight);
    when(scenarioGridModelMock.getRow(uiRowIndex)).thenReturn(gridRow);
    when(rendererHelperMock.getColumnInformation(50.0)).thenReturn(columnInformationMock);
    when(columnInformationMock.getColumn()).thenReturn(columnMock);
}
Also used : GridColumn(org.uberfire.ext.wires.core.grids.client.model.GridColumn) GridRow(org.uberfire.ext.wires.core.grids.client.model.GridRow) Test(org.junit.Test)

Example 54 with GridRow

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

the class GuidedDecisionTableGridHighlightHelperTest method testOnFound.

@Test
public void testOnFound() {
    final GridHighlightHelper highlightHelper = mock(GridHighlightHelper.class);
    final GridData model = mock(GridData.class);
    final GridColumn<?> column1 = mock(GridColumn.class);
    final GridColumn<?> column2 = mock(GridColumn.class);
    final GridRow gridRow1 = mock(GridRow.class);
    final GridRow gridRow2 = mock(GridRow.class);
    final GridRow gridRow3 = mock(GridRow.class);
    final GridRow gridRow4 = mock(GridRow.class);
    final double gridRow1Height = 100;
    final double gridRow2Height = 101;
    final double gridRow3Height = 102;
    final double gridRow4Height = 103;
    final double column1Width = 90;
    final double column2Width = 110;
    final int row = 3;
    final int column = 1;
    final GuidedDecisionTableView widget = mock(GuidedDecisionTableView.class);
    final double paddingX = 310;
    final double paddingY = 406;
    doReturn(highlightHelper).when(helper).highlightHelper(modeller, widget);
    when(gridWidget2.getModel()).thenReturn(model);
    when(model.getColumns()).thenReturn(asList(column1, column2));
    when(model.getRows()).thenReturn(asList(gridRow1, gridRow2, gridRow3, gridRow4));
    when(gridRow1.getHeight()).thenReturn(gridRow1Height);
    when(gridRow2.getHeight()).thenReturn(gridRow2Height);
    when(gridRow3.getHeight()).thenReturn(gridRow3Height);
    when(gridRow4.getHeight()).thenReturn(gridRow4Height);
    when(column1.getWidth()).thenReturn(column1Width);
    when(column2.getWidth()).thenReturn(column2Width);
    when(highlightHelper.withPaddingX(paddingX)).thenReturn(highlightHelper);
    when(highlightHelper.withPaddingY(paddingY)).thenReturn(highlightHelper);
    doReturn(paddingX).when(helper).getPaddingX(column, modeller, widget);
    doReturn(paddingY).when(helper).getPaddingY(row, modeller, widget);
    helper.highlight(row, column, widget, modeller);
    verify(highlightHelper).highlight(row, column);
}
Also used : GridHighlightHelper(org.uberfire.ext.wires.core.grids.client.util.GridHighlightHelper) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) GuidedDecisionTableView(org.drools.workbench.screens.guided.dtable.client.widget.table.GuidedDecisionTableView) GridRow(org.uberfire.ext.wires.core.grids.client.model.GridRow) 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