com.vaadin.data.ValueProvider Java Examples
The following examples show how to use
com.vaadin.data.ValueProvider.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WebAbstractDataGrid.java From cuba with Apache License 2.0 | 6 votes |
protected ValueProvider getColumnPresentationValueProvider(Column<E> column) { Function presentationProvider = column.getPresentationProvider(); Converter converter = column.getConverter(); Function<?, String> formatter = column.getFormatter(); Renderer renderer = column.getRenderer(); // The following priority is used to determine a value provider: // a presentation provider > a converter > a formatter > a renderer's presentation provider > // a value provider that always returns its input argument > a default presentation provider //noinspection RedundantCast return presentationProvider != null ? (ValueProvider) presentationProvider::apply : converter != null ? new DataGridConverterBasedValueProvider(converter) : formatter != null ? new FormatterBasedValueProvider(formatter) : renderer != null && ((AbstractRenderer) renderer).getPresentationValueProvider() != null ? ((AbstractRenderer) renderer).getPresentationValueProvider() : renderer != null // In case renderer != null and there are no other user specified value providers // We use a value provider that always returns its input argument instead of a default // value provider as we want to keep the original value type. ? ValueProvider.identity() : getDefaultPresentationValueProvider(column); }
Example #2
Source File: WebAbstractDataGrid.java From cuba with Apache License 2.0 | 6 votes |
protected ValueProvider getDefaultPresentationValueProvider(Column<E> column) { MetaProperty metaProperty = column.getPropertyPath() != null ? column.getPropertyPath().getMetaProperty() : null; if (column.getFormatter() != null) { //noinspection unchecked return new FormatterBasedValueProvider<>(column.getFormatter()); } else if (metaProperty != null) { if (Collection.class.isAssignableFrom(metaProperty.getJavaType())) { return new FormatterBasedValueProvider<>(new CollectionFormatter(metadataTools)); } if (column.getType() == Boolean.class) { return new YesNoIconPresentationValueProvider(); } } return new StringPresentationValueProvider(metaProperty, metadataTools); }
Example #3
Source File: WebHtmlRenderer.java From cuba with Apache License 2.0 | 5 votes |
@Override public ValueProvider<String, String> getPresentationValueProvider() { return (ValueProvider<String, String>) html -> getDataGrid().isHtmlSanitizerEnabled() ? htmlSanitizer.sanitize(html) : html; }
Example #4
Source File: WebIconRenderer.java From cuba with Apache License 2.0 | 5 votes |
@Override public ValueProvider<Icons.Icon, Resource> getPresentationValueProvider() { return (ValueProvider<Icons.Icon, Resource>) icon -> { String iconName = icons.get(icon); return iconResolver.getIconResource(iconName); }; }
Example #5
Source File: WebAbstractDataGrid.java From cuba with Apache License 2.0 | 5 votes |
protected ValueProvider<E, Object> createGeneratedColumnValueProvider(String columnId, ColumnGenerator<E, ?> generator) { return (ValueProvider<E, Object>) item -> { ColumnGeneratorEvent<E> event = new ColumnGeneratorEvent<>(WebAbstractDataGrid.this, item, columnId, this::createInstanceContainer); return generator.getValue(event); }; }
Example #6
Source File: WebAbstractDataGrid.java From cuba with Apache License 2.0 | 5 votes |
public ValueProvider<?, V> getPresentationValueProvider() { // Some renderers need specific presentation ValueProvider to be set at the same time // (see com.vaadin.ui.Grid.Column.setRenderer(com.vaadin.data.ValueProvider<V,P>, // com.vaadin.ui.renderers.Renderer<? super P>)). // Default `null` means do not use any presentation ValueProvider return null; }
Example #7
Source File: WebAbstractDataGrid.java From cuba with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") protected void updateRendererInternal() { if (gridColumn != null) { com.vaadin.ui.renderers.Renderer vRenderer = owner.getColumnRendererImplementation(this); ValueProvider vPresentationProvider = owner.getColumnPresentationValueProvider(this); gridColumn.setRenderer(vPresentationProvider, vRenderer); owner.repaint(); } }
Example #8
Source File: WebPickerField.java From cuba with Apache License 2.0 | 5 votes |
protected ValueProvider<V, String> createTextFieldValueProvider() { return new EntityNameValueProvider<V>(metadataTools) { @Override public String apply(V entity) { if (optionCaptionProvider != null) { return optionCaptionProvider.apply(entity); } return super.apply(entity); } }; }
Example #9
Source File: GridCellFilter.java From vaadin-grid-util with MIT License | 5 votes |
private void refreshFilters() { dataProvider.clearFilters(); SerializablePredicate<T> filter = null; for (Entry<String, SerializablePredicate> entry : assignedFilters.entrySet()) { final String columnId = entry.getKey(); ValueProvider<T, ?> provider = null; try { provider = propertySet.getProperty(columnId).get().getGetter(); } catch (Exception e) { try { provider = grid.getColumn(columnId).getValueProvider(); }catch (Exception ex){ e.printStackTrace(); ex.printStackTrace(); throw e; } } SerializablePredicate<T> singleFilter = InMemoryDataProviderHelpers.createValueProviderFilter(provider, entry.getValue()); if (filter == null) { filter = singleFilter; } else { SerializablePredicate<T> tempFilter = filter; filter = (item -> tempFilter.test(item) && singleFilter.test(item)); } } if (filter != null) { dataProvider.setFilter(filter); } }
Example #10
Source File: DemoUI.java From vaadin-grid-util with MIT License | 5 votes |
private void setColumnRenderes(final Grid grid) { grid.getColumn("id") .setRenderer( new EditDeleteButtonValueRenderer<Inhabitants>(edit -> { Notification.show(edit.getItem() .toString() + " want's to get edited", Type.HUMANIZED_MESSAGE); }, delete -> { Notification.show(delete.getItem() .toString() + " want's to get deleted", Type.WARNING_MESSAGE); })) .setWidth(160); grid.getColumn("bodySize") .setRenderer(new IndicatorRenderer(1.8, 1.1)) .setWidth(150); grid.getColumn("birthday") .setRenderer(new DateRenderer(DateFormat.getDateInstance())) .setWidth(210); grid.getColumn("onFacebook") .setRenderer(new BooleanRenderer()) .setWidth(130); /* * the icon of the editButton will get overwritten below by css styling @see DemoUI.initColumnAlignments */ grid.addColumn((ValueProvider<Inhabitants, String>) value -> String.format("%s <i>(%d)</i>", value.getCountry() .getName(), value.getCountry() .getPopulation()), new EditButtonValueRenderer<Inhabitants>(e -> { Notification.show("Goto Link for " + e.getItem() .getCountry() .getName(), Type.HUMANIZED_MESSAGE); })); }
Example #11
Source File: WebComponentRenderer.java From cuba with Apache License 2.0 | 4 votes |
@Override public ValueProvider<Component, com.vaadin.ui.Component> getPresentationValueProvider() { return (ValueProvider<Component, com.vaadin.ui.Component>) value -> value.unwrap(com.vaadin.ui.Component.class); }
Example #12
Source File: CubaTreeGrid.java From cuba with Apache License 2.0 | 4 votes |
@Override protected <V, P> Column<T, V> createColumn(ValueProvider<T, V> valueProvider, ValueProvider<V, P> presentationProvider, AbstractRenderer<? super T, ? super P> renderer) { return new CubaGridColumn<>(valueProvider, presentationProvider, renderer); }
Example #13
Source File: CubaGridColumn.java From cuba with Apache License 2.0 | 4 votes |
public <P> CubaGridColumn(ValueProvider<T, V> valueProvider, ValueProvider<V, P> presentationProvider, Renderer<? super P> renderer) { super(valueProvider, presentationProvider, renderer); }
Example #14
Source File: CubaPickerField.java From cuba with Apache License 2.0 | 4 votes |
public ValueProvider<T, String> getTextFieldValueProvider() { return textFieldValueProvider; }
Example #15
Source File: CubaPickerField.java From cuba with Apache License 2.0 | 4 votes |
public void setTextFieldValueProvider(ValueProvider<T, String> textFieldValueProvider) { this.textFieldValueProvider = textFieldValueProvider; }
Example #16
Source File: CubaGrid.java From cuba with Apache License 2.0 | 4 votes |
@Override protected <V, P> Column<T, V> createColumn(ValueProvider<T, V> valueProvider, ValueProvider<V, P> presentationProvider, AbstractRenderer<? super T, ? super P> renderer) { return new CubaGridColumn<>(valueProvider, presentationProvider, renderer); }