@Test public void testGetItemsRowNumberColumn() { setupGrid(0); assertDefaultListItems(grid.getItems(0, 0), true); }
@Override @SuppressWarnings("unused") public List<ListSelectorItem> getItems(final int uiRowIndex, final int uiColumnIndex) { final List<ListSelectorItem> items = new ArrayList<>(); final boolean isMultiRow = SelectionUtils.isMultiRow(model); final boolean isMultiSelect = SelectionUtils.isMultiSelect(model); if (uiRowIndex < model.getRowCount() - 1) { items.add(ListSelectorHeaderItem.build(translationService.format(DMNEditorConstants.ContextEditor_Header))); items.add(ListSelectorTextItem.build(translationService.format(DMNEditorConstants.ContextEditor_InsertContextEntryAbove), !isMultiRow, () -> { cellEditorControls.hide(); getExpression().get().ifPresent(e -> addContextEntry(uiRowIndex)); })); items.add(ListSelectorTextItem.build(translationService.format(DMNEditorConstants.ContextEditor_InsertContextEntryBelow), !isMultiRow, () -> { cellEditorControls.hide(); getExpression().get().ifPresent(e -> addContextEntry(uiRowIndex + 1)); })); items.add(ListSelectorTextItem.build(translationService.format(DMNEditorConstants.ContextEditor_DeleteContextEntry), !isMultiRow && model.getRowCount() > 2 && uiRowIndex < model.getRowCount() - 1, () -> { cellEditorControls.hide(); deleteContextEntry(uiRowIndex); })); } if (ContextUIModelMapperHelper.getSection(uiColumnIndex) != ContextUIModelMapperHelper.ContextSection.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; }
ContextGrid extends BaseExpressionGrid<Context, ContextGridData, ContextUIModelMapper> implements HasRowDragRestrictions,
                                                                                                               HasListSelectorControl { @Override @SuppressWarnings("unused") public List<ListSelectorItem> getItems(final int uiRowIndex, final int uiColumnIndex) { final List<ListSelectorItem> items = new ArrayList<>(); final boolean isMultiRow = SelectionUtils.isMultiRow(model); final boolean isMultiSelect = SelectionUtils.isMultiSelect(model); if (uiRowIndex < model.getRowCount() - 1) { items.add(ListSelectorHeaderItem.build(translationService.format(DMNEditorConstants.ContextEditor_Header))); items.add(ListSelectorTextItem.build(translationService.format(DMNEditorConstants.ContextEditor_InsertContextEntryAbove), !isMultiRow, () -> { cellEditorControls.hide(); getExpression().get().ifPresent(e -> addContextEntry(uiRowIndex)); })); items.add(ListSelectorTextItem.build(translationService.format(DMNEditorConstants.ContextEditor_InsertContextEntryBelow), !isMultiRow, () -> { cellEditorControls.hide(); getExpression().get().ifPresent(e -> addContextEntry(uiRowIndex + 1)); })); items.add(ListSelectorTextItem.build(translationService.format(DMNEditorConstants.ContextEditor_DeleteContextEntry), !isMultiRow && model.getRowCount() > 2 && uiRowIndex < model.getRowCount() - 1, () -> { cellEditorControls.hide(); deleteContextEntry(uiRowIndex); })); } if (ContextUIModelMapperHelper.getSection(uiColumnIndex) != ContextUIModelMapperHelper.ContextSection.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; } }
ContextGrid extends BaseExpressionGrid<Context, ContextGridData, ContextUIModelMapper> implements HasRowDragRestrictions,
                                                                                                               HasListSelectorControl { @Override @SuppressWarnings("unused") public List<ListSelectorItem> getItems(final int uiRowIndex, final int uiColumnIndex) { final List<ListSelectorItem> items = new ArrayList<>(); final boolean isMultiRow = SelectionUtils.isMultiRow(model); final boolean isMultiSelect = SelectionUtils.isMultiSelect(model); if (uiRowIndex < model.getRowCount() - 1) { items.add(ListSelectorHeaderItem.build(translationService.format(DMNEditorConstants.ContextEditor_Header))); items.add(ListSelectorTextItem.build(translationService.format(DMNEditorConstants.ContextEditor_InsertContextEntryAbove), !isMultiRow, () -> { cellEditorControls.hide(); getExpression().get().ifPresent(e -> addContextEntry(uiRowIndex)); })); items.add(ListSelectorTextItem.build(translationService.format(DMNEditorConstants.ContextEditor_InsertContextEntryBelow), !isMultiRow, () -> { cellEditorControls.hide(); getExpression().get().ifPresent(e -> addContextEntry(uiRowIndex + 1)); })); items.add(ListSelectorTextItem.build(translationService.format(DMNEditorConstants.ContextEditor_DeleteContextEntry), !isMultiRow && model.getRowCount() > 2 && uiRowIndex < model.getRowCount() - 1, () -> { cellEditorControls.hide(); deleteContextEntry(uiRowIndex); })); } if (ContextUIModelMapperHelper.getSection(uiColumnIndex) != ContextUIModelMapperHelper.ContextSection.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; } ContextGrid(final GridCellTuple parent,
                       final Optional<String> nodeUUID,
                       final HasExpression hasExpression,
                       final Optional<HasName> hasName,
                       final DMNGridPanel gridPanel,
                       final DMNGridLayer gridLayer,
                       final ContextGridData 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); }
ContextGrid extends BaseExpressionGrid<Context, ContextGridData, ContextUIModelMapper> implements HasRowDragRestrictions,
                                                                                                               HasListSelectorControl { @Override @SuppressWarnings("unused") public List<ListSelectorItem> getItems(final int uiRowIndex, final int uiColumnIndex) { final List<ListSelectorItem> items = new ArrayList<>(); final boolean isMultiRow = SelectionUtils.isMultiRow(model); final boolean isMultiSelect = SelectionUtils.isMultiSelect(model); if (uiRowIndex < model.getRowCount() - 1) { items.add(ListSelectorHeaderItem.build(translationService.format(DMNEditorConstants.ContextEditor_Header))); items.add(ListSelectorTextItem.build(translationService.format(DMNEditorConstants.ContextEditor_InsertContextEntryAbove), !isMultiRow, () -> { cellEditorControls.hide(); getExpression().get().ifPresent(e -> addContextEntry(uiRowIndex)); })); items.add(ListSelectorTextItem.build(translationService.format(DMNEditorConstants.ContextEditor_InsertContextEntryBelow), !isMultiRow, () -> { cellEditorControls.hide(); getExpression().get().ifPresent(e -> addContextEntry(uiRowIndex + 1)); })); items.add(ListSelectorTextItem.build(translationService.format(DMNEditorConstants.ContextEditor_DeleteContextEntry), !isMultiRow && model.getRowCount() > 2 && uiRowIndex < model.getRowCount() - 1, () -> { cellEditorControls.hide(); deleteContextEntry(uiRowIndex); })); } if (ContextUIModelMapperHelper.getSection(uiColumnIndex) != ContextUIModelMapperHelper.ContextSection.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; } ContextGrid(final GridCellTuple parent,
                       final Optional<String> nodeUUID,
                       final HasExpression hasExpression,
                       final Optional<HasName> hasName,
                       final DMNGridPanel gridPanel,
                       final DMNGridLayer gridLayer,
                       final ContextGridData 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 ContextUIModelMapper makeUiModelMapper(); @Override void initialiseUiColumns(); @Override void initialiseUiRows(); @Override void initialiseUiCells(); @Override boolean isRowDragPermitted(final GridWidgetDnDHandlersState state); @Override @SuppressWarnings("unused") List<ListSelectorItem> getItems(final int uiRowIndex,
                                           final int uiColumnIndex); @Override void onItemSelected(final ListSelectorItem item); @Override void doAfterSelectionChange(final int uiRowIndex,
                                       final int uiColumnIndex); @Override void doAfterHeaderSelectionChange(final int uiHeaderRowIndex,
                                             final int uiHeaderColumnIndex); }
ContextGrid extends BaseExpressionGrid<Context, ContextGridData, ContextUIModelMapper> implements HasRowDragRestrictions,
                                                                                                               HasListSelectorControl { @Override @SuppressWarnings("unused") public List<ListSelectorItem> getItems(final int uiRowIndex, final int uiColumnIndex) { final List<ListSelectorItem> items = new ArrayList<>(); final boolean isMultiRow = SelectionUtils.isMultiRow(model); final boolean isMultiSelect = SelectionUtils.isMultiSelect(model); if (uiRowIndex < model.getRowCount() - 1) { items.add(ListSelectorHeaderItem.build(translationService.format(DMNEditorConstants.ContextEditor_Header))); items.add(ListSelectorTextItem.build(translationService.format(DMNEditorConstants.ContextEditor_InsertContextEntryAbove), !isMultiRow, () -> { cellEditorControls.hide(); getExpression().get().ifPresent(e -> addContextEntry(uiRowIndex)); })); items.add(ListSelectorTextItem.build(translationService.format(DMNEditorConstants.ContextEditor_InsertContextEntryBelow), !isMultiRow, () -> { cellEditorControls.hide(); getExpression().get().ifPresent(e -> addContextEntry(uiRowIndex + 1)); })); items.add(ListSelectorTextItem.build(translationService.format(DMNEditorConstants.ContextEditor_DeleteContextEntry), !isMultiRow && model.getRowCount() > 2 && uiRowIndex < model.getRowCount() - 1, () -> { cellEditorControls.hide(); deleteContextEntry(uiRowIndex); })); } if (ContextUIModelMapperHelper.getSection(uiColumnIndex) != ContextUIModelMapperHelper.ContextSection.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; } ContextGrid(final GridCellTuple parent,
                       final Optional<String> nodeUUID,
                       final HasExpression hasExpression,
                       final Optional<HasName> hasName,
                       final DMNGridPanel gridPanel,
                       final DMNGridLayer gridLayer,
                       final ContextGridData 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 ContextUIModelMapper makeUiModelMapper(); @Override void initialiseUiColumns(); @Override void initialiseUiRows(); @Override void initialiseUiCells(); @Override boolean isRowDragPermitted(final GridWidgetDnDHandlersState state); @Override @SuppressWarnings("unused") List<ListSelectorItem> getItems(final int uiRowIndex,
                                           final int uiColumnIndex); @Override void onItemSelected(final ListSelectorItem item); @Override void doAfterSelectionChange(final int uiRowIndex,
                                       final int uiColumnIndex); @Override void doAfterHeaderSelectionChange(final int uiHeaderRowIndex,
                                             final int uiHeaderColumnIndex);  }