@Test public void testGetItemsWithCellSelectionsCoveringMultipleRows() { setupGrid(); addListRow(0); grid.getModel().selectCell(0, ROW_COLUMN_INDEX); grid.getModel().selectCell(1, ROW_COLUMN_INDEX); assertDefaultListItems(grid.getItems(0, ROW_COLUMN_INDEX), false); }
@Override public java.util.List<ListSelectorItem> getItems(final int uiRowIndex, final int uiColumnIndex) { final java.util.List<ListSelectorItem> items = new ArrayList<>(); final boolean isMultiRow = SelectionUtils.isMultiRow(model); final boolean isMultiSelect = SelectionUtils.isMultiSelect(model); items.add(ListSelectorHeaderItem.build(translationService.format(DMNEditorConstants.ListEditor_HeaderRows))); items.add(ListSelectorTextItem.build(translationService.format(DMNEditorConstants.ListEditor_InsertRowAbove), !isMultiRow, () -> { cellEditorControls.hide(); getExpression().get().ifPresent(e -> addRow(uiRowIndex)); })); items.add(ListSelectorTextItem.build(translationService.format(DMNEditorConstants.ListEditor_InsertRowBelow), !isMultiRow, () -> { cellEditorControls.hide(); getExpression().get().ifPresent(e -> addRow(uiRowIndex + 1)); })); items.add(ListSelectorTextItem.build(translationService.format(DMNEditorConstants.ListEditor_DeleteRow), !isMultiRow && model.getRowCount() > 1, () -> { cellEditorControls.hide(); getExpression().get().ifPresent(e -> deleteRow(uiRowIndex)); })); if (ListUIModelMapperHelper.getSection(uiColumnIndex) != ListUIModelMapperHelper.ListSection.EXPRESSION) { return items; } final GridCell<?> cell = model.getCell(uiRowIndex, uiColumnIndex); final ExpressionCellValue ecv = (ExpressionCellValue) cell.getValue(); if (!ecv.getValue().isPresent()) { return items; } final BaseExpressionGrid grid = ecv.getValue().get(); if (grid instanceof UndefinedExpressionGrid) { return items; } if (items.size() > 0) { items.add(new ListSelectorDividerItem()); } items.add(ListSelectorTextItem.build(translationService.format(DMNEditorConstants.ExpressionEditor_Clear), !isMultiSelect, () -> { cellEditorControls.hide(); clearExpressionType(uiRowIndex); })); return items; }
ListGrid extends BaseExpressionGrid<List, ListGridData, ListUIModelMapper> implements HasListSelectorControl { @Override public java.util.List<ListSelectorItem> getItems(final int uiRowIndex, final int uiColumnIndex) { final java.util.List<ListSelectorItem> items = new ArrayList<>(); final boolean isMultiRow = SelectionUtils.isMultiRow(model); final boolean isMultiSelect = SelectionUtils.isMultiSelect(model); items.add(ListSelectorHeaderItem.build(translationService.format(DMNEditorConstants.ListEditor_HeaderRows))); items.add(ListSelectorTextItem.build(translationService.format(DMNEditorConstants.ListEditor_InsertRowAbove), !isMultiRow, () -> { cellEditorControls.hide(); getExpression().get().ifPresent(e -> addRow(uiRowIndex)); })); items.add(ListSelectorTextItem.build(translationService.format(DMNEditorConstants.ListEditor_InsertRowBelow), !isMultiRow, () -> { cellEditorControls.hide(); getExpression().get().ifPresent(e -> addRow(uiRowIndex + 1)); })); items.add(ListSelectorTextItem.build(translationService.format(DMNEditorConstants.ListEditor_DeleteRow), !isMultiRow && model.getRowCount() > 1, () -> { cellEditorControls.hide(); getExpression().get().ifPresent(e -> deleteRow(uiRowIndex)); })); if (ListUIModelMapperHelper.getSection(uiColumnIndex) != ListUIModelMapperHelper.ListSection.EXPRESSION) { return items; } final GridCell<?> cell = model.getCell(uiRowIndex, uiColumnIndex); final ExpressionCellValue ecv = (ExpressionCellValue) cell.getValue(); if (!ecv.getValue().isPresent()) { return items; } final BaseExpressionGrid grid = ecv.getValue().get(); if (grid instanceof UndefinedExpressionGrid) { return items; } if (items.size() > 0) { items.add(new ListSelectorDividerItem()); } items.add(ListSelectorTextItem.build(translationService.format(DMNEditorConstants.ExpressionEditor_Clear), !isMultiSelect, () -> { cellEditorControls.hide(); clearExpressionType(uiRowIndex); })); return items; } }
ListGrid extends BaseExpressionGrid<List, ListGridData, ListUIModelMapper> implements HasListSelectorControl { @Override public java.util.List<ListSelectorItem> getItems(final int uiRowIndex, final int uiColumnIndex) { final java.util.List<ListSelectorItem> items = new ArrayList<>(); final boolean isMultiRow = SelectionUtils.isMultiRow(model); final boolean isMultiSelect = SelectionUtils.isMultiSelect(model); items.add(ListSelectorHeaderItem.build(translationService.format(DMNEditorConstants.ListEditor_HeaderRows))); items.add(ListSelectorTextItem.build(translationService.format(DMNEditorConstants.ListEditor_InsertRowAbove), !isMultiRow, () -> { cellEditorControls.hide(); getExpression().get().ifPresent(e -> addRow(uiRowIndex)); })); items.add(ListSelectorTextItem.build(translationService.format(DMNEditorConstants.ListEditor_InsertRowBelow), !isMultiRow, () -> { cellEditorControls.hide(); getExpression().get().ifPresent(e -> addRow(uiRowIndex + 1)); })); items.add(ListSelectorTextItem.build(translationService.format(DMNEditorConstants.ListEditor_DeleteRow), !isMultiRow && model.getRowCount() > 1, () -> { cellEditorControls.hide(); getExpression().get().ifPresent(e -> deleteRow(uiRowIndex)); })); if (ListUIModelMapperHelper.getSection(uiColumnIndex) != ListUIModelMapperHelper.ListSection.EXPRESSION) { return items; } final GridCell<?> cell = model.getCell(uiRowIndex, uiColumnIndex); final ExpressionCellValue ecv = (ExpressionCellValue) cell.getValue(); if (!ecv.getValue().isPresent()) { return items; } final BaseExpressionGrid grid = ecv.getValue().get(); if (grid instanceof UndefinedExpressionGrid) { return items; } if (items.size() > 0) { items.add(new ListSelectorDividerItem()); } items.add(ListSelectorTextItem.build(translationService.format(DMNEditorConstants.ExpressionEditor_Clear), !isMultiSelect, () -> { cellEditorControls.hide(); clearExpressionType(uiRowIndex); })); return items; } ListGrid(final GridCellTuple parent,
                    final Optional<String> nodeUUID,
                    final HasExpression hasExpression,
                    final Optional<HasName> hasName,
                    final DMNGridPanel gridPanel,
                    final DMNGridLayer gridLayer,
                    final ListGridData gridData,
                    final DefinitionUtils definitionUtils,
                    final SessionManager sessionManager,
                    final SessionCommandManager<AbstractCanvasHandler> sessionCommandManager,
                    final DefaultCanvasCommandFactory canvasCommandFactory,
                    final Event<ExpressionEditorChanged> editorSelectedEvent,
                    final Event<RefreshFormPropertiesEvent> refreshFormPropertiesEvent,
                    final Event<DomainObjectSelectionEvent> domainObjectSelectionEvent,
                    final CellEditorControlsView.Presenter cellEditorControls,
                    final ListSelectorView.Presenter listSelector,
                    final TranslationService translationService,
                    final boolean isOnlyVisualChangeAllowed,
                    final int nesting,
                    final Supplier<ExpressionEditorDefinitions> expressionEditorDefinitionsSupplier,
                    final ValueAndDataTypePopoverView.Presenter headerEditor,
                    final ReadOnlyProvider readOnlyProvider); }
ListGrid extends BaseExpressionGrid<List, ListGridData, ListUIModelMapper> implements HasListSelectorControl { @Override public java.util.List<ListSelectorItem> getItems(final int uiRowIndex, final int uiColumnIndex) { final java.util.List<ListSelectorItem> items = new ArrayList<>(); final boolean isMultiRow = SelectionUtils.isMultiRow(model); final boolean isMultiSelect = SelectionUtils.isMultiSelect(model); items.add(ListSelectorHeaderItem.build(translationService.format(DMNEditorConstants.ListEditor_HeaderRows))); items.add(ListSelectorTextItem.build(translationService.format(DMNEditorConstants.ListEditor_InsertRowAbove), !isMultiRow, () -> { cellEditorControls.hide(); getExpression().get().ifPresent(e -> addRow(uiRowIndex)); })); items.add(ListSelectorTextItem.build(translationService.format(DMNEditorConstants.ListEditor_InsertRowBelow), !isMultiRow, () -> { cellEditorControls.hide(); getExpression().get().ifPresent(e -> addRow(uiRowIndex + 1)); })); items.add(ListSelectorTextItem.build(translationService.format(DMNEditorConstants.ListEditor_DeleteRow), !isMultiRow && model.getRowCount() > 1, () -> { cellEditorControls.hide(); getExpression().get().ifPresent(e -> deleteRow(uiRowIndex)); })); if (ListUIModelMapperHelper.getSection(uiColumnIndex) != ListUIModelMapperHelper.ListSection.EXPRESSION) { return items; } final GridCell<?> cell = model.getCell(uiRowIndex, uiColumnIndex); final ExpressionCellValue ecv = (ExpressionCellValue) cell.getValue(); if (!ecv.getValue().isPresent()) { return items; } final BaseExpressionGrid grid = ecv.getValue().get(); if (grid instanceof UndefinedExpressionGrid) { return items; } if (items.size() > 0) { items.add(new ListSelectorDividerItem()); } items.add(ListSelectorTextItem.build(translationService.format(DMNEditorConstants.ExpressionEditor_Clear), !isMultiSelect, () -> { cellEditorControls.hide(); clearExpressionType(uiRowIndex); })); return items; } ListGrid(final GridCellTuple parent,
                    final Optional<String> nodeUUID,
                    final HasExpression hasExpression,
                    final Optional<HasName> hasName,
                    final DMNGridPanel gridPanel,
                    final DMNGridLayer gridLayer,
                    final ListGridData gridData,
                    final DefinitionUtils definitionUtils,
                    final SessionManager sessionManager,
                    final SessionCommandManager<AbstractCanvasHandler> sessionCommandManager,
                    final DefaultCanvasCommandFactory canvasCommandFactory,
                    final Event<ExpressionEditorChanged> editorSelectedEvent,
                    final Event<RefreshFormPropertiesEvent> refreshFormPropertiesEvent,
                    final Event<DomainObjectSelectionEvent> domainObjectSelectionEvent,
                    final CellEditorControlsView.Presenter cellEditorControls,
                    final ListSelectorView.Presenter listSelector,
                    final TranslationService translationService,
                    final boolean isOnlyVisualChangeAllowed,
                    final int nesting,
                    final Supplier<ExpressionEditorDefinitions> expressionEditorDefinitionsSupplier,
                    final ValueAndDataTypePopoverView.Presenter headerEditor,
                    final ReadOnlyProvider readOnlyProvider); @Override ListUIModelMapper makeUiModelMapper(); @Override void initialiseUiColumns(); @Override void initialiseUiRows(); @Override void initialiseUiCells(); @Override java.util.List<ListSelectorItem> getItems(final int uiRowIndex,
                                                     final int uiColumnIndex); @Override void onItemSelected(final ListSelectorItem item); @Override void doAfterSelectionChange(final int uiRowIndex,
                                       final int uiColumnIndex); }
ListGrid extends BaseExpressionGrid<List, ListGridData, ListUIModelMapper> implements HasListSelectorControl { @Override public java.util.List<ListSelectorItem> getItems(final int uiRowIndex, final int uiColumnIndex) { final java.util.List<ListSelectorItem> items = new ArrayList<>(); final boolean isMultiRow = SelectionUtils.isMultiRow(model); final boolean isMultiSelect = SelectionUtils.isMultiSelect(model); items.add(ListSelectorHeaderItem.build(translationService.format(DMNEditorConstants.ListEditor_HeaderRows))); items.add(ListSelectorTextItem.build(translationService.format(DMNEditorConstants.ListEditor_InsertRowAbove), !isMultiRow, () -> { cellEditorControls.hide(); getExpression().get().ifPresent(e -> addRow(uiRowIndex)); })); items.add(ListSelectorTextItem.build(translationService.format(DMNEditorConstants.ListEditor_InsertRowBelow), !isMultiRow, () -> { cellEditorControls.hide(); getExpression().get().ifPresent(e -> addRow(uiRowIndex + 1)); })); items.add(ListSelectorTextItem.build(translationService.format(DMNEditorConstants.ListEditor_DeleteRow), !isMultiRow && model.getRowCount() > 1, () -> { cellEditorControls.hide(); getExpression().get().ifPresent(e -> deleteRow(uiRowIndex)); })); if (ListUIModelMapperHelper.getSection(uiColumnIndex) != ListUIModelMapperHelper.ListSection.EXPRESSION) { return items; } final GridCell<?> cell = model.getCell(uiRowIndex, uiColumnIndex); final ExpressionCellValue ecv = (ExpressionCellValue) cell.getValue(); if (!ecv.getValue().isPresent()) { return items; } final BaseExpressionGrid grid = ecv.getValue().get(); if (grid instanceof UndefinedExpressionGrid) { return items; } if (items.size() > 0) { items.add(new ListSelectorDividerItem()); } items.add(ListSelectorTextItem.build(translationService.format(DMNEditorConstants.ExpressionEditor_Clear), !isMultiSelect, () -> { cellEditorControls.hide(); clearExpressionType(uiRowIndex); })); return items; } ListGrid(final GridCellTuple parent,
                    final Optional<String> nodeUUID,
                    final HasExpression hasExpression,
                    final Optional<HasName> hasName,
                    final DMNGridPanel gridPanel,
                    final DMNGridLayer gridLayer,
                    final ListGridData gridData,
                    final DefinitionUtils definitionUtils,
                    final SessionManager sessionManager,
                    final SessionCommandManager<AbstractCanvasHandler> sessionCommandManager,
                    final DefaultCanvasCommandFactory canvasCommandFactory,
                    final Event<ExpressionEditorChanged> editorSelectedEvent,
                    final Event<RefreshFormPropertiesEvent> refreshFormPropertiesEvent,
                    final Event<DomainObjectSelectionEvent> domainObjectSelectionEvent,
                    final CellEditorControlsView.Presenter cellEditorControls,
                    final ListSelectorView.Presenter listSelector,
                    final TranslationService translationService,
                    final boolean isOnlyVisualChangeAllowed,
                    final int nesting,
                    final Supplier<ExpressionEditorDefinitions> expressionEditorDefinitionsSupplier,
                    final ValueAndDataTypePopoverView.Presenter headerEditor,
                    final ReadOnlyProvider readOnlyProvider); @Override ListUIModelMapper makeUiModelMapper(); @Override void initialiseUiColumns(); @Override void initialiseUiRows(); @Override void initialiseUiCells(); @Override java.util.List<ListSelectorItem> getItems(final int uiRowIndex,
                                                     final int uiColumnIndex); @Override void onItemSelected(final ListSelectorItem item); @Override void doAfterSelectionChange(final int uiRowIndex,
                                       final int uiColumnIndex);  }