use of org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow in project kie-wb-common by kiegroup.
the class MoveColumnsCommandTest method addUiModelRow.
@Override
protected void addUiModelRow(final int rowIndex) {
final DMNGridRow uiRow = new DMNGridRow();
uiModel.appendRow(uiRow);
uiModel.setCellValue(rowIndex, 0, new BaseGridCellValue<>(rowIndex + 1));
uiModel.setCellValue(rowIndex, 1, new BaseGridCellValue<>("value0"));
uiModel.setCellValue(rowIndex, 2, new BaseGridCellValue<>("value1"));
}
use of org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow in project kie-wb-common by kiegroup.
the class ExpressionContainerUIModelMapperTest method setup.
@Before
@SuppressWarnings("unchecked")
public void setup() {
uiModel = new BaseGridData();
uiModel.appendRow(new DMNGridRow());
uiModel.appendColumn(uiExpressionColumn);
doReturn(0).when(uiExpressionColumn).getIndex();
doReturn(MINIMUM_COLUMN_WIDTH).when(uiExpressionColumn).getMinimumWidth();
parent = new GridCellTuple(0, 0, expressionContainerGrid);
final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
expressionEditorDefinitions.add(literalExpressionEditorDefinition);
expressionEditorDefinitions.add(undefinedExpressionEditorDefinition);
doReturn(expressionEditorDefinitions).when(expressionEditorDefinitionsSupplier).get();
doReturn(Optional.of(literalExpression)).when(literalExpressionEditorDefinition).getModelClass();
doReturn(Optional.of(literalExpression)).when(literalExpressionEditor).getExpression();
doReturn(Optional.of(literalExpressionEditor)).when(literalExpressionEditorDefinition).getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), any(Optional.class), anyInt());
doReturn(Optional.empty()).when(undefinedExpressionEditorDefinition).getModelClass();
doReturn(Optional.of(undefinedExpressionEditor)).when(undefinedExpressionEditorDefinition).getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), any(Optional.class), anyInt());
mapper = new ExpressionContainerUIModelMapper(parent, () -> uiModel, () -> Optional.ofNullable(expression), () -> NODE_UUID, () -> hasExpression, () -> Optional.of(hasName), expressionEditorDefinitionsSupplier, listSelector);
}
use of org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow in project kie-wb-common by kiegroup.
the class UndefinedExpressionUIModelMapperTest method setup.
@Before
@SuppressWarnings("unchecked")
public void setup() {
this.uiModel = new BaseGridData();
this.uiModel.appendColumn(uiColumn);
this.uiModel.appendRow(new DMNGridRow());
this.mapper = new UndefinedExpressionUIModelMapper(() -> uiModel, () -> Optional.ofNullable(expression), listSelector, hasExpression, new GridCellTuple(PARENT_ROW_INDEX, PARENT_COLUMN_INDEX, parentGridWidget));
this.cellValueSupplier = () -> Optional.of(new ExpressionCellValue(Optional.of(editor)));
when(parentGridWidget.getModel()).thenReturn(parentGridUiModel);
when(parentGridUiModel.getCell(eq(PARENT_ROW_INDEX), eq(PARENT_COLUMN_INDEX))).thenReturn(parentGridUiCell);
when(parentGridUiCell.getSelectionStrategy()).thenReturn(parentGridUiCellCellSelectionStrategy);
}
use of org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow in project kie-wb-common by kiegroup.
the class BaseExpressionGridGeneralTest method testSelectFirstCellWithRowAndRowNumberColumn.
@Test
public void testSelectFirstCellWithRowAndRowNumberColumn() {
grid.getModel().appendRow(new DMNGridRow());
appendColumns(RowNumberColumn.class);
grid.selectFirstCell();
assertThat(grid.getModel().getSelectedCells()).isEmpty();
}
use of org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow in project kie-wb-common by kiegroup.
the class BaseExpressionGridGeneralTest method testUpdateWidthOfPeers.
/*
* Test that parent column width is updated to sum of nested columns
* The update is forced from nested column at position indexOfColumnToUpdate
* The default width of parent column is 100
*/
private void testUpdateWidthOfPeers(final int indexOfColumnToUpdate, final double... widthsOfNestedColumns) {
// parent column
final BaseExpressionGrid parentGrid = mock(BaseExpressionGrid.class);
final GridData parentGridData = mock(GridData.class);
final DMNGridColumn parentColumn = mockColumn(100, null);
doReturn(parentGrid).when(parentCell).getGridWidget();
doReturn(parentGridData).when(parentGrid).getModel();
doReturn(Collections.singletonList(parentColumn)).when(parentGridData).getColumns();
doReturn(Collections.singleton(parentGrid)).when(gridLayer).getGridWidgets();
// nested columns
final List<DMNGridColumn> columns = Arrays.stream(widthsOfNestedColumns).mapToObj(width -> mockColumn(width, grid)).collect(Collectors.toList());
grid.getModel().appendRow(new DMNGridRow());
columns.stream().forEach(column -> grid.getModel().appendColumn(column));
// force the peers width update
columns.get(indexOfColumnToUpdate).updateWidthOfPeers();
// assert parent width is equal to sum of nested columns widths
final double padding = BaseExpressionGrid.DEFAULT_PADDING * 2;
Assertions.assertThat(parentColumn.getWidth()).isEqualTo(Arrays.stream(widthsOfNestedColumns).sum() + padding);
}
Aggregations