当前位置: 首页>>代码示例>>Java>>正文


Java DataProvider类代码示例

本文整理汇总了Java中com.vaadin.data.provider.DataProvider的典型用法代码示例。如果您正苦于以下问题:Java DataProvider类的具体用法?Java DataProvider怎么用?Java DataProvider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DataProvider类属于com.vaadin.data.provider包,在下文中一共展示了DataProvider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testDataProvider

import com.vaadin.data.provider.DataProvider; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testDataProvider() {
    Person p1 = new Person(1, "John", LocalDate.of(1990, Month.JANUARY, 2));
    Person p2 = new Person(1, "George", LocalDate.of(1991, Month.JUNE, 19));
    Person p3 = new Person(1, "Tim", LocalDate.of(1995, Month.APRIL, 7));

    List<Person> persons = Arrays.asList(p1, p2, p3);
    ListDataProvider<Person> dataProvider = DataProvider.ofCollection(persons);

    FNativeSelect<Person> select = new FNativeSelect<Person>().withCaption("My NativeSelect")
                                                              .withWidth(300, Unit.PIXELS)
                                                              .withDataProvider(dataProvider);

    assertEquals("My NativeSelect", select.getCaption());
    assertFalse(select.isCaptionAsHtml());
    assertEquals(300, select.getWidth(), 0);
    assertEquals(Unit.PIXELS, select.getWidthUnits());
    assertEquals(3, ((ListDataProvider<Person>) select.getDataProvider()).getItems().size());

}
 
开发者ID:viydaag,项目名称:vaadin-fluent-api,代码行数:22,代码来源:FNativeSelectTest.java

示例2: testDataProvider

import com.vaadin.data.provider.DataProvider; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testDataProvider() {
    Person p1 = new Person(1, "John", LocalDate.of(1990, Month.JANUARY, 2));
    Person p2 = new Person(1, "George", LocalDate.of(1991, Month.JUNE, 19));
    Person p3 = new Person(1, "Tim", LocalDate.of(1995, Month.APRIL, 7));

    List<Person> persons = Arrays.asList(p1, p2, p3);
    ListDataProvider<Person> dataProvider = DataProvider.ofCollection(persons);

    FComboBox<Person> combBox = new FComboBox<Person>().withCaption("My ComboBox")
                                                       .withWidth(300, Unit.PIXELS)
                                                       .withDataProvider(
                                                               (item, filterText) -> item.toLowerCase().contains(filterText.toLowerCase()),
                                                               dataProvider);

    assertEquals("My ComboBox", combBox.getCaption());
    assertFalse(combBox.isCaptionAsHtml());
    assertEquals(300, combBox.getWidth(), 0);
    assertEquals(Unit.PIXELS, combBox.getWidthUnits());
    assertEquals(3, ((ListDataProvider<Person>) combBox.getDataProvider()).getItems().size());

}
 
开发者ID:viydaag,项目名称:vaadin-fluent-api,代码行数:24,代码来源:FComboBoxTest.java

示例3: setDataProvider

import com.vaadin.data.provider.DataProvider; //导入依赖的package包/类
@Override
public <C> void setDataProvider(final DataProvider<T, C> dataProvider, final SerializableFunction<String, C> filterConverter) {
    Objects.requireNonNull(dataProvider, "dataProvider cannot be null");
    Objects.requireNonNull(filterConverter, "filterConverter cannot be null");

    final SerializableFunction<String, C> convertOrNull = filterText -> {
        if (filterText == null || filterText.isEmpty()) {
            return null;
        }

        return filterConverter.apply(filterText);
    };

    final SerializableConsumer<C> providerFilterSlot = internalSetDataProvider(dataProvider, convertOrNull.apply(this.currentFilterText));

    this.filterSlot = filter -> providerFilterSlot.accept(convertOrNull.apply(filter));
}
 
开发者ID:bonprix,项目名称:vaadin-combobox-multiselect,代码行数:18,代码来源:ComboBoxMultiselect.java

示例4: internalSetDataProvider

import com.vaadin.data.provider.DataProvider; //导入依赖的package包/类
@Override
protected <F> SerializableConsumer<F> internalSetDataProvider(final DataProvider<T, F> dataProvider, final F initialFilter) {
    final SerializableConsumer<F> consumer = super.internalSetDataProvider(dataProvider, initialFilter);

    if (getDataProvider() instanceof ListDataProvider) {
        final ListDataProvider<T> listDataProvider = ((ListDataProvider<T>) getDataProvider());
        listDataProvider.setSortComparator((o1, o2) -> {
            final boolean selected1 = this.sortingSelection.contains(o1);
            final boolean selected2 = this.sortingSelection.contains(o2);

            if (selected1 && !selected2) {
                return -1;
            }
            if (!selected1 && selected2) {
                return 1;
            }

            return getItemCaptionGenerator().apply(o1)
                    .compareToIgnoreCase(getItemCaptionGenerator().apply(o2));
        });
    }

    return consumer;
}
 
开发者ID:bonprix,项目名称:vaadin-combobox-multiselect,代码行数:25,代码来源:ComboBoxMultiselect.java

示例5: testEnum

import com.vaadin.data.provider.DataProvider; //导入依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testEnum() throws NoSuchFieldException, SecurityException {
	Optional<Component> result = cfr.createComponent(MyEntity.class.getField("myEnum"));
	assertTrue(result.isPresent());
	assertTrue(result.get() instanceof ComboBox);
	ComboBox<MyEnum> c = (ComboBox<MyEnum>)result.get();
	DataProvider<?, ?> dp = c.getDataProvider();
	Query<?, ?> q = new Query<>(0, 2, null, null, null);
	assertEquals(2, dp.size((Query)q));
}
 
开发者ID:ljessendk,项目名称:easybinder,代码行数:12,代码来源:ComponentFactoryRegistryTest.java

示例6: selectable4

import com.vaadin.data.provider.DataProvider; //导入依赖的package包/类
public void selectable4() {
	// tag::selectable4[]
	SingleSelect<TestData> singleSelect = Components.input.singleSelect(TestData.class)
			.items(new TestData(1), new TestData(2)).build(); // <1>

	singleSelect = Components.input.singleSelect(TestData.class)
			.dataSource(ItemDataProvider.create(q -> 2, (q, o, l) -> Stream.of(new TestData(1), new TestData(2))))
			.build(); // <2>

	singleSelect = Components.input.singleSelect(TestData.class)
			.dataSource(DataProvider.ofItems(new TestData(1), new TestData(2))).build(); // <3>
	// end::selectable4[]
}
 
开发者ID:holon-platform,项目名称:holon-vaadin,代码行数:14,代码来源:ExampleSelectable.java

示例7: setDataProvider

import com.vaadin.data.provider.DataProvider; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void setDataProvider(DataProvider<ITEM, ?> dataProvider) {
	if (getInternalField() instanceof HasDataProvider) {
		((HasDataProvider) getInternalField()).setDataProvider(dataProvider);
	} else if (getInternalField() instanceof HasFilterableDataProvider) {
		((HasFilterableDataProvider) getInternalField()).setDataProvider(dataProvider, t -> null);
	}
}
 
开发者ID:holon-platform,项目名称:holon-vaadin,代码行数:10,代码来源:SingleSelectField.java

示例8: setDataProvider

import com.vaadin.data.provider.DataProvider; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void setDataProvider(DataProvider<ITEM, ?> dataProvider) {
	if (getInternalField() instanceof HasDataProvider) {
		((HasDataProvider) getInternalField()).setDataProvider(dataProvider);
	}
}
 
开发者ID:holon-platform,项目名称:holon-vaadin,代码行数:8,代码来源:MultiSelectField.java

示例9: withDataProvider

import com.vaadin.data.provider.DataProvider; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public default THIS withDataProvider(DataProvider<ITEM, ?> dataProvider) {
    ((Tree<ITEM>) this).setDataProvider(dataProvider);
    return (THIS) this;
}
 
开发者ID:viydaag,项目名称:vaadin-fluent-api,代码行数:7,代码来源:FluentTree.java

示例10: setItems

import com.vaadin.data.provider.DataProvider; //导入依赖的package包/类
/**
 * {@inheritDoc}
 * <p>
 * Filtering will use a case insensitive match to show all items where the filter text is a substring of the caption displayed for that item.
 */
@Override
public void setItems(final Collection<T> items) {
    final ListDataProvider<T> listDataProvider = DataProvider.ofCollection(items);

    setDataProvider(listDataProvider);

    // sets the PageLength to 10.
    // if there are less items the 10 in the combobox, PageLength will get the amount of items.
    setPageLength(getDataProvider().size(new Query<>()) >= ComboBoxMultiselect.DEFAULT_PAGE_LENGTH ? ComboBoxMultiselect.DEFAULT_PAGE_LENGTH : getDataProvider().size(new Query<>()));
}
 
开发者ID:bonprix,项目名称:vaadin-combobox-multiselect,代码行数:16,代码来源:ComboBoxMultiselect.java

示例11: setDataProvider

import com.vaadin.data.provider.DataProvider; //导入依赖的package包/类
@Deprecated
public void setDataProvider(DataProvider<Log, ?> dataProvider) {
    if (MongoDataProvider.class.isAssignableFrom(dataProvider.getClass())) {
        super.setDataProvider(dataProvider);
    }
    else throw new IllegalArgumentException("Data provider must be a MongoDataProvider");
}
 
开发者ID:andyphillips404,项目名称:awplab-core,代码行数:8,代码来源:LogViewer.java

示例12: PagedDataProvider

import com.vaadin.data.provider.DataProvider; //导入依赖的package包/类
public PagedDataProvider(DataProvider<T, F> dataProvider, int pageLength) {
	pagingControls = new PagingControls(this, pageLength);
	this.dataProvider = dataProvider;
	this.dataProvider.addDataProviderListener(event -> {
		if (event instanceof DataRefreshEvent) {
			fireEvent(event);
		} else {
			setBackendSize(null);
			refreshAll();
		}
	});
}
 
开发者ID:tsuoanttila,项目名称:GridExtensionPack,代码行数:13,代码来源:PagedDataProvider.java

示例13: initialize

import com.vaadin.data.provider.DataProvider; //导入依赖的package包/类
@Before
public void initialize() {
	Stream<String> stream = IntStream.range(0, 300).boxed().map(i -> "Item " + i);
	dp = DataProvider.fromStream(stream);
	pagedDP = new PagedDataProvider<>(dp);
	controls = pagedDP.getPagingControls();
}
 
开发者ID:tsuoanttila,项目名称:GridExtensionPack,代码行数:8,代码来源:PagedDataProviderTest.java

示例14: getPresentationTypeForField

import com.vaadin.data.provider.DataProvider; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
protected <PRESENTATION> Optional<Class<PRESENTATION>> getPresentationTypeForField(HasValue<PRESENTATION> field) {
	// Unfortunately HasValue in Vaadin does not define a getType() method.

	// Try to find the field type using reflection. This will work for any fields
	// except fields with generic types.
	Type valueType = GenericTypeReflector.getTypeParameter(field.getClass(), HasValue.class.getTypeParameters()[0]);
	if (valueType != null) {
		if (valueType instanceof ParameterizedType) {
			ParameterizedType pType = (ParameterizedType) valueType;
			return Optional.of((Class<PRESENTATION>) pType.getRawType());
		}
		return Optional.of((Class<PRESENTATION>) valueType);
	}

	// Not possible to find using reflection (due to type erasure).
	// If field is an instance of HasGenericType
	if (field instanceof HasGenericType) {
		HasGenericType<PRESENTATION> type = (HasGenericType<PRESENTATION>) field;
		return Optional.of(type.getGenericType());
	}

	// The road to success is paved with dirty hacks....

	// If the field has a non null empty value we can fetch the type from this
	PRESENTATION emptyValue = field.getEmptyValue();
	if (emptyValue != null) {
		return Optional.of((Class<PRESENTATION>) emptyValue.getClass());
	}

	// If the field has a current value we can fetch the type from this
	PRESENTATION currentValue = field.getValue();
	if (currentValue != null) {
		return Optional.of((Class<PRESENTATION>) currentValue.getClass());
	}

	// If the field has items we can fetch the type from the first item
	if (field instanceof HasItems) {
		HasItems<PRESENTATION> hasItems = (HasItems<PRESENTATION>) field;
		DataProvider<?, ?> dp = hasItems.getDataProvider();
		Query<?, ?> q = new Query<>(0, 1, null, null, null);
		if (dp.size((Query) q) > 0) {
			return hasItems.getDataProvider().fetch((Query) q).findFirst().map(e -> e.getClass());
		}
	}

	return Optional.empty();
}
 
开发者ID:ljessendk,项目名称:easybinder,代码行数:49,代码来源:ReflectionBinder.java

示例15: resetDataProvider

import com.vaadin.data.provider.DataProvider; //导入依赖的package包/类
private void resetDataProvider() {
    registrationDataProvider = DataProvider.ofCollection(presenter.getCalledInRegistrations());
    calledInPatientsGrid.setDataProvider(registrationDataProvider);
}
 
开发者ID:mrts,项目名称:vaadin-javaee-clinic-patient-queue-example,代码行数:5,代码来源:InfoscreenViewImpl.java


注:本文中的com.vaadin.data.provider.DataProvider类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。