@Test @SuppressWarnings("unchecked") public void testEditWhenRowIsEditable() { when(isEditable.test(anyInt())).thenReturn(true); column.edit(cell, context, callback); verify(editor).bind(any(HasValueAndTypeRef.class), eq(UI_ROW_INDEX), eq(UI_COLUMN_INDEX)); verify(cellEditorControls).show(eq(editor), eq((int) RELATIVE_X), eq((int) RELATIVE_Y)); }
@Override public void edit(final GridCell<InformationItemCell.HasNameCell> cell, final GridBodyCellRenderContext context, final Consumer<GridCellValue<InformationItemCell.HasNameCell>> callback) { final int rowIndex = context.getRowIndex(); if (!isEditable.test(rowIndex)) { return; } final int uiRowIndex = context.getRowIndex(); final int uiColumnIndex = context.getColumnIndex(); final double cellWidth = context.getCellWidth(); final double cellHeight = context.getCellHeight(); final double absoluteCellX = context.getAbsoluteCellX(); final double absoluteCellY = context.getAbsoluteCellY(); final InformationItemCell.HasNameAndDataTypeCell binding = (InformationItemCell.HasNameAndDataTypeCell) cell.getValue().getValue(); editor.bind(new HasValueAndTypeRef<Name>() { @Override public QName getTypeRef() { return binding.getTypeRef(); } @Override public void setTypeRef(final QName typeRef) { if (Objects.equals(typeRef, getTypeRef())) { return; } setTypeRefConsumer.accept(binding, typeRef); } @Override public Name getValue() { return binding.getName(); } @Override public void setValue(final Name name) { if (Objects.equals(name, getValue())) { return; } if (name == null || name.getValue() == null || name.getValue().trim().isEmpty()) { clearValueConsumer.accept(binding); } else { setValueConsumer.accept(binding, name); } } @Override public String getPopoverTitle() { return EditableNameAndDataTypeColumn.this.getPopoverTitle(); } @Override public Name toModelValue(final String componentValue) { return new Name(componentValue); } @Override public String toWidgetValue(final Name modelValue) { return modelValue.getValue(); } @Override public String getValueLabel() { return translationService.getTranslation(DMNEditorConstants.NameAndDataTypePopover_NameLabel); } @Override public String normaliseValue(final String componentValue) { return NameUtils.normaliseName(componentValue); } @Override public DMNModelInstrumentedBase asDMNModelInstrumentedBase() { return binding.asDMNModelInstrumentedBase(); } @Override public List<HasTypeRef> getHasTypeRefs() { return getNotNullHasTypeRefs(binding); } }, uiRowIndex, uiColumnIndex); final double[] dxy = {absoluteCellX + cellWidth / 2, absoluteCellY + cellHeight / 2}; final Optional<Point2D> rx = ((GridBodyCellEditContext) context).getRelativeLocation(); rx.ifPresent(r -> { dxy[0] = r.getX(); dxy[1] = r.getY(); }); cellEditorControls.show(editor, (int) (dxy[0]), (int) (dxy[1])); }
EditableNameAndDataTypeColumn extends DMNSimpleGridColumn<G, InformationItemCell.HasNameCell> { @Override public void edit(final GridCell<InformationItemCell.HasNameCell> cell, final GridBodyCellRenderContext context, final Consumer<GridCellValue<InformationItemCell.HasNameCell>> callback) { final int rowIndex = context.getRowIndex(); if (!isEditable.test(rowIndex)) { return; } final int uiRowIndex = context.getRowIndex(); final int uiColumnIndex = context.getColumnIndex(); final double cellWidth = context.getCellWidth(); final double cellHeight = context.getCellHeight(); final double absoluteCellX = context.getAbsoluteCellX(); final double absoluteCellY = context.getAbsoluteCellY(); final InformationItemCell.HasNameAndDataTypeCell binding = (InformationItemCell.HasNameAndDataTypeCell) cell.getValue().getValue(); editor.bind(new HasValueAndTypeRef<Name>() { @Override public QName getTypeRef() { return binding.getTypeRef(); } @Override public void setTypeRef(final QName typeRef) { if (Objects.equals(typeRef, getTypeRef())) { return; } setTypeRefConsumer.accept(binding, typeRef); } @Override public Name getValue() { return binding.getName(); } @Override public void setValue(final Name name) { if (Objects.equals(name, getValue())) { return; } if (name == null || name.getValue() == null || name.getValue().trim().isEmpty()) { clearValueConsumer.accept(binding); } else { setValueConsumer.accept(binding, name); } } @Override public String getPopoverTitle() { return EditableNameAndDataTypeColumn.this.getPopoverTitle(); } @Override public Name toModelValue(final String componentValue) { return new Name(componentValue); } @Override public String toWidgetValue(final Name modelValue) { return modelValue.getValue(); } @Override public String getValueLabel() { return translationService.getTranslation(DMNEditorConstants.NameAndDataTypePopover_NameLabel); } @Override public String normaliseValue(final String componentValue) { return NameUtils.normaliseName(componentValue); } @Override public DMNModelInstrumentedBase asDMNModelInstrumentedBase() { return binding.asDMNModelInstrumentedBase(); } @Override public List<HasTypeRef> getHasTypeRefs() { return getNotNullHasTypeRefs(binding); } }, uiRowIndex, uiColumnIndex); final double[] dxy = {absoluteCellX + cellWidth / 2, absoluteCellY + cellHeight / 2}; final Optional<Point2D> rx = ((GridBodyCellEditContext) context).getRelativeLocation(); rx.ifPresent(r -> { dxy[0] = r.getX(); dxy[1] = r.getY(); }); cellEditorControls.show(editor, (int) (dxy[0]), (int) (dxy[1])); } }
EditableNameAndDataTypeColumn extends DMNSimpleGridColumn<G, InformationItemCell.HasNameCell> { @Override public void edit(final GridCell<InformationItemCell.HasNameCell> cell, final GridBodyCellRenderContext context, final Consumer<GridCellValue<InformationItemCell.HasNameCell>> callback) { final int rowIndex = context.getRowIndex(); if (!isEditable.test(rowIndex)) { return; } final int uiRowIndex = context.getRowIndex(); final int uiColumnIndex = context.getColumnIndex(); final double cellWidth = context.getCellWidth(); final double cellHeight = context.getCellHeight(); final double absoluteCellX = context.getAbsoluteCellX(); final double absoluteCellY = context.getAbsoluteCellY(); final InformationItemCell.HasNameAndDataTypeCell binding = (InformationItemCell.HasNameAndDataTypeCell) cell.getValue().getValue(); editor.bind(new HasValueAndTypeRef<Name>() { @Override public QName getTypeRef() { return binding.getTypeRef(); } @Override public void setTypeRef(final QName typeRef) { if (Objects.equals(typeRef, getTypeRef())) { return; } setTypeRefConsumer.accept(binding, typeRef); } @Override public Name getValue() { return binding.getName(); } @Override public void setValue(final Name name) { if (Objects.equals(name, getValue())) { return; } if (name == null || name.getValue() == null || name.getValue().trim().isEmpty()) { clearValueConsumer.accept(binding); } else { setValueConsumer.accept(binding, name); } } @Override public String getPopoverTitle() { return EditableNameAndDataTypeColumn.this.getPopoverTitle(); } @Override public Name toModelValue(final String componentValue) { return new Name(componentValue); } @Override public String toWidgetValue(final Name modelValue) { return modelValue.getValue(); } @Override public String getValueLabel() { return translationService.getTranslation(DMNEditorConstants.NameAndDataTypePopover_NameLabel); } @Override public String normaliseValue(final String componentValue) { return NameUtils.normaliseName(componentValue); } @Override public DMNModelInstrumentedBase asDMNModelInstrumentedBase() { return binding.asDMNModelInstrumentedBase(); } @Override public List<HasTypeRef> getHasTypeRefs() { return getNotNullHasTypeRefs(binding); } }, uiRowIndex, uiColumnIndex); final double[] dxy = {absoluteCellX + cellWidth / 2, absoluteCellY + cellHeight / 2}; final Optional<Point2D> rx = ((GridBodyCellEditContext) context).getRelativeLocation(); rx.ifPresent(r -> { dxy[0] = r.getX(); dxy[1] = r.getY(); }); cellEditorControls.show(editor, (int) (dxy[0]), (int) (dxy[1])); } EditableNameAndDataTypeColumn(final HeaderMetaData headerMetaData,
                                         final double width,
                                         final G gridWidget,
                                         final Predicate<Integer> isEditable,
                                         final Consumer<HasName> clearValueConsumer,
                                         final BiConsumer<HasName, Name> setValueConsumer,
                                         final BiConsumer<HasTypeRef, QName> setTypeRefConsumer,
                                         final TranslationService translationService,
                                         final CellEditorControlsView.Presenter cellEditorControls,
                                         final ValueAndDataTypePopoverView.Presenter editor);  EditableNameAndDataTypeColumn(final List<HeaderMetaData> headerMetaData,
                                         final double width,
                                         final G gridWidget,
                                         final Predicate<Integer> isEditable,
                                         final Consumer<HasName> clearValueConsumer,
                                         final BiConsumer<HasName, Name> setValueConsumer,
                                         final BiConsumer<HasTypeRef, QName> setTypeRefConsumer,
                                         final TranslationService translationService,
                                         final CellEditorControlsView.Presenter cellEditorControls,
                                         final ValueAndDataTypePopoverView.Presenter editor); }
EditableNameAndDataTypeColumn extends DMNSimpleGridColumn<G, InformationItemCell.HasNameCell> { @Override public void edit(final GridCell<InformationItemCell.HasNameCell> cell, final GridBodyCellRenderContext context, final Consumer<GridCellValue<InformationItemCell.HasNameCell>> callback) { final int rowIndex = context.getRowIndex(); if (!isEditable.test(rowIndex)) { return; } final int uiRowIndex = context.getRowIndex(); final int uiColumnIndex = context.getColumnIndex(); final double cellWidth = context.getCellWidth(); final double cellHeight = context.getCellHeight(); final double absoluteCellX = context.getAbsoluteCellX(); final double absoluteCellY = context.getAbsoluteCellY(); final InformationItemCell.HasNameAndDataTypeCell binding = (InformationItemCell.HasNameAndDataTypeCell) cell.getValue().getValue(); editor.bind(new HasValueAndTypeRef<Name>() { @Override public QName getTypeRef() { return binding.getTypeRef(); } @Override public void setTypeRef(final QName typeRef) { if (Objects.equals(typeRef, getTypeRef())) { return; } setTypeRefConsumer.accept(binding, typeRef); } @Override public Name getValue() { return binding.getName(); } @Override public void setValue(final Name name) { if (Objects.equals(name, getValue())) { return; } if (name == null || name.getValue() == null || name.getValue().trim().isEmpty()) { clearValueConsumer.accept(binding); } else { setValueConsumer.accept(binding, name); } } @Override public String getPopoverTitle() { return EditableNameAndDataTypeColumn.this.getPopoverTitle(); } @Override public Name toModelValue(final String componentValue) { return new Name(componentValue); } @Override public String toWidgetValue(final Name modelValue) { return modelValue.getValue(); } @Override public String getValueLabel() { return translationService.getTranslation(DMNEditorConstants.NameAndDataTypePopover_NameLabel); } @Override public String normaliseValue(final String componentValue) { return NameUtils.normaliseName(componentValue); } @Override public DMNModelInstrumentedBase asDMNModelInstrumentedBase() { return binding.asDMNModelInstrumentedBase(); } @Override public List<HasTypeRef> getHasTypeRefs() { return getNotNullHasTypeRefs(binding); } }, uiRowIndex, uiColumnIndex); final double[] dxy = {absoluteCellX + cellWidth / 2, absoluteCellY + cellHeight / 2}; final Optional<Point2D> rx = ((GridBodyCellEditContext) context).getRelativeLocation(); rx.ifPresent(r -> { dxy[0] = r.getX(); dxy[1] = r.getY(); }); cellEditorControls.show(editor, (int) (dxy[0]), (int) (dxy[1])); } EditableNameAndDataTypeColumn(final HeaderMetaData headerMetaData,
                                         final double width,
                                         final G gridWidget,
                                         final Predicate<Integer> isEditable,
                                         final Consumer<HasName> clearValueConsumer,
                                         final BiConsumer<HasName, Name> setValueConsumer,
                                         final BiConsumer<HasTypeRef, QName> setTypeRefConsumer,
                                         final TranslationService translationService,
                                         final CellEditorControlsView.Presenter cellEditorControls,
                                         final ValueAndDataTypePopoverView.Presenter editor);  EditableNameAndDataTypeColumn(final List<HeaderMetaData> headerMetaData,
                                         final double width,
                                         final G gridWidget,
                                         final Predicate<Integer> isEditable,
                                         final Consumer<HasName> clearValueConsumer,
                                         final BiConsumer<HasName, Name> setValueConsumer,
                                         final BiConsumer<HasTypeRef, QName> setTypeRefConsumer,
                                         final TranslationService translationService,
                                         final CellEditorControlsView.Presenter cellEditorControls,
                                         final ValueAndDataTypePopoverView.Presenter editor); @Override void edit(final GridCell<InformationItemCell.HasNameCell> cell,
                     final GridBodyCellRenderContext context,
                     final Consumer<GridCellValue<InformationItemCell.HasNameCell>> callback); @Override void setWidth(final double width); }
EditableNameAndDataTypeColumn extends DMNSimpleGridColumn<G, InformationItemCell.HasNameCell> { @Override public void edit(final GridCell<InformationItemCell.HasNameCell> cell, final GridBodyCellRenderContext context, final Consumer<GridCellValue<InformationItemCell.HasNameCell>> callback) { final int rowIndex = context.getRowIndex(); if (!isEditable.test(rowIndex)) { return; } final int uiRowIndex = context.getRowIndex(); final int uiColumnIndex = context.getColumnIndex(); final double cellWidth = context.getCellWidth(); final double cellHeight = context.getCellHeight(); final double absoluteCellX = context.getAbsoluteCellX(); final double absoluteCellY = context.getAbsoluteCellY(); final InformationItemCell.HasNameAndDataTypeCell binding = (InformationItemCell.HasNameAndDataTypeCell) cell.getValue().getValue(); editor.bind(new HasValueAndTypeRef<Name>() { @Override public QName getTypeRef() { return binding.getTypeRef(); } @Override public void setTypeRef(final QName typeRef) { if (Objects.equals(typeRef, getTypeRef())) { return; } setTypeRefConsumer.accept(binding, typeRef); } @Override public Name getValue() { return binding.getName(); } @Override public void setValue(final Name name) { if (Objects.equals(name, getValue())) { return; } if (name == null || name.getValue() == null || name.getValue().trim().isEmpty()) { clearValueConsumer.accept(binding); } else { setValueConsumer.accept(binding, name); } } @Override public String getPopoverTitle() { return EditableNameAndDataTypeColumn.this.getPopoverTitle(); } @Override public Name toModelValue(final String componentValue) { return new Name(componentValue); } @Override public String toWidgetValue(final Name modelValue) { return modelValue.getValue(); } @Override public String getValueLabel() { return translationService.getTranslation(DMNEditorConstants.NameAndDataTypePopover_NameLabel); } @Override public String normaliseValue(final String componentValue) { return NameUtils.normaliseName(componentValue); } @Override public DMNModelInstrumentedBase asDMNModelInstrumentedBase() { return binding.asDMNModelInstrumentedBase(); } @Override public List<HasTypeRef> getHasTypeRefs() { return getNotNullHasTypeRefs(binding); } }, uiRowIndex, uiColumnIndex); final double[] dxy = {absoluteCellX + cellWidth / 2, absoluteCellY + cellHeight / 2}; final Optional<Point2D> rx = ((GridBodyCellEditContext) context).getRelativeLocation(); rx.ifPresent(r -> { dxy[0] = r.getX(); dxy[1] = r.getY(); }); cellEditorControls.show(editor, (int) (dxy[0]), (int) (dxy[1])); } EditableNameAndDataTypeColumn(final HeaderMetaData headerMetaData,
                                         final double width,
                                         final G gridWidget,
                                         final Predicate<Integer> isEditable,
                                         final Consumer<HasName> clearValueConsumer,
                                         final BiConsumer<HasName, Name> setValueConsumer,
                                         final BiConsumer<HasTypeRef, QName> setTypeRefConsumer,
                                         final TranslationService translationService,
                                         final CellEditorControlsView.Presenter cellEditorControls,
                                         final ValueAndDataTypePopoverView.Presenter editor);  EditableNameAndDataTypeColumn(final List<HeaderMetaData> headerMetaData,
                                         final double width,
                                         final G gridWidget,
                                         final Predicate<Integer> isEditable,
                                         final Consumer<HasName> clearValueConsumer,
                                         final BiConsumer<HasName, Name> setValueConsumer,
                                         final BiConsumer<HasTypeRef, QName> setTypeRefConsumer,
                                         final TranslationService translationService,
                                         final CellEditorControlsView.Presenter cellEditorControls,
                                         final ValueAndDataTypePopoverView.Presenter editor); @Override void edit(final GridCell<InformationItemCell.HasNameCell> cell,
                     final GridBodyCellRenderContext context,
                     final Consumer<GridCellValue<InformationItemCell.HasNameCell>> callback); @Override void setWidth(final double width);  }