/** * 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(); }
@Override public <T, P> GridPropertyListingBuilder render(Property<T> property, Converter<P, T> converter, Renderer<? super P> renderer) { ObjectUtils.argumentNotNull(property, "Property must be not null"); getInstance().getPropertyColumn(property).setConverter(converter); getInstance().getPropertyColumn(property).setRenderer(renderer); return builder(); }
@Override public <V, P> GridItemListingBuilder<T> render(String property, Converter<V, P> converter, Renderer<? super P> renderer) { ObjectUtils.argumentNotNull(property, "Property must be not null"); getInstance().getPropertyColumn(property).setConverter(converter); getInstance().getPropertyColumn(property).setRenderer(renderer); return builder(); }
/** * AJoute un renderer à une colonne * * @param propertyId * @param renderer */ public void setColumnRenderer(String propertyId, Renderer<?> renderer) { Column col = getColumn(propertyId); if (col == null) { return; } col.setRenderer(renderer); }
@Override public HorizontalAlignment getCellAlignment(final String propId) { final Renderer<?> renderer = getRenderer(propId); if (renderer != null) { if (ExcelExport.isNumeric(renderer.getPresentationType())) { return HorizontalAlignment.RIGHT; } } return defaultAlignment; }
protected Renderer<?> getRenderer(final String propId) { // Grid.Column (as of 8.0.3) does not expose its renderer, we have to get it from extensions final Column<T, ?> column = getColumn(propId); if (column != null) { for (Extension each : column.getExtensions()) { if (each instanceof Renderer<?>) { return (Renderer<?>) each; } } } return null; }
@Override public Class<?> getPropertyType(final String propId) { Renderer<?> renderer = getRenderer(propId); if (renderer != null) { return renderer.getPresentationType(); } else { return String.class; } }
/** * Get the renderer to use with given property id. * @param property Property id * @return Optional property renderer */ protected Optional<Renderer<?>> getPropertyRenderer(P property) { Optional<Renderer<?>> propertyRenderer = getPropertyColumn(property).getRenderer(); if (propertyRenderer.isPresent()) { return propertyRenderer; } return getDefaultPropertyRenderer(property); }
@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); }
@Override public <T, P> GridPropertyListingBuilder render(Property<T> property, ValueProvider<T, P> presentationProvider, Renderer<? super P> renderer) { ObjectUtils.argumentNotNull(property, "Property must be not null"); getInstance().getPropertyColumn(property).setPresentationProvider(presentationProvider); getInstance().getPropertyColumn(property).setRenderer(renderer); return builder(); }
@Override public <V, P> GridItemListingBuilder<T> render(String property, ValueProvider<V, P> presentationProvider, Renderer<? super P> renderer) { ObjectUtils.argumentNotNull(property, "Property must be not null"); getInstance().getPropertyColumn(property).setPresentationProvider(presentationProvider); getInstance().getPropertyColumn(property).setRenderer(renderer); return builder(); }
@Override protected Renderer<Number> createImplementation() { if (numberFormat != null) { return new NumberRenderer(numberFormat, getNullRepresentation()); } else { checkNotNullArgument(formatString, "Format string may not be null"); checkNotNullArgument(locale, "Locale may not be null"); return new NumberRenderer(formatString, locale, getNullRepresentation()); } }
@Override protected Renderer createImplementation() { if (listener != null) { return new CubaImageRenderer(createClickListenerWrapper(listener)); } else { return new CubaImageRenderer(); } }
@Override protected Renderer<String> createImplementation() { if (listener != null) { return new CubaClickableTextRenderer(createClickListenerWrapper(listener), getNullRepresentation()); } else { return new CubaClickableTextRenderer(getNullRepresentation()); } }
@Override public <T> GridPropertyListingBuilder render(Property<T> property, Renderer<? super T> renderer) { ObjectUtils.argumentNotNull(property, "Property must be not null"); getInstance().getPropertyColumn(property).setRenderer(renderer); return builder(); }
@Override public GridItemListingBuilder<T> render(String property, Renderer<?> renderer) { ObjectUtils.argumentNotNull(property, "Property must be not null"); getInstance().getPropertyColumn(property).setRenderer(renderer); return builder(); }
/** * {@inheritDoc} */ @Override public Renderer<?> getRenderer() { return renderer; }
/** * {@inheritDoc} */ @Override public void setRenderer(Renderer<?> renderer) { this.renderer = renderer; }
@Override public Optional<Renderer<?>> getRenderer() { return Optional.ofNullable(renderer); }
@Override public void setRenderer(Renderer<?> renderer) { this.renderer = renderer; }
@Override protected Renderer<Boolean> createImplementation() { return new CubaCheckBoxRenderer(); }
@Override protected Renderer<com.vaadin.ui.Component> createImplementation() { return new ComponentRenderer(); }
/** * Gets the {@link Renderer} to use to display column value * @return The {@link Renderer} to use to display column value */ Renderer<?> getRenderer();
/** * Sets the {@link Renderer} to use to display column value * @param renderer The {@link Renderer} to use to display column value */ void setRenderer(Renderer<?> renderer);
/** * Set a custom {@link Renderer} for given item property. * @param property Item property to set the renderer for (not null) * @param renderer Renderer to use * @return this */ GridItemListingBuilder<T> render(String property, Renderer<?> renderer);
/** * Set a custom {@link Renderer} and {@link Converter} for given item property. * @param <V> Property value type * @param <P> Presentation value type * @param property Item property to set the renderer for * @param converter Conveter to use * @param renderer Renderer to use * @return this */ <V, P> GridItemListingBuilder<T> render(String property, Converter<V, P> converter, Renderer<? super P> renderer);
/** * Set a custom {@link Renderer} for given item property. * @param <T> Property type * @param property Item property to set the renderer for (not null) * @param renderer Renderer to use * @return this */ <T> GridPropertyListingBuilder render(Property<T> property, Renderer<? super T> renderer);
/** * Set a custom {@link Renderer} and {@link Converter} for given item property. * @param <T> Property type * @param <P> Presentation value type * @param property Item property to set the renderer for * @param converter Value converter * @param renderer Renderer to use * @return this */ <T, P> GridPropertyListingBuilder render(Property<T> property, Converter<P, T> converter, Renderer<? super P> renderer);
/** * Gets the {@link Renderer} to use to display column value * @return The {@link Renderer} to use to display column value */ Optional<Renderer<?>> getRenderer();
/** * Get the default property {@link Renderer} to use for given property value. * @param property Property id * @return Optional default editor renderer */ protected Optional<Renderer<?>> getDefaultPropertyRenderer(P property) { return Optional.empty(); }
/** * Set a custom {@link Renderer} and presentation provider for given item property. * @param <V> Property value type * @param <P> Presentation value type * @param property Item property to set the renderer for * @param presentationProvider Presentation provider * @param renderer Renderer to use * @return this */ <V, P> GridItemListingBuilder<T> render(String property, ValueProvider<V, P> presentationProvider, Renderer<? super P> renderer);
/** * Set a custom {@link Renderer} and presentation provider for given item property. * @param <T> Property type * @param <P> Presentation value type * @param property Item property to set the renderer for * @param presentationProvider Presentation provider * @param renderer Renderer to use * @return this */ <T, P> GridPropertyListingBuilder render(Property<T> property, ValueProvider<T, P> presentationProvider, Renderer<? super P> renderer);
/** * @param definition * that can be used to configure the renderer if needed. * @return new {@link Renderer} instance that can be used to visualize the * value provided by this {@link BeanGridValueProvider} */ Renderer<?> getRenderer(ColumnDefinition definition);