use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue in project drools-wb by kiegroup.
the class GridRowComparatorTest method testIntegerColumn.
@Test
public void testIntegerColumn() {
baseGridData.appendColumn(mock(IntegerUiColumn.class));
final BaseGridRow a = new BaseGridRow();
baseGridData.appendRow(a);
final BaseGridRow b = new BaseGridRow();
baseGridData.appendRow(b);
final BaseGridRow c = new BaseGridRow();
baseGridData.appendRow(c);
final BaseGridRow d = new BaseGridRow();
baseGridData.appendRow(d);
baseGridData.setCell(0, 0, () -> new BaseGridCell<>(new BaseGridCellValue<>(100)));
baseGridData.setCell(1, 0, () -> new BaseGridCell<>(new BaseGridCellValue<>(100)));
baseGridData.setCell(2, 0, () -> new BaseGridCell<>(new BaseGridCellValue<>(0)));
baseGridData.setCell(3, 0, () -> new BaseGridCell<>(null));
assertTrue(comparator.compare(a, b) == 0);
assertTrue(comparator.compare(a, c) > 0);
assertTrue(comparator.compare(c, a) < 0);
assertTrue(comparator.compare(c, d) > 0);
assertTrue(comparator.compare(d, c) < 0);
}
use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue in project kie-wb-common by kiegroup.
the class LiteralExpressionGridTest method setup.
@Before
public void setup() {
tupleWithoutValue = new GridCellTuple(0, 0, gridWidget);
tupleWithValue = new GridCellValueTuple<>(0, 0, gridWidget, new BaseGridCellValue<>("value"));
definition = new LiteralExpressionEditorDefinition(gridPanel, gridLayer, definitionUtils, sessionManager, sessionCommandManager, canvasCommandFactory, cellEditorControls, listSelector, translationService);
final Decision decision = new Decision();
decision.setName(new Name("name"));
hasName = Optional.of(decision);
expression = definition.getModelClass();
expression.ifPresent(e -> e.setText(EXPRESSION_TEXT));
doReturn(session).when(sessionManager).getCurrentSession();
doReturn(canvasHandler).when(session).getCanvasHandler();
doReturn(mock(Bounds.class)).when(gridLayer).getVisibleBounds();
when(gridWidget.getModel()).thenReturn(new BaseGridData(false));
when(canvasHandler.getGraphIndex()).thenReturn(index);
when(index.get(anyString())).thenReturn(element);
when(element.getContent()).thenReturn(mock(Definition.class));
when(definitionUtils.getNameIdentifier(any())).thenReturn("name");
when(canvasCommandFactory.updatePropertyValue(any(Element.class), anyString(), any())).thenReturn(mock(UpdateElementPropertyCommand.class));
when(parentGridWidget.getModel()).thenReturn(parentGridUiModel);
when(parent.getGridWidget()).thenReturn(parentGridWidget);
when(parent.getRowIndex()).thenReturn(0);
when(parent.getColumnIndex()).thenReturn(1);
}
use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue in project kie-wb-common by kiegroup.
the class LiteralExpressionUIModelMapper method fromDMNModel.
@Override
public void fromDMNModel(final int rowIndex, final int columnIndex) {
dmnModel.get().ifPresent(literalExpression -> {
uiModel.get().setCell(rowIndex, columnIndex, () -> new LiteralExpressionCell<>(new BaseGridCellValue<>(literalExpression.getText()), listSelector));
uiModel.get().getCell(rowIndex, columnIndex).setSelectionStrategy((final GridData model, final int uiRowIndex, final int uiColumnIndex, final boolean isShiftKeyDown, final boolean isControlKeyDown) -> {
final GridData parentUiModel = parent.getGridWidget().getModel();
return parentUiModel.getCell(parent.getRowIndex(), parent.getColumnIndex()).getSelectionStrategy().handleSelection(parentUiModel, parent.getRowIndex(), parent.getColumnIndex(), isShiftKeyDown, isControlKeyDown);
});
});
}
use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue in project kie-wb-common by kiegroup.
the class ContextUIModelMapper method fromDMNModel.
@Override
public void fromDMNModel(final int rowIndex, final int columnIndex) {
dmnModel.get().ifPresent(context -> {
final boolean isLastRow = isLastRow(rowIndex);
final ContextUIModelMapperHelper.ContextSection section = ContextUIModelMapperHelper.getSection(columnIndex);
switch(section) {
case ROW_INDEX:
if (!isLastRow) {
uiModel.get().setCell(rowIndex, columnIndex, () -> new ContextGridCell<>(new BaseGridCellValue<>(rowIndex + 1), listSelector));
} else {
uiModel.get().setCell(rowIndex, columnIndex, () -> new DMNGridCell<>(new BaseGridCellValue<>((Integer) null)));
}
uiModel.get().getCell(rowIndex, columnIndex).setSelectionStrategy(RowSelectionStrategy.INSTANCE);
break;
case NAME:
final InformationItem variable = context.getContextEntry().get(rowIndex).getVariable();
uiModel.get().setCell(rowIndex, columnIndex, () -> new InformationItemCell(() -> InformationItemCell.HasNameAndDataTypeCell.wrap(variable, DEFAULT_ROW_CAPTION), listSelector));
break;
case EXPRESSION:
final ContextEntry ce = context.getContextEntry().get(rowIndex);
final Optional<Expression> expression = Optional.ofNullable(ce.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(), ce, Optional.ofNullable(ce.getVariable()), 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 BaseExpressionGridGeneralTest method setup.
@Override
public void setup() {
super.setup();
tupleWithoutValue = new GridCellTuple(0, 0, grid);
tupleWithValue = new GridCellValueTuple<>(0, 0, grid, new BaseGridCellValue<>("value"));
when(sessionManager.getCurrentSession()).thenReturn(session);
when(session.getCanvasHandler()).thenReturn(canvasHandler);
when(canvasHandler.getDiagram()).thenReturn(diagram);
when(diagram.getGraph()).thenReturn(graph);
when(graph.nodes()).thenReturn(Collections.singletonList(node));
when(canvasHandler.getGraphIndex()).thenReturn(index);
when(element.getContent()).thenReturn(definition);
when(definition.getDefinition()).thenReturn(DEFINITION);
when(definitionUtils.getNameIdentifier(DEFINITION)).thenReturn(NAME_ID);
when(updateElementPropertyCommand.execute(canvasHandler)).thenReturn(CanvasCommandResultBuilder.SUCCESS);
when(grid.getHeader()).thenReturn(header);
when(header.getY()).thenReturn(0.0);
when(renderer.getHeaderHeight()).thenReturn(HEADER_HEIGHT);
when(renderer.getHeaderRowHeight()).thenReturn(HEADER_HEIGHT);
}
Aggregations