use of org.kie.workbench.common.dmn.api.definition.model.DMNModelInstrumentedBase in project kie-wb-common by kiegroup.
the class EditableNameAndDataTypeColumn method edit.
@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]));
}
Aggregations