Example usage for com.google.gwt.user.cellview.client Column setFieldUpdater

List of usage examples for com.google.gwt.user.cellview.client Column setFieldUpdater

Introduction

In this page you can find the example usage for com.google.gwt.user.cellview.client Column setFieldUpdater.

Prototype

public void setFieldUpdater(FieldUpdater<T, C> fieldUpdater) 

Source Link

Document

Set the FieldUpdater used for updating values in the column.

Usage

From source file:org.kie.workbench.common.forms.dynamic.client.rendering.renderers.lov.creator.input.widget.impl.BooleanEditableColumnGenerator.java

License:Apache License

@Override
protected Column<TableEntry<Boolean>, String> getEditableColumn(UberfirePagedTable<TableEntry<Boolean>> table,
        CellEditionHandler<Boolean> cellEditionHandler) {

    final String yesLiteral = translationService
            .getTranslation(FormRenderingConstants.BooleanEditableColumnGeneratorYes);
    final String noLiteral = translationService
            .getTranslation(FormRenderingConstants.BooleanEditableColumnGeneratorNo);

    final List<String> values = new ArrayList<>();
    values.add(yesLiteral);/*from www .  ja va  2  s  . c o  m*/
    values.add(noLiteral);

    Column<TableEntry<Boolean>, String> column = new Column<TableEntry<Boolean>, String>(
            new SelectionCell(values)) {
        @Override
        public String getValue(TableEntry<Boolean> model) {
            if (model.getValue() == null) {
                model.setValue(Boolean.FALSE);
            }

            if (model.getValue()) {
                return yesLiteral;
            }

            return noLiteral;
        }
    };

    ColumnFieldUpdater<Boolean, String> updater = new ColumnFieldUpdater<Boolean, String>(table, column) {

        @Override
        protected boolean validate(String value, TableEntry<Boolean> model) {
            return true;
        }

        @Override
        protected Boolean convert(String flatValue) {

            if (flatValue.equals(yesLiteral)) {
                return Boolean.TRUE;
            }

            return Boolean.FALSE;
        }
    };

    updater.setCellEditionHandler(cellEditionHandler);

    column.setFieldUpdater(updater);

    return column;
}

From source file:org.kie.workbench.common.forms.dynamic.client.rendering.renderers.lov.creator.input.widget.impl.CharacterEditableColumnGenerator.java

License:Apache License

@Override
protected Column<TableEntry<String>, String> getEditableColumn(UberfirePagedTable<TableEntry<String>> table,
        CellEditionHandler<String> cellEditionHandler) {
    Column<TableEntry<String>, String> column = new Column<TableEntry<String>, String>(new EditTextCell()) {
        @Override/*from  www  . j av a2s . co  m*/
        public String getValue(TableEntry<String> model) {
            if (model.getValue() == null) {
                model.setValue("");
            }
            return model.getValue();
        }
    };

    ColumnFieldUpdater<String, String> updater = new ColumnFieldUpdater<String, String>(table, column) {

        @Override
        protected boolean validate(String value, TableEntry<String> model) {
            if (value != null && !value.isEmpty()) {
                if (value.length() != 1) {
                    cellEditionHandler.showValidationError(translationService.getTranslation(
                            FormRenderingConstants.CharacterEditableColumnGeneratorValidationError));
                    return false;
                }
            }

            return true;
        }

        @Override
        protected String convert(String flatValue) {
            if (flatValue == null || flatValue.isEmpty()) {
                return null;
            }
            return super.convert(flatValue);
        }
    };

    updater.setCellEditionHandler(cellEditionHandler);

    column.setFieldUpdater(updater);

    return column;
}

From source file:org.kie.workbench.common.forms.dynamic.client.rendering.renderers.lov.creator.input.widget.impl.DateEditableColumnGenerator.java

License:Apache License

@Override
protected Column<TableEntry<Date>, Date> getEditableColumn(UberfirePagedTable<TableEntry<Date>> table,
        CellEditionHandler<Date> cellEditionHandler) {

    Column<TableEntry<Date>, Date> column = new Column<TableEntry<Date>, Date>(dateTimePickerCells.get()) {
        @Override//  w  w w.  java  2s  .  c om
        public Date getValue(TableEntry<Date> model) {
            if (model.getValue() == null) {
                model.setValue(new Date());
            }
            return model.getValue();
        }
    };

    ColumnFieldUpdater<Date, Date> updater = new ColumnFieldUpdater<Date, Date>(table, column) {

        @Override
        protected boolean validate(Date value, TableEntry<Date> model) {
            return true;
        }
    };

    updater.setCellEditionHandler(cellEditionHandler);

    column.setFieldUpdater(updater);

    return column;
}

From source file:org.kie.workbench.common.forms.dynamic.client.rendering.renderers.lov.creator.input.widget.impl.numeric.AbstractNumericEditableColumnGenerator.java

License:Apache License

@Override
protected Column<TableEntry<NUMBER>, String> getEditableColumn(UberfirePagedTable<TableEntry<NUMBER>> table,
        CellEditionHandler<NUMBER> cellEditionHandler) {
    Column<TableEntry<NUMBER>, String> column = new Column<TableEntry<NUMBER>, String>(new EditTextCell()) {
        @Override//  w  ww.ja  v a2  s .c  o  m
        public String getValue(TableEntry<NUMBER> model) {
            if (model.getValue() == null) {
                return "";
            }
            return model.getValue().toString();
        }
    };

    ColumnFieldUpdater<NUMBER, String> updater = new ColumnFieldUpdater<NUMBER, String>(table, column) {

        @Override
        protected boolean validate(String flatValue, TableEntry<NUMBER> model) {
            return doValidate(flatValue, model, cellEditionHandler);
        }

        @Override
        protected NUMBER convert(String flatValue) {
            if (flatValue == null || flatValue.isEmpty()) {
                return null;
            }
            return doConvert(flatValue);
        }
    };

    updater.setCellEditionHandler(cellEditionHandler);

    column.setFieldUpdater(updater);

    return column;
}

From source file:org.kie.workbench.common.forms.dynamic.client.rendering.renderers.lov.creator.input.widget.impl.StringEditableColumnGenerator.java

License:Apache License

@Override
protected Column<TableEntry<String>, String> getEditableColumn(UberfirePagedTable<TableEntry<String>> table,
        CellEditionHandler<String> cellEditionHandler) {
    Column<TableEntry<String>, String> column = new Column<TableEntry<String>, String>(new EditTextCell()) {
        @Override//from   w  w  w . j  ava  2 s .c  om
        public String getValue(TableEntry<String> model) {
            if (model.getValue() == null) {
                model.setValue("");
            }
            return model.getValue();
        }
    };

    ColumnFieldUpdater<String, String> updater = new ColumnFieldUpdater<String, String>(table, column) {

        @Override
        protected boolean validate(String value, TableEntry<String> model) {
            return true;
        }
    };

    updater.setCellEditionHandler(cellEditionHandler);

    column.setFieldUpdater(updater);

    return column;
}

From source file:org.kie.workbench.common.forms.dynamic.client.rendering.renderers.lov.creator.input.widget.MultipleInputComponentViewImpl.java

License:Apache License

@Override
public void render() {
    hideErrorMessage();/*from w  w w  .  j  av  a2  s.  co m*/

    DOMUtil.removeAllChildren(table);

    tableWidget = new UberfirePagedTable<>(presenter.getPageSize());
    tableWidget.setHeight(ROW_HEIGHT * (presenter.getPageSize() + 1) + "px");
    tableWidget.setDataProvider(presenter.getProvider());

    tableWidget.setColumnPickerButtonVisible(false);

    if (!presenter.isReadOnly()) {
        Column<TableEntry<TYPE>, Boolean> select = new Column<TableEntry<TYPE>, Boolean>(new CheckboxCell()) {
            @Override
            public Boolean getValue(TableEntry<TYPE> object) {
                return presenter.isSelected(object);
            }
        };

        tableWidget.addColumn(select, "");

        tableWidget.setColumnWidth(select, 35, Style.Unit.PX);

        select.setFieldUpdater((index, tableEntry, value) -> {
            presenter.selectValue(tableEntry);
        });
    }

    EditableColumnGenerator<TYPE> columnGenerator = presenter.getColumnGenerator();

    columnGenerator.registerColumn(tableWidget, new CellEdtionHandlerImpl(), presenter.isReadOnly());

    tableWidget.setEmptyTableCaption(
            translationService.getTranslation(FormRenderingConstants.LOVCreationComponentViewImplNoItems));

    enableRemoveButton(false);
    enablePromoteButton(false);
    enableDegradeButton(false);

    refreshTable();

    DOMUtil.appendWidgetToElement(table, tableWidget);
}

From source file:org.kie.workbench.common.screens.datamodeller.client.pdescriptor.PersistenceUnitPropertyGridViewImpl.java

License:Apache License

private void addPropertyNameColumn() {
    Column<PropertyRow, String> column = new Column<PropertyRow, String>(new EditTextCell()) {
        @Override//from   w  w w.java2s . c om
        public String getValue(PropertyRow propertyRow) {
            if (propertyRow.getName() != null) {
                return propertyRow.getName();
            } else {
                return "";
            }
        }
    };

    column.setFieldUpdater(new PropertyNameFieldUpdater<PropertyRow, String>((EditTextCell) column.getCell()));

    dataGrid.addColumn(column, Constants.INSTANCE.persistence_unit_property_grid_property_name_column());
    dataGrid.setColumnWidth(column, 45, Style.Unit.PCT);
}

From source file:org.kie.workbench.common.screens.datamodeller.client.pdescriptor.PersistenceUnitPropertyGridViewImpl.java

License:Apache License

private void addPropertyValueColumn() {
    final Column<PropertyRow, String> column = new Column<PropertyRow, String>(new EditTextCell()) {

        @Override/*from w  w  w .ja  v a  2 s . c  o m*/
        public String getValue(PropertyRow propertyRow) {
            if (propertyRow.getValue() != null) {
                return propertyRow.getValue();
            } else {
                return "";
            }
        }
    };

    column.setFieldUpdater(new PropertyValueFieldUpdater<PropertyRow, String>((EditTextCell) column.getCell()));

    dataGrid.addColumn(column, Constants.INSTANCE.persistence_unit_property_grid_property_value_column());
    dataGrid.setColumnWidth(column, 45, Style.Unit.PCT);
}

From source file:org.kie.workbench.common.screens.datamodeller.client.pdescriptor.PersistenceUnitPropertyGridViewImpl.java

License:Apache License

private void addRemoveRowColumn() {
    Column<PropertyRow, String> column = new Column<PropertyRow, String>(
            new ButtonCell(IconType.TRASH, ButtonType.DANGER, ButtonSize.SMALL)) {
        @Override//from   w  w w .j  a v a  2 s .  com
        public String getValue(PropertyRow propertyRow) {
            return Constants.INSTANCE.persistence_unit_property_grid_action_delete();
        }
    };

    column.setFieldUpdater(new FieldUpdater<PropertyRow, String>() {
        @Override
        public void update(int index, PropertyRow propertyRow, String value) {

            if (!readOnly) {
                onRemoveProperty(propertyRow);
            }
        }
    });

    dataGrid.addColumn(column, Constants.INSTANCE.persistence_unit_property_grid_property_action_column());
    dataGrid.setColumnWidth(column, 10, Style.Unit.PCT);
}

From source file:org.kie.workbench.common.screens.datamodeller.client.pdescriptor.ProjectClassListViewImpl.java

License:Apache License

private void addRemoveRowColumn() {
    Column<ClassRow, String> column = new Column<ClassRow, String>(
            new ButtonCell(IconType.TRASH, ButtonType.DANGER, ButtonSize.SMALL)) {
        @Override/*from  w  ww  .j  a v  a  2 s.  c om*/
        public String getValue(ClassRow classRow) {
            return Constants.INSTANCE.project_class_list_action_delete();
        }
    };

    column.setFieldUpdater(new FieldUpdater<ClassRow, String>() {
        @Override
        public void update(int index, ClassRow classRow, String value) {
            if (!readOnly) {
                onRemoveClass(classRow);
            }
        }
    });

    dataGrid.addColumn(column, Constants.INSTANCE.project_class_list_action_column());
    dataGrid.setColumnWidth(column, 10, Style.Unit.PCT);
}