use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue in project kie-wb-common by kiegroup.
the class EditableNameAndDataTypeColumnTest method setup.
@Before
public void setup() {
when(gridWidget.getExpression()).thenReturn(Optional::empty);
this.cell = new BaseGridCell<>(new BaseGridCellValue<>(HasNameAndDataTypeCell.wrap(informationItem)));
this.column = spy(new EditableNameAndDataTypeColumn<ContextGrid>(headerMetaData, DMNGridColumn.DEFAULT_WIDTH, gridWidget, isEditable, clearValueConsumer, setValueConsumer, setTypeRefConsumer, translationService, cellEditorControls, editor) {
@Override
protected String getPopoverTitle() {
return POPOVER_TITLE;
}
});
when(context.getRelativeLocation()).thenReturn(Optional.of(new Point2D(RELATIVE_X, RELATIVE_Y)));
when(context.getRowIndex()).thenReturn(UI_ROW_INDEX);
when(context.getColumnIndex()).thenReturn(UI_COLUMN_INDEX);
when(context.getAbsoluteCellX()).thenReturn(ABSOLUTE_CELL_X);
when(context.getAbsoluteCellY()).thenReturn(ABSOLUTE_CELL_Y);
when(gridWidget.getParentInformation()).thenReturn(new GridCellTuple(0, 0, gridWidget));
when(translationService.getTranslation(Mockito.<String>any())).thenAnswer(i -> i.getArguments()[0]);
}
use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue in project kie-wb-common by kiegroup.
the class LiteralExpressionGridRowTest method testGetHeightWithHasDynamicHeightCell.
@Test
public void testGetHeightWithHasDynamicHeightCell() {
final GridRow row = spy(new LiteralExpressionGridRow());
final Map<Integer, GridCell> cells = new HashMap<Integer, GridCell>() {
{
put(0, new MockHasDynamicHeightCell<>(new BaseGridCellValue<>("cheese")));
put(1, new BaseGridCell<>(new BaseGridCellValue<>("cheese")));
}
};
doReturn(cells).when(row).getCells();
assertThat(row.getHeight()).isEqualTo(CELL_HEIGHT);
}
use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue in project kie-wb-common by kiegroup.
the class LiteralExpressionGridRowTest method testGetHeightWithoutHasDynamicHeightCell.
@Test
public void testGetHeightWithoutHasDynamicHeightCell() {
final GridRow row = spy(new LiteralExpressionGridRow());
final Map<Integer, GridCell> cells = new HashMap<Integer, GridCell>() {
{
put(0, new BaseGridCell<>(new BaseGridCellValue<>("cheese")));
}
};
doReturn(cells).when(row).getCells();
assertThat(row.getHeight()).isEqualTo(DEFAULT_HEIGHT);
}
use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue in project kie-wb-common by kiegroup.
the class ListUIModelMapper method fromDMNModel.
@Override
public void fromDMNModel(final int rowIndex, final int columnIndex) {
dmnModel.get().ifPresent(list -> {
final ListUIModelMapperHelper.ListSection section = ListUIModelMapperHelper.getSection(columnIndex);
switch(section) {
case ROW_INDEX:
uiModel.get().setCell(rowIndex, columnIndex, () -> new ContextGridCell<>(new BaseGridCellValue<>(rowIndex + 1), listSelector));
uiModel.get().getCell(rowIndex, columnIndex).setSelectionStrategy(RowSelectionStrategy.INSTANCE);
break;
case EXPRESSION:
final HasExpression hasExpression = list.getExpression().get(rowIndex);
final Optional<Expression> expression = Optional.ofNullable(hasExpression.getExpression());
final boolean isOnlyVisualChangeAllowed = this.isOnlyVisualChangeAllowedSupplier.get();
final Optional<ExpressionEditorDefinition<Expression>> expressionEditorDefinition = expressionEditorDefinitionsSupplier.get().getExpressionEditorDefinition(expression);
expressionEditorDefinition.ifPresent(ed -> {
final Optional<BaseExpressionGrid<? extends Expression, ? extends GridData, ? extends BaseUIModelMapper>> editor = ed.getEditor(new GridCellTuple(rowIndex, columnIndex, gridWidget), Optional.empty(), hasExpression, Optional.empty(), isOnlyVisualChangeAllowed, nesting + 1);
uiModel.get().setCell(rowIndex, columnIndex, () -> new ContextGridCell<>(new ExpressionCellValue(editor), listSelector));
});
}
});
}
use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue in project kie-wb-common by kiegroup.
the class InvocationUIModelMapper method toDMNModel.
@Override
@SuppressWarnings("unchecked")
public void toDMNModel(final int rowIndex, final int columnIndex, final Supplier<Optional<GridCellValue<?>>> cell) {
dmnModel.get().ifPresent(invocation -> {
switch(columnIndex) {
case ROW_NUMBER_COLUMN_INDEX:
break;
case BINDING_PARAMETER_COLUMN_INDEX:
invocation.getBinding().get(rowIndex).getParameter().getName().setValue(cell.get().orElse(new BaseGridCellValue<>("")).getValue().toString());
break;
case BINDING_EXPRESSION_COLUMN_INDEX:
cell.get().ifPresent(v -> {
final ExpressionCellValue ecv = (ExpressionCellValue) v;
ecv.getValue().ifPresent(beg -> {
beg.getExpression().get().ifPresent(e -> invocation.getBinding().get(rowIndex).setExpression((Expression) e));
});
});
}
});
}
Aggregations