use of org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow in project kie-wb-common by kiegroup.
the class ExpressionEditorColumnTest method testMinimalWidthTwoCellsSumWithPadding.
/**
* (10)[100](10)
* (10)[50][60](10)
* (10)[105](10)
*/
@Test
public void testMinimalWidthTwoCellsSumWithPadding() throws Exception {
gridData.appendColumn(column);
gridData.appendRow(new DMNGridRow());
gridData.appendRow(new DMNGridRow());
gridData.appendRow(new DMNGridRow());
mockCellsWithPadding(0, 0, PADDING, 100);
mockCellsWithPadding(1, 0, PADDING, 50, 60);
mockCellsWithPadding(2, 0, PADDING, 105);
Assertions.assertThat(column.getMinimumWidth()).isEqualTo(130);
}
use of org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow 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 DMNGridRow());
this.uiModel.appendRow(new DMNGridRow());
this.uiModel.appendColumn(uiRowNumberColumn);
this.uiModel.appendColumn(uiInputClauseColumn);
this.uiModel.appendColumn(uiOutputClauseColumn);
this.uiModel.appendColumn(uiDescriptionColumn);
doReturn(0).when(uiRowNumberColumn).getIndex();
doReturn(1).when(uiInputClauseColumn).getIndex();
doReturn(2).when(uiOutputClauseColumn).getIndex();
doReturn(3).when(uiDescriptionColumn).getIndex();
this.dtable = new DecisionTable();
this.dtable.getInput().add(new InputClause());
this.dtable.getOutput().add(new OutputClause());
this.dtable.getRule().add(new DecisionRule() {
{
getInputEntry().add(new UnaryTests() {
{
setText("i1");
}
});
getOutputEntry().add(new LiteralExpression() {
{
setText("o1");
}
});
setDescription(new Description("desc1"));
}
});
this.dtable.getRule().add(new DecisionRule() {
{
getInputEntry().add(new UnaryTests() {
{
setText("i2");
}
});
getOutputEntry().add(new LiteralExpression() {
{
setText("o2");
}
});
setDescription(new Description("desc2"));
}
});
this.mapper = new DecisionTableUIModelMapper(() -> uiModel, () -> Optional.of(dtable), listSelector);
this.cellValueSupplier = Optional::empty;
}
use of org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow in project kie-wb-common by kiegroup.
the class FunctionUIModelMapperTest method setup.
@Before
@SuppressWarnings("unchecked")
public void setup() {
this.uiModel = new BaseGridData();
this.uiModel.appendRow(new DMNGridRow());
this.uiModel.appendRow(new DMNGridRow());
this.uiModel.appendColumn(uiExpressionEditorColumn);
doReturn(0).when(uiExpressionEditorColumn).getIndex();
doReturn(uiModel).when(gridWidget).getModel();
// Core Editor definitions
final ExpressionEditorDefinitions expressionEditorDefinitions = new ExpressionEditorDefinitions();
expressionEditorDefinitions.add(literalExpressionEditorDefinition);
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());
// Supplementary Editor definitions
final ExpressionEditorDefinitions supplementaryEditorDefinitions = new ExpressionEditorDefinitions();
supplementaryEditorDefinitions.add(supplementaryEditorDefinition);
doReturn(supplementaryEditorDefinitions).when(supplementaryEditorDefinitionsSupplier).get();
doReturn(Optional.of(context)).when(supplementaryEditorDefinition).getModelClass();
doReturn(Optional.of(context)).when(supplementaryEditor).getExpression();
doReturn(Optional.of(supplementaryEditor)).when(supplementaryEditorDefinition).getEditor(any(GridCellTuple.class), any(Optional.class), any(HasExpression.class), any(Optional.class), any(Optional.class), anyInt());
this.function = new FunctionDefinition();
this.mapper = new FunctionUIModelMapper(gridWidget, () -> uiModel, () -> Optional.of(function), expressionEditorDefinitionsSupplier, supplementaryEditorDefinitionsSupplier, listSelector, 0);
this.cellValueSupplier = Optional::empty;
}
use of org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow in project kie-wb-common by kiegroup.
the class LiteralExpressionUIModelMapperTest method setup.
@Before
@SuppressWarnings("unchecked")
public void setup() {
uiModel = new BaseGridData();
uiModel.appendRow(new DMNGridRow());
uiModel.appendColumn(uiLiteralExpressionColumn);
doReturn(0).when(uiLiteralExpressionColumn).getIndex();
when(parentGridWidget.getModel()).thenReturn(parentGridUiModel);
when(parentGridUiModel.getCell(eq(PARENT_ROW_INDEX), eq(PARENT_COLUMN_INDEX))).thenReturn(parentGridUiCell);
when(parentGridUiCell.getSelectionStrategy()).thenReturn(parentGridUiCellCellSelectionStrategy);
literalExpression = new LiteralExpression();
mapper = new LiteralExpressionUIModelMapper(() -> uiModel, () -> Optional.of(literalExpression), listSelector, new GridCellTuple(PARENT_ROW_INDEX, PARENT_COLUMN_INDEX, parentGridWidget));
}
use of org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridRow in project kie-wb-common by kiegroup.
the class InvocationGrid method addParameterBinding.
void addParameterBinding(final int index) {
expression.ifPresent(invocation -> {
final Binding binding = new Binding();
final InformationItem parameter = new InformationItem();
parameter.setName(new Name("p" + invocation.getBinding().size()));
binding.setParameter(parameter);
sessionCommandManager.execute((AbstractCanvasHandler) sessionManager.getCurrentSession().getCanvasHandler(), new AddParameterBindingCommand(invocation, binding, model, new DMNGridRow(), index, uiModelMapper, this::synchroniseView));
});
}
Aggregations