EditMenuBuilder extends BaseMenu implements MenuFactory.CustomMenuBuilder { @Override public void onDecisionTableSelectionsChangedEvent(final @Observes DecisionTableSelectionsChangedEvent event) { super.onDecisionTableSelectionsChangedEvent(event); } @Inject  EditMenuBuilder(final Clipboard clipboard,
                           final TranslationService ts,
                           final MenuItemFactory menuItemFactory,
                           final DecisionTablePopoverUtils popoverUtils); @PostConstruct void setup(); @Override void push(final MenuFactory.CustomMenuBuilder element); @Override MenuItem build(); @Override void onDecisionTableSelectedEvent(final @Observes DecisionTableSelectedEvent event); @Override void onDecisionTableSelectionsChangedEvent(final @Observes DecisionTableSelectionsChangedEvent event); @Override void onRefreshMenusEvent(final @Observes RefreshMenusEvent event); @Override void initialise();  }
@Test public void testOnDecisionTableSelectionsChangedEventWithNoSelections() { builder.onDecisionTableSelectionsChangedEvent(new DecisionTableSelectionsChangedEvent(dtPresenter)); assertFalse(builder.miCut.getMenuItem().isEnabled()); assertFalse(builder.miCopy.getMenuItem().isEnabled()); assertFalse(builder.miPaste.getMenuItem().isEnabled()); assertFalse(builder.miDeleteSelectedCells.getMenuItem().isEnabled()); assertFalse(builder.miDeleteSelectedColumns.getMenuItem().isEnabled()); assertFalse(builder.miDeleteSelectedRows.getMenuItem().isEnabled()); assertFalse(builder.miOtherwiseCell.getMenuItem().isEnabled()); }
@Test public void testOnDecisionTableSelectionsChangedEventWithNonOtherwiseColumnSelectedAndItHasEditableColumns() { model.getMetadataCols().add(new MetadataCol52()); model.getData().add(makeDTCellValue52()); uiModel.selectCell(0, 3); builder.onDecisionTableSelectionsChangedEvent(new DecisionTableSelectionsChangedEvent(dtPresenter)); assertTrue(builder.miCut.getMenuItem().isEnabled()); assertTrue(builder.miCopy.getMenuItem().isEnabled()); assertFalse(builder.miPaste.getMenuItem().isEnabled()); assertTrue(builder.miDeleteSelectedCells.getMenuItem().isEnabled()); assertTrue(builder.miDeleteSelectedColumns.getMenuItem().isEnabled()); assertTrue(builder.miDeleteSelectedRows.getMenuItem().isEnabled()); assertFalse(builder.miOtherwiseCell.getMenuItem().isEnabled()); verify(builder.miOtherwiseCell.getMenuItemView(), times(1)).setIconType(eq(null)); }
@Test public void testOnDecisionTableSelectionsChangedEventWithNonOtherwiseColumnSelectedAndItDoesNotHaveEditableColumns() { when(dtPresenter.hasEditableColumns()).thenReturn(false); model.getMetadataCols().add(new MetadataCol52()); model.getData().add(makeDTCellValue52()); uiModel.selectCell(0, 3); builder.onDecisionTableSelectionsChangedEvent(new DecisionTableSelectionsChangedEvent(dtPresenter)); assertTrue(builder.miCut.getMenuItem().isEnabled()); assertTrue(builder.miCopy.getMenuItem().isEnabled()); assertFalse(builder.miPaste.getMenuItem().isEnabled()); assertTrue(builder.miDeleteSelectedCells.getMenuItem().isEnabled()); assertFalse(builder.miDeleteSelectedColumns.getMenuItem().isEnabled()); assertTrue(builder.miDeleteSelectedRows.getMenuItem().isEnabled()); assertFalse(builder.miOtherwiseCell.getMenuItem().isEnabled()); verify(builder.miOtherwiseCell.getMenuItemView(), times(1)).setIconType(eq(null)); }
@Test public void testOnDecisionTableSelectionsChangedEventWithOtherwiseColumnSelectedAndItHasEditableColumns() { model.getConditions().add(makePattern52()); model.getData().add(makeDTCellValue52()); uiModel.selectCell(0, 3); builder.onDecisionTableSelectionsChangedEvent(new DecisionTableSelectionsChangedEvent(dtPresenter)); assertTrue(builder.miCut.getMenuItem().isEnabled()); assertTrue(builder.miCopy.getMenuItem().isEnabled()); assertFalse(builder.miPaste.getMenuItem().isEnabled()); assertTrue(builder.miDeleteSelectedCells.getMenuItem().isEnabled()); assertTrue(builder.miDeleteSelectedColumns.getMenuItem().isEnabled()); assertTrue(builder.miDeleteSelectedRows.getMenuItem().isEnabled()); assertTrue(builder.miOtherwiseCell.getMenuItem().isEnabled()); verify(builder.miOtherwiseCell.getMenuItemView(), times(1)).setIconType(eq(null)); }
@Test public void testOnDecisionTableSelectionsChangedEventWithOtherwiseColumnSelectedAndItDoesNotHaveEditableColumns() { when(dtPresenter.hasEditableColumns()).thenReturn(false); model.getConditions().add(makePattern52()); model.getData().add(makeDTCellValue52()); uiModel.selectCell(0, 3); builder.onDecisionTableSelectionsChangedEvent(new DecisionTableSelectionsChangedEvent(dtPresenter)); assertTrue(builder.miCut.getMenuItem().isEnabled()); assertTrue(builder.miCopy.getMenuItem().isEnabled()); assertFalse(builder.miPaste.getMenuItem().isEnabled()); assertTrue(builder.miDeleteSelectedCells.getMenuItem().isEnabled()); assertFalse(builder.miDeleteSelectedColumns.getMenuItem().isEnabled()); assertTrue(builder.miDeleteSelectedRows.getMenuItem().isEnabled()); assertTrue(builder.miOtherwiseCell.getMenuItem().isEnabled()); verify(builder.miOtherwiseCell.getMenuItemView(), times(1)).setIconType(eq(null)); }
@Test public void testOnDecisionTableSelectionsChangedEventWithOtherwiseCellSelectedAndItHasEditableColumns() { model.getConditions().add(makePattern52()); model.getData().add(makeDTCellValue52ListWithOtherwise()); uiModel.selectCell(0, 3); builder.onDecisionTableSelectionsChangedEvent(new DecisionTableSelectionsChangedEvent(dtPresenter)); assertTrue(builder.miCut.getMenuItem().isEnabled()); assertTrue(builder.miCopy.getMenuItem().isEnabled()); assertFalse(builder.miPaste.getMenuItem().isEnabled()); assertTrue(builder.miDeleteSelectedCells.getMenuItem().isEnabled()); assertTrue(builder.miDeleteSelectedColumns.getMenuItem().isEnabled()); assertTrue(builder.miDeleteSelectedRows.getMenuItem().isEnabled()); assertTrue(builder.miOtherwiseCell.getMenuItem().isEnabled()); verify(builder.miOtherwiseCell.getMenuItemView(), times(1)).setIconType(eq(IconType.CHECK)); }
@Test public void testOnDecisionTableSelectionsChangedEventWithOtherwiseCellSelectedAndItDoesNotHaveEditableColumns() { when(dtPresenter.hasEditableColumns()).thenReturn(false); model.getConditions().add(makePattern52()); model.getData().add(makeDTCellValue52ListWithOtherwise()); uiModel.selectCell(0, 3); builder.onDecisionTableSelectionsChangedEvent(new DecisionTableSelectionsChangedEvent(dtPresenter)); assertTrue(builder.miCut.getMenuItem().isEnabled()); assertTrue(builder.miCopy.getMenuItem().isEnabled()); assertFalse(builder.miPaste.getMenuItem().isEnabled()); assertTrue(builder.miDeleteSelectedCells.getMenuItem().isEnabled()); assertFalse(builder.miDeleteSelectedColumns.getMenuItem().isEnabled()); assertTrue(builder.miDeleteSelectedRows.getMenuItem().isEnabled()); assertTrue(builder.miOtherwiseCell.getMenuItem().isEnabled()); verify(builder.miOtherwiseCell.getMenuItemView(), times(1)).setIconType(eq(IconType.CHECK)); }
@Test public void testOnDecisionTableSelectionsChangedEventWithSelectionsWithClipboardPopulatedAndItHasEditableColumns() { model.getMetadataCols().add(new MetadataCol52()); model.getData().add(makeDTCellValue52()); uiModel.selectCell(0, 3); clipboard.setData(makeClipboardHashSetData()); builder.onDecisionTableSelectionsChangedEvent(new DecisionTableSelectionsChangedEvent(dtPresenter)); assertTrue(builder.miCut.getMenuItem().isEnabled()); assertTrue(builder.miCopy.getMenuItem().isEnabled()); assertTrue(builder.miPaste.getMenuItem().isEnabled()); assertTrue(builder.miDeleteSelectedCells.getMenuItem().isEnabled()); assertTrue(builder.miDeleteSelectedColumns.getMenuItem().isEnabled()); assertTrue(builder.miDeleteSelectedRows.getMenuItem().isEnabled()); assertFalse(builder.miOtherwiseCell.getMenuItem().isEnabled()); verify(builder.miOtherwiseCell.getMenuItemView(), times(1)).setIconType(eq(null)); }
@Test public void testOnDecisionTableSelectionsChangedEventWithSelectionsWithClipboardPopulatedAndItDoesNotHaveEditableColumns() { when(dtPresenter.hasEditableColumns()).thenReturn(false); model.getMetadataCols().add(new MetadataCol52()); model.getData().add(makeDTCellValue52()); uiModel.selectCell(0, 3); clipboard.setData(makeClipboardHashSetData()); builder.onDecisionTableSelectionsChangedEvent(new DecisionTableSelectionsChangedEvent(dtPresenter)); assertTrue(builder.miCut.getMenuItem().isEnabled()); assertTrue(builder.miCopy.getMenuItem().isEnabled()); assertTrue(builder.miPaste.getMenuItem().isEnabled()); assertTrue(builder.miDeleteSelectedCells.getMenuItem().isEnabled()); assertFalse(builder.miDeleteSelectedColumns.getMenuItem().isEnabled()); assertTrue(builder.miDeleteSelectedRows.getMenuItem().isEnabled()); assertFalse(builder.miOtherwiseCell.getMenuItem().isEnabled()); verify(builder.miOtherwiseCell.getMenuItemView(), times(1)).setIconType(eq(null)); }