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

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

Introduction

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

Prototype

@Override
public Cell<C> getCell() 

Source Link

Document

Returns the Cell responsible for rendering items in the column.

Usage

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

License:Apache License

@SuppressWarnings("unchecked")
public boolean importValuesToKeyboardSelectedColumn(List<String> values) {
    int colIndex = dataGrid.getKeyboardSelectedColumn();
    int rowIndex = dataGrid.getKeyboardSelectedRow() + dataGrid.getPageStart();

    if (null != values && !values.isEmpty()) {
        if (colIndex >= 1 && colIndex < dataGrid.getColumnCount() && rowIndex >= 0
                && rowIndex < dataGrid.getRowCount()) {
            Column<R, ?> column = dataGrid.getColumn(colIndex);
            List<R> rows = dataProvider.getList();

            if (isColumnEditable(column, rows.get(rowIndex))) {
                if (column instanceof SamplesViewImpl.SampleNameColumn) {
                    for (int i = 0; i < values.size(); i++) {
                        String value = values.get(i);
                        for (int j = i + 1; j < values.size(); j++) {
                            if (value.equalsIgnoreCase(values.get(j))) {
                                NotificationPopupPanel
                                        .error("Please ensure all sample names are unique, duplicate name '"
                                                + values.get(j) + "'.", true, false);
                                return false;
                            }/*from   ww w.j  a  v  a2s . co  m*/
                        }
                    }
                }

                Cell<String> cell = (Cell<String>) column.getCell();

                FieldUpdater<R, String> updater = (FieldUpdater<R, String>) column.getFieldUpdater();
                for (int i = 0; i < Math.min(rows.size() - rowIndex, values.size()); i++) {
                    int j = i + rowIndex;
                    if (isColumnEditable(column, rows.get(j))) {
                        updater.update(j, rows.get(j), values.get(i));
                        ((AbstractEditableCell) cell).clearViewData(rows.get(j));
                    }
                }
                dataProvider.refresh();
            }
        }
    }
    return true;
}