AttributeColumnConfigRow { public void init(final AttributeCol52 attributeColumn, final GuidedDecisionTableModellerView.Presenter presenter) { view.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); view.addColumnLabel(attributeColumn); final AttributeCol52 originalColumn = attributeColumn; if (Objects.equals(attributeColumn.getAttribute(), Attribute.SALIENCE.getAttributeName())) { useRowNumberCheckBox = view.addUseRowNumberCheckBox(attributeColumn, presenter.isActiveDecisionTableEditable(), (event) -> { final AttributeCol52 editedColumn = originalColumn.cloneColumn(); editedColumn.setUseRowNumber(useRowNumberCheckBox.getValue()); reverseOrderCheckBox.setEnabled(useRowNumberCheckBox.getValue()); try { final Optional<GuidedDecisionTableView.Presenter> dtPresenter = presenter.getActiveDecisionTable(); if (dtPresenter.isPresent()) { dtPresenter.get().updateColumn(originalColumn, editedColumn); } } catch (VetoException veto) { presenter.getView().showGenericVetoMessage(); } }); view.add(new Span("(")); reverseOrderCheckBox = view.addReverseOrderCheckBox(attributeColumn, presenter.isActiveDecisionTableEditable(), (event) -> { final AttributeCol52 editedColumn = originalColumn.cloneColumn(); editedColumn.setReverseOrder(reverseOrderCheckBox.getValue()); try { final Optional<GuidedDecisionTableView.Presenter> dtPresenter = presenter.getActiveDecisionTable(); if (dtPresenter.isPresent()) { dtPresenter.get().updateColumn(originalColumn, editedColumn); } } catch (VetoException veto) { presenter.getView().showGenericVetoMessage(); } }); view.add(new Span(")")); } view.addDefaultValue(attributeColumn, presenter.isActiveDecisionTableEditable(), (event) -> { final AttributeCol52 editedColumn = originalColumn.cloneColumn(); editedColumn.setDefaultValue(event.getEditedDefaultValue()); try { final Optional<GuidedDecisionTableView.Presenter> dtPresenter = presenter.getActiveDecisionTable(); if (dtPresenter.isPresent()) { dtPresenter.get().updateColumn(originalColumn, editedColumn); } } catch (VetoException veto) { presenter.getView().showGenericVetoMessage(); } }); hideColumnCheckBox = view.addHideColumnCheckBox(attributeColumn, (event) -> { final AttributeCol52 editedColumn = originalColumn.cloneColumn(); editedColumn.setHideColumn(hideColumnCheckBox.getValue()); try { final Optional<GuidedDecisionTableView.Presenter> dtPresenter = presenter.getActiveDecisionTable(); if (dtPresenter.isPresent()) { dtPresenter.get().updateColumn(originalColumn, editedColumn); } } catch (VetoException veto) { presenter.getView().showGenericVetoMessage(); } }); addRemoveAttributeButton(attributeColumn, presenter); } AttributeColumnConfigRow(); void init(final AttributeCol52 attributeColumn,
                     final GuidedDecisionTableModellerView.Presenter presenter); Widget getView();  }
@Test public void testInit() throws Exception { columnConfigRow.init(attributeColumn, presenter); verify(view).setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); verify(view).addColumnLabel(attributeColumn); }
@Test public void testInitUseRowNumberCheckBox() throws Exception { when(useRowNumberCheckBox.getValue()).thenReturn(true); columnConfigRow.init(attributeColumn, presenter); verify(view).addUseRowNumberCheckBox(eq(attributeColumn), eq(true), clickCaptor.capture()); clickCaptor.getValue().onClick(null); verify(editedAttributeColumn).setUseRowNumber(true); verify(reverseOrderCheckBox).setEnabled(true); verify(decisionTable).updateColumn(attributeColumn, editedAttributeColumn); }
@Test public void testInitUseRowNumberCheckBoxWithoutActiveDecisionTable() throws Exception { when(useRowNumberCheckBox.getValue()).thenReturn(true); when(presenter.getActiveDecisionTable()).thenReturn(Optional.empty()); columnConfigRow.init(attributeColumn, presenter); verify(view).addUseRowNumberCheckBox(eq(attributeColumn), eq(true), clickCaptor.capture()); clickCaptor.getValue().onClick(null); verify(decisionTable, never()).updateColumn(any(AttributeCol52.class), any(AttributeCol52.class)); }
@Test public void testInitReverseOrder() throws Exception { when(reverseOrderCheckBox.getValue()).thenReturn(true); columnConfigRow.init(attributeColumn, presenter); verify(view).addReverseOrderCheckBox(eq(attributeColumn), eq(true), clickCaptor.capture()); clickCaptor.getValue().onClick(null); verify(editedAttributeColumn).setReverseOrder(true); verify(decisionTable).updateColumn(attributeColumn, editedAttributeColumn); }
@Test public void testInitReverseOrderWithoutActiveDecisionTable() throws Exception { when(reverseOrderCheckBox.getValue()).thenReturn(true); when(presenter.getActiveDecisionTable()).thenReturn(Optional.empty()); columnConfigRow.init(attributeColumn, presenter); verify(view).addReverseOrderCheckBox(eq(attributeColumn), eq(true), clickCaptor.capture()); clickCaptor.getValue().onClick(null); verify(decisionTable, never()).updateColumn(any(AttributeCol52.class), any(AttributeCol52.class)); }
@Test public void testInitDefaultValue() throws Exception { when(event.getEditedDefaultValue()).thenReturn(defaultValue); columnConfigRow.init(attributeColumn, presenter); verify(view).addDefaultValue(eq(attributeColumn), eq(true), defaultValueCaptor.capture()); defaultValueCaptor.getValue().onDefaultValueChanged(event); verify(editedAttributeColumn).setDefaultValue(defaultValue); verify(decisionTable).updateColumn(attributeColumn, editedAttributeColumn); }
@Test public void testInitDefaultValueWithoutActiveDecisionTable() throws Exception { when(event.getEditedDefaultValue()).thenReturn(defaultValue); when(presenter.getActiveDecisionTable()).thenReturn(Optional.empty()); columnConfigRow.init(attributeColumn, presenter); verify(view).addDefaultValue(eq(attributeColumn), eq(true), defaultValueCaptor.capture()); defaultValueCaptor.getValue().onDefaultValueChanged(event); verify(decisionTable, never()).updateColumn(any(AttributeCol52.class), any(AttributeCol52.class)); }
@Test public void testInitHideColumn() throws Exception { when(hideColumnCheckBox.getValue()).thenReturn(true); columnConfigRow.init(attributeColumn, presenter); verify(view).addHideColumnCheckBox(eq(attributeColumn), clickCaptor.capture()); clickCaptor.getValue().onClick(null); verify(editedAttributeColumn).setHideColumn(true); verify(decisionTable).updateColumn(attributeColumn, editedAttributeColumn); }
@Test public void testInitHideColumnWithoutActiveDecisionTable() throws Exception { when(hideColumnCheckBox.getValue()).thenReturn(true); when(presenter.getActiveDecisionTable()).thenReturn(Optional.empty()); columnConfigRow.init(attributeColumn, presenter); verify(view).addHideColumnCheckBox(eq(attributeColumn), clickCaptor.capture()); clickCaptor.getValue().onClick(null); verify(decisionTable, never()).updateColumn(any(AttributeCol52.class), any(AttributeCol52.class)); }