Example usage for com.google.gwt.text.shared Renderer render

List of usage examples for com.google.gwt.text.shared Renderer render

Introduction

In this page you can find the example usage for com.google.gwt.text.shared Renderer render.

Prototype

String render(T object);

Source Link

Document

Renders object as plain text.

Usage

From source file:com.arcbees.chosen.integrationtest.client.domain.CarBrand.java

License:Apache License

public static Set<String> getAllNames(Renderer<CarBrand> renderer) {
    Set<String> brandNames = new HashSet<String>();
    for (CarBrand carBrand : CarBrand.values()) {
        brandNames.add(renderer.render(carBrand));
    }//from   w  w  w.j  a  va  2 s .c  o m

    return brandNames;
}

From source file:com.gafactory.core.client.ui.grids.BaseListGrid.java

License:Open Source License

protected <V> Column<T, String> addRenderedColumn(final ValueProvider<T, V> valueProvider,
        final Renderer<V> renderer, String header, int width, boolean sortable) {
    return addColumn(new TextColumn<T>() {
        @Override/*from  w  ww.  j  a  v a 2 s.  c  om*/
        public String getValue(T object) {
            return object != null ? renderer.render(valueProvider.getValue(object)) : EMPTY_STRING;
        }
    }, header, width, sortable, valueProvider.getPath());
}

From source file:fr.putnami.pwt.core.widget.client.base.AbstractTextOutput.java

License:Open Source License

public void setRenderer(Renderer<T> renderer) {
    this.renderer = renderer;
    if (renderer != null) {
        this.setText(renderer.render(this.getValue()));
    }/*from  w  w w. ja  va  2 s  . co  m*/
}

From source file:org.kaaproject.kaa.server.admin.client.mvp.view.event.EventMapGrid.java

License:Apache License

@Override
protected float constructColumnsImpl(DataGrid<ApplicationEventMapDto> table) {
    float prefWidth = 0;

    prefWidth += constructStringColumn(table, Utils.constants.fqn(),
            new StringValueProvider<ApplicationEventMapDto>() {
                @Override/*w  ww .j  ava  2  s . co m*/
                public String getValue(ApplicationEventMapDto item) {
                    return item.getFqn();
                }
            }, 160);

    final Renderer<ApplicationEventAction> actionRenderer = new Renderer<ApplicationEventAction>() {

        @Override
        public String render(ApplicationEventAction action) {
            return Utils.constants.getString(action.name().toLowerCase());
        }

        @Override
        public void render(ApplicationEventAction action, Appendable appendable) throws IOException {
            appendable.append(render(action));
        }
    };

    if (enableActions) {
        List<ApplicationEventAction> actions = new ArrayList<>();
        for (ApplicationEventAction action : ApplicationEventAction.values()) {
            actions.add(action);
        }

        ValueSelectionCell<ApplicationEventAction> actionsCell = new ValueSelectionCell<>(actions,
                actionRenderer);

        Column<ApplicationEventMapDto, ApplicationEventAction> actionColumn = new Column<ApplicationEventMapDto, ApplicationEventAction>(
                actionsCell) {
            @Override
            public ApplicationEventAction getValue(ApplicationEventMapDto object) {
                return object.getAction();
            }
        };

        Header<SafeHtml> actionHeader = new SafeHtmlHeader(
                SafeHtmlUtils.fromSafeConstant(Utils.constants.action()));

        table.addColumn(actionColumn, actionHeader);
        actionColumn.setFieldUpdater(new FieldUpdater<ApplicationEventMapDto, ApplicationEventAction>() {
            @Override
            public void update(int index, ApplicationEventMapDto object, ApplicationEventAction value) {
                object.setAction(value);
            }
        });
        table.setColumnWidth(actionColumn, 80, Unit.PX);
        prefWidth += 80;
    } else {
        prefWidth += constructStringColumn(table, Utils.constants.action(),
                new StringValueProvider<ApplicationEventMapDto>() {
                    @Override
                    public String getValue(ApplicationEventMapDto item) {
                        return actionRenderer.render(item.getAction());
                    }
                }, 80);
    }

    return prefWidth;
}