private ValueEditor<O> addValueEditor(boolean deleteVisible) {
final ValueEditor<O> editor = getFreshValueEditor();
currentEditors.add(editor);
final int rowCount = tableField.getRowCount();
tableField.setWidget(rowCount, 0, editor.asWidget());
final DeleteButton deleteButton = new DeleteButton();
deleteButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
handleDelete(editor);
}
});
tableField.setWidget(rowCount, 1, deleteButton);
final FlexTable.FlexCellFormatter formatter = tableField.getFlexCellFormatter();
formatter.setWidth(rowCount, 0, "100%");
formatter.setVerticalAlignment(rowCount, 0, HasVerticalAlignment.ALIGN_TOP);
formatter.setWidth(rowCount, 1, "30px");
formatter.getElement(rowCount, 1).getStyle().setPaddingLeft(1, Style.Unit.PX);
formatter.setVerticalAlignment(rowCount, 1, HasVerticalAlignment.ALIGN_TOP);
editor.addDirtyChangedHandler(dirtyChangedHandler);
editor.addValueChangeHandler(valueChangeHandler);
deleteButton.setVisible(deleteVisible);
deleteButton.setEnabled(enabled);
if(editor instanceof HasEnabled) {
((HasEnabled) editor).setEnabled(enabled);
}
if(editor instanceof HasPlaceholder) {
((HasPlaceholder) editor).setPlaceholder(placeholder);