From c0d712cdbea886ea299644144bd6d7445cecec44 Mon Sep 17 00:00:00 2001 From: elmot Date: Thu, 10 Nov 2016 15:30:11 +0200 Subject: [PATCH] Renaming DataSource -> DataProvider to avoid collisions with javax.sql.DataSource Change-Id: I6babcadc72f3f37feff98088eee23b153a080f11 --- .../datamodel/chapter-datamodel.asciidoc | 2 +- ....asciidoc => datamodel-providers.asciidoc} | 54 ++++++++-------- .../main/java/com/vaadin/data/Listing.java | 18 +++--- ...aSource.java => AbstractDataProvider.java} | 13 ++-- ...taSource.java => BackEndDataProvider.java} | 20 +++--- .../vaadin/server/data/DataChangeEvent.java | 14 ++-- .../vaadin/server/data/DataCommunicator.java | 64 +++++++++---------- .../com/vaadin/server/data/DataGenerator.java | 2 +- .../{DataSource.java => DataProvider.java} | 40 ++++++------ ...istener.java => DataProviderListener.java} | 4 +- ...tDataSource.java => ListDataProvider.java} | 36 +++++------ .../java/com/vaadin/ui/AbstractListing.java | 10 +-- .../com/vaadin/ui/AbstractMultiSelect.java | 2 +- .../com/vaadin/ui/AbstractSingleSelect.java | 4 +- .../java/com/vaadin/ui/CheckBoxGroup.java | 26 ++++---- .../src/main/java/com/vaadin/ui/ComboBox.java | 22 +++---- .../main/java/com/vaadin/ui/ListSelect.java | 14 ++-- .../main/java/com/vaadin/ui/NativeSelect.java | 10 +-- .../java/com/vaadin/ui/RadioButtonGroup.java | 26 ++++---- .../java/com/vaadin/ui/TwinColSelect.java | 14 ++-- .../components/grid/SingleSelectionModel.java | 6 +- .../vaadin/ui/declarative/DesignContext.java | 2 +- .../declarative/ShouldWriteDataDelegate.java | 2 +- ...est.java => AbstractDataProviderTest.java} | 20 +++--- .../server/data/DataCommunicatorTest.java | 28 ++++---- .../ListDataProviderTest.java} | 60 ++++++++--------- .../{datasource => provider}/StrBean.java | 4 +- .../bov/DataProviderBoVTest.java} | 28 ++++---- .../{datasource => provider}/bov/Person.java | 2 +- .../bov/PersonService.java | 2 +- .../grid/GridSingleSelectionModelTest.java | 2 +- .../StateGetDoesNotMarkDirtyTest.java | 2 +- .../com/vaadin/ui/AbstractListingTest.java | 38 +++++------ .../vaadin/ui/AbstractMultiSelectTest.java | 6 +- .../vaadin/ui/AbstractSingleSelectTest.java | 2 +- .../com/vaadin/ui/RadioButtonGroupTest.java | 4 +- .../AbstractListingTestUI.java | 2 +- .../AbstractMultiSelectTestUI.java | 2 +- .../checkbox/CheckBoxGroupTestUI.java | 2 +- .../combobox/ComboBoxClickIcon.java | 4 +- .../ComboBoxEmptyItemsKeyboardNavigation.java | 4 +- .../combobox/ComboBoxEnablesComboBox.java | 6 +- .../components/combobox/ComboBoxInPopup.java | 4 +- .../ComboBoxInvalidNullSelection.java | 26 ++++---- .../combobox/ComboBoxLargeIcons.java | 4 +- .../combobox/ComboBoxMousewheel.java | 4 +- .../combobox/ComboBoxNavigation.java | 4 +- .../ComboBoxPopupWhenBodyScrolls.java | 4 +- .../ComboBoxSelectingWithNewItemsAllowed.java | 2 +- .../ComboBoxUndefinedWidthAndIcon.java | 4 +- .../combobox/ComboFocusBlurEvents.java | 4 +- .../combobox/ComboboxMenuBarAutoopen.java | 4 +- .../combobox/ComboboxPrimaryStyleNames.java | 4 +- .../combobox/ComboboxStyleChangeWidth.java | 4 +- .../grid/GridApplyFilterWhenScrolledDown.java | 10 +-- ...taSource.java => RefreshDataProvider.java} | 30 ++++----- .../listselect/ListSelectAddRemoveItems.java | 56 ++++++++-------- .../radiobutton/RadioButtonGroupTestUI.java | 4 +- .../slider/SliderValueFromDataSource.java | 2 +- .../java/com/vaadin/tests/data/DummyData.java | 16 ++--- ...vingComponentsWhileOldParentInvisible.java | 2 +- .../performance/AbstractBeansMemoryTest.java | 4 +- ...mDataSource.java => ItemDataProvider.java} | 8 +-- .../checkboxgroup/CheckBoxGroupTest.java | 4 +- ...Test.java => RefreshDataProviderTest.java} | 4 +- .../components/listselect/ListSelectTest.java | 4 +- .../nativeselect/NativeSelectTest.java | 4 +- .../radiobutton/RadioButtonGroupTest.java | 4 +- .../twincolselect/TwinColSelectTest.java | 6 +- .../com/vaadin/tests/data/DummyDataTest.java | 12 ++-- 70 files changed, 430 insertions(+), 431 deletions(-) rename documentation/datamodel/{datamodel-datasources.asciidoc => datamodel-providers.asciidoc} (93%) rename server/src/main/java/com/vaadin/server/data/{AbstractDataSource.java => AbstractDataProvider.java} (87%) rename server/src/main/java/com/vaadin/server/data/{BackEndDataSource.java => BackEndDataProvider.java} (77%) rename server/src/main/java/com/vaadin/server/data/{DataSource.java => DataProvider.java} (64%) rename server/src/main/java/com/vaadin/server/data/{DataSourceListener.java => DataProviderListener.java} (93%) rename server/src/main/java/com/vaadin/server/data/{ListDataSource.java => ListDataProvider.java} (67%) rename server/src/test/java/com/vaadin/server/data/{AbstractDataSourceTest.java => AbstractDataProviderTest.java} (73%) rename server/src/test/java/com/vaadin/server/data/{datasource/ListDataSourceTest.java => provider/ListDataProviderTest.java} (77%) rename server/src/test/java/com/vaadin/server/data/{datasource => provider}/StrBean.java (96%) rename server/src/test/java/com/vaadin/server/data/{datasource/bov/DataSourceBoVTest.java => provider/bov/DataProviderBoVTest.java} (86%) rename server/src/test/java/com/vaadin/server/data/{datasource => provider}/bov/Person.java (95%) rename server/src/test/java/com/vaadin/server/data/{datasource => provider}/bov/PersonService.java (96%) rename uitest/src/main/java/com/vaadin/tests/components/grid/basics/{RefreshDataSource.java => RefreshDataProvider.java} (70%) rename uitest/src/main/java/com/vaadin/tests/util/{ItemDataSource.java => ItemDataProvider.java} (57%) rename uitest/src/test/java/com/vaadin/tests/components/grid/basics/{RefreshDataSourceTest.java => RefreshDataProviderTest.java} (96%) diff --git a/documentation/datamodel/chapter-datamodel.asciidoc b/documentation/datamodel/chapter-datamodel.asciidoc index 5fa29a6957..6e9cf214d5 100644 --- a/documentation/datamodel/chapter-datamodel.asciidoc +++ b/documentation/datamodel/chapter-datamodel.asciidoc @@ -14,7 +14,7 @@ include::datamodel-fields.asciidoc[leveloffset=+2] include::datamodel-forms.asciidoc[leveloffset=+2] -include::datamodel-datasources.asciidoc[leveloffset=+2] +include::datamodel-providers.asciidoc[leveloffset=+2] include::datamodel-selection.asciidoc[leveloffset=+2] (((range="endofrange", startref="term.datamodel"))) diff --git a/documentation/datamodel/datamodel-datasources.asciidoc b/documentation/datamodel/datamodel-providers.asciidoc similarity index 93% rename from documentation/datamodel/datamodel-datasources.asciidoc rename to documentation/datamodel/datamodel-providers.asciidoc index f8cf2fe6b9..852c1f0c66 100644 --- a/documentation/datamodel/datamodel-datasources.asciidoc +++ b/documentation/datamodel/datamodel-providers.asciidoc @@ -4,7 +4,7 @@ order: 4 layout: page --- -[[datamodel.datasources]] +[[datamodel.dataproviders]] = Showing Many Items in a Listing A common pattern in applications is that the user is first presented with a list of items, from which she selects one or several items to continue working with. @@ -77,24 +77,24 @@ comboBox.setFilter((filterText, item) -> item.getCaption().equalsIgnoreCase(filterText)); ---- -Instead of directly assigning the item collection as the items that a component should be using, we can instead create a [classname]#ListDataSource# that contains the items. +Instead of directly assigning the item collection as the items that a component should be using, we can instead create a [classname]#ListDataProvider# that contains the items. The list data source can be shared between different components in the same [classname]#VaadinSession# since it is stateless. We can also apply different sorting options for each component, without affecting how data is shown in the other components. [source, java] ---- -ListDataSource dataSource = - new ListDataSource<>(persons); +ListDataProvider dataProvider = + new ListDataProvider<>(persons); ComboBox comboBox = new ComboBox<>(); // The combo box shows the person sorted by name -comboBox.setDataSource( - dataSource.sortedBy(Person::getName)); +comboBox.setDataProvider( + dataProvider.sortedBy(Person::getName)); Grid grid = new Grid<>(); // The grid shows the same persons sorted by year of birth -grid.setDataSource( - dataSource.sortedBy(Person::getYearOfBirth)); +grid.setDataProvider( + dataProvider.sortedBy(Person::getYearOfBirth)); ---- The [classname]#Listing# component cannot automatically know about changes to the list of items or to any individual item. @@ -102,8 +102,8 @@ We must notify the data source when items are changed, added or removed so that [source, java] ---- -ListDataSource dataSource = - new ListDataSource<>(persons); +ListDataProvider dataProvider = + new ListDataProvider<>(persons); Button addPersonButton = new Button("Add person", clickEvent -> { @@ -112,7 +112,7 @@ Button addPersonButton = new Button("Add person", persons.add(new Person("James Monroe", 1758)); - dataSource.notifyAdd(addIndex); + dataProvider.notifyAdd(addIndex); }); Button modifyPersonButton = new Button("Modify person", @@ -121,7 +121,7 @@ Button modifyPersonButton = new Button("Modify person", personToChange.setName("Changed person"); - dataSource.refresh(0); + dataProvider.refresh(0); }); ---- @@ -152,7 +152,7 @@ Information about which items to fetch as well as some additional details are ma [source, java] ---- -DataSource dataSource = new BackendDataSource<>( +DataProvider dataProvider = new BackendDataProvider<>( // First callback fetches items based on a query query -> { // The index of the first item to load @@ -170,7 +170,7 @@ DataSource dataSource = new BackendDataSource<>( ); Grid grid = new Grid<>(); -grid.setDataSource(dataSource); +grid.setDataProvider(dataProvider); // Columns are configured in the same way as before ... @@ -208,7 +208,7 @@ The sorting options set through the component will be available through [interfa [source, java] ---- -DataSource dataSource = new BackEndDataSource<>( +DataProvider dataProvider = new BackEndDataProvider<>( query -> { List sortOrders = new ArrayList<>(); for(SortOrder queryOrder : query.getSortOrders()) { @@ -238,7 +238,7 @@ When a data source that does lazy loading is used, [classname]#Grid# and other s ---- Grid grid = new Grid<>(); -grid.setDataSource(dataSource); +grid.setDataProvider(dataProvider); // Will be sortable by the user // When sorting by this column, the query will have a SortOrder @@ -329,7 +329,7 @@ We can create a helper method for handling the filter since the same logic is ne [source, java] ---- -DataSource dataSource = new BackEndDataSource<>( +DataProvider dataProvider = new BackEndDataProvider<>( query -> { BackendFilter filter = query.getFilter(); @@ -361,20 +361,20 @@ public static String filterToNamePrefix(BackendFilter filter) { ---- [TIP] -If the amount of data in the backend is small enough, it might be better to load all the items into a list and use a [classname]#ListDataSource# instead of implementing filtering or sorting support in a custom [classname]#DataSource# class and configuring the components accordingly. +If the amount of data in the backend is small enough, it might be better to load all the items into a list and use a [classname]#ListDataProvider# instead of implementing filtering or sorting support in a custom [classname]#DataProvider# class and configuring the components accordingly. -We can also create a base data source and then use different variations for different components, similarly to the previous examples with [classname]#ListDataSource#. +We can also create a base data source and then use different variations for different components, similarly to the previous examples with [classname]#ListDataProvider#. [source, java] ---- -DataSource dataSource = ... +DataProvider dataProvider = ... -grid.setDataSource(dataSource +grid.setDataProvider(dataProvider .filteredBy(new Like("name", "Ge%")) .sortedBy(new SortOrder( "yearOfBirth", SortDirection.ASCENDING))); -comboBox.setDataSource(dataSource +comboBox.setDataProvider(dataProvider .sortedBy(new SortOrder( "name", SortOrder.DESCENDING))); @@ -382,7 +382,7 @@ comboBox.setDataSource(dataSource === Special Fetching Cases -In some cases it might be necessary directly extend [classname]#BackendDataSource# instead of constructing an instance based the two simple callback methods shown above. +In some cases it might be necessary directly extend [classname]#BackendDataProvider# instead of constructing an instance based the two simple callback methods shown above. One such case is if the backend loads items based on a page index and a page size so that the start index in the query always needs to be a multiple of the page size. As an example, our service interface made for paging could look like this. @@ -401,8 +401,8 @@ Components using this data source will take the information into account when qu [source, java] ---- -public class PersonDataSource - extends BackendDataSource { +public class PersonDataProvider + extends BackendDataProvider { @Override public boolean alignQueries() { @@ -435,8 +435,8 @@ While our data source implementation could deal with that limitation internally [source, java] ---- -public class PersonDataSource - extends BackendDataSource { +public class PersonDataProvider + extends BackendDataProvider { @Override public int getMaxLimit() { diff --git a/server/src/main/java/com/vaadin/data/Listing.java b/server/src/main/java/com/vaadin/data/Listing.java index 422b3a1128..ec48be8875 100644 --- a/server/src/main/java/com/vaadin/data/Listing.java +++ b/server/src/main/java/com/vaadin/data/Listing.java @@ -18,7 +18,7 @@ package com.vaadin.data; import java.io.Serializable; import java.util.Collection; -import com.vaadin.server.data.DataSource; +import com.vaadin.server.data.DataProvider; /** * A generic interface for components that show a list of data. @@ -34,18 +34,18 @@ public interface Listing extends Serializable { /** * Returns the source of data items used by this listing. * - * @return the data source, not null + * @return the data provider, not null */ - DataSource getDataSource(); + DataProvider getDataProvider(); /** - * Sets the source of data items used by this listing. The data source is + * Sets the source of data items used by this listing. The data provider is * queried for displayed items as needed. * - * @param dataSource - * the data source, not null + * @param dataProvider + * the data provider, not null */ - void setDataSource(DataSource dataSource); + void setDataProvider(DataProvider dataProvider); /** * Sets the collection of data items of this listing. @@ -55,7 +55,7 @@ public interface Listing extends Serializable { * */ default void setItems(Collection items) { - setDataSource(DataSource.create(items)); + setDataProvider(DataProvider.create(items)); } /** @@ -65,7 +65,7 @@ public interface Listing extends Serializable { * the data items to display */ default void setItems(@SuppressWarnings("unchecked") T... items) { - setDataSource(DataSource.create(items)); + setDataProvider(DataProvider.create(items)); } } diff --git a/server/src/main/java/com/vaadin/server/data/AbstractDataSource.java b/server/src/main/java/com/vaadin/server/data/AbstractDataProvider.java similarity index 87% rename from server/src/main/java/com/vaadin/server/data/AbstractDataSource.java rename to server/src/main/java/com/vaadin/server/data/AbstractDataProvider.java index f54056e1b0..531d77e44c 100644 --- a/server/src/main/java/com/vaadin/server/data/AbstractDataSource.java +++ b/server/src/main/java/com/vaadin/server/data/AbstractDataProvider.java @@ -17,27 +17,26 @@ package com.vaadin.server.data; import java.lang.reflect.Method; import java.util.EventObject; -import java.util.Objects; import com.vaadin.event.EventRouter; import com.vaadin.shared.Registration; /** - * Abstract data source implementation which takes care of refreshing data from + * Abstract data provider implementation which takes care of refreshing data from * the underlying data provider. * * @author Vaadin Ltd * @since 8.0 * */ -public abstract class AbstractDataSource implements DataSource { +public abstract class AbstractDataProvider implements DataProvider { private EventRouter eventRouter; @Override - public Registration addDataSourceListener(DataSourceListener listener) { + public Registration addDataProviderListener(DataProviderListener listener) { addListener(DataChangeEvent.class, listener, - DataSourceListener.class.getMethods()[0]); + DataProviderListener.class.getMethods()[0]); return () -> removeListener(DataChangeEvent.class, listener); } @@ -61,7 +60,7 @@ public abstract class AbstractDataSource implements DataSource { * the activation method. * */ - protected void addListener(Class eventType, DataSourceListener listener, + protected void addListener(Class eventType, DataProviderListener listener, Method method) { if (eventRouter == null) { eventRouter = new EventRouter(); @@ -83,7 +82,7 @@ public abstract class AbstractDataSource implements DataSource { * type eventType with one or more methods. */ protected void removeListener(Class eventType, - DataSourceListener listener) { + DataProviderListener listener) { if (eventRouter != null) { eventRouter.removeListener(eventType, listener); } diff --git a/server/src/main/java/com/vaadin/server/data/BackEndDataSource.java b/server/src/main/java/com/vaadin/server/data/BackEndDataProvider.java similarity index 77% rename from server/src/main/java/com/vaadin/server/data/BackEndDataSource.java rename to server/src/main/java/com/vaadin/server/data/BackEndDataProvider.java index 3ca31de15a..89a780248f 100644 --- a/server/src/main/java/com/vaadin/server/data/BackEndDataSource.java +++ b/server/src/main/java/com/vaadin/server/data/BackEndDataProvider.java @@ -23,18 +23,18 @@ import java.util.stream.Stream; import com.vaadin.server.SerializableFunction; /** - * A {@link DataSource} for any back end. + * A {@link DataProvider} for any back end. * * @param - * data source data type + * data provider data type */ -public class BackEndDataSource extends AbstractDataSource { +public class BackEndDataProvider extends AbstractDataProvider { private final SerializableFunction> request; private final SerializableFunction sizeCallback; /** - * Constructs a new DataSource to request data from an arbitrary back end + * Constructs a new DataProvider to request data from an arbitrary back end * request function. * * @param request @@ -42,8 +42,8 @@ public class BackEndDataSource extends AbstractDataSource { * @param sizeCallback * function that return the amount of data in back end for query */ - public BackEndDataSource(SerializableFunction> request, - SerializableFunction sizeCallback) { + public BackEndDataProvider(SerializableFunction> request, + SerializableFunction sizeCallback) { Objects.requireNonNull(request, "Request function can't be null"); Objects.requireNonNull(sizeCallback, "Size callback can't be null"); this.request = request; @@ -61,15 +61,15 @@ public class BackEndDataSource extends AbstractDataSource { } /** - * Sets a default sorting order to the data source. + * Sets a default sorting order to the data provider. * * @param sortOrders * a list of sorting information containing field ids and * directions - * @return new data source with modified sorting + * @return new data provider with modified sorting */ - public BackEndDataSource sortingBy(List> sortOrders) { - return new BackEndDataSource<>(query -> { + public BackEndDataProvider sortingBy(List> sortOrders) { + return new BackEndDataProvider<>(query -> { List> queryOrder = new ArrayList<>( query.getSortOrders()); queryOrder.addAll(sortOrders); diff --git a/server/src/main/java/com/vaadin/server/data/DataChangeEvent.java b/server/src/main/java/com/vaadin/server/data/DataChangeEvent.java index cf2e9621de..94d28fc9d3 100644 --- a/server/src/main/java/com/vaadin/server/data/DataChangeEvent.java +++ b/server/src/main/java/com/vaadin/server/data/DataChangeEvent.java @@ -18,10 +18,10 @@ package com.vaadin.server.data; import java.util.EventObject; /** - * An event fired when the data of a {@code DataSource} changes. + * An event fired when the data of a {@code DataProvider} changes. * * - * @see DataSourceListener + * @see DataProviderListener * * @author Vaadin Ltd * @since 8.0 @@ -31,18 +31,18 @@ public class DataChangeEvent extends EventObject { /** * Creates a new {@code DataChangeEvent} event originating from the given - * data source. + * data provider. * * @param source - * the data source, not null + * the data provider, not null */ - public DataChangeEvent(DataSource source) { + public DataChangeEvent(DataProvider source) { super(source); } @Override - public DataSource getSource() { - return (DataSource) super.getSource(); + public DataProvider getSource() { + return (DataProvider) super.getSource(); } } diff --git a/server/src/main/java/com/vaadin/server/data/DataCommunicator.java b/server/src/main/java/com/vaadin/server/data/DataCommunicator.java index 24bb464722..46b8fa079a 100644 --- a/server/src/main/java/com/vaadin/server/data/DataCommunicator.java +++ b/server/src/main/java/com/vaadin/server/data/DataCommunicator.java @@ -52,7 +52,7 @@ import elemental.json.JsonObject; */ public class DataCommunicator extends AbstractExtension { - private Registration dataSourceUpdateRegistration; + private Registration dataProviderUpdateRegistration; /** * Simple implementation of collection data provider communication. All data @@ -180,7 +180,7 @@ public class DataCommunicator extends AbstractExtension { private final Collection> generators = new LinkedHashSet<>(); private final ActiveDataHandler handler = new ActiveDataHandler(); - private DataSource dataSource = DataSource.create(); + private DataProvider dataProvider = DataProvider.create(); private final DataKeyMapper keyMapper; private boolean reset = false; @@ -202,13 +202,13 @@ public class DataCommunicator extends AbstractExtension { @Override public void attach() { super.attach(); - attachDataSourceListener(); + attachDataProviderListener(); } @Override public void detach() { super.detach(); - detachDataSourceListener(); + detachDataProviderListener(); } /** @@ -219,7 +219,7 @@ public class DataCommunicator extends AbstractExtension { public void beforeClientResponse(boolean initial) { super.beforeClientResponse(initial); - if (getDataSource() == null) { + if (getDataProvider() == null) { return; } @@ -227,14 +227,14 @@ public class DataCommunicator extends AbstractExtension { Set filters = Collections.emptySet(); if (initial || reset) { - int dataSourceSize; - if (getDataSource().isInMemory() && inMemoryFilter != null) { - dataSourceSize = (int) getDataSource().fetch(new Query()) + int dataProviderSize; + if (getDataProvider().isInMemory() && inMemoryFilter != null) { + dataProviderSize = (int) getDataProvider().fetch(new Query()) .filter(inMemoryFilter).count(); } else { - dataSourceSize = getDataSource().size(new Query(filters)); + dataProviderSize = getDataProvider().size(new Query(filters)); } - rpc.reset(dataSourceSize); + rpc.reset(dataProviderSize); } if (!pushRows.isEmpty()) { @@ -243,9 +243,9 @@ public class DataCommunicator extends AbstractExtension { Stream rowsToPush; - if (getDataSource().isInMemory()) { + if (getDataProvider().isInMemory()) { // We can safely request all the data when in memory - rowsToPush = getDataSource().fetch(new Query()); + rowsToPush = getDataProvider().fetch(new Query()); if (inMemoryFilter != null) { rowsToPush = rowsToPush.filter(inMemoryFilter); } @@ -255,7 +255,7 @@ public class DataCommunicator extends AbstractExtension { rowsToPush = rowsToPush.skip(offset).limit(limit); } else { Query query = new Query(offset, limit, backEndSorting, filters); - rowsToPush = getDataSource().fetch(query); + rowsToPush = getDataProvider().fetch(query); } pushData(offset, rowsToPush); } @@ -458,39 +458,39 @@ public class DataCommunicator extends AbstractExtension { } /** - * Gets the current data source from this DataCommunicator. + * Gets the current data provider from this DataCommunicator. * - * @return the data source + * @return the data provider */ - public DataSource getDataSource() { - return dataSource; + public DataProvider getDataProvider() { + return dataProvider; } /** - * Sets the current data source for this DataCommunicator. + * Sets the current data provider for this DataCommunicator. * - * @param dataSource - * the data source to set, not null + * @param dataProvider + * the data provider to set, not null */ - public void setDataSource(DataSource dataSource) { - Objects.requireNonNull(dataSource, "data source cannot be null"); - this.dataSource = dataSource; - detachDataSourceListener(); + public void setDataProvider(DataProvider dataProvider) { + Objects.requireNonNull(dataProvider, "data provider cannot be null"); + this.dataProvider = dataProvider; + detachDataProviderListener(); if (isAttached()) { - attachDataSourceListener(); + attachDataProviderListener(); } reset(); } - private void attachDataSourceListener() { - dataSourceUpdateRegistration = getDataSource() - .addDataSourceListener(event -> reset()); + private void attachDataProviderListener() { + dataProviderUpdateRegistration = getDataProvider() + .addDataProviderListener(event -> reset()); } - private void detachDataSourceListener() { - if (dataSourceUpdateRegistration != null) { - dataSourceUpdateRegistration.remove(); - dataSourceUpdateRegistration = null; + private void detachDataProviderListener() { + if (dataProviderUpdateRegistration != null) { + dataProviderUpdateRegistration.remove(); + dataProviderUpdateRegistration = null; } } } diff --git a/server/src/main/java/com/vaadin/server/data/DataGenerator.java b/server/src/main/java/com/vaadin/server/data/DataGenerator.java index ff4c82888c..f062e9b80a 100644 --- a/server/src/main/java/com/vaadin/server/data/DataGenerator.java +++ b/server/src/main/java/com/vaadin/server/data/DataGenerator.java @@ -35,7 +35,7 @@ public interface DataGenerator extends Serializable { /** * Adds custom data for the given item to its serialized {@code JsonObject} - * representation. This JSON object will be sent to client-side DataSource. + * representation. This JSON object will be sent to client-side DataProvider. * * @param item * the data item being serialized diff --git a/server/src/main/java/com/vaadin/server/data/DataSource.java b/server/src/main/java/com/vaadin/server/data/DataProvider.java similarity index 64% rename from server/src/main/java/com/vaadin/server/data/DataSource.java rename to server/src/main/java/com/vaadin/server/data/DataProvider.java index c4042ecc11..b99cbe5d75 100644 --- a/server/src/main/java/com/vaadin/server/data/DataSource.java +++ b/server/src/main/java/com/vaadin/server/data/DataProvider.java @@ -23,7 +23,7 @@ import java.util.stream.Stream; import com.vaadin.shared.Registration; /** - * Minimal DataSource API for communication between the DataProvider and a back + * Minimal DataProvider API for communication between the DataProvider and a back * end service. * * @author Vaadin Ltd. @@ -31,15 +31,15 @@ import com.vaadin.shared.Registration; * @param * data type * - * @see ListDataSource - * @see BackEndDataSource + * @see ListDataProvider + * @see BackEndDataProvider * * @since 8.0 */ -public interface DataSource extends Serializable { +public interface DataProvider extends Serializable { /** - * Gets whether the DataSource content all available in memory or does it + * Gets whether the DataProvider content all available in memory or does it * use some external backend. * * @return {@code true} if all data is in memory; {@code false} if not @@ -47,16 +47,16 @@ public interface DataSource extends Serializable { boolean isInMemory(); /** - * Gets the amount of data in this DataSource. + * Gets the amount of data in this DataProvider. * * @param t * query with sorting and filtering - * @return the size of the data source + * @return the size of the data provider */ int size(Query t); /** - * Fetches data from this DataSource using given {@code query}. + * Fetches data from this DataProvider using given {@code query}. * * @param query * given query to request data @@ -72,7 +72,7 @@ public interface DataSource extends Serializable { void refreshAll(); /** - * Adds a data source listener. The listener is called when some piece of + * Adds a data provider listener. The listener is called when some piece of * data is updated. *

* The {@link #refreshAll()} method fires {@link DataChangeEvent} each time @@ -84,36 +84,36 @@ public interface DataSource extends Serializable { * the data change listener, not null * @return a registration for the listener */ - Registration addDataSourceListener(DataSourceListener listener); + Registration addDataProviderListener(DataProviderListener listener); /** - * This method creates a new {@link ListDataSource} from a given Collection. - * The ListDataSource creates a protective List copy of all the contents in + * This method creates a new {@link ListDataProvider} from a given Collection. + * The ListDataProvider creates a protective List copy of all the contents in * the Collection. * * @param * the data item type * @param items * the collection of data, not null - * @return a new list data source + * @return a new list data provider */ - public static ListDataSource create(Collection items) { - return new ListDataSource<>(items); + public static ListDataProvider create(Collection items) { + return new ListDataProvider<>(items); } /** - * This method creates a new {@link ListDataSource} from given objects.The - * ListDataSource creates a protective List copy of all the contents in the + * This method creates a new {@link ListDataProvider} from given objects.The + * ListDataProvider creates a protective List copy of all the contents in the * array. * * @param * the data item type * @param items * the data items - * @return a new list data source + * @return a new list data provider */ @SafeVarargs - public static ListDataSource create(T... items) { - return new ListDataSource<>(Arrays.asList(items)); + public static ListDataProvider create(T... items) { + return new ListDataProvider<>(Arrays.asList(items)); } } diff --git a/server/src/main/java/com/vaadin/server/data/DataSourceListener.java b/server/src/main/java/com/vaadin/server/data/DataProviderListener.java similarity index 93% rename from server/src/main/java/com/vaadin/server/data/DataSourceListener.java rename to server/src/main/java/com/vaadin/server/data/DataProviderListener.java index c9c486cfd1..54ec2d1877 100644 --- a/server/src/main/java/com/vaadin/server/data/DataSourceListener.java +++ b/server/src/main/java/com/vaadin/server/data/DataProviderListener.java @@ -19,12 +19,12 @@ import java.io.Serializable; /** * Interface for listening for a data change events fired by a - * {@link DataSource}. + * {@link DataProvider}. * * @author Vaadin Ltd * @since 8.0 */ -public interface DataSourceListener extends Serializable { +public interface DataProviderListener extends Serializable { /** * Invoked when this listener receives a data change event from a data diff --git a/server/src/main/java/com/vaadin/server/data/ListDataSource.java b/server/src/main/java/com/vaadin/server/data/ListDataProvider.java similarity index 67% rename from server/src/main/java/com/vaadin/server/data/ListDataSource.java rename to server/src/main/java/com/vaadin/server/data/ListDataProvider.java index 1e2724dc5b..14527749a5 100644 --- a/server/src/main/java/com/vaadin/server/data/ListDataSource.java +++ b/server/src/main/java/com/vaadin/server/data/ListDataProvider.java @@ -22,42 +22,42 @@ import java.util.function.Function; import java.util.stream.Stream; /** - * {@link DataSource} wrapper for {@link Collection}s. This class does not + * {@link DataProvider} wrapper for {@link Collection}s. This class does not * actually handle the {@link Query} parameters. * * @param * data type */ -public class ListDataSource extends AbstractDataSource { +public class ListDataProvider extends AbstractDataProvider { private Comparator sortOrder; private final Collection backend; /** - * Constructs a new ListDataSource. This method makes a protective copy of + * Constructs a new ListDataProvider. This method makes a protective copy of * the contents of the Collection. * * @param items * the initial data, not null */ - public ListDataSource(Collection items) { + public ListDataProvider(Collection items) { Objects.requireNonNull(items, "items cannot be null"); backend = items; sortOrder = null; } /** - * Chaining constructor for making modified {@link ListDataSource}s. This + * Chaining constructor for making modified {@link ListDataProvider}s. This * Constructor is used internally for making sorted and filtered variants of - * a base data source with actual data. + * a base data provider with actual data. * * @param items - * the backend data from the original list data source + * the backend data from the original list data provider * @param sortOrder * a {@link Comparator} providing the needed sorting order * */ - protected ListDataSource(Collection items, Comparator sortOrder) { + protected ListDataProvider(Collection items, Comparator sortOrder) { this(items); this.sortOrder = sortOrder; } @@ -72,24 +72,24 @@ public class ListDataSource extends AbstractDataSource { } /** - * Creates a new list data source based on this list data source with the + * Creates a new list data provider based on this list data provider with the * given sort order. *

- * NOTE: this data source is not modified in any way. + * NOTE: this data provider is not modified in any way. * * @param sortOrder * a {@link Comparator} providing the needed sorting order - * @return new data source with modified sorting + * @return new data provider with modified sorting */ - public ListDataSource sortingBy(Comparator sortOrder) { - return new ListDataSource<>(backend, sortOrder); + public ListDataProvider sortingBy(Comparator sortOrder) { + return new ListDataProvider<>(backend, sortOrder); } /** - * Creates a new list data source based on this list data source with the + * Creates a new list data provider based on this list data provider with the * given sort order. *

- * NOTE: this data source is not modified in any way. + * NOTE: this data provider is not modified in any way. *

* This method is a short-hand for * {@code sortingBy(Comparator.comparing(sortOrder))}. @@ -98,9 +98,9 @@ public class ListDataSource extends AbstractDataSource { * function to sort by * @param * the type of the Comparable sort key - * @return new data source with modified sorting + * @return new data provider with modified sorting */ - public > ListDataSource sortingBy( + public > ListDataProvider sortingBy( Function sortOrder) { return sortingBy(Comparator.comparing(sortOrder)); } @@ -113,7 +113,7 @@ public class ListDataSource extends AbstractDataSource { /** * {@inheritDoc} *

- * For in-memory data source the query is not handled, and it will always + * For in-memory data provider the query is not handled, and it will always * return the full size. */ @Override diff --git a/server/src/main/java/com/vaadin/ui/AbstractListing.java b/server/src/main/java/com/vaadin/ui/AbstractListing.java index 40d3001ca6..99dd6e5eb1 100644 --- a/server/src/main/java/com/vaadin/ui/AbstractListing.java +++ b/server/src/main/java/com/vaadin/ui/AbstractListing.java @@ -22,7 +22,7 @@ import com.vaadin.data.SelectionModel; import com.vaadin.server.AbstractExtension; import com.vaadin.server.data.DataCommunicator; import com.vaadin.server.data.DataGenerator; -import com.vaadin.server.data.DataSource; +import com.vaadin.server.data.DataProvider; /** * A base class for listing components. Provides common handling for fetching @@ -133,13 +133,13 @@ public abstract class AbstractListing extends AbstractComponent } @Override - public void setDataSource(DataSource dataSource) { - getDataCommunicator().setDataSource(dataSource); + public void setDataProvider(DataProvider dataProvider) { + getDataCommunicator().setDataProvider(dataProvider); } @Override - public DataSource getDataSource() { - return getDataCommunicator().getDataSource(); + public DataProvider getDataProvider() { + return getDataCommunicator().getDataProvider(); } /** diff --git a/server/src/main/java/com/vaadin/ui/AbstractMultiSelect.java b/server/src/main/java/com/vaadin/ui/AbstractMultiSelect.java index fc6ce4f0a4..25173d4646 100644 --- a/server/src/main/java/com/vaadin/ui/AbstractMultiSelect.java +++ b/server/src/main/java/com/vaadin/ui/AbstractMultiSelect.java @@ -138,7 +138,7 @@ public abstract class AbstractMultiSelect extends AbstractListing private SerializablePredicate itemEnabledProvider = item -> true; /** - * Creates a new multi select with an empty data source. + * Creates a new multi select with an empty data provider. */ protected AbstractMultiSelect() { registerRpc(new MultiSelectServerRpcImpl()); diff --git a/server/src/main/java/com/vaadin/ui/AbstractSingleSelect.java b/server/src/main/java/com/vaadin/ui/AbstractSingleSelect.java index 2ffcedde15..e04e871cb4 100644 --- a/server/src/main/java/com/vaadin/ui/AbstractSingleSelect.java +++ b/server/src/main/java/com/vaadin/ui/AbstractSingleSelect.java @@ -246,7 +246,7 @@ public abstract class AbstractSingleSelect extends AbstractListing * the item to select or {@code null} to clear selection */ protected void setSelectedFromServer(T item) { - // TODO creates a key if item not in data source + // TODO creates a key if item not in data provider String key = itemToKey(item); if (isKeySelected(key) || isSelected(item)) { @@ -282,7 +282,7 @@ public abstract class AbstractSingleSelect extends AbstractListing if (item == null) { return null; } else { - // TODO creates a key if item not in data source + // TODO creates a key if item not in data provider return getDataCommunicator().getKeyMapper().key(item); } } diff --git a/server/src/main/java/com/vaadin/ui/CheckBoxGroup.java b/server/src/main/java/com/vaadin/ui/CheckBoxGroup.java index 9c25b3e75b..a3f99e7b27 100644 --- a/server/src/main/java/com/vaadin/ui/CheckBoxGroup.java +++ b/server/src/main/java/com/vaadin/ui/CheckBoxGroup.java @@ -27,13 +27,13 @@ import com.vaadin.event.FieldEvents.FocusEvent; import com.vaadin.event.FieldEvents.FocusListener; import com.vaadin.event.FieldEvents.FocusNotifier; import com.vaadin.server.SerializablePredicate; -import com.vaadin.server.data.DataSource; +import com.vaadin.server.data.DataProvider; import com.vaadin.shared.Registration; import com.vaadin.shared.ui.optiongroup.CheckBoxGroupState; /** * A group of Checkboxes. Individual checkboxes are made from items supplied by - * a {@link DataSource}. Checkboxes may have captions and icons. + * a {@link DataProvider}. Checkboxes may have captions and icons. * * @param * item type @@ -48,7 +48,7 @@ public class CheckBoxGroup extends AbstractMultiSelect * * @param caption * caption text - * @see Listing#setDataSource(DataSource) + * @see Listing#setDataProvider(DataProvider) */ public CheckBoxGroup(String caption) { this(); @@ -56,37 +56,37 @@ public class CheckBoxGroup extends AbstractMultiSelect } /** - * Constructs a new CheckBoxGroup with caption and DataSource. + * Constructs a new CheckBoxGroup with caption and DataProvider. * * @param caption * the caption text - * @param dataSource - * the data source, not null - * @see Listing#setDataSource(DataSource) + * @param dataProvider + * the data provider, not null + * @see Listing#setDataProvider(DataProvider) */ - public CheckBoxGroup(String caption, DataSource dataSource) { + public CheckBoxGroup(String caption, DataProvider dataProvider) { this(caption); - setDataSource(dataSource); + setDataProvider(dataProvider); } /** - * Constructs a new CheckBoxGroup with caption and DataSource containing + * Constructs a new CheckBoxGroup with caption and DataProvider containing * given items. * * @param caption * the caption text * @param items * the data items to use, not null - * @see Listing#setDataSource(DataSource) + * @see Listing#setDataProvider(DataProvider) */ public CheckBoxGroup(String caption, Collection items) { - this(caption, DataSource.create(items)); + this(caption, DataProvider.create(items)); } /** * Constructs a new CheckBoxGroup. * - * @see Listing#setDataSource(DataSource) + * @see Listing#setDataProvider(DataProvider) */ public CheckBoxGroup() { registerRpc(new FocusAndBlurServerRpcDecorator(this, this::fireEvent)); diff --git a/server/src/main/java/com/vaadin/ui/ComboBox.java b/server/src/main/java/com/vaadin/ui/ComboBox.java index d4df2236f7..60a229ba55 100644 --- a/server/src/main/java/com/vaadin/ui/ComboBox.java +++ b/server/src/main/java/com/vaadin/ui/ComboBox.java @@ -34,7 +34,7 @@ import com.vaadin.server.Resource; import com.vaadin.server.ResourceReference; import com.vaadin.server.data.DataCommunicator; import com.vaadin.server.data.DataKeyMapper; -import com.vaadin.server.data.DataSource; +import com.vaadin.server.data.DataProvider; import com.vaadin.shared.Registration; import com.vaadin.shared.data.DataCommunicatorConstants; import com.vaadin.shared.ui.combobox.ComboBoxConstants; @@ -124,7 +124,7 @@ public class ComboBox extends AbstractSingleSelect implements HasValue, /** * Constructs an empty combo box without a caption. The content of the combo - * box can be set with {@link #setDataSource(DataSource)} or + * box can be set with {@link #setDataProvider(DataProvider)} or * {@link #setItems(Collection)} */ public ComboBox() { @@ -146,7 +146,7 @@ public class ComboBox extends AbstractSingleSelect implements HasValue, /** * Constructs an empty combo box, whose content can be set with - * {@link #setDataSource(DataSource)} or {@link #setItems(Collection)}. + * {@link #setDataProvider(DataProvider)} or {@link #setItems(Collection)}. * * @param caption * the caption to show in the containing layout, null for no @@ -158,7 +158,7 @@ public class ComboBox extends AbstractSingleSelect implements HasValue, } /** - * Constructs a combo box with a static in-memory data source with the given + * Constructs a combo box with a static in-memory data provider with the given * options. * * @param caption @@ -168,21 +168,21 @@ public class ComboBox extends AbstractSingleSelect implements HasValue, * collection of options, not null */ public ComboBox(String caption, Collection options) { - this(caption, DataSource.create(options)); + this(caption, DataProvider.create(options)); } /** - * Constructs a combo box with the given data source. + * Constructs a combo box with the given data provider. * * @param caption * the caption to show in the containing layout, null for no * caption - * @param dataSource - * the data source to use, not null + * @param dataProvider + * the data provider to use, not null */ - public ComboBox(String caption, DataSource dataSource) { + public ComboBox(String caption, DataProvider dataProvider) { this(caption); - setDataSource(dataSource); + setDataProvider(dataProvider); } /** @@ -489,7 +489,7 @@ public class ComboBox extends AbstractSingleSelect implements HasValue, /** * Returns the handler called when the user enters a new item (not present - * in the data source). + * in the data provider). * * @return new item handler or null if none specified */ diff --git a/server/src/main/java/com/vaadin/ui/ListSelect.java b/server/src/main/java/com/vaadin/ui/ListSelect.java index 7bbcbb2e8b..e616fa2af3 100644 --- a/server/src/main/java/com/vaadin/ui/ListSelect.java +++ b/server/src/main/java/com/vaadin/ui/ListSelect.java @@ -17,7 +17,7 @@ package com.vaadin.ui; import java.util.Collection; -import com.vaadin.server.data.DataSource; +import com.vaadin.server.data.DataProvider; import com.vaadin.shared.ui.listselect.ListSelectState; /** @@ -54,16 +54,16 @@ public class ListSelect extends AbstractMultiSelect { } /** - * Constructs a new ListSelect with caption and data source for options. + * Constructs a new ListSelect with caption and data provider for options. * * @param caption * the caption to set, can be {@code null} - * @param dataSource - * the data source, not {@code null} + * @param dataProvider + * the data provider, not {@code null} */ - public ListSelect(String caption, DataSource dataSource) { + public ListSelect(String caption, DataProvider dataProvider) { this(caption); - setDataSource(dataSource); + setDataProvider(dataProvider); } /** @@ -75,7 +75,7 @@ public class ListSelect extends AbstractMultiSelect { * the options, cannot be {@code null} */ public ListSelect(String caption, Collection options) { - this(caption, DataSource.create(options)); + this(caption, DataProvider.create(options)); } /** diff --git a/server/src/main/java/com/vaadin/ui/NativeSelect.java b/server/src/main/java/com/vaadin/ui/NativeSelect.java index a1ec0dca40..2a696c75d4 100644 --- a/server/src/main/java/com/vaadin/ui/NativeSelect.java +++ b/server/src/main/java/com/vaadin/ui/NativeSelect.java @@ -25,7 +25,7 @@ import com.vaadin.event.FieldEvents.FocusAndBlurServerRpcDecorator; import com.vaadin.event.FieldEvents.FocusEvent; import com.vaadin.event.FieldEvents.FocusListener; import com.vaadin.event.FieldEvents.FocusNotifier; -import com.vaadin.server.data.DataSource; +import com.vaadin.server.data.DataProvider; import com.vaadin.shared.Registration; import com.vaadin.shared.data.DataCommunicatorConstants; import com.vaadin.shared.ui.nativeselect.NativeSelectState; @@ -81,16 +81,16 @@ public class NativeSelect extends AbstractSingleSelect /** * Creates a new {@code NativeSelect} with the given caption, using the - * given {@code DataSource} as the source of data items. + * given {@code DataProvider} as the source of data items. * * @param caption * the component caption to set, null for no caption - * @param dataSource + * @param dataProvider * the source of data items to use, not null */ - public NativeSelect(String caption, DataSource dataSource) { + public NativeSelect(String caption, DataProvider dataProvider) { this(caption); - setDataSource(dataSource); + setDataProvider(dataProvider); } @Override diff --git a/server/src/main/java/com/vaadin/ui/RadioButtonGroup.java b/server/src/main/java/com/vaadin/ui/RadioButtonGroup.java index 4c5b814f22..8949493d6f 100644 --- a/server/src/main/java/com/vaadin/ui/RadioButtonGroup.java +++ b/server/src/main/java/com/vaadin/ui/RadioButtonGroup.java @@ -31,7 +31,7 @@ import com.vaadin.server.Resource; import com.vaadin.server.ResourceReference; import com.vaadin.server.SerializablePredicate; import com.vaadin.server.data.DataGenerator; -import com.vaadin.server.data.DataSource; +import com.vaadin.server.data.DataProvider; import com.vaadin.shared.Registration; import com.vaadin.shared.ui.ListingJsonConstants; import com.vaadin.shared.ui.optiongroup.RadioButtonGroupState; @@ -40,7 +40,7 @@ import elemental.json.JsonObject; /** * A group of RadioButtons. Individual radiobuttons are made from items supplied - * by a {@link DataSource}. RadioButtons may have captions and icons. + * by a {@link DataProvider}. RadioButtons may have captions and icons. * * @param * item type @@ -61,7 +61,7 @@ public class RadioButtonGroup extends AbstractSingleSelect * * @param caption * caption text - * @see Listing#setDataSource(DataSource) + * @see Listing#setDataProvider(DataProvider) */ public RadioButtonGroup(String caption) { this(); @@ -69,37 +69,37 @@ public class RadioButtonGroup extends AbstractSingleSelect } /** - * Constructs a new RadioButtonGroup with caption and DataSource. + * Constructs a new RadioButtonGroup with caption and DataProvider. * * @param caption * the caption text - * @param dataSource - * the data source, not null - * @see Listing#setDataSource(DataSource) + * @param dataProvider + * the data provider, not null + * @see Listing#setDataProvider(DataProvider) */ - public RadioButtonGroup(String caption, DataSource dataSource) { + public RadioButtonGroup(String caption, DataProvider dataProvider) { this(caption); - setDataSource(dataSource); + setDataProvider(dataProvider); } /** - * Constructs a new RadioButtonGroup with caption and DataSource containing + * Constructs a new RadioButtonGroup with caption and DataProvider containing * given items. * * @param caption * the caption text * @param items * the data items to use, not null - * @see Listing#setDataSource(DataSource) + * @see Listing#setDataProvider(DataProvider) */ public RadioButtonGroup(String caption, Collection items) { - this(caption, DataSource.create(items)); + this(caption, DataProvider.create(items)); } /** * Constructs a new RadioButtonGroup. * - * @see Listing#setDataSource(DataSource) + * @see Listing#setDataProvider(DataProvider) */ public RadioButtonGroup() { registerRpc(new FocusAndBlurServerRpcDecorator(this, this::fireEvent)); diff --git a/server/src/main/java/com/vaadin/ui/TwinColSelect.java b/server/src/main/java/com/vaadin/ui/TwinColSelect.java index 4b321559a3..0858a76830 100644 --- a/server/src/main/java/com/vaadin/ui/TwinColSelect.java +++ b/server/src/main/java/com/vaadin/ui/TwinColSelect.java @@ -18,7 +18,7 @@ package com.vaadin.ui; import java.util.Collection; -import com.vaadin.server.data.DataSource; +import com.vaadin.server.data.DataProvider; import com.vaadin.shared.ui.twincolselect.TwinColSelectState; /** @@ -50,16 +50,16 @@ public class TwinColSelect extends AbstractMultiSelect { } /** - * Constructs a new TwinColSelect with caption and data source for options. + * Constructs a new TwinColSelect with caption and data provider for options. * * @param caption * the caption to set, can be {@code null} - * @param dataSource - * the data source, not {@code null} + * @param dataProvider + * the data provider, not {@code null} */ - public TwinColSelect(String caption, DataSource dataSource) { + public TwinColSelect(String caption, DataProvider dataProvider) { this(caption); - setDataSource(dataSource); + setDataProvider(dataProvider); } /** @@ -71,7 +71,7 @@ public class TwinColSelect extends AbstractMultiSelect { * the options, cannot be {@code null} */ public TwinColSelect(String caption, Collection options) { - this(caption, DataSource.create(options)); + this(caption, DataProvider.create(options)); } /** diff --git a/server/src/main/java/com/vaadin/ui/components/grid/SingleSelectionModel.java b/server/src/main/java/com/vaadin/ui/components/grid/SingleSelectionModel.java index bf2f55648e..6829cfc0e0 100644 --- a/server/src/main/java/com/vaadin/ui/components/grid/SingleSelectionModel.java +++ b/server/src/main/java/com/vaadin/ui/components/grid/SingleSelectionModel.java @@ -187,7 +187,7 @@ public class SingleSelectionModel extends AbstractGridExtension * the item to select or {@code null} to clear selection */ protected void setSelectedFromServer(T item) { - // TODO creates a key if item not in data source + // TODO creates a key if item not in data provider String key = itemToKey(item); if (isSelected(item) || isKeySelected(key)) { @@ -210,7 +210,7 @@ public class SingleSelectionModel extends AbstractGridExtension if (item == null) { return null; } else { - // TODO creates a key if item not in data source + // TODO creates a key if item not in data provider return grid.getDataCommunicator().getKeyMapper().key(item); } } @@ -296,4 +296,4 @@ public class SingleSelectionModel extends AbstractGridExtension } }; } -} \ No newline at end of file +} diff --git a/server/src/main/java/com/vaadin/ui/declarative/DesignContext.java b/server/src/main/java/com/vaadin/ui/declarative/DesignContext.java index 761c7edd04..b72edc4c1a 100644 --- a/server/src/main/java/com/vaadin/ui/declarative/DesignContext.java +++ b/server/src/main/java/com/vaadin/ui/declarative/DesignContext.java @@ -753,7 +753,7 @@ public class DesignContext implements Serializable { /** * Determines whether the container data of a component should be written * out by delegating to a {@link ShouldWriteDataDelegate}. The default - * delegate assumes that all component data is provided by a data source + * delegate assumes that all component data is provided by a data provider * connected to a back end system and that the data should thus not be * written. * diff --git a/server/src/main/java/com/vaadin/ui/declarative/ShouldWriteDataDelegate.java b/server/src/main/java/com/vaadin/ui/declarative/ShouldWriteDataDelegate.java index 5ad97fb4ef..ed686f0f2b 100644 --- a/server/src/main/java/com/vaadin/ui/declarative/ShouldWriteDataDelegate.java +++ b/server/src/main/java/com/vaadin/ui/declarative/ShouldWriteDataDelegate.java @@ -32,7 +32,7 @@ public interface ShouldWriteDataDelegate extends Serializable { /** * The default delegate implementation that assumes that all component data - * is provided by a data source connected to a back end system and that the + * is provided by a data provider connected to a back end system and that the * data should thus not be written. */ public static final ShouldWriteDataDelegate DEFAULT = ( diff --git a/server/src/test/java/com/vaadin/server/data/AbstractDataSourceTest.java b/server/src/test/java/com/vaadin/server/data/AbstractDataProviderTest.java similarity index 73% rename from server/src/test/java/com/vaadin/server/data/AbstractDataSourceTest.java rename to server/src/test/java/com/vaadin/server/data/AbstractDataProviderTest.java index 187f8e0d77..b1260b8097 100644 --- a/server/src/test/java/com/vaadin/server/data/AbstractDataSourceTest.java +++ b/server/src/test/java/com/vaadin/server/data/AbstractDataProviderTest.java @@ -27,9 +27,9 @@ import com.vaadin.shared.Registration; * @author Vaadin Ltd * */ -public class AbstractDataSourceTest { +public class AbstractDataProviderTest { - private static class TestDataSource extends AbstractDataSource { + private static class TestDataProvider extends AbstractDataProvider { @Override public Stream fetch(Query t) { return null; @@ -48,25 +48,25 @@ public class AbstractDataSourceTest { @Test public void refreshAll_notifyListeners() { - AbstractDataSource dataSource = new TestDataSource(); + AbstractDataProvider dataProvider = new TestDataProvider(); AtomicReference event = new AtomicReference<>(); - dataSource.addDataSourceListener(ev -> { + dataProvider.addDataProviderListener(ev -> { Assert.assertNull(event.get()); event.set(ev); }); - dataSource.refreshAll(); + dataProvider.refreshAll(); Assert.assertNotNull(event.get()); - Assert.assertEquals(dataSource, event.get().getSource()); + Assert.assertEquals(dataProvider, event.get().getSource()); } @Test public void removeListener_listenerIsNotNotified() { - AbstractDataSource dataSource = new TestDataSource(); + AbstractDataProvider dataProvider = new TestDataProvider(); AtomicReference event = new AtomicReference<>(); - Registration registration = dataSource - .addDataSourceListener(ev -> event.set(ev)); + Registration registration = dataProvider + .addDataProviderListener(ev -> event.set(ev)); registration.remove(); - dataSource.refreshAll(); + dataProvider.refreshAll(); Assert.assertNull(event.get()); } } diff --git a/server/src/test/java/com/vaadin/server/data/DataCommunicatorTest.java b/server/src/test/java/com/vaadin/server/data/DataCommunicatorTest.java index c9a30fa517..4c40c1a654 100644 --- a/server/src/test/java/com/vaadin/server/data/DataCommunicatorTest.java +++ b/server/src/test/java/com/vaadin/server/data/DataCommunicatorTest.java @@ -52,18 +52,18 @@ public class DataCommunicatorTest { } } - private static class TestDataSource extends ListDataSource + private static class TestDataProvider extends ListDataProvider implements Registration { private Registration registration; - public TestDataSource() { + public TestDataProvider() { super(Collections.singleton(new Object())); } @Override - public Registration addDataSourceListener(DataSourceListener listener) { - registration = super.addDataSourceListener(listener); + public Registration addDataProviderListener(DataProviderListener listener) { + registration = super.addDataProviderListener(listener); return this; } @@ -89,41 +89,41 @@ public class DataCommunicatorTest { Mockito.mock(VaadinService.class)); @Test - public void attach_dataSourceListenerIsNotAddedBeforeAttachAndAddedAfter() { + public void attach_dataProviderListenerIsNotAddedBeforeAttachAndAddedAfter() { session.lock(); UI ui = new TestUI(session); TestDataCommunicator communicator = new TestDataCommunicator(); - TestDataSource dataSource = new TestDataSource(); - communicator.setDataSource(dataSource); + TestDataProvider dataProvider = new TestDataProvider(); + communicator.setDataProvider(dataProvider); - Assert.assertFalse(dataSource.isListenerAdded()); + Assert.assertFalse(dataProvider.isListenerAdded()); communicator.extend(ui); - Assert.assertTrue(dataSource.isListenerAdded()); + Assert.assertTrue(dataProvider.isListenerAdded()); } @Test - public void detach_dataSourceListenerIsRemovedAfterDetach() { + public void detach_dataProviderListenerIsRemovedAfterDetach() { session.lock(); UI ui = new TestUI(session); TestDataCommunicator communicator = new TestDataCommunicator(); - TestDataSource dataSource = new TestDataSource(); - communicator.setDataSource(dataSource); + TestDataProvider dataProvider = new TestDataProvider(); + communicator.setDataProvider(dataProvider); communicator.extend(ui); - Assert.assertTrue(dataSource.isListenerAdded()); + Assert.assertTrue(dataProvider.isListenerAdded()); communicator.detach(); - Assert.assertFalse(dataSource.isListenerAdded()); + Assert.assertFalse(dataProvider.isListenerAdded()); } } diff --git a/server/src/test/java/com/vaadin/server/data/datasource/ListDataSourceTest.java b/server/src/test/java/com/vaadin/server/data/provider/ListDataProviderTest.java similarity index 77% rename from server/src/test/java/com/vaadin/server/data/datasource/ListDataSourceTest.java rename to server/src/test/java/com/vaadin/server/data/provider/ListDataProviderTest.java index a428858a42..37b4214a45 100644 --- a/server/src/test/java/com/vaadin/server/data/datasource/ListDataSourceTest.java +++ b/server/src/test/java/com/vaadin/server/data/provider/ListDataProviderTest.java @@ -1,4 +1,4 @@ -package com.vaadin.server.data.datasource; +package com.vaadin.server.data.provider; import static org.junit.Assert.assertTrue; @@ -7,33 +7,33 @@ import java.util.LinkedList; import java.util.List; import java.util.stream.Collectors; +import com.vaadin.server.data.DataProvider; import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import com.vaadin.server.data.DataSource; -import com.vaadin.server.data.ListDataSource; +import com.vaadin.server.data.ListDataProvider; import com.vaadin.server.data.Query; -public class ListDataSourceTest { +public class ListDataProviderTest { - private ListDataSource dataSource; + private ListDataProvider dataProvider; private List data; @Before public void setUp() { data = StrBean.generateRandomBeans(100); - dataSource = DataSource.create(data); + dataProvider = DataProvider.create(data); } @Test public void testListContainsAllData() { List list = new LinkedList<>(data); - dataSource.fetch(new Query()) + dataProvider.fetch(new Query()) .forEach(str -> assertTrue( - "Data source contained values not in original data", + "Data provider contained values not in original data", list.remove(str))); - assertTrue("Not all values from original data were in data source", + assertTrue("Not all values from original data were in data provider", list.isEmpty()); } @@ -42,7 +42,7 @@ public class ListDataSourceTest { Comparator comp = Comparator.comparing(StrBean::getValue) .thenComparing(StrBean::getRandomNumber) .thenComparing(StrBean::getId); - List list = dataSource.sortingBy(comp).fetch(new Query()) + List list = dataProvider.sortingBy(comp).fetch(new Query()) .collect(Collectors.toList()); // First value in data is { Xyz, 10, 100 } which should be last in list @@ -63,7 +63,7 @@ public class ListDataSourceTest { public void testDefatulSortWithSpecifiedPostSort() { Comparator comp = Comparator.comparing(StrBean::getValue) .thenComparing(Comparator.comparing(StrBean::getId).reversed()); - List list = dataSource.sortingBy(comp).fetch(new Query()) + List list = dataProvider.sortingBy(comp).fetch(new Query()) // The sort here should come e.g from a Component .sorted(Comparator.comparing(StrBean::getRandomNumber)) .collect(Collectors.toList()); @@ -90,7 +90,7 @@ public class ListDataSourceTest { @Test public void testDefatulSortWithFunction() { - List list = dataSource.sortingBy(StrBean::getValue) + List list = dataProvider.sortingBy(StrBean::getValue) .fetch(new Query()).collect(Collectors.toList()); Assert.assertEquals("Sorted data and original data sizes don't match", @@ -109,47 +109,47 @@ public class ListDataSourceTest { public void refreshAll_changeBeanInstance() { StrBean bean = new StrBean("foo", -1, hashCode()); Query query = new Query(); - int size = dataSource.size(query); + int size = dataProvider.size(query); data.set(0, bean); - dataSource.refreshAll(); + dataProvider.refreshAll(); - List list = dataSource.fetch(query) + List list = dataProvider.fetch(query) .collect(Collectors.toList()); StrBean first = list.get(0); Assert.assertEquals(bean.getValue(), first.getValue()); Assert.assertEquals(bean.getRandomNumber(), first.getRandomNumber()); Assert.assertEquals(bean.getId(), first.getId()); - Assert.assertEquals(size, dataSource.size(query)); + Assert.assertEquals(size, dataProvider.size(query)); } @Test public void refreshAll_updateBean() { Query query = new Query(); - int size = dataSource.size(query); + int size = dataProvider.size(query); StrBean bean = data.get(0); bean.setValue("foo"); - dataSource.refreshAll(); + dataProvider.refreshAll(); - List list = dataSource.fetch(query) + List list = dataProvider.fetch(query) .collect(Collectors.toList()); StrBean first = list.get(0); Assert.assertEquals("foo", first.getValue()); - Assert.assertEquals(size, dataSource.size(query)); + Assert.assertEquals(size, dataProvider.size(query)); } @Test public void refreshAll_sortingBy_changeBeanInstance() { StrBean bean = new StrBean("foo", -1, hashCode()); Query query = new Query(); - int size = dataSource.size(query); + int size = dataProvider.size(query); data.set(0, bean); - ListDataSource dSource = dataSource + ListDataProvider dSource = dataProvider .sortingBy(Comparator.comparing(StrBean::getId)); dSource.refreshAll(); @@ -159,7 +159,7 @@ public class ListDataSourceTest { Assert.assertEquals(bean.getRandomNumber(), first.getRandomNumber()); Assert.assertEquals(bean.getId(), first.getId()); - Assert.assertEquals(size, dataSource.size(query)); + Assert.assertEquals(size, dataProvider.size(query)); } @Test @@ -167,29 +167,29 @@ public class ListDataSourceTest { StrBean bean = new StrBean("foo", -1, hashCode()); Query query = new Query(); - int size = dataSource.size(query); + int size = dataProvider.size(query); data.add(0, bean); - dataSource.refreshAll(); + dataProvider.refreshAll(); - List list = dataSource.fetch(query) + List list = dataProvider.fetch(query) .collect(Collectors.toList()); StrBean first = list.get(0); Assert.assertEquals(bean.getValue(), first.getValue()); Assert.assertEquals(bean.getRandomNumber(), first.getRandomNumber()); Assert.assertEquals(bean.getId(), first.getId()); - Assert.assertEquals(size + 1, dataSource.size(query)); + Assert.assertEquals(size + 1, dataProvider.size(query)); } @Test public void refreshAll_removeBeanInstance() { Query query = new Query(); - int size = dataSource.size(query); + int size = dataProvider.size(query); data.remove(0); - dataSource.refreshAll(); + dataProvider.refreshAll(); - Assert.assertEquals(size - 1, dataSource.size(query)); + Assert.assertEquals(size - 1, dataProvider.size(query)); } } diff --git a/server/src/test/java/com/vaadin/server/data/datasource/StrBean.java b/server/src/test/java/com/vaadin/server/data/provider/StrBean.java similarity index 96% rename from server/src/test/java/com/vaadin/server/data/datasource/StrBean.java rename to server/src/test/java/com/vaadin/server/data/provider/StrBean.java index 44650d63bb..b0a346d9c5 100644 --- a/server/src/test/java/com/vaadin/server/data/datasource/StrBean.java +++ b/server/src/test/java/com/vaadin/server/data/provider/StrBean.java @@ -1,4 +1,4 @@ -package com.vaadin.server.data.datasource; +package com.vaadin.server.data.provider; import java.io.Serializable; import java.util.ArrayList; @@ -50,4 +50,4 @@ class StrBean implements Serializable { public String toString() { return "{ " + value + ", " + randomNumber + ", " + id + " }"; } -} \ No newline at end of file +} diff --git a/server/src/test/java/com/vaadin/server/data/datasource/bov/DataSourceBoVTest.java b/server/src/test/java/com/vaadin/server/data/provider/bov/DataProviderBoVTest.java similarity index 86% rename from server/src/test/java/com/vaadin/server/data/datasource/bov/DataSourceBoVTest.java rename to server/src/test/java/com/vaadin/server/data/provider/bov/DataProviderBoVTest.java index 58f0c32401..2ad7fc4178 100644 --- a/server/src/test/java/com/vaadin/server/data/datasource/bov/DataSourceBoVTest.java +++ b/server/src/test/java/com/vaadin/server/data/provider/bov/DataProviderBoVTest.java @@ -13,7 +13,7 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.vaadin.server.data.datasource.bov; +package com.vaadin.server.data.provider.bov; import java.util.ArrayList; import java.util.Arrays; @@ -22,11 +22,11 @@ import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; +import com.vaadin.server.data.BackEndDataProvider; +import com.vaadin.server.data.DataProvider; import org.junit.Before; import org.junit.Test; -import com.vaadin.server.data.BackEndDataSource; -import com.vaadin.server.data.DataSource; import com.vaadin.server.data.SortOrder; import com.vaadin.shared.data.sort.SortDirection; @@ -35,7 +35,7 @@ import com.vaadin.shared.data.sort.SortDirection; * * @author Vaadin Ltd */ -public class DataSourceBoVTest { +public class DataProviderBoVTest { private PersonServiceImpl personService; @@ -96,13 +96,13 @@ public class DataSourceBoVTest { @Test public void testPersons() { - DataSource dataSource = createUnsortedDatasource(); - // TODO test if the datasource contains all defined Persons in + DataProvider dataProvider = createUnsortedDataProvider(); + // TODO test if the provider contains all defined Persons in // correct(unchanged) order } - private DataSource createUnsortedDatasource() { - DataSource dataSource = new BackEndDataSource<>( + private DataProvider createUnsortedDataProvider() { + DataProvider dataProvider = new BackEndDataProvider<>( // First callback fetches items based on a query query -> { // The index of the first item to load @@ -118,19 +118,19 @@ public class DataSourceBoVTest { }, // Second callback fetches the number of items for a query query -> getPersonService().getPersonCount()); - return dataSource; + return dataProvider; } @Test public void testSortedPersons() { - DataSource dataSource = createSortedDataSource(); - // TODO test if datasource contains all defined Persons in correct order + DataProvider dataProvider = createSortedDataProvider(); + // TODO test if provider contains all defined Persons in correct order // TODO test Query.sortOrders correctness } - private DataSource createSortedDataSource() { - DataSource dataSource = new BackEndDataSource<>( + private DataProvider createSortedDataProvider() { + DataProvider dataProvider = new BackEndDataProvider<>( // First callback fetches items based on a query query -> { List sortOrders = new ArrayList<>(); @@ -149,7 +149,7 @@ public class DataSourceBoVTest { }, // Second callback fetches the number of items for a query query -> getPersonService().getPersonCount()); - return dataSource; + return dataProvider; } public PersonServiceImpl getPersonService() { diff --git a/server/src/test/java/com/vaadin/server/data/datasource/bov/Person.java b/server/src/test/java/com/vaadin/server/data/provider/bov/Person.java similarity index 95% rename from server/src/test/java/com/vaadin/server/data/datasource/bov/Person.java rename to server/src/test/java/com/vaadin/server/data/provider/bov/Person.java index f551e5be98..8a60510949 100644 --- a/server/src/test/java/com/vaadin/server/data/datasource/bov/Person.java +++ b/server/src/test/java/com/vaadin/server/data/provider/bov/Person.java @@ -13,7 +13,7 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.vaadin.server.data.datasource.bov; +package com.vaadin.server.data.provider.bov; import java.io.Serializable; diff --git a/server/src/test/java/com/vaadin/server/data/datasource/bov/PersonService.java b/server/src/test/java/com/vaadin/server/data/provider/bov/PersonService.java similarity index 96% rename from server/src/test/java/com/vaadin/server/data/datasource/bov/PersonService.java rename to server/src/test/java/com/vaadin/server/data/provider/bov/PersonService.java index 18e6132313..70c355720e 100644 --- a/server/src/test/java/com/vaadin/server/data/datasource/bov/PersonService.java +++ b/server/src/test/java/com/vaadin/server/data/provider/bov/PersonService.java @@ -13,7 +13,7 @@ * License for the specific language governing permissions and limitations under * the License. */ -package com.vaadin.server.data.datasource.bov; +package com.vaadin.server.data.provider.bov; import java.io.Serializable; import java.util.Collection; diff --git a/server/src/test/java/com/vaadin/tests/components/grid/GridSingleSelectionModelTest.java b/server/src/test/java/com/vaadin/tests/components/grid/GridSingleSelectionModelTest.java index 9746e2eef1..67b35c5208 100644 --- a/server/src/test/java/com/vaadin/tests/components/grid/GridSingleSelectionModelTest.java +++ b/server/src/test/java/com/vaadin/tests/components/grid/GridSingleSelectionModelTest.java @@ -18,7 +18,7 @@ import org.mockito.Mockito; import com.vaadin.data.HasValue.ValueChangeEvent; import com.vaadin.event.selection.SingleSelectionEvent; import com.vaadin.event.selection.SingleSelectionListener; -import com.vaadin.server.data.datasource.bov.Person; +import com.vaadin.server.data.provider.bov.Person; import com.vaadin.shared.Registration; import com.vaadin.shared.data.DataCommunicatorClientRpc; import com.vaadin.ui.Grid; diff --git a/server/src/test/java/com/vaadin/tests/server/component/StateGetDoesNotMarkDirtyTest.java b/server/src/test/java/com/vaadin/tests/server/component/StateGetDoesNotMarkDirtyTest.java index 70b7b0b77c..b6392f0910 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/StateGetDoesNotMarkDirtyTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/StateGetDoesNotMarkDirtyTest.java @@ -23,7 +23,7 @@ public class StateGetDoesNotMarkDirtyTest { @Before public void setUp() { - excludedMethods.add(Label.class.getName() + "getDataSourceValue"); + excludedMethods.add(Label.class.getName() + "getDataProviderValue"); excludedMethods.add("getConnectorId"); } diff --git a/server/src/test/java/com/vaadin/ui/AbstractListingTest.java b/server/src/test/java/com/vaadin/ui/AbstractListingTest.java index 494fc2e1c5..eca5eed854 100644 --- a/server/src/test/java/com/vaadin/ui/AbstractListingTest.java +++ b/server/src/test/java/com/vaadin/ui/AbstractListingTest.java @@ -6,13 +6,13 @@ import java.util.LinkedList; import java.util.List; import java.util.stream.Stream; +import com.vaadin.server.data.BackEndDataProvider; import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import com.vaadin.server.data.BackEndDataSource; -import com.vaadin.server.data.DataSource; -import com.vaadin.server.data.ListDataSource; +import com.vaadin.server.data.DataProvider; +import com.vaadin.server.data.ListDataProvider; import com.vaadin.server.data.Query; import com.vaadin.ui.AbstractListing.AbstractListingExtension; @@ -66,38 +66,38 @@ public class AbstractListingTest { public void testSetItemsWithCollection() { listing.setItems(items); List list = new LinkedList<>(items); - listing.getDataSource().fetch(new Query()).forEach( - str -> Assert.assertTrue("Unexpected item in data source", + listing.getDataProvider().fetch(new Query()).forEach( + str -> Assert.assertTrue("Unexpected item in data provider", list.remove(str))); - Assert.assertTrue("Not all items from list were in data source", + Assert.assertTrue("Not all items from list were in data provider", list.isEmpty()); } @Test public void testSetItemsWithVarargs() { listing.setItems(ITEM_ARRAY); - listing.getDataSource().fetch(new Query()).forEach( - str -> Assert.assertTrue("Unexpected item in data source", + listing.getDataProvider().fetch(new Query()).forEach( + str -> Assert.assertTrue("Unexpected item in data provider", items.remove(str))); - Assert.assertTrue("Not all items from list were in data source", + Assert.assertTrue("Not all items from list were in data provider", items.isEmpty()); } @Test - public void testSetDataSource() { - ListDataSource dataSource = DataSource.create(items); - listing.setDataSource(dataSource); - Assert.assertEquals("setDataSource did not set data source", dataSource, - listing.getDataSource()); - listing.setDataSource(new BackEndDataSource<>(q -> Stream.of(ITEM_ARRAY) + public void testSetDataProvider() { + ListDataProvider dataProvider = DataProvider.create(items); + listing.setDataProvider(dataProvider); + Assert.assertEquals("setDataProvider did not set data provider", dataProvider, + listing.getDataProvider()); + listing.setDataProvider(new BackEndDataProvider<>(q -> Stream.of(ITEM_ARRAY) .skip(q.getOffset()).limit(q.getLimit()), q -> ITEM_ARRAY.length)); - Assert.assertNotEquals("setDataSource did not replace data source", - dataSource, listing.getDataSource()); + Assert.assertNotEquals("setDataProvider did not replace data provider", + dataProvider, listing.getDataProvider()); } @Test - public void testAddDataGeneratorBeforeDataSource() { + public void testAddDataGeneratorBeforeDataProvider() { CountGenerator generator = new CountGenerator(); generator.extend(listing); listing.setItems("Foo"); @@ -107,7 +107,7 @@ public class AbstractListingTest { } @Test - public void testAddDataGeneratorAfterDataSource() { + public void testAddDataGeneratorAfterDataProvider() { CountGenerator generator = new CountGenerator(); listing.setItems("Foo"); generator.extend(listing); diff --git a/server/src/test/java/com/vaadin/ui/AbstractMultiSelectTest.java b/server/src/test/java/com/vaadin/ui/AbstractMultiSelectTest.java index 92c288fc34..e31e6e28db 100644 --- a/server/src/test/java/com/vaadin/ui/AbstractMultiSelectTest.java +++ b/server/src/test/java/com/vaadin/ui/AbstractMultiSelectTest.java @@ -26,6 +26,7 @@ import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; import java.util.stream.Stream; +import com.vaadin.server.data.DataProvider; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -39,7 +40,6 @@ import org.mockito.Mockito; import com.vaadin.data.HasValue.ValueChangeEvent; import com.vaadin.event.selection.MultiSelectionEvent; import com.vaadin.event.selection.MultiSelectionListener; -import com.vaadin.server.data.DataSource; import com.vaadin.shared.Registration; import com.vaadin.shared.data.selection.MultiSelectServerRpc; @@ -63,8 +63,8 @@ public class AbstractMultiSelectTest { public void setUp() { selectToTest.deselectAll(); // Intentional deviation from upcoming selection order - selectToTest.setDataSource( - DataSource.create("3", "2", "1", "5", "8", "7", "4", "6")); + selectToTest.setDataProvider( + DataProvider.create("3", "2", "1", "5", "8", "7", "4", "6")); rpc = ComponentTest.getRpcProxy(selectToTest, MultiSelectServerRpc.class); } diff --git a/server/src/test/java/com/vaadin/ui/AbstractSingleSelectTest.java b/server/src/test/java/com/vaadin/ui/AbstractSingleSelectTest.java index b429afb600..83cfbd1ee1 100644 --- a/server/src/test/java/com/vaadin/ui/AbstractSingleSelectTest.java +++ b/server/src/test/java/com/vaadin/ui/AbstractSingleSelectTest.java @@ -33,7 +33,7 @@ import org.mockito.Mockito; import com.vaadin.data.HasValue.ValueChangeEvent; import com.vaadin.event.selection.SingleSelectionEvent; import com.vaadin.event.selection.SingleSelectionListener; -import com.vaadin.server.data.datasource.bov.Person; +import com.vaadin.server.data.provider.bov.Person; import com.vaadin.shared.Registration; import com.vaadin.shared.data.DataCommunicatorClientRpc; diff --git a/server/src/test/java/com/vaadin/ui/RadioButtonGroupTest.java b/server/src/test/java/com/vaadin/ui/RadioButtonGroupTest.java index ec48a74799..22b9206760 100644 --- a/server/src/test/java/com/vaadin/ui/RadioButtonGroupTest.java +++ b/server/src/test/java/com/vaadin/ui/RadioButtonGroupTest.java @@ -24,7 +24,7 @@ import org.junit.Before; import org.junit.Test; import com.vaadin.data.SelectionModel.Multi; -import com.vaadin.server.data.DataSource; +import com.vaadin.server.data.DataProvider; import com.vaadin.shared.data.selection.SelectionServerRpc; public class RadioButtonGroupTest { @@ -35,7 +35,7 @@ public class RadioButtonGroupTest { radioButtonGroup = new RadioButtonGroup<>(); // Intentional deviation from upcoming selection order radioButtonGroup - .setDataSource(DataSource.create("Third", "Second", "First")); + .setDataProvider(DataProvider.create("Third", "Second", "First")); } @Test diff --git a/uitest/src/main/java/com/vaadin/tests/components/abstractlisting/AbstractListingTestUI.java b/uitest/src/main/java/com/vaadin/tests/components/abstractlisting/AbstractListingTestUI.java index 126eb4bf33..9d2ca4f6ea 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/abstractlisting/AbstractListingTestUI.java +++ b/uitest/src/main/java/com/vaadin/tests/components/abstractlisting/AbstractListingTestUI.java @@ -28,7 +28,7 @@ public abstract class AbstractListingTestUI> options.put("10000", 10000); options.put("100000", 100000); - createSelectAction("Items", "Data source", options, "20", + createSelectAction("Items", "Data provider", options, "20", (c, number, data) -> { c.setItems(createItems(number)); }); diff --git a/uitest/src/main/java/com/vaadin/tests/components/abstractlisting/AbstractMultiSelectTestUI.java b/uitest/src/main/java/com/vaadin/tests/components/abstractlisting/AbstractMultiSelectTestUI.java index 89f9f9e0ea..0037f0f2d1 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/abstractlisting/AbstractMultiSelectTestUI.java +++ b/uitest/src/main/java/com/vaadin/tests/components/abstractlisting/AbstractMultiSelectTestUI.java @@ -32,7 +32,7 @@ public abstract class AbstractMultiSelectTestUI { abstractMultiSelect .setItemCaptionGenerator(captionGenerator); - abstractMultiSelect.getDataSource().refreshAll(); + abstractMultiSelect.getDataProvider().refreshAll(); }, true); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/checkbox/CheckBoxGroupTestUI.java b/uitest/src/main/java/com/vaadin/tests/components/checkbox/CheckBoxGroupTestUI.java index 95d2c016b1..56d45995cb 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/checkbox/CheckBoxGroupTestUI.java +++ b/uitest/src/main/java/com/vaadin/tests/components/checkbox/CheckBoxGroupTestUI.java @@ -64,7 +64,7 @@ public class CheckBoxGroupTestUI } else { group.setItemIconGenerator(DEFAULT_ICON_GENERATOR); } - group.getDataSource().refreshAll(); + group.getDataProvider().refreshAll(); } private int getIndex(Object item) { diff --git a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxClickIcon.java b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxClickIcon.java index f6de3d22ba..d6d0c78ea6 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxClickIcon.java +++ b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxClickIcon.java @@ -17,7 +17,7 @@ package com.vaadin.tests.components.combobox; import com.vaadin.server.FontAwesome; import com.vaadin.server.VaadinRequest; -import com.vaadin.server.data.DataSource; +import com.vaadin.server.data.DataProvider; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.ComboBox; @@ -31,7 +31,7 @@ public class ComboBoxClickIcon extends AbstractReindeerTestUI { @Override protected void setup(VaadinRequest request) { final ComboBox combo = new ComboBox<>(null, - DataSource.create("A", "B", "C")); + DataProvider.create("A", "B", "C")); combo.setItemIconGenerator(item -> FontAwesome.ALIGN_CENTER); combo.setTextInputAllowed(false); addComponent(combo); diff --git a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxEmptyItemsKeyboardNavigation.java b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxEmptyItemsKeyboardNavigation.java index 8d3936aecd..90d6ad74a1 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxEmptyItemsKeyboardNavigation.java +++ b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxEmptyItemsKeyboardNavigation.java @@ -1,7 +1,7 @@ package com.vaadin.tests.components.combobox; import com.vaadin.server.VaadinRequest; -import com.vaadin.server.data.DataSource; +import com.vaadin.server.data.DataProvider; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.ComboBox; @@ -9,7 +9,7 @@ public class ComboBoxEmptyItemsKeyboardNavigation extends AbstractReindeerTestUI @Override protected void setup(VaadinRequest request) { ComboBox comboBox = new ComboBox<>(null, - DataSource.create("foo", "bar")); + DataProvider.create("foo", "bar")); addComponent(comboBox); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxEnablesComboBox.java b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxEnablesComboBox.java index 3917ad2ebd..c6ff7496af 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxEnablesComboBox.java +++ b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxEnablesComboBox.java @@ -1,7 +1,7 @@ package com.vaadin.tests.components.combobox; import com.vaadin.tests.components.TestBase; -import com.vaadin.tests.util.ItemDataSource; +import com.vaadin.tests.util.ItemDataProvider; import com.vaadin.ui.ComboBox; public class ComboBoxEnablesComboBox extends TestBase { @@ -11,10 +11,10 @@ public class ComboBoxEnablesComboBox extends TestBase { @Override protected void setup() { ComboBox cb = new ComboBox<>("Always enabled", - new ItemDataSource(10)); + new ItemDataProvider(10)); cb.addValueChangeListener(event -> cb2.setEnabled(true)); cb2 = new ComboBox("Initially disabled", - new ItemDataSource(10)); + new ItemDataProvider(10)); cb2.setEnabled(false); addComponent(cb); diff --git a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxInPopup.java b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxInPopup.java index f34259e750..fdb97f3402 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxInPopup.java +++ b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxInPopup.java @@ -1,7 +1,7 @@ package com.vaadin.tests.components.combobox; import com.vaadin.event.ShortcutAction.KeyCode; -import com.vaadin.server.data.DataSource; +import com.vaadin.server.data.DataProvider; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; @@ -36,7 +36,7 @@ public class ComboBoxInPopup extends TestBase { private Component createComboBox() { return new ComboBox("A combo box", - DataSource.create("Yes", "No", "Maybe")); + DataProvider.create("Yes", "No", "Maybe")); } @Override diff --git a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxInvalidNullSelection.java b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxInvalidNullSelection.java index a569801cbe..d01565e7c7 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxInvalidNullSelection.java +++ b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxInvalidNullSelection.java @@ -1,6 +1,6 @@ package com.vaadin.tests.components.combobox; -import com.vaadin.server.data.DataSource; +import com.vaadin.server.data.DataProvider; import com.vaadin.tests.components.TestBase; import com.vaadin.tests.util.Log; import com.vaadin.ui.Button; @@ -9,28 +9,28 @@ import com.vaadin.ui.ComboBox; public class ComboBoxInvalidNullSelection extends TestBase { private static final Object CAPTION = "C"; - private DataSource ds1; - private DataSource ds2; + private DataProvider ds1; + private DataProvider ds2; private ComboBox combo; private Log log = new Log(5); @Override protected void setup() { - createDataSources(); + createDataProviders(); - Button b = new Button("Swap data source"); + Button b = new Button("Swap data provider"); b.addClickListener(event -> { - if (combo.getDataSource() == ds1) { - combo.setDataSource(ds2); + if (combo.getDataProvider() == ds1) { + combo.setDataProvider(ds2); } else { - combo.setDataSource(ds1); + combo.setDataProvider(ds1); } combo.setValue("Item 3"); }); combo = new ComboBox<>(); - combo.setDataSource(ds1); + combo.setDataProvider(ds1); combo.addValueChangeListener( event -> log.log("Value is now: " + combo.getValue())); addComponent(log); @@ -39,16 +39,16 @@ public class ComboBoxInvalidNullSelection extends TestBase { addComponent(new Button("Dummy for TestBench")); } - private void createDataSources() { - ds1 = DataSource.create("Item 1", "Item 2", "Item 3", "Item 4"); + private void createDataProviders() { + ds1 = DataProvider.create("Item 1", "Item 2", "Item 3", "Item 4"); - ds2 = DataSource.create("Item 3"); + ds2 = DataProvider.create("Item 3"); } @Override protected String getDescription() { - return "Select \"Item 3\" in the ComboBox, change the data source, focus and blur the ComboBox. The value should temporarily change to null when changing data source but not when focusing and blurring the ComboBox"; + return "Select \"Item 3\" in the ComboBox, change the data provider, focus and blur the ComboBox. The value should temporarily change to null when changing data provider but not when focusing and blurring the ComboBox"; } @Override diff --git a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxLargeIcons.java b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxLargeIcons.java index c262b5f01a..1909a90c92 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxLargeIcons.java +++ b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxLargeIcons.java @@ -3,7 +3,7 @@ package com.vaadin.tests.components.combobox; import java.util.Date; import com.vaadin.server.ThemeResource; -import com.vaadin.server.data.DataSource; +import com.vaadin.server.data.DataProvider; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.ComboBox; @@ -22,7 +22,7 @@ public class ComboBoxLargeIcons extends TestBase { @Override protected void setup() { ComboBox cb = new ComboBox(null, - DataSource.create("folder-add", "folder-delete", "arrow-down", + DataProvider.create("folder-add", "folder-delete", "arrow-down", "arrow-left", "arrow-right", "arrow-up", "document-add", "document-delete", "document-doc", "document-edit", "document-image", "document-pdf", "document-ppt", diff --git a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxMousewheel.java b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxMousewheel.java index 8479733267..f77de3650c 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxMousewheel.java +++ b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxMousewheel.java @@ -17,7 +17,7 @@ package com.vaadin.tests.components.combobox; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; -import com.vaadin.tests.util.ItemDataSource; +import com.vaadin.tests.util.ItemDataProvider; import com.vaadin.ui.ComboBox; /** @@ -37,7 +37,7 @@ public class ComboBoxMousewheel extends AbstractReindeerTestUI { } private ComboBox createComboBox(String caption) { - ComboBox cb = new ComboBox<>(caption, new ItemDataSource(100)); + ComboBox cb = new ComboBox<>(caption, new ItemDataProvider(100)); cb.setId(caption); return cb; } diff --git a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxNavigation.java b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxNavigation.java index b4b12bcb5b..bc5144a7bf 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxNavigation.java +++ b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxNavigation.java @@ -1,7 +1,7 @@ package com.vaadin.tests.components.combobox; import com.vaadin.tests.components.TestBase; -import com.vaadin.tests.util.ItemDataSource; +import com.vaadin.tests.util.ItemDataProvider; import com.vaadin.ui.ComboBox; public class ComboBoxNavigation extends TestBase { @@ -18,7 +18,7 @@ public class ComboBoxNavigation extends TestBase { @Override protected void setup() { - ComboBox cb = new ComboBox<>(null, new ItemDataSource(100)); + ComboBox cb = new ComboBox<>(null, new ItemDataProvider(100)); addComponent(cb); diff --git a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxPopupWhenBodyScrolls.java b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxPopupWhenBodyScrolls.java index b42e66e531..04636a3f4f 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxPopupWhenBodyScrolls.java +++ b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxPopupWhenBodyScrolls.java @@ -17,7 +17,7 @@ package com.vaadin.tests.components.combobox; import com.vaadin.server.VaadinRequest; import com.vaadin.tests.components.AbstractReindeerTestUI; -import com.vaadin.tests.util.ItemDataSource; +import com.vaadin.tests.util.ItemDataProvider; import com.vaadin.ui.ComboBox; import com.vaadin.ui.Label; @@ -29,7 +29,7 @@ public class ComboBoxPopupWhenBodyScrolls extends AbstractReindeerTestUI { .add("body.v-generated-body { overflow: auto;height:auto;}"); getPage().getStyles().add( "body.v-generated-body .v-ui.v-scrollable{ overflow: visible;height:auto !important;}"); - ComboBox cb = new ComboBox<>(null, new ItemDataSource(10)); + ComboBox cb = new ComboBox<>(null, new ItemDataProvider(10)); Label spacer = new Label("foo"); spacer.setHeight("2000px"); diff --git a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxSelectingWithNewItemsAllowed.java b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxSelectingWithNewItemsAllowed.java index dc87ee59e5..a3e48f3509 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxSelectingWithNewItemsAllowed.java +++ b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxSelectingWithNewItemsAllowed.java @@ -36,7 +36,7 @@ public class ComboBoxSelectingWithNewItemsAllowed extends ComboBoxSelecting { }); comboBox.addValueChangeListener(event -> label.setValue( - String.valueOf(comboBox.getDataSource().size(new Query())))); + String.valueOf(comboBox.getDataProvider().size(new Query())))); addComponent(label); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxUndefinedWidthAndIcon.java b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxUndefinedWidthAndIcon.java index d1f8c16562..10ec271745 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxUndefinedWidthAndIcon.java +++ b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxUndefinedWidthAndIcon.java @@ -2,13 +2,13 @@ package com.vaadin.tests.components.combobox; import com.vaadin.server.ThemeResource; import com.vaadin.tests.components.TestBase; -import com.vaadin.tests.util.ItemDataSource; +import com.vaadin.tests.util.ItemDataProvider; import com.vaadin.ui.ComboBox; public class ComboBoxUndefinedWidthAndIcon extends TestBase { @Override protected void setup() { - ComboBox cb = new ComboBox<>(null, new ItemDataSource(200)); + ComboBox cb = new ComboBox<>(null, new ItemDataProvider(200)); cb.setItemIconGenerator( item -> new ThemeResource("../runo/icons/16/users.png")); diff --git a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboFocusBlurEvents.java b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboFocusBlurEvents.java index 5513c9eba9..9ab060e702 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboFocusBlurEvents.java +++ b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboFocusBlurEvents.java @@ -1,7 +1,7 @@ package com.vaadin.tests.components.combobox; import com.vaadin.tests.components.TestBase; -import com.vaadin.tests.util.ItemDataSource; +import com.vaadin.tests.util.ItemDataProvider; import com.vaadin.ui.ComboBox; import com.vaadin.ui.TextField; import com.vaadin.v7.data.util.ObjectProperty; @@ -16,7 +16,7 @@ public class ComboFocusBlurEvents extends TestBase { protected void setup() { ComboBox cb = new ComboBox<>("Combobox", - new ItemDataSource(100)); + new ItemDataProvider(100)); cb.setPlaceholder("Enter text"); cb.setDescription("Some Combobox"); addComponent(cb); diff --git a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboboxMenuBarAutoopen.java b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboboxMenuBarAutoopen.java index a0793aef47..3d5a2ad3c9 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboboxMenuBarAutoopen.java +++ b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboboxMenuBarAutoopen.java @@ -17,7 +17,7 @@ package com.vaadin.tests.components.combobox; import com.vaadin.server.Page; import com.vaadin.server.VaadinRequest; -import com.vaadin.server.data.DataSource; +import com.vaadin.server.data.DataProvider; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.ComboBox; import com.vaadin.ui.HorizontalLayout; @@ -38,7 +38,7 @@ public class ComboboxMenuBarAutoopen extends AbstractReindeerTestUI { HorizontalLayout layout = new HorizontalLayout(); layout.setSpacing(true); ComboBox combo = new ComboBox<>(null, - DataSource.create("1", "2", "3")); + DataProvider.create("1", "2", "3")); layout.addComponent(combo); MenuBar menubar = getMenubar(); diff --git a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboboxPrimaryStyleNames.java b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboboxPrimaryStyleNames.java index 8072db9de4..7e78036d56 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboboxPrimaryStyleNames.java +++ b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboboxPrimaryStyleNames.java @@ -1,6 +1,6 @@ package com.vaadin.tests.components.combobox; -import com.vaadin.server.data.DataSource; +import com.vaadin.server.data.DataProvider; import com.vaadin.tests.components.TestBase; import com.vaadin.ui.Button; import com.vaadin.ui.ComboBox; @@ -10,7 +10,7 @@ public class ComboboxPrimaryStyleNames extends TestBase { @Override protected void setup() { final ComboBox box = new ComboBox(null, - DataSource.create("Value 1", "Value 2", "Value 3", "Value 4")); + DataProvider.create("Value 1", "Value 2", "Value 3", "Value 4")); box.setPrimaryStyleName("my-combobox"); addComponent(box); diff --git a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboboxStyleChangeWidth.java b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboboxStyleChangeWidth.java index 3faef53ed7..6d5f02be48 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboboxStyleChangeWidth.java +++ b/uitest/src/main/java/com/vaadin/tests/components/combobox/ComboboxStyleChangeWidth.java @@ -16,7 +16,7 @@ package com.vaadin.tests.components.combobox; import com.vaadin.server.VaadinRequest; -import com.vaadin.server.data.DataSource; +import com.vaadin.server.data.DataProvider; import com.vaadin.tests.components.AbstractTestUIWithLog; import com.vaadin.ui.Button; import com.vaadin.ui.ComboBox; @@ -30,7 +30,7 @@ public class ComboboxStyleChangeWidth extends AbstractTestUIWithLog { @Override protected void setup(VaadinRequest request) { - final ComboBox cbFoo = new ComboBox<>(null, DataSource.create( + final ComboBox cbFoo = new ComboBox<>(null, DataProvider.create( "A really long string that causes an inline width to be set")); cbFoo.setSizeUndefined(); diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/GridApplyFilterWhenScrolledDown.java b/uitest/src/main/java/com/vaadin/tests/components/grid/GridApplyFilterWhenScrolledDown.java index b452965765..b1672fbbed 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/grid/GridApplyFilterWhenScrolledDown.java +++ b/uitest/src/main/java/com/vaadin/tests/components/grid/GridApplyFilterWhenScrolledDown.java @@ -5,7 +5,7 @@ import java.util.List; import com.vaadin.server.SerializableFunction; import com.vaadin.server.VaadinRequest; -import com.vaadin.server.data.DataSource; +import com.vaadin.server.data.DataProvider; import com.vaadin.tests.components.AbstractTestUI; import com.vaadin.ui.Button; import com.vaadin.ui.Grid; @@ -28,15 +28,15 @@ public class GridApplyFilterWhenScrolledDown extends AbstractTestUI { addComponent(grid); Button button = new Button("Filter Test item", - event -> filter(grid.getDataSource(), data)); + event -> filter(grid.getDataProvider(), data)); addComponent(button); } - private void filter(DataSource dataSource, List data) { + private void filter(DataProvider dataProvider, List data) { String last = data.get(data.size() - 1); data.clear(); data.add(last); - dataSource.refreshAll(); + dataProvider.refreshAll(); } -} \ No newline at end of file +} diff --git a/uitest/src/main/java/com/vaadin/tests/components/grid/basics/RefreshDataSource.java b/uitest/src/main/java/com/vaadin/tests/components/grid/basics/RefreshDataProvider.java similarity index 70% rename from uitest/src/main/java/com/vaadin/tests/components/grid/basics/RefreshDataSource.java rename to uitest/src/main/java/com/vaadin/tests/components/grid/basics/RefreshDataProvider.java index fec3e4aee3..288bc190f3 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/grid/basics/RefreshDataSource.java +++ b/uitest/src/main/java/com/vaadin/tests/components/grid/basics/RefreshDataProvider.java @@ -18,8 +18,8 @@ package com.vaadin.tests.components.grid.basics; import java.util.List; import com.vaadin.server.VaadinRequest; -import com.vaadin.server.data.DataSource; -import com.vaadin.server.data.ListDataSource; +import com.vaadin.server.data.DataProvider; +import com.vaadin.server.data.ListDataProvider; import com.vaadin.tests.components.AbstractReindeerTestUI; import com.vaadin.ui.Button; import com.vaadin.ui.Grid; @@ -28,52 +28,52 @@ import com.vaadin.ui.Grid; * @author Vaadin Ltd * */ -public class RefreshDataSource extends AbstractReindeerTestUI { +public class RefreshDataProvider extends AbstractReindeerTestUI { @Override protected void setup(VaadinRequest request) { Grid grid = new Grid<>(); List data = DataObject.generateObjects(); - ListDataSource dataSource = DataSource.create(data); - grid.setDataSource(dataSource); + ListDataProvider dataProvider = DataProvider.create(data); + grid.setDataProvider(dataProvider); - grid.setDataSource(dataSource); + grid.setDataProvider(dataProvider); grid.addColumn("Coordinates", DataObject::getCoordinates); addComponent(grid); Button update = new Button("Update data", - event -> updateData(dataSource, data)); + event -> updateData(dataProvider, data)); update.setId("update"); addComponent(update); - Button add = new Button("Add data", event -> addData(dataSource, data)); + Button add = new Button("Add data", event -> addData(dataProvider, data)); add.setId("add"); addComponent(add); Button remove = new Button("Remove data", - event -> removeData(dataSource, data)); + event -> removeData(dataProvider, data)); remove.setId("remove"); addComponent(remove); } - private void updateData(DataSource dataSource, + private void updateData(DataProvider dataProvider, List data) { data.get(0).setCoordinates("Updated coordinates"); - dataSource.refreshAll(); + dataProvider.refreshAll(); } - private void addData(DataSource dataSource, + private void addData(DataProvider dataProvider, List data) { DataObject dataObject = new DataObject(); dataObject.setCoordinates("Added"); data.add(0, dataObject); - dataSource.refreshAll(); + dataProvider.refreshAll(); } - private void removeData(DataSource dataSource, + private void removeData(DataProvider dataProvider, List data) { data.remove(0); - dataSource.refreshAll(); + dataProvider.refreshAll(); } } diff --git a/uitest/src/main/java/com/vaadin/tests/components/listselect/ListSelectAddRemoveItems.java b/uitest/src/main/java/com/vaadin/tests/components/listselect/ListSelectAddRemoveItems.java index d78025bf4c..0ee679e891 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/listselect/ListSelectAddRemoveItems.java +++ b/uitest/src/main/java/com/vaadin/tests/components/listselect/ListSelectAddRemoveItems.java @@ -21,21 +21,21 @@ import java.util.List; import java.util.stream.Collectors; import com.vaadin.server.VaadinRequest; -import com.vaadin.server.data.ListDataSource; +import com.vaadin.server.data.ListDataProvider; import com.vaadin.tests.components.AbstractTestUIWithLog; import com.vaadin.ui.Button; import com.vaadin.ui.ListSelect; -// FIXME this test should be updated once the datasource supports CRUD operations #77 +// FIXME this test should be updated once the provider supports CRUD operations #77 public class ListSelectAddRemoveItems extends AbstractTestUIWithLog { - private ListDataSource dataSource = new ListDataSource<>( + private ListDataProvider dataProvider = new ListDataProvider<>( Collections.emptyList()); private ListSelect listSelect; @Override protected void setup(VaadinRequest request) { - listSelect = new ListSelect<>("ListSelect", dataSource); + listSelect = new ListSelect<>("ListSelect", dataProvider); listSelect.setWidth("100px"); listSelect.setRows(10); @@ -50,69 +50,69 @@ public class ListSelectAddRemoveItems extends AbstractTestUIWithLog { })); addComponent(new Button("Add first", event -> { - List list = dataSource.fetch(null) + List list = dataProvider.fetch(null) .collect(Collectors.toList()); list.add(0, "first"); - dataSource = new ListDataSource<>(list); - listSelect.setDataSource(dataSource); + dataProvider = new ListDataProvider<>(list); + listSelect.setDataProvider(dataProvider); logContainer(); })); addComponent(new Button("Add middle", event -> { - List list = dataSource.fetch(null) + List list = dataProvider.fetch(null) .collect(Collectors.toList()); list.add(list.size() / 2, "middle"); - dataSource = new ListDataSource<>(list); - listSelect.setDataSource(dataSource); + dataProvider = new ListDataProvider<>(list); + listSelect.setDataProvider(dataProvider); logContainer(); })); addComponent(new Button("Add last", event -> { - List list = dataSource.fetch(null) + List list = dataProvider.fetch(null) .collect(Collectors.toList()); list.add("last"); - dataSource = new ListDataSource<>(list); - listSelect.setDataSource(dataSource); + dataProvider = new ListDataProvider<>(list); + listSelect.setDataProvider(dataProvider); logContainer(); })); addComponent(new Button("Swap", event -> { - List list = dataSource.fetch(null) + List list = dataProvider.fetch(null) .collect(Collectors.toList()); Collections.swap(list, 0, list.size() - 1); - dataSource = new ListDataSource<>(list); - listSelect.setDataSource(dataSource); + dataProvider = new ListDataProvider<>(list); + listSelect.setDataProvider(dataProvider); logContainer(); })); addComponent(new Button("Remove first", event -> { - List list = dataSource.fetch(null) + List list = dataProvider.fetch(null) .collect(Collectors.toList()); list.remove(0); - dataSource = new ListDataSource<>(list); - listSelect.setDataSource(dataSource); + dataProvider = new ListDataProvider<>(list); + listSelect.setDataProvider(dataProvider); logContainer(); })); addComponent(new Button("Remove middle", event -> { - List list = dataSource.fetch(null) + List list = dataProvider.fetch(null) .collect(Collectors.toList()); list.remove(list.size() / 2); - dataSource = new ListDataSource<>(list); - listSelect.setDataSource(dataSource); + dataProvider = new ListDataProvider<>(list); + listSelect.setDataProvider(dataProvider); logContainer(); })); addComponent(new Button("Remove last", event -> { - List list = dataSource.fetch(null) + List list = dataProvider.fetch(null) .collect(Collectors.toList()); list.remove(list.size() - 1); - dataSource = new ListDataSource<>(list); - listSelect.setDataSource(dataSource); + dataProvider = new ListDataProvider<>(list); + listSelect.setDataProvider(dataProvider); logContainer(); })); @@ -121,7 +121,7 @@ public class ListSelectAddRemoveItems extends AbstractTestUIWithLog { private void logContainer() { StringBuilder b = new StringBuilder(); - List list = dataSource.fetch(null).collect(Collectors.toList()); + List list = dataProvider.fetch(null).collect(Collectors.toList()); for (int i = 0; i < list.size(); i++) { Object id = list.get(i); if (i != 0) { @@ -134,8 +134,8 @@ public class ListSelectAddRemoveItems extends AbstractTestUIWithLog { } public void resetContainer() { - dataSource = new ListDataSource<>(Arrays.asList("a", "b", "c")); - listSelect.setDataSource(dataSource); + dataProvider = new ListDataProvider<>(Arrays.asList("a", "b", "c")); + listSelect.setDataProvider(dataProvider); } @Override diff --git a/uitest/src/main/java/com/vaadin/tests/components/radiobutton/RadioButtonGroupTestUI.java b/uitest/src/main/java/com/vaadin/tests/components/radiobutton/RadioButtonGroupTestUI.java index 246441598b..07e5b2c4d0 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/radiobutton/RadioButtonGroupTestUI.java +++ b/uitest/src/main/java/com/vaadin/tests/components/radiobutton/RadioButtonGroupTestUI.java @@ -75,7 +75,7 @@ public class RadioButtonGroupTestUI } else { group.setItemIconGenerator(item -> null); } - group.getDataSource().refreshAll(); + group.getDataProvider().refreshAll(); } private void createItemCaptionGeneratorMenu() { @@ -88,7 +88,7 @@ public class RadioButtonGroupTestUI createSelectAction("Item Caption Generator", "Item Caption Generator", options, "None", (radioButtonGroup, captionGenerator, data) -> { radioButtonGroup.setItemCaptionGenerator(captionGenerator); - radioButtonGroup.getDataSource().refreshAll(); + radioButtonGroup.getDataProvider().refreshAll(); }, true); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/slider/SliderValueFromDataSource.java b/uitest/src/main/java/com/vaadin/tests/components/slider/SliderValueFromDataSource.java index 9d147eb3b5..6f9bd6b4ef 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/slider/SliderValueFromDataSource.java +++ b/uitest/src/main/java/com/vaadin/tests/components/slider/SliderValueFromDataSource.java @@ -47,7 +47,7 @@ public class SliderValueFromDataSource extends AbstractReindeerTestUI { @Override protected String getTestDescription() { - return "Slider and ProgressBar do not properly pass a value from data source to the client"; + return "Slider and ProgressBar do not properly pass a value from data provider to the client"; } @Override diff --git a/uitest/src/main/java/com/vaadin/tests/data/DummyData.java b/uitest/src/main/java/com/vaadin/tests/data/DummyData.java index cc1e60e7b0..fdf8a710d0 100644 --- a/uitest/src/main/java/com/vaadin/tests/data/DummyData.java +++ b/uitest/src/main/java/com/vaadin/tests/data/DummyData.java @@ -9,7 +9,7 @@ import java.util.stream.Stream; import com.vaadin.annotations.Widgetset; import com.vaadin.server.VaadinRequest; -import com.vaadin.server.data.ListDataSource; +import com.vaadin.server.data.ListDataProvider; import com.vaadin.server.data.Query; import com.vaadin.shared.data.DataCommunicatorConstants; import com.vaadin.tests.components.AbstractTestUIWithLog; @@ -22,12 +22,12 @@ import com.vaadin.ui.HorizontalLayout; public class DummyData extends AbstractTestUIWithLog { /** - * DataSource that keeps track on how often the data is requested. + * DataProvider that keeps track on how often the data is requested. */ - private class LoggingDataSource extends ListDataSource { + private class LoggingDataProvider extends ListDataProvider { private int count = 0; - private LoggingDataSource(Collection collection) { + private LoggingDataProvider(Collection collection) { super(collection); } @@ -80,7 +80,7 @@ public class DummyData extends AbstractTestUIWithLog { for (int i = 0; i < 300; ++i) { items.add("Foo " + i); } - dummy.setDataSource(new LoggingDataSource(items)); + dummy.setDataProvider(new LoggingDataProvider(items)); dummy.setValue("Foo 200"); HorizontalLayout controls = new HorizontalLayout(); @@ -88,11 +88,11 @@ public class DummyData extends AbstractTestUIWithLog { controls.addComponent(new Button("Select Foo 20", e -> { dummy.setValue("Foo " + 20); })); - controls.addComponent(new Button("Reset data source", e -> { - dummy.setDataSource(new LoggingDataSource(items)); + controls.addComponent(new Button("Reset data provider", e -> { + dummy.setDataProvider(new LoggingDataProvider(items)); })); controls.addComponent(new Button("Remove all data", e -> { - dummy.setDataSource(new LoggingDataSource(Collections.emptyList())); + dummy.setDataProvider(new LoggingDataProvider(Collections.emptyList())); })); addComponent(dummy); } diff --git a/uitest/src/main/java/com/vaadin/tests/layouts/MovingComponentsWhileOldParentInvisible.java b/uitest/src/main/java/com/vaadin/tests/layouts/MovingComponentsWhileOldParentInvisible.java index 910265696f..16e131da76 100644 --- a/uitest/src/main/java/com/vaadin/tests/layouts/MovingComponentsWhileOldParentInvisible.java +++ b/uitest/src/main/java/com/vaadin/tests/layouts/MovingComponentsWhileOldParentInvisible.java @@ -53,7 +53,7 @@ public class MovingComponentsWhileOldParentInvisible extends TestBase { }); componentContainerSelect.setValue(componentContainerSelect - .getDataSource().fetch(new Query()).iterator().next()); + .getDataProvider().fetch(new Query()).iterator().next()); Button but1 = new Button("Move in and out of component container", new Button.ClickListener() { diff --git a/uitest/src/main/java/com/vaadin/tests/performance/AbstractBeansMemoryTest.java b/uitest/src/main/java/com/vaadin/tests/performance/AbstractBeansMemoryTest.java index 526b758e22..8f352e23f3 100644 --- a/uitest/src/main/java/com/vaadin/tests/performance/AbstractBeansMemoryTest.java +++ b/uitest/src/main/java/com/vaadin/tests/performance/AbstractBeansMemoryTest.java @@ -175,7 +175,7 @@ public abstract class AbstractBeansMemoryTest private Component createMenu(T component) { MenuBar menu = new MenuBar(); createContainerSizeMenu(menu.addItem("Size", null), component); - createContainerMenu(menu.addItem("Data source", null), component); + createContainerMenu(menu.addItem("Data provider", null), component); menu.addItem("Create only data", item -> toggleDataOnly(item, component)).setCheckable(true); @@ -208,7 +208,7 @@ public abstract class AbstractBeansMemoryTest private MenuItem addContainerSizeMenu(int size, MenuItem menu, T component) { - MenuItem item = menu.addItem("Set data source size to " + size, + MenuItem item = menu.addItem("Set data provider size to " + size, itm -> setData(itm, size, component, isInMemory)); item.setCheckable(true); return item; diff --git a/uitest/src/main/java/com/vaadin/tests/util/ItemDataSource.java b/uitest/src/main/java/com/vaadin/tests/util/ItemDataProvider.java similarity index 57% rename from uitest/src/main/java/com/vaadin/tests/util/ItemDataSource.java rename to uitest/src/main/java/com/vaadin/tests/util/ItemDataProvider.java index e7a184f6da..5d207720d0 100644 --- a/uitest/src/main/java/com/vaadin/tests/util/ItemDataSource.java +++ b/uitest/src/main/java/com/vaadin/tests/util/ItemDataProvider.java @@ -2,16 +2,16 @@ package com.vaadin.tests.util; import java.util.stream.IntStream; -import com.vaadin.server.data.BackEndDataSource; +import com.vaadin.server.data.BackEndDataProvider; /** - * A data source for tests that creates "Item n" strings on the fly. + * A data provider for tests that creates "Item n" strings on the fly. * * @author Vaadin Ltd */ -public class ItemDataSource extends BackEndDataSource { +public class ItemDataProvider extends BackEndDataProvider { - public ItemDataSource(int size) { + public ItemDataProvider(int size) { super(q -> IntStream .range(q.getOffset(), Math.max(q.getOffset() + q.getLimit() + 1, size)) diff --git a/uitest/src/test/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupTest.java b/uitest/src/test/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupTest.java index b4e462a983..65c12e2687 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/checkboxgroup/CheckBoxGroupTest.java @@ -55,13 +55,13 @@ public class CheckBoxGroupTest extends MultiBrowserTest { @Test public void initialItems_reduceItemCount_containsCorrectItems() { - selectMenuPath("Component", "Data source", "Items", "5"); + selectMenuPath("Component", "Data provider", "Items", "5"); assertItems(5); } @Test public void initialItems_increaseItemCount_containsCorrectItems() { - selectMenuPath("Component", "Data source", "Items", "100"); + selectMenuPath("Component", "Data provider", "Items", "100"); assertItems(100); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/grid/basics/RefreshDataSourceTest.java b/uitest/src/test/java/com/vaadin/tests/components/grid/basics/RefreshDataProviderTest.java similarity index 96% rename from uitest/src/test/java/com/vaadin/tests/components/grid/basics/RefreshDataSourceTest.java rename to uitest/src/test/java/com/vaadin/tests/components/grid/basics/RefreshDataProviderTest.java index e73bbd602c..7c60bb9572 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/grid/basics/RefreshDataSourceTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/grid/basics/RefreshDataProviderTest.java @@ -26,7 +26,7 @@ import com.vaadin.tests.tb3.MultiBrowserTest; * @author Vaadin Ltd * */ -public class RefreshDataSourceTest extends MultiBrowserTest { +public class RefreshDataProviderTest extends MultiBrowserTest { @Test public void updateFirstRow() { @@ -61,4 +61,4 @@ public class RefreshDataSourceTest extends MultiBrowserTest { old, first.getText()); } -} \ No newline at end of file +} diff --git a/uitest/src/test/java/com/vaadin/tests/components/listselect/ListSelectTest.java b/uitest/src/test/java/com/vaadin/tests/components/listselect/ListSelectTest.java index 68011d7813..d934fa448f 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/listselect/ListSelectTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/listselect/ListSelectTest.java @@ -32,13 +32,13 @@ public class ListSelectTest extends SingleBrowserTestPhantomJS2 { @Test public void initialItems_reduceItemCount_containsCorrectItems() { - selectMenuPath("Component", "Data source", "Items", "5"); + selectMenuPath("Component", "Data provider", "Items", "5"); assertItems(5); } @Test public void initialItems_increaseItemCount_containsCorrectItems() { - selectMenuPath("Component", "Data source", "Items", "100"); + selectMenuPath("Component", "Data provider", "Items", "100"); assertItems(100); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/nativeselect/NativeSelectTest.java b/uitest/src/test/java/com/vaadin/tests/components/nativeselect/NativeSelectTest.java index 364e53aa75..abb7acb428 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/nativeselect/NativeSelectTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/nativeselect/NativeSelectTest.java @@ -39,13 +39,13 @@ public class NativeSelectTest extends MultiBrowserTest { @Test public void initialItems_reduceItemCount_containsCorrectItems() { - selectMenuPath("Component", "Data source", "Items", "5"); + selectMenuPath("Component", "Data provider", "Items", "5"); assertItems(5); } @Test public void initialItems_increaseItemCount_containsCorrectItems() { - selectMenuPath("Component", "Data source", "Items", "100"); + selectMenuPath("Component", "Data provider", "Items", "100"); assertItems(100); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/radiobutton/RadioButtonGroupTest.java b/uitest/src/test/java/com/vaadin/tests/components/radiobutton/RadioButtonGroupTest.java index b2546347dd..bff6e85b98 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/radiobutton/RadioButtonGroupTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/radiobutton/RadioButtonGroupTest.java @@ -50,13 +50,13 @@ public class RadioButtonGroupTest extends MultiBrowserTest { @Test public void initialItems_reduceItemCount_containsCorrectItems() { - selectMenuPath("Component", "Data source", "Items", "5"); + selectMenuPath("Component", "Data provider", "Items", "5"); assertItems(5); } @Test public void initialItems_increaseItemCount_containsCorrectItems() { - selectMenuPath("Component", "Data source", "Items", "100"); + selectMenuPath("Component", "Data provider", "Items", "100"); assertItems(100); } diff --git a/uitest/src/test/java/com/vaadin/tests/components/twincolselect/TwinColSelectTest.java b/uitest/src/test/java/com/vaadin/tests/components/twincolselect/TwinColSelectTest.java index ad2752112f..cc819a2744 100644 --- a/uitest/src/test/java/com/vaadin/tests/components/twincolselect/TwinColSelectTest.java +++ b/uitest/src/test/java/com/vaadin/tests/components/twincolselect/TwinColSelectTest.java @@ -32,19 +32,19 @@ public class TwinColSelectTest extends MultiBrowserTest { @Test public void initialItems_reduceItemCount_containsCorrectItems() { - selectMenuPath("Component", "Data source", "Items", "5"); + selectMenuPath("Component", "Data provider", "Items", "5"); assertItems(5); } @Test public void initialItems_increaseItemCount_containsCorrectItems() { - selectMenuPath("Component", "Data source", "Items", "100"); + selectMenuPath("Component", "Data provider", "Items", "100"); assertItems(100); } @Test public void itemsMovedFromLeftToRight() { - selectMenuPath("Component", "Data source", "Items", "5"); + selectMenuPath("Component", "Data provider", "Items", "5"); assertItems(5); selectItems("Item 1", "Item 2", "Item 4"); diff --git a/uitest/src/test/java/com/vaadin/tests/data/DummyDataTest.java b/uitest/src/test/java/com/vaadin/tests/data/DummyDataTest.java index 1e9f0f9ade..b05c64e713 100644 --- a/uitest/src/test/java/com/vaadin/tests/data/DummyDataTest.java +++ b/uitest/src/test/java/com/vaadin/tests/data/DummyDataTest.java @@ -57,10 +57,10 @@ public class DummyDataTest extends SingleBrowserTest { } @Test - public void testDataSourceChangeOnlyOneRequest() { - // Change to a new logging data source + public void testDataProviderChangeOnlyOneRequest() { + // Change to a new logging data provider $(ButtonElement.class).get(1).click(); - assertEquals("DataSource change should only cause 1 request", + assertEquals("DataProvider change should only cause 1 request", "3. Backend request #0", getLogRow(0)); } @@ -69,12 +69,12 @@ public class DummyDataTest extends SingleBrowserTest { assertEquals("Unexpected amount of content on init.", 300, $(DummyElement.class).first() .findElements(By.className("v-label")).size()); - // Change to an empty data source + // Change to an empty data provider $(ButtonElement.class).get(2).click(); - assertEquals("Empty data source did not work as expected.", 0, + assertEquals("Empty data provider did not work as expected.", 0, $(DummyElement.class).first() .findElements(By.className("v-label")).size()); - // Change back to logging data source + // Change back to logging data provider $(ButtonElement.class).get(1).click(); assertEquals("Data was not correctly restored.", 300, $(DummyElement.class).first() -- 2.39.5