Java 类com.vaadin.ui.renderers.ImageRenderer 实例源码

项目:holon-vaadin7    文件:DefaultItemListing.java   
/**
 * Get the default {@link Renderer} for given <code>property</code>.
 * @param property Property
 * @return The default {@link Renderer}, if available
 */
protected Optional<Renderer<?>> getDefaultPropertyRenderer(P property) {
    Class<?> type = getPropertyColumnType(property);
    // Images
    if (type != null
            && (ExternalResource.class.isAssignableFrom(type) || ThemeResource.class.isAssignableFrom(type))) {
        return Optional.of(new ImageRenderer());
    }
    if (type != null && FontIcon.class.isAssignableFrom(type)) {
        return Optional.of(new HtmlRenderer(""));
    }
    return Optional.empty();
}
项目:holon-vaadin    文件:DefaultPropertyListing.java   
@Override
protected Optional<Renderer<?>> getDefaultPropertyRenderer(Property property) {
    if (Component.class.isAssignableFrom(property.getType())) {
        return Optional.of(new ComponentRenderer());
    }
    if (FontIcon.class.isAssignableFrom(property.getType())) {
        return Optional.of(new HtmlRenderer(""));
    }
    if (ExternalResource.class.isAssignableFrom(property.getType())
            || ThemeResource.class.isAssignableFrom(property.getType())) {
        return Optional.of(new ImageRenderer());
    }
    return super.getDefaultPropertyRenderer(property);
}
项目:java-pwa    文件:MyUI.java   
@Override
protected void init(VaadinRequest vaadinRequest) {

    BeanItemContainer<Workout> container = new BeanItemContainer<>(
            Workout.class, new WorkoutDataReader().run());

    Grid grid = new Grid();
    grid.setContainerDataSource(container);
    grid.getColumn("sport").setRenderer(new ImageRenderer());
    grid.setSizeFull();

    setContent(grid);
}
项目:tree-grid    文件:DemoUI.java   
@Override
protected void init(VaadinRequest request) {

    final VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setMargin(true);

    final ComboBox combo = new ComboBox(null, Arrays.asList(DEMO_SIMPLE, DEMO_IMAGE));
    combo.setNullSelectionAllowed(false);
    combo.setSizeUndefined();
    layout.addComponent(combo);

    final TreeGrid grid = new TreeGrid();
    grid.setWidth(800, Unit.PIXELS);

    DemoContainer container = new DemoContainer();
    grid.setContainerDataSource(container);

    grid.getColumn(DemoContainer.PROPERTY_ICON).setRenderer(new ImageRenderer());
    grid.getColumn(DemoContainer.PROPERTY_ICON).setEditable(false);

    grid.setSelectionMode(Grid.SelectionMode.SINGLE);
    grid.setColumnReorderingAllowed(true);
    grid.setEditorEnabled(true);

    layout.addComponent(grid);

    combo.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            switch ((String) event.getProperty().getValue()) {
            case DEMO_IMAGE:
                grid.getColumn(DemoContainer.PROPERTY_ICON).setHidden(false);
                grid.setHierarchyColumn(DemoContainer.PROPERTY_ICON);
                grid.setColumnOrder(
                        DemoContainer.PROPERTY_ICON,
                        DemoContainer.PROPERTY_NAME,
                        DemoContainer.PROPERTY_HOURS,
                        DemoContainer.PROPERTY_MODIFIED);
                setTheme("demo2");
                break;
            case DEMO_SIMPLE:
            default:
                grid.getColumn(DemoContainer.PROPERTY_ICON).setHidden(true);
                grid.setHierarchyColumn(DemoContainer.PROPERTY_NAME);
                grid.setColumnOrder(
                        DemoContainer.PROPERTY_NAME,
                        DemoContainer.PROPERTY_HOURS,
                        DemoContainer.PROPERTY_MODIFIED);
                setTheme("demo");
                break;
            }
        }
    });

    combo.select(DEMO_SIMPLE);

    setContent(layout);
}