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:com.bearsoft.gwt.ui.widgets.grid.GridSection.java

public <C> void redrawAllRowsInColumn(int aIndex, ListDataProvider<T> aDataProvider) {
    if (aIndex >= 0 && aIndex < getColumnCount()) {
        int start = getVisibleRange().getStart();
        Column<T, C> column = (Column<T, C>) getColumn(aIndex);
        Cell<C> cell = column.getCell();
        List<T> data = aDataProvider.getList();
        ProvidesKey<T> keys = getKeyProvider();
        NodeList<TableRowElement> rows = getTableBodyElement().getRows();
        for (int i = 0; i < rows.getLength(); i++) {
            TableRowElement row = rows.getItem(i);
            NodeList<TableCellElement> cells = row.getCells();
            if (aIndex >= 0 && aIndex < cells.getLength()) {
                TableCellElement toRerender = cells.getItem(aIndex);
                if (toRerender != null) {
                    SafeHtmlBuilder sb = new SafeHtmlBuilder();
                    int dataIdx = start + i;
                    if (dataIdx >= 0 && dataIdx < data.size()) {
                        T object = data.get(dataIdx);
                        Cell.Context cx = new Cell.Context(start + i, aIndex, keys.getKey(object));
                        cell.render(cx, column.getValue(object), sb);
                        // Take into account, that cell builder supports
                        // some
                        // maps
                        // to cells' divs
                        // and generates them. So we have to work with first
                        // <div>
                        // in <td>.
                        toRerender.getFirstChildElement().setInnerSafeHtml(sb.toSafeHtml());
                    }/*from   w ww.  j a  va  2 s .  c om*/
                }
            }
        }
    }
}

From source file:org.guvnor.ala.ui.openshift.client.pipeline.template.table.TemplateParamsTableView.java

License:Apache License

private void addParamValueColumn() {
    final Column<TemplateParam, String> column = new Column<TemplateParam, String>(new EditTextCell()) {
        @Override//from  w  w  w . jav a 2 s. c o m
        public String getValue(TemplateParam templateParam) {
            if (templateParam.getValue() != null) {
                return templateParam.getValue();
            } else {
                return EMPTY_STRING;
            }
        }
    };

    column.setFieldUpdater(new ParamValueFieldUpdater((EditTextCell) column.getCell()));

    dataGrid.addColumn(column, translationService.getTranslation(TemplateParamsTableView_ParamValueColumn));
    dataGrid.setColumnWidth(column, 55, Style.Unit.PCT);
}

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// w w w  . j  av  a 2  s .c o m
        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   ww w  .jav  a 2s . 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.projecteditor.client.forms.DependencyGridViewImpl.java

License:Apache License

private void addGroupIdColumn() {
    Column<Dependency, String> column = new Column<Dependency, String>(
            new WaterMarkEditTextCell(ProjectEditorResources.CONSTANTS.EnterAGroupID())) {
        @Override/* w w w.jav  a2 s . c  om*/
        public String getValue(Dependency dependency) {
            if (dependency.getGroupId() != null) {
                return dependency.getGroupId();
            } else {
                return "";
            }
        }
    };

    // BZ-1007894: If field value is not correct, do not update the model and the widget cell value.
    DependencyFieldUpdater fieldUpdater = new DependencyFieldUpdater((WaterMarkEditTextCell) column.getCell());
    fieldUpdater.emptyHandler = new DependencyFieldUpdaterHandler() {
        @Override
        public void handle(Dependency dep, String value) {
            Window.alert(ProjectEditorResources.CONSTANTS.GroupIdMissing());
        }
    };
    fieldUpdater.notValidValueHandler = new DependencyFieldUpdaterHandler() {
        @Override
        public void handle(Dependency dep, String value) {
            Window.alert(ProjectEditorResources.CONSTANTS.XMLMarkIsNotAllowed());
        }
    };
    fieldUpdater.validHandler = new DependencyFieldUpdaterHandler() {
        @Override
        public void handle(Dependency dep, String value) {
            dep.setGroupId(value);
        }
    };

    column.setFieldUpdater(fieldUpdater);

    dataGrid.addColumn(column, ProjectEditorResources.CONSTANTS.GroupID());
}

From source file:org.kie.workbench.common.screens.projecteditor.client.forms.DependencyGridViewImpl.java

License:Apache License

private void addArtifactIdColumn() {
    final Column<Dependency, String> column = new Column<Dependency, String>(
            new WaterMarkEditTextCell(ProjectEditorResources.CONSTANTS.EnterAnArtifactID())) {

        @Override//from  w w w.  j  a  va  2 s.c  o m
        public String getValue(Dependency dependency) {
            if (dependency.getArtifactId() != null) {
                return dependency.getArtifactId();
            } else {
                return "";
            }
        }
    };

    // BZ-1007894: If field value is not correct, do not update the model and the widet cell value.
    DependencyFieldUpdater fieldUpdater = new DependencyFieldUpdater((WaterMarkEditTextCell) column.getCell());
    fieldUpdater.emptyHandler = new DependencyFieldUpdaterHandler() {
        @Override
        public void handle(Dependency dep, String value) {
            Window.alert(ProjectEditorResources.CONSTANTS.ArtifactIdMissing());
        }
    };
    fieldUpdater.notValidValueHandler = new DependencyFieldUpdaterHandler() {
        @Override
        public void handle(Dependency dep, String value) {
            Window.alert(ProjectEditorResources.CONSTANTS.XMLMarkIsNotAllowed());
        }
    };
    fieldUpdater.validHandler = new DependencyFieldUpdaterHandler() {
        @Override
        public void handle(Dependency dep, String value) {
            dep.setArtifactId(value);
        }
    };

    column.setFieldUpdater(fieldUpdater);

    dataGrid.addColumn(column, ProjectEditorResources.CONSTANTS.ArtifactID());
}

From source file:org.kie.workbench.common.screens.projecteditor.client.forms.DependencyGridViewImpl.java

License:Apache License

private void addVersionColumn() {
    Column<Dependency, String> column = new Column<Dependency, String>(
            new WaterMarkEditTextCell(ProjectEditorResources.CONSTANTS.EnterAVersion())) {
        @Override//from   w w w.  j a v a2 s . c om
        public String getValue(Dependency dependency) {
            if (dependency.getVersion() != null) {
                return dependency.getVersion();
            } else {
                return "";
            }
        }
    };

    // BZ-1007894: If field value is not correct, do not update the model and the widget cell value.
    DependencyFieldUpdater fieldUpdater = new DependencyFieldUpdater((WaterMarkEditTextCell) column.getCell());
    fieldUpdater.emptyHandler = new DependencyFieldUpdaterHandler() {
        @Override
        public void handle(Dependency dep, String value) {
            Window.alert(ProjectEditorResources.CONSTANTS.VersionMissing());
        }
    };
    fieldUpdater.notValidValueHandler = new DependencyFieldUpdaterHandler() {
        @Override
        public void handle(Dependency dep, String value) {
            Window.alert(ProjectEditorResources.CONSTANTS.XMLMarkIsNotAllowed());
        }
    };
    fieldUpdater.validHandler = new DependencyFieldUpdaterHandler() {
        @Override
        public void handle(Dependency dep, String value) {
            dep.setVersion(value);
        }
    };

    column.setFieldUpdater(fieldUpdater);

    dataGrid.addColumn(column, ProjectEditorResources.CONSTANTS.Version());
}

From source file:org.mklab.taskit.client.ui.HelpCallListViewImpl.java

License:Apache License

private void listenSelectionEvent() {
    // ??/*from w  w  w.  j a  va  2  s.co  m*/
    final SingleSelectionModel<HelpCallListItem> selectionModel = new SingleSelectionModel<HelpCallListItem>();
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {

        @SuppressWarnings("synthetic-access")
        @Override
        public void onSelectionChange(@SuppressWarnings("unused") SelectionChangeEvent event) {
            final HelpCallListItem selectedCall = selectionModel.getSelectedObject();
            HelpCallListViewImpl.this.presenter.helpCallSelected(selectedCall.getHelpCall());
        }
    });

    // ????????????????
    CellPreviewEvent.Handler<HelpCallListViewImpl.HelpCallListItem> cellPreviewHandler = new DefaultSelectionEventManager<HelpCallListViewImpl.HelpCallListItem>(
            null) {

        @Override
        public void onCellPreview(CellPreviewEvent<HelpCallListItem> event) {
            @SuppressWarnings("unqualified-field-access")
            Column<?, ?> column = table.getColumn(event.getColumn());
            if (column.getCell() instanceof ButtonCell) {
                return;
            }

            super.onCellPreview(event);
        }
    };
    this.table.setSelectionModel(selectionModel, cellPreviewHandler);
    this.table.addCellPreviewHandler(cellPreviewHandler);
}

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

License:Apache License

@SuppressWarnings("unchecked")
private boolean isColumnEditable(Column<R, ?> column, R row) {
    if (column instanceof ConditionalColumn) {
        return ((ConditionalColumn<R>) column).isEditable(row);
    } else {// w  w  w  .ja  va 2 s  .  c om
        return (column.getCell() instanceof AbstractEditableCell);
    }
}

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

License:Apache License

@SuppressWarnings("unchecked")
public void fillDownKeyboardSelectedColumn() {
    int colIndex = dataGrid.getKeyboardSelectedColumn();
    int rowIndex = dataGrid.getKeyboardSelectedRow() + dataGrid.getPageStart();

    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))
                && !(column instanceof SamplesViewImpl.SampleNameColumn)) {
            AbstractEditableCell<R, String> cell = (AbstractEditableCell<R, String>) column.getCell();
            String value = (String) column.getValue(rows.get(rowIndex));
            FieldUpdater<R, String> updater = (FieldUpdater<R, String>) column.getFieldUpdater();

            for (int i = rowIndex + 1; i < rows.size(); i++) {
                if (isColumnEditable(column, rows.get(i))) {
                    updater.update(i, rows.get(i), value);
                    cell.clearViewData(rows.get(i));
                }/*from   w  ww  . ja v  a  2  s .c o m*/
            }
            dataProvider.refresh();
        } else {
            NotificationPopupPanel.warning("Fill-down function is not allowed for this column", true, false);
        }
    }
}