Search in sources :

Example 16 with Expression

use of org.eclipse.bpmn2.Expression in project kie-wb-common by kiegroup.

the class FunctionUIModelMapper method setUiModelEditor.

private void setUiModelEditor(final int rowIndex, final int columnIndex, final FunctionDefinition function, final ExpressionEditorDefinition<Expression> ed) {
    final GridCellTuple expressionParent = new GridCellTuple(0, 0, gridWidget);
    final Optional<Expression> expression = Optional.ofNullable(function.getExpression());
    final Optional<BaseExpressionGrid> editor = ed.getEditor(expressionParent, Optional.empty(), function, expression, Optional.empty(), nesting + 1);
    uiModel.get().setCell(rowIndex, columnIndex, () -> new FunctionGridCell<>(new ExpressionCellValue(editor), listSelector));
}
Also used : GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) Expression(org.kie.workbench.common.dmn.api.definition.v1_1.Expression) BaseExpressionGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid) ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue)

Example 17 with Expression

use of org.eclipse.bpmn2.Expression 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((Expression) beg.getExpression().orElse(null)));
        });
    });
}
Also used : Expression(org.kie.workbench.common.dmn.api.definition.v1_1.Expression) ExpressionCellValue(org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue)

Example 18 with Expression

use of org.eclipse.bpmn2.Expression 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 InformationItemNameCell(() -> variable, listSelector));
                break;
            case BINDING_EXPRESSION_COLUMN_INDEX:
                final Binding binding = invocation.getBinding().get(rowIndex);
                final Optional<Expression> expression = Optional.ofNullable(binding.getExpression());
                final Optional<ExpressionEditorDefinition<Expression>> expressionEditorDefinition = expressionEditorDefinitionsSupplier.get().getExpressionEditorDefinition(expression);
                expressionEditorDefinition.ifPresent(ed -> {
                    final Optional<BaseExpressionGrid> editor = ed.getEditor(new GridCellTuple(rowIndex, columnIndex, gridWidget), Optional.empty(), binding, expression, Optional.ofNullable(binding.getParameter()), nesting + 1);
                    uiModel.get().setCell(rowIndex, columnIndex, () -> new InvocationGridCell<>(new ExpressionCellValue(editor), listSelector));
                });
        }
    });
}
Also used : Binding(org.kie.workbench.common.dmn.api.definition.v1_1.Binding) InformationItemNameCell(org.kie.workbench.common.dmn.client.editors.expressions.types.context.InformationItemNameCell) ExpressionEditorDefinition(org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinition) InformationItem(org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem) GridCellTuple(org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple) Expression(org.kie.workbench.common.dmn.api.definition.v1_1.Expression) BaseExpressionGrid(org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid) 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 Expression

use of org.eclipse.bpmn2.Expression in project kie-wb-common by kiegroup.

the class RelationUIModelMapper method toDMNModel.

@Override
public void toDMNModel(final int rowIndex, final int columnIndex, final Supplier<Optional<GridCellValue<?>>> cell) {
    dmnModel.get().ifPresent(relation -> {
        final RelationUIModelMapperHelper.RelationSection section = RelationUIModelMapperHelper.getSection(relation, columnIndex);
        switch(section) {
            case ROW_INDEX:
                break;
            case INFORMATION_ITEM:
                final org.kie.workbench.common.dmn.api.definition.v1_1.List row = relation.getRow().get(rowIndex);
                final int iiIndex = RelationUIModelMapperHelper.getInformationItemIndex(relation, columnIndex);
                final Expression e = row.getExpression().get(iiIndex);
                final Optional<Expression> expression = Optional.ofNullable(e);
                expression.ifPresent(ex -> {
                    // Whilst the DMN 1.1 specification allows for ANY expression to be used we have made the simplification
                    // to limit ourselves to LiteralExpressions. Our Grid-system supports ANY (nested) expression too; however
                    // the simplification has been made for the benefit of USERS.
                    final LiteralExpression le = (LiteralExpression) ex;
                    le.setText(cell.get().orElse(new BaseGridCellValue<>("")).getValue().toString());
                });
        }
    });
}
Also used : LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) Expression(org.kie.workbench.common.dmn.api.definition.v1_1.Expression) LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) BaseGridCellValue(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue)

Example 20 with Expression

use of org.eclipse.bpmn2.Expression in project kie-wb-common by kiegroup.

the class RelationUIModelMapper method fromDMNModel.

@Override
public void fromDMNModel(final int rowIndex, final int columnIndex) {
    dmnModel.get().ifPresent(relation -> {
        final RelationUIModelMapperHelper.RelationSection section = RelationUIModelMapperHelper.getSection(relation, columnIndex);
        switch(section) {
            case ROW_INDEX:
                uiModel.get().setCell(rowIndex, columnIndex, () -> new RelationGridCell<>(new BaseGridCellValue<>(rowIndex + 1), listSelector));
                uiModel.get().getCell(rowIndex, columnIndex).setSelectionStrategy(RowSelectionStrategy.INSTANCE);
                break;
            case INFORMATION_ITEM:
                final org.kie.workbench.common.dmn.api.definition.v1_1.List row = relation.getRow().get(rowIndex);
                final int iiIndex = RelationUIModelMapperHelper.getInformationItemIndex(relation, columnIndex);
                final Expression e = row.getExpression().get(iiIndex);
                final Optional<Expression> expression = Optional.ofNullable(e);
                expression.ifPresent(ex -> {
                    // Whilst the DMN 1.1 specification allows for ANY expression to be used we have made the simplification
                    // to limit ourselves to LiteralExpressions. Our Grid-system supports ANY (nested) expression too; however
                    // the simplification has been made for the benefit of USERS.
                    final LiteralExpression le = (LiteralExpression) ex;
                    uiModel.get().setCell(rowIndex, columnIndex, () -> new RelationGridCell<>(new BaseGridCellValue<>(le.getText()), listSelector));
                });
        }
    });
}
Also used : LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) LiteralExpression(org.kie.workbench.common.dmn.api.definition.v1_1.LiteralExpression) Expression(org.kie.workbench.common.dmn.api.definition.v1_1.Expression) BaseGridCellValue(org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue)

Aggregations

Expression (org.kie.workbench.common.dmn.api.definition.v1_1.Expression)19 Expression (org.apache.commons.jexl2.Expression)14 JexlContext (org.apache.commons.jexl2.JexlContext)12 JexlEngine (org.apache.commons.jexl2.JexlEngine)9 MapContext (org.apache.commons.jexl2.MapContext)8 ENotificationImpl (org.eclipse.emf.ecore.impl.ENotificationImpl)7 Expression (org.eclipse.xtext.resource.bug385636.Expression)7 ExpressionCellValue (org.kie.workbench.common.dmn.client.editors.expressions.types.context.ExpressionCellValue)7 BaseExpressionGrid (org.kie.workbench.common.dmn.client.widgets.grid.BaseExpressionGrid)6 ArrayList (java.util.ArrayList)5 Expression (org.kie.dmn.model.v1_1.Expression)5 InformationItem (org.kie.workbench.common.dmn.api.definition.v1_1.InformationItem)5 BaseGridCellValue (org.uberfire.ext.wires.core.grids.client.model.impl.BaseGridCellValue)5 Description (org.kie.workbench.common.dmn.api.property.dmn.Description)4 Id (org.kie.workbench.common.dmn.api.property.dmn.Id)4 ExpressionEditorDefinition (org.kie.workbench.common.dmn.client.editors.expressions.types.ExpressionEditorDefinition)4 GridCellTuple (org.kie.workbench.common.dmn.client.widgets.grid.model.GridCellTuple)4 CompiledExpression (org.kie.dmn.feel.lang.CompiledExpression)3 HasExpression (org.kie.workbench.common.dmn.api.definition.HasExpression)3 HashMap (java.util.HashMap)2