use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow in project kie-wb-common by kiegroup.
the class AddOutputClauseCommandTest method testCanvasCommandAddOutputClauseToRuleWithoutInputsThenUndo.
@Test
public void testCanvasCommandAddOutputClauseToRuleWithoutInputsThenUndo() throws Exception {
makeCommand(DecisionTableUIModelMapperHelper.ROW_INDEX_COLUMN_COUNT);
final String ruleOneOutputValue = "one";
final String ruleTwoOutputValue = "two";
dtable.getRule().add(new DecisionRule());
dtable.getRule().add(new DecisionRule());
uiModel.appendRow(new BaseGridRow());
uiModel.appendRow(new BaseGridRow());
// Graph command populates OutputEntries so overwrite with test values
final Command<GraphCommandExecutionContext, RuleViolation> graphCommand = command.newGraphCommand(canvasHandler);
graphCommand.execute(graphCommandExecutionContext);
dtable.getRule().get(0).getOutputEntry().get(0).getText().setValue(ruleOneOutputValue);
dtable.getRule().get(1).getOutputEntry().get(0).getText().setValue(ruleTwoOutputValue);
final Command<AbstractCanvasHandler, CanvasViolation> canvasAddOutputClauseCommand = command.newCanvasCommand(canvasHandler);
canvasAddOutputClauseCommand.execute(canvasHandler);
// first rule
assertEquals(ruleOneOutputValue, uiModel.getRow(0).getCells().get(1).getValue().getValue());
// second rule
assertEquals(ruleTwoOutputValue, uiModel.getRow(1).getCells().get(1).getValue().getValue());
assertEquals(2, uiModel.getColumnCount());
assertEquals(CanvasCommandResultBuilder.SUCCESS, canvasAddOutputClauseCommand.undo(canvasHandler));
assertEquals(1, uiModel.getColumnCount());
verify(executeCanvasOperation).execute();
verify(undoCanvasOperation).execute();
verify(command, times(2)).updateParentInformation();
}
use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow in project kie-wb-common by kiegroup.
the class MoveRowsCommandTest method addUiModelRow.
protected void addUiModelRow(final int rowIndex) {
final GridRow uiRow = new BaseGridRow();
uiModel.appendRow(uiRow);
uiModel.setCellValue(rowIndex, 0, new BaseGridCellValue<>(rowIndex + 1));
uiModel.setCellValue(rowIndex, 1, new BaseGridCellValue<>("name" + rowIndex));
uiModel.setCellValue(rowIndex, 2, new BaseGridCellValue<>("editor" + rowIndex));
}
use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow in project kie-wb-common by kiegroup.
the class DecisionTableUIModelMapperTest method setup.
@Before
@SuppressWarnings("unchecked")
public void setup() {
this.uiModel = new BaseGridData();
this.uiModel.appendRow(new BaseGridRow());
this.uiModel.appendRow(new BaseGridRow());
this.uiModel.appendColumn(uiRowNumberColumn);
this.uiModel.appendColumn(uiInputClauseColumn);
this.uiModel.appendColumn(uiOutputClauseColumn);
this.uiModel.appendColumn(uiAnnotationClauseColumn);
doReturn(0).when(uiRowNumberColumn).getIndex();
doReturn(1).when(uiInputClauseColumn).getIndex();
doReturn(2).when(uiOutputClauseColumn).getIndex();
doReturn(3).when(uiAnnotationClauseColumn).getIndex();
this.dtable = new DecisionTable();
this.dtable.getInput().add(new InputClause());
this.dtable.getOutput().add(new OutputClause());
this.dtable.getAnnotations().add(new RuleAnnotationClause());
this.dtable.getRule().add(new DecisionRule() {
{
getInputEntry().add(new UnaryTests() {
{
getText().setValue("i1");
}
});
getOutputEntry().add(new LiteralExpression() {
{
getText().setValue("o1");
}
});
getAnnotationEntry().add(new RuleAnnotationClauseText() {
{
getText().setValue("a1");
}
});
}
});
this.dtable.getRule().add(new DecisionRule() {
{
getInputEntry().add(new UnaryTests() {
{
getText().setValue("i2");
}
});
getOutputEntry().add(new LiteralExpression() {
{
getText().setValue("o2");
}
});
getAnnotationEntry().add(new RuleAnnotationClauseText() {
{
getText().setValue("a2");
}
});
}
});
this.mapper = new DecisionTableUIModelMapper(() -> uiModel, () -> Optional.of(dtable), listSelector, DEFAULT_HEIGHT);
}
use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow in project kie-wb-common by kiegroup.
the class DMNGridLayerTest method testSelectNestedGridWidget.
@Test
public void testSelectNestedGridWidget() {
final GridWidget gridWidget = mock(GridWidget.class);
final GridData gridData = new BaseGridData(false);
gridData.appendRow(new BaseGridRow());
gridData.appendColumn(mock(GridColumn.class));
gridData.setCellValue(0, 0, new ExpressionCellValue(Optional.of(expressionGrid)));
gridLayer.register(gridWidget);
gridLayer.register(expressionGrid);
assertThat(gridLayer.getSelectedGridWidget().isPresent()).isFalse();
// Select nested grid
when(gridWidget.getModel()).thenReturn(gridData);
when(expressionGrid.getModel()).thenReturn(new BaseGridData(false));
gridLayer.select(expressionGrid);
assertThat(gridLayer.getSelectedGridWidget().isPresent()).isTrue();
assertThat(gridLayer.getSelectedGridWidget().get()).isEqualTo(expressionGrid);
verify(expressionGrid).select();
verify(gridLayer).batch();
// Select outer grid, deselecting nested grid
reset(gridLayer, gridWidget, expressionGrid);
when(gridWidget.getModel()).thenReturn(gridData);
when(expressionGrid.getModel()).thenReturn(new BaseGridData(false));
when(expressionGrid.isSelected()).thenReturn(true);
gridLayer.select(gridWidget);
assertThat(gridLayer.getSelectedGridWidget().isPresent()).isTrue();
assertThat(gridLayer.getSelectedGridWidget().get()).isEqualTo(gridWidget);
verify(gridWidget).select();
verify(expressionGrid).deselect();
verify(gridLayer).batch();
// Reselect outer grid, there should be no change in selections and the GridLayer should not be redrawn
reset(gridLayer, gridWidget, expressionGrid);
when(gridWidget.getModel()).thenReturn(gridData);
when(gridWidget.isSelected()).thenReturn(true);
when(expressionGrid.getModel()).thenReturn(new BaseGridData(false));
when(expressionGrid.isSelected()).thenReturn(false);
gridLayer.select(gridWidget);
verify(gridWidget, never()).select();
verify(expressionGrid, never()).deselect();
verify(gridLayer, never()).batch();
}
use of org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow in project kie-wb-common by kiegroup.
the class DMNGridPanelCellSelectionHandlerTest method mockGridWidget.
private BaseExpressionGrid mockGridWidget() {
final BaseExpressionGrid gridWidget = mock(BaseExpressionGrid.class);
final GridData gridData = new DMNGridData();
when(gridWidget.getModel()).thenReturn(gridData);
gridData.appendColumn(new RowNumberColumn());
IntStream.range(0, 3).forEach(i -> {
final GridColumn gridColumn = mock(GridColumn.class);
final List<GridColumn.HeaderMetaData> headerMetaData = Collections.singletonList(mock(GridColumn.HeaderMetaData.class));
when(gridColumn.getIndex()).thenReturn(i);
when(gridColumn.getHeaderMetaData()).thenReturn(headerMetaData);
gridData.appendColumn(gridColumn);
});
gridData.appendRow(new BaseGridRow());
gridData.appendRow(new BaseGridRow());
gridData.appendRow(new BaseGridRow());
return gridWidget;
}
Aggregations