Example usage for com.google.gwt.user.cellview.client ConditionalColumn ConditionalColumn

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

Introduction

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

Prototype

public ConditionalColumn(Cell<String> cell) 

Source Link

Usage

From source file:uk.ac.ebi.fg.annotare2.web.gwt.editor.client.view.experiment.design.ExtractAttributesViewImpl.java

License:Apache License

private void addColumnForPairedLayout(final ExtractAttribute attr) {
    Cell<String> cell = attr.hasOptions() ? new SelectionCell(attr.getOptions()) : new EditTextCell();

    Column<ExtractAttributesRow, String> column = new ConditionalColumn<ExtractAttributesRow>(cell) {
        @Override// w w w  .  jav a 2 s .  co m
        public String getValue(ExtractAttributesRow row) {
            String value = row.getValue(attr);
            return value == null ? "" : attr.hasOptions() ? attr.getOption(value) : value;
        }

        @Override
        public boolean isEditable(ExtractAttributesRow row) {
            return isPairedLayout(row.getValue(LIBRARY_LAYOUT));
        }
    };
    column.setCellStyleNames("app-SelectionCell");
    column.setFieldUpdater(new FieldUpdater<ExtractAttributesRow, String>() {
        @Override
        public void update(int index, ExtractAttributesRow row, String value) {
            row.setValue(attr.hasOptions() ? attr.getValue(value) : value, attr);
            updateRow(row);
        }
    });
    gridView.addPermanentColumn(attr.getTitle(), column, null, 150, Style.Unit.PX);
}