@Test public void testFromDMNModelExpression() { setup(false); mapper.fromDMNModel(0, EXPRESSION_COLUMN_INDEX); mapper.fromDMNModel(1, EXPRESSION_COLUMN_INDEX); assertUndefinedExpressionGridCellEditor(0, undefinedExpressionEditor); assertUndefinedExpressionGridCellEditor(1, literalExpressionEditor); }
@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)); }); } }); }
ContextUIModelMapper extends BaseUIModelMapper<Context> { @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)); }); } }); } }
ContextUIModelMapper extends BaseUIModelMapper<Context> { @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)); }); } }); } ContextUIModelMapper(final GridWidget gridWidget,
                                final Supplier<GridData> uiModel,
                                final Supplier<Optional<Context>> dmnModel,
                                final Supplier<Boolean> isOnlyVisualChangeAllowedSupplier,
                                final Supplier<ExpressionEditorDefinitions> expressionEditorDefinitionsSupplier,
                                final ListSelectorView.Presenter listSelector,
                                final int nesting); }
ContextUIModelMapper extends BaseUIModelMapper<Context> { @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)); }); } }); } ContextUIModelMapper(final GridWidget gridWidget,
                                final Supplier<GridData> uiModel,
                                final Supplier<Optional<Context>> dmnModel,
                                final Supplier<Boolean> isOnlyVisualChangeAllowedSupplier,
                                final Supplier<ExpressionEditorDefinitions> expressionEditorDefinitionsSupplier,
                                final ListSelectorView.Presenter listSelector,
                                final int nesting); @Override void fromDMNModel(final int rowIndex,
                             final int columnIndex); @Override @SuppressWarnings("unchecked") void toDMNModel(final int rowIndex,
                           final int columnIndex,
                           final Supplier<Optional<GridCellValue<?>>> cell); }
ContextUIModelMapper extends BaseUIModelMapper<Context> { @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)); }); } }); } ContextUIModelMapper(final GridWidget gridWidget,
                                final Supplier<GridData> uiModel,
                                final Supplier<Optional<Context>> dmnModel,
                                final Supplier<Boolean> isOnlyVisualChangeAllowedSupplier,
                                final Supplier<ExpressionEditorDefinitions> expressionEditorDefinitionsSupplier,
                                final ListSelectorView.Presenter listSelector,
                                final int nesting); @Override void fromDMNModel(final int rowIndex,
                             final int columnIndex); @Override @SuppressWarnings("unchecked") void toDMNModel(final int rowIndex,
                           final int columnIndex,
                           final Supplier<Optional<GridCellValue<?>>> cell); static final String DEFAULT_ROW_CAPTION; }