Search in sources :

Example 16 with ExpressionCellValue

use of org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue in project kie-wb-common by kiegroup.

the class SetKindCommandTest method setup.

@Before
public void setup() {
    this.function = new FunctionDefinition();
    this.function.setKind(originalKind);
    this.function.setExpression(originalExpression);
    this.uiModel = new BaseGridData();
    this.uiModel.appendColumn(mockColumn);
    this.uiModel.appendRow(new BaseGridRow());
    this.uiModel.setCellValue(0, 0, new ExpressionCellValue(Optional.of(originalEditor)));
    doReturn(uiModel).when(gridWidget).getModel();
    doReturn(ruleManager).when(handler).getRuleManager();
}
Also used : BaseGridRow(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow) FunctionDefinition(org.kie.workbench.common.dmn.api.definition.model.FunctionDefinition) ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue) BaseGridData(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData) Before(org.junit.Before)

Example 17 with ExpressionCellValue

use of org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue in project kie-wb-common by kiegroup.

the class SetCellValueCommandTest method assertCanvasMutationOnExecute.

private void assertCanvasMutationOnExecute() {
    verify(gridModel).setCellValue(eq(ROW_INDEX), eq(COLUMN_INDEX), gridCellValueCaptor.capture());
    final GridCellValue<?> gcv = gridCellValueCaptor.getValue();
    assertTrue(gcv instanceof ExpressionCellValue);
    final ExpressionCellValue ecv = (ExpressionCellValue) gcv;
    assertEquals(ecv.getValue().get(), expressionEditor);
    verify(executeCanvasOperation).execute(eq(Optional.of(expressionEditor)));
}
Also used : ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue)

Example 18 with ExpressionCellValue

use of org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue in project kie-wb-common by kiegroup.

the class InvocationUIModelMapper method fromDMNModel.

@Override
public void fromDMNModel(final int rowIndex, final int columnIndex) {
    dmnModel.get().ifPresent(invocation -> {
        switch(columnIndex) {
            case ROW_NUMBER_COLUMN_INDEX:
                uiModel.get().setCell(rowIndex, columnIndex, () -> new InvocationGridCell<>(new BaseGridCellValue<>(rowIndex + 1), listSelector));
                uiModel.get().getCell(rowIndex, columnIndex).setSelectionStrategy(RowSelectionStrategy.INSTANCE);
                break;
            case BINDING_PARAMETER_COLUMN_INDEX:
                final InformationItem variable = invocation.getBinding().get(rowIndex).getParameter();
                uiModel.get().setCell(rowIndex, columnIndex, () -> new InformationItemCell(() -> InformationItemCell.HasNameAndDataTypeCell.wrap(variable), listSelector));
                break;
            case BINDING_EXPRESSION_COLUMN_INDEX:
                final Binding binding = invocation.getBinding().get(rowIndex);
                final Optional<Expression> expression = Optional.ofNullable(binding.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(), binding, Optional.ofNullable(binding.getParameter()), isOnlyVisualChangeAllowed, nesting + 1);
                    uiModel.get().setCell(rowIndex, columnIndex, () -> new InvocationGridCell<>(new ExpressionCellValue(editor), listSelector));
                });
        }
    });
}
Also used : Binding(org.kie.workbench.common.dmn.api.definition.model.Binding) ExpressionEditorDefinition(org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinition) InformationItem(org.kie.workbench.common.dmn.api.definition.model.InformationItem) InformationItemCell(org.kie.workbench.common.dmn.client.editors.expressions.types.context.InformationItemCell) GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) Expression(org.kie.workbench.common.dmn.api.definition.model.Expression) BaseExpressionGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid) BaseUIModelMapper(org.kie.workbench.common.dmn.client.widgets.grid.model.BaseUIModelMapper) GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue) BaseGridCellValue(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue)

Example 19 with ExpressionCellValue

use of org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue in project kie-wb-common by kiegroup.

the class ListUIModelMapper method toDMNModel.

@Override
public void toDMNModel(final int rowIndex, final int columnIndex, final Supplier<Optional<GridCellValue<?>>> cell) {
    dmnModel.get().ifPresent(list -> {
        final ListUIModelMapperHelper.ListSection section = ListUIModelMapperHelper.getSection(columnIndex);
        switch(section) {
            case ROW_INDEX:
                break;
            case EXPRESSION:
                cell.get().ifPresent(v -> {
                    final ExpressionCellValue ecv = (ExpressionCellValue) v;
                    ecv.getValue().ifPresent(beg -> {
                        list.getExpression().get(rowIndex).setExpression(beg.getExpression().get().orElse(null));
                    });
                });
        }
    });
}
Also used : ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue)

Example 20 with ExpressionCellValue

use of org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue in project kie-wb-common by kiegroup.

the class FunctionUIModelMapper method toDMNModel.

@Override
@SuppressWarnings("unchecked")
public void toDMNModel(final int rowIndex, final int columnIndex, final Supplier<Optional<GridCellValue<?>>> cell) {
    dmnModel.get().ifPresent(function -> {
        cell.get().ifPresent(v -> {
            final ExpressionCellValue ecv = (ExpressionCellValue) v;
            ecv.getValue().ifPresent(beg -> function.setExpression(beg.getExpression().get().orElse(null)));
        });
    });
}
Also used : ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue)

Aggregations

ExpressionCellValue (org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue)63 Test (org.junit.Test)28 GridData (org.uberfire.ext.wires.core.grids.client.model.GridData)22 BaseExpressionGrid (org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid)21 GridCellTuple (org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple)17 Expression (org.kie.workbench.common.dmn.api.definition.model.Expression)14 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)12 ExpressionEditorColumn (org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionEditorColumn)11 GridCell (org.uberfire.ext.wires.core.grids.client.model.GridCell)10 BaseGridData (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridData)10 BaseGridRow (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridRow)10 AbstractCanvasHandler (org.kie.workbench.common.stunner.core.client.canvas.AbstractCanvasHandler)9 GridRow (org.uberfire.ext.wires.core.grids.client.model.GridRow)9 Optional (java.util.Optional)8 LiteralExpression (org.kie.workbench.common.dmn.api.definition.model.LiteralExpression)8 BaseUIModelMapper (org.kie.workbench.common.dmn.client.widgets.grid.model.BaseUIModelMapper)8 Before (org.junit.Before)6 DMNGridData (org.kie.workbench.common.dmn.client.widgets.grid.model.DMNGridData)6 CanvasViolation (org.kie.workbench.common.stunner.core.client.command.CanvasViolation)6 GridColumn (org.uberfire.ext.wires.core.grids.client.model.GridColumn)6