@Test public void testFromDMNModelInputClause() { mapper.fromDMNModel(0, 1); mapper.fromDMNModel(1, 1); assertEquals("i1", uiModel.getCell(0, 1).getValue().getValue()); assertTrue(uiModel.getCell(0, 1) instanceof DecisionTableGridCell); assertEquals("i2", uiModel.getCell(1, 1).getValue().getValue()); assertTrue(uiModel.getCell(1, 1) instanceof DecisionTableGridCell); }
@Override public void fromDMNModel(final int rowIndex, final int columnIndex) { dmnModel.get().ifPresent(dtable -> { final DecisionRule rule = dtable.getRule().get(rowIndex); final DecisionTableSection section = DecisionTableUIModelMapperHelper.getSection(dtable, columnIndex); switch (section) { case ROW_INDEX: uiModel.get().setCell(rowIndex, columnIndex, () -> new DecisionTableGridCell<>(new BaseGridCellValue<>(rowIndex + 1), listSelector, lineHeight)); uiModel.get().getCell(rowIndex, columnIndex).setSelectionStrategy(RowSelectionStrategy.INSTANCE); break; case INPUT_CLAUSES: final int iei = DecisionTableUIModelMapperHelper.getInputEntryIndex(dtable, columnIndex); uiModel.get().setCell(rowIndex, columnIndex, () -> new DecisionTableGridCell<>(new BaseGridCellValue<>(rule.getInputEntry().get(iei).getText().getValue()), listSelector, lineHeight)); break; case OUTPUT_CLAUSES: final int oei = DecisionTableUIModelMapperHelper.getOutputEntryIndex(dtable, columnIndex); uiModel.get().setCell(rowIndex, columnIndex, () -> new DecisionTableGridCell<>(new BaseGridCellValue<>(rule.getOutputEntry().get(oei).getText().getValue()), listSelector, lineHeight)); break; case ANNOTATION_CLAUSES: final int annotationIndex = DecisionTableUIModelMapperHelper.getAnnotationEntryIndex(dtable, columnIndex); final String textValue = rule.getAnnotationEntry().get(annotationIndex).getText().getValue(); uiModel.get().setCell(rowIndex, columnIndex, () -> new DecisionTableGridCell<>(new BaseGridCellValue<>(textValue), listSelector, lineHeight)); break; } }); }
DecisionTableUIModelMapper extends BaseUIModelMapper<DecisionTable> { @Override public void fromDMNModel(final int rowIndex, final int columnIndex) { dmnModel.get().ifPresent(dtable -> { final DecisionRule rule = dtable.getRule().get(rowIndex); final DecisionTableSection section = DecisionTableUIModelMapperHelper.getSection(dtable, columnIndex); switch (section) { case ROW_INDEX: uiModel.get().setCell(rowIndex, columnIndex, () -> new DecisionTableGridCell<>(new BaseGridCellValue<>(rowIndex + 1), listSelector, lineHeight)); uiModel.get().getCell(rowIndex, columnIndex).setSelectionStrategy(RowSelectionStrategy.INSTANCE); break; case INPUT_CLAUSES: final int iei = DecisionTableUIModelMapperHelper.getInputEntryIndex(dtable, columnIndex); uiModel.get().setCell(rowIndex, columnIndex, () -> new DecisionTableGridCell<>(new BaseGridCellValue<>(rule.getInputEntry().get(iei).getText().getValue()), listSelector, lineHeight)); break; case OUTPUT_CLAUSES: final int oei = DecisionTableUIModelMapperHelper.getOutputEntryIndex(dtable, columnIndex); uiModel.get().setCell(rowIndex, columnIndex, () -> new DecisionTableGridCell<>(new BaseGridCellValue<>(rule.getOutputEntry().get(oei).getText().getValue()), listSelector, lineHeight)); break; case ANNOTATION_CLAUSES: final int annotationIndex = DecisionTableUIModelMapperHelper.getAnnotationEntryIndex(dtable, columnIndex); final String textValue = rule.getAnnotationEntry().get(annotationIndex).getText().getValue(); uiModel.get().setCell(rowIndex, columnIndex, () -> new DecisionTableGridCell<>(new BaseGridCellValue<>(textValue), listSelector, lineHeight)); break; } }); } }
DecisionTableUIModelMapper extends BaseUIModelMapper<DecisionTable> { @Override public void fromDMNModel(final int rowIndex, final int columnIndex) { dmnModel.get().ifPresent(dtable -> { final DecisionRule rule = dtable.getRule().get(rowIndex); final DecisionTableSection section = DecisionTableUIModelMapperHelper.getSection(dtable, columnIndex); switch (section) { case ROW_INDEX: uiModel.get().setCell(rowIndex, columnIndex, () -> new DecisionTableGridCell<>(new BaseGridCellValue<>(rowIndex + 1), listSelector, lineHeight)); uiModel.get().getCell(rowIndex, columnIndex).setSelectionStrategy(RowSelectionStrategy.INSTANCE); break; case INPUT_CLAUSES: final int iei = DecisionTableUIModelMapperHelper.getInputEntryIndex(dtable, columnIndex); uiModel.get().setCell(rowIndex, columnIndex, () -> new DecisionTableGridCell<>(new BaseGridCellValue<>(rule.getInputEntry().get(iei).getText().getValue()), listSelector, lineHeight)); break; case OUTPUT_CLAUSES: final int oei = DecisionTableUIModelMapperHelper.getOutputEntryIndex(dtable, columnIndex); uiModel.get().setCell(rowIndex, columnIndex, () -> new DecisionTableGridCell<>(new BaseGridCellValue<>(rule.getOutputEntry().get(oei).getText().getValue()), listSelector, lineHeight)); break; case ANNOTATION_CLAUSES: final int annotationIndex = DecisionTableUIModelMapperHelper.getAnnotationEntryIndex(dtable, columnIndex); final String textValue = rule.getAnnotationEntry().get(annotationIndex).getText().getValue(); uiModel.get().setCell(rowIndex, columnIndex, () -> new DecisionTableGridCell<>(new BaseGridCellValue<>(textValue), listSelector, lineHeight)); break; } }); } DecisionTableUIModelMapper(final Supplier<GridData> uiModel,
                                      final Supplier<Optional<DecisionTable>> dmnModel,
                                      final ListSelectorView.Presenter listSelector,
                                      final double lineHeight); }
DecisionTableUIModelMapper extends BaseUIModelMapper<DecisionTable> { @Override public void fromDMNModel(final int rowIndex, final int columnIndex) { dmnModel.get().ifPresent(dtable -> { final DecisionRule rule = dtable.getRule().get(rowIndex); final DecisionTableSection section = DecisionTableUIModelMapperHelper.getSection(dtable, columnIndex); switch (section) { case ROW_INDEX: uiModel.get().setCell(rowIndex, columnIndex, () -> new DecisionTableGridCell<>(new BaseGridCellValue<>(rowIndex + 1), listSelector, lineHeight)); uiModel.get().getCell(rowIndex, columnIndex).setSelectionStrategy(RowSelectionStrategy.INSTANCE); break; case INPUT_CLAUSES: final int iei = DecisionTableUIModelMapperHelper.getInputEntryIndex(dtable, columnIndex); uiModel.get().setCell(rowIndex, columnIndex, () -> new DecisionTableGridCell<>(new BaseGridCellValue<>(rule.getInputEntry().get(iei).getText().getValue()), listSelector, lineHeight)); break; case OUTPUT_CLAUSES: final int oei = DecisionTableUIModelMapperHelper.getOutputEntryIndex(dtable, columnIndex); uiModel.get().setCell(rowIndex, columnIndex, () -> new DecisionTableGridCell<>(new BaseGridCellValue<>(rule.getOutputEntry().get(oei).getText().getValue()), listSelector, lineHeight)); break; case ANNOTATION_CLAUSES: final int annotationIndex = DecisionTableUIModelMapperHelper.getAnnotationEntryIndex(dtable, columnIndex); final String textValue = rule.getAnnotationEntry().get(annotationIndex).getText().getValue(); uiModel.get().setCell(rowIndex, columnIndex, () -> new DecisionTableGridCell<>(new BaseGridCellValue<>(textValue), listSelector, lineHeight)); break; } }); } DecisionTableUIModelMapper(final Supplier<GridData> uiModel,
                                      final Supplier<Optional<DecisionTable>> dmnModel,
                                      final ListSelectorView.Presenter listSelector,
                                      final double lineHeight); @Override void fromDMNModel(final int rowIndex,
                             final int columnIndex); @Override void toDMNModel(final int rowIndex,
                           final int columnIndex,
                           final Supplier<Optional<GridCellValue<?>>> cell); }
DecisionTableUIModelMapper extends BaseUIModelMapper<DecisionTable> { @Override public void fromDMNModel(final int rowIndex, final int columnIndex) { dmnModel.get().ifPresent(dtable -> { final DecisionRule rule = dtable.getRule().get(rowIndex); final DecisionTableSection section = DecisionTableUIModelMapperHelper.getSection(dtable, columnIndex); switch (section) { case ROW_INDEX: uiModel.get().setCell(rowIndex, columnIndex, () -> new DecisionTableGridCell<>(new BaseGridCellValue<>(rowIndex + 1), listSelector, lineHeight)); uiModel.get().getCell(rowIndex, columnIndex).setSelectionStrategy(RowSelectionStrategy.INSTANCE); break; case INPUT_CLAUSES: final int iei = DecisionTableUIModelMapperHelper.getInputEntryIndex(dtable, columnIndex); uiModel.get().setCell(rowIndex, columnIndex, () -> new DecisionTableGridCell<>(new BaseGridCellValue<>(rule.getInputEntry().get(iei).getText().getValue()), listSelector, lineHeight)); break; case OUTPUT_CLAUSES: final int oei = DecisionTableUIModelMapperHelper.getOutputEntryIndex(dtable, columnIndex); uiModel.get().setCell(rowIndex, columnIndex, () -> new DecisionTableGridCell<>(new BaseGridCellValue<>(rule.getOutputEntry().get(oei).getText().getValue()), listSelector, lineHeight)); break; case ANNOTATION_CLAUSES: final int annotationIndex = DecisionTableUIModelMapperHelper.getAnnotationEntryIndex(dtable, columnIndex); final String textValue = rule.getAnnotationEntry().get(annotationIndex).getText().getValue(); uiModel.get().setCell(rowIndex, columnIndex, () -> new DecisionTableGridCell<>(new BaseGridCellValue<>(textValue), listSelector, lineHeight)); break; } }); } DecisionTableUIModelMapper(final Supplier<GridData> uiModel,
                                      final Supplier<Optional<DecisionTable>> dmnModel,
                                      final ListSelectorView.Presenter listSelector,
                                      final double lineHeight); @Override void fromDMNModel(final int rowIndex,
                             final int columnIndex); @Override void toDMNModel(final int rowIndex,
                           final int columnIndex,
                           final Supplier<Optional<GridCellValue<?>>> cell);  }