use of org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue in project kie-wb-common by kiegroup.
the class FunctionUIModelMapper method setUiModelEditor.
private void setUiModelEditor(final int rowIndex, final int columnIndex, final FunctionDefinition function, final ExpressionEditorDefinition<Expression> ed) {
final GridCellTuple expressionParent = new GridCellTuple(rowIndex, columnIndex, gridWidget);
final boolean isOnlyVisualChangeAllowed = this.isOnlyVisualChangeAllowedSupplier.get();
final Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> editor = ed.getEditor(expressionParent, Optional.empty(), function, Optional.empty(), isOnlyVisualChangeAllowed, nesting);
uiModel.get().setCell(rowIndex, columnIndex, () -> new FunctionGridCell<>(new ExpressionCellValue(editor), listSelector));
}
use of org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue in project kie-wb-common by kiegroup.
the class UndefinedExpressionUIModelMapper method toDMNModel.
@Override
public void toDMNModel(final int rowIndex, final int columnIndex, final Supplier<Optional<GridCellValue<?>>> cell) {
cell.get().ifPresent(v -> {
final ExpressionCellValue ecv = (ExpressionCellValue) v;
ecv.getValue().ifPresent(beg -> {
hasExpression.setExpression(beg.getExpression().get().orElse(null));
beg.getExpression().get().ifPresent(e -> e.setParent(hasExpression.asDMNModelInstrumentedBase()));
});
});
}
use of org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue in project kie-wb-common by kiegroup.
the class CommandUtilsTest method testUpdateParentInformation_WithExpressionColumn.
@Test
@SuppressWarnings("unchecked")
public void testUpdateParentInformation_WithExpressionColumn() {
setupUiModel(Pair.newPair(new ExpressionEditorColumn(gridLayer, new BaseHeaderMetaData("column"), ExpressionEditorColumn.DEFAULT_WIDTH, gridWidget), (rowIndex) -> {
final BaseExpressionGrid grid = mock(BaseExpressionGrid.class);
final GridCellTuple gct = new GridCellTuple(rowIndex, 0, mock(GridWidget.class));
when(grid.getParentInformation()).thenReturn(gct);
return new ExpressionCellValue(Optional.of(grid));
}));
assertParentInformationValues(0);
gridData.moveRowTo(0, gridData.getRow(ROW_COUNT - 1));
CommandUtils.updateParentInformation(gridData);
assertParentInformationValues(0);
}
use of org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue in project kie-wb-common by kiegroup.
the class CommandUtilsTest method assertParentInformationValues.
private void assertParentInformationValues(final int expressionColumnIndex) {
IntStream.range(0, ROW_COUNT).forEach(rowIndex -> {
final ExpressionCellValue ecv = ((ExpressionCellValue) gridData.getCell(rowIndex, expressionColumnIndex).getValue());
final BaseExpressionGrid grid = ecv.getValue().get();
assertEquals(rowIndex, grid.getParentInformation().getRowIndex());
assertEquals(expressionColumnIndex, grid.getParentInformation().getColumnIndex());
});
}
use of org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue in project kie-wb-common by kiegroup.
the class ListGridTest method testOnItemSelectedExpressionColumnDefinedExpressionTypeWithCellSelectionsCoveringMultipleRows.
@Test
public void testOnItemSelectedExpressionColumnDefinedExpressionTypeWithCellSelectionsCoveringMultipleRows() {
setupGrid();
addListRow(0);
grid.getModel().selectCell(0, ROW_COLUMN_INDEX);
grid.getModel().selectCell(1, ROW_COLUMN_INDEX);
// Set an editor for expression at (0, EXPRESSION_COLUMN_INDEX)
final BaseExpressionGrid editor = mock(BaseExpressionGrid.class);
grid.getModel().setCellValue(0, EXPRESSION_COLUMN_INDEX, new ExpressionCellValue(Optional.of(editor)));
final List<HasListSelectorControl.ListSelectorItem> items = grid.getItems(0, EXPRESSION_COLUMN_INDEX);
assertThat(items.size()).isEqualTo(6);
assertDefaultListItems(items.subList(0, 4), false);
assertThat(items.get(DIVIDER)).isInstanceOf(HasListSelectorControl.ListSelectorDividerItem.class);
assertListSelectorTextItem(items.get(CLEAR_EXPRESSION_TYPE), DMNEditorConstants.ExpressionEditor_Clear, false);
}
Aggregations