summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorLeif Åstrand <legioth@gmail.com>2017-01-13 10:08:01 +0200
committerGitHub <noreply@github.com>2017-01-13 10:08:01 +0200
commit0c471fbab5149b2bf7851631706cef2fda29a1d9 (patch)
tree7468dd851162b61d3dfdffea87b147350f10965e /server
parent253a61c1957941759deff87518989a71c30fc301 (diff)
downloadvaadin-framework-0c471fbab5149b2bf7851631706cef2fda29a1d9.tar.gz
vaadin-framework-0c471fbab5149b2bf7851631706cef2fda29a1d9.zip
Replace Listing with HasDataProvider and HasFilterableDataProvider (#8122)
* Replace Listing with HasDataProvider and HasFilterableDataProvider The type parameters of the Listing interface does in practice mean that it isn't useful for anything. This patch replaces that interface with separate types for components that require filterable data providers and components that support any kind of data provider. The setItem methods are extracted to a common interface that is also directly implemented by AbstractListing.
Diffstat (limited to 'server')
-rw-r--r--server/src/main/java/com/vaadin/data/HasDataProvider.java60
-rw-r--r--server/src/main/java/com/vaadin/data/HasFilterableDataProvider.java54
-rw-r--r--server/src/main/java/com/vaadin/data/HasItems.java76
-rw-r--r--server/src/main/java/com/vaadin/data/Listing.java113
-rw-r--r--server/src/main/java/com/vaadin/data/provider/DataProvider.java10
-rw-r--r--server/src/main/java/com/vaadin/ui/AbstractListing.java16
-rw-r--r--server/src/main/java/com/vaadin/ui/AbstractMultiSelect.java7
-rw-r--r--server/src/main/java/com/vaadin/ui/AbstractSingleSelect.java11
-rw-r--r--server/src/main/java/com/vaadin/ui/CheckBoxGroup.java11
-rw-r--r--server/src/main/java/com/vaadin/ui/ComboBox.java18
-rw-r--r--server/src/main/java/com/vaadin/ui/Grid.java6
-rw-r--r--server/src/main/java/com/vaadin/ui/ListSelect.java4
-rw-r--r--server/src/main/java/com/vaadin/ui/NativeSelect.java4
-rw-r--r--server/src/main/java/com/vaadin/ui/RadioButtonGroup.java11
-rw-r--r--server/src/main/java/com/vaadin/ui/TwinColSelect.java4
-rw-r--r--server/src/test/java/com/vaadin/tests/server/component/abstractlisting/AbstractListingDeclarativeTest.java10
-rw-r--r--server/src/test/java/com/vaadin/tests/server/component/abstractmultiselect/AbstractMultiSelectDeclarativeTest.java3
-rw-r--r--server/src/test/java/com/vaadin/tests/server/component/abstractsingleselect/AbstractSingleSelectDeclarativeTest.java3
-rw-r--r--server/src/test/java/com/vaadin/ui/AbstractListingTest.java4
-rw-r--r--server/src/test/java/com/vaadin/ui/AbstractMultiSelectTest.java20
-rw-r--r--server/src/test/java/com/vaadin/ui/AbstractSingleSelectTest.java11
21 files changed, 268 insertions, 188 deletions
diff --git a/server/src/main/java/com/vaadin/data/HasDataProvider.java b/server/src/main/java/com/vaadin/data/HasDataProvider.java
new file mode 100644
index 0000000000..142ef29336
--- /dev/null
+++ b/server/src/main/java/com/vaadin/data/HasDataProvider.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2000-2016 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.data;
+
+import java.util.Collection;
+
+import com.vaadin.data.provider.DataProvider;
+
+/**
+ * A generic interface for listing components that use a data provider for
+ * showing data.
+ * <p>
+ * A listing component should implement either this interface or
+ * {@link HasFilterableDataProvider}, but not both.
+ *
+ * @author Vaadin Ltd.
+ *
+ * @param <T>
+ * the item data type
+ * @since 8.0
+ *
+ * @see HasFilterableDataProvider
+ */
+public interface HasDataProvider<T> extends HasItems<T> {
+
+ /**
+ * Returns the source of data items used by this listing.
+ *
+ * @return the data provider, not null
+ */
+ public DataProvider<T, ?> getDataProvider();
+
+ /**
+ * Sets the data provider for this listing. The data provider is queried for
+ * displayed items as needed.
+ *
+ * @param dataProvider
+ * the data provider, not null
+ */
+ public void setDataProvider(DataProvider<T, ?> dataProvider);
+
+ @Override
+ public default void setItems(Collection<T> items) {
+ setDataProvider(DataProvider.create(items));
+ }
+
+}
diff --git a/server/src/main/java/com/vaadin/data/HasFilterableDataProvider.java b/server/src/main/java/com/vaadin/data/HasFilterableDataProvider.java
new file mode 100644
index 0000000000..03e2e30379
--- /dev/null
+++ b/server/src/main/java/com/vaadin/data/HasFilterableDataProvider.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2000-2016 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.data;
+
+import com.vaadin.data.provider.DataProvider;
+
+/**
+ * A generic interface for listing components that use a filterable data
+ * provider for showing data.
+ * <p>
+ * A listing component should implement either this interface or
+ * {@link HasDataProvider}, but not both.
+ *
+ * @author Vaadin Ltd.
+ *
+ * @param <T>
+ * the item data type
+ * @param <F>
+ * the filter type
+ * @since 8.0
+ *
+ * @see HasDataProvider
+ */
+public interface HasFilterableDataProvider<T, F> extends HasItems<T> {
+
+ /**
+ * Returns the source of data items used by this listing.
+ *
+ * @return the data provider, not null
+ */
+ public DataProvider<T, F> getDataProvider();
+
+ /**
+ * Sets the data provider for this listing. The data provider is queried for
+ * displayed items as needed.
+ *
+ * @param dataProvider
+ * the data provider, not null
+ */
+ public void setDataProvider(DataProvider<T, F> dataProvider);
+}
diff --git a/server/src/main/java/com/vaadin/data/HasItems.java b/server/src/main/java/com/vaadin/data/HasItems.java
new file mode 100644
index 0000000000..22023d55b2
--- /dev/null
+++ b/server/src/main/java/com/vaadin/data/HasItems.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2000-2016 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.data;
+
+import java.io.Serializable;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import com.vaadin.data.provider.BackEndDataProvider;
+import com.vaadin.ui.Component;
+
+/**
+ * A component that displays a collection of items.
+ *
+ * @author Vaadin Ltd
+ *
+ * @param <T>
+ * the type of the displayed item
+ */
+public interface HasItems<T> extends Component, Serializable {
+ /**
+ * Sets the data items of this component provided as a collection.
+ * <p>
+ * The provided collection instance may be used as-is. Subsequent
+ * modification of the collection might cause inconsistent data to be shown
+ * in the component unless it is explicitly instructed to read the data
+ * again.
+ *
+ * @param items
+ * the data items to display, not null
+ *
+ */
+ public void setItems(Collection<T> items);
+
+ /**
+ * Sets the data items of this listing.
+ *
+ * @param items
+ * the data items to display
+ */
+ public default void setItems(@SuppressWarnings("unchecked") T... items) {
+ setItems(Arrays.asList(items));
+ }
+
+ /**
+ * Sets the data items of this listing provided as a stream.
+ * <p>
+ * This is just a shorthand for {@link #setItems(Collection)}, by
+ * <b>collecting all the items in the stream to a list</b>.
+ * <p>
+ * <strong>Using big streams is not recommended, you should instead use a
+ * lazy data provider.</strong> See {@link BackEndDataProvider} for more
+ * info.
+ *
+ * @param streamOfItems
+ * the stream of data items to display, not {@code null}
+ */
+ public default void setItems(Stream<T> streamOfItems) {
+ setItems(streamOfItems.collect(Collectors.toList()));
+ }
+}
diff --git a/server/src/main/java/com/vaadin/data/Listing.java b/server/src/main/java/com/vaadin/data/Listing.java
deleted file mode 100644
index 064948e3ba..0000000000
--- a/server/src/main/java/com/vaadin/data/Listing.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright 2000-2016 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.data;
-
-import java.io.Serializable;
-import java.util.Collection;
-import java.util.stream.Stream;
-
-import com.vaadin.data.provider.BackEndDataProvider;
-import com.vaadin.data.provider.DataProvider;
-import com.vaadin.ui.Component;
-
-/**
- * A generic interface for components that show a list of data.
- *
- * @author Vaadin Ltd.
- *
- * @param <T>
- * the item data type
- * @param <D>
- * the data provider type; used to provide constraints on the data
- * provider and filter
- * @since 8.0
- */
-public interface Listing<T, D extends DataProvider<T, ?>>
- extends Component, Serializable {
-
- /**
- * Returns the source of data items used by this listing.
- *
- * @return the data provider, not null
- */
- D getDataProvider();
-
- /**
- * Sets the data provider for this listing. The data provider is queried for
- * displayed items as needed.
- *
- * @param dataProvider
- * the data provider, not null
- */
- void setDataProvider(D dataProvider);
-
- /**
- * Sets the data items of this listing provided as a collection.
- * <p>
- * <strong>Note for component developers: </strong> If the component
- * implementing this interface uses a custom data provider and/or filter
- * types, this method should be overridden to provide the same functionality
- * with the correct data provider type. This might require filter conversion
- * or a completely custom implementation.
- *
- * @param items
- * the data items to display, not null
- *
- */
- default void setItems(Collection<T> items) {
- setDataProvider((D) DataProvider.create(items));
- }
-
- /**
- * Sets the data items of this listing.
- * <p>
- * <strong>Note for component developers: </strong> If the component
- * implementing this interface uses a custom data provider and/or filter
- * types, this method should be overridden to provide the same functionality
- * with the correct data provider type. This might require filter conversion
- * or a completely custom implementation.
- *
- * @param items
- * the data items to display
- */
- default void setItems(@SuppressWarnings("unchecked") T... items) {
- setDataProvider((D) DataProvider.create(items));
- }
-
- /**
- * Sets the data items of this listing provided as a stream.
- * <p>
- * This is just a shorthand for {@link #setItems(Collection)}, by
- * <b>collecting all the items in the stream to a list</b>.
- * <p>
- * <strong>Using big streams is not recommended, you should instead use a
- * lazy data provider.</strong> See {@link BackEndDataProvider} for more
- * info.
- * <p>
- * <strong>Note for component developers: </strong> If the component
- * implementing this interface uses a custom data provider and/or filter
- * types, this method should be overridden to provide the same functionality
- * with the correct data provider type. This might require filter conversion
- * or a completely custom implementation.
- *
- * @param streamOfItems
- * the stream of data items to display, not {@code null}
- */
- default void setItems(Stream<T> streamOfItems) {
- setDataProvider((D) DataProvider.create(streamOfItems));
- }
-
-}
diff --git a/server/src/main/java/com/vaadin/data/provider/DataProvider.java b/server/src/main/java/com/vaadin/data/provider/DataProvider.java
index 8bc4aa3d4b..cdf3387212 100644
--- a/server/src/main/java/com/vaadin/data/provider/DataProvider.java
+++ b/server/src/main/java/com/vaadin/data/provider/DataProvider.java
@@ -22,15 +22,17 @@ import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-import com.vaadin.data.Listing;
+import com.vaadin.data.HasDataProvider;
+import com.vaadin.data.HasFilterableDataProvider;
import com.vaadin.server.SerializableFunction;
import com.vaadin.shared.Registration;
/**
* A common interface for fetching data from a backend. The {@link DataProvider}
- * interface is used by {@link Listing} components. The listing component will
- * provide a {@link Query} object with request information, and the data
- * provider uses this information to return a stream containing requested beans.
+ * interface is used by listing components implementing {@link HasDataProvider}
+ * or {@link HasFilterableDataProvider}. The listing component will provide a
+ * {@link Query} object with request information, and the data provider uses
+ * this information to return a stream containing requested beans.
* <p>
* Vaadin comes with a ready-made solution for in-memory data, known as
* {@link ListDataProvider} which can be created using static {@code create}
diff --git a/server/src/main/java/com/vaadin/ui/AbstractListing.java b/server/src/main/java/com/vaadin/ui/AbstractListing.java
index cacc9240f2..c3328683a1 100644
--- a/server/src/main/java/com/vaadin/ui/AbstractListing.java
+++ b/server/src/main/java/com/vaadin/ui/AbstractListing.java
@@ -20,7 +20,9 @@ import java.util.Objects;
import org.jsoup.nodes.Attributes;
import org.jsoup.nodes.Element;
-import com.vaadin.data.Listing;
+import com.vaadin.data.HasDataProvider;
+import com.vaadin.data.HasFilterableDataProvider;
+import com.vaadin.data.HasItems;
import com.vaadin.data.provider.DataCommunicator;
import com.vaadin.data.provider.DataGenerator;
import com.vaadin.data.provider.DataProvider;
@@ -40,7 +42,7 @@ import com.vaadin.ui.declarative.DesignFormatter;
* backend data items, selection logic, and server-client communication.
* <p>
* <strong>Note: </strong> concrete component implementations should implement
- * the {@link Listing} interface.
+ * the {@link HasDataProvider} or {@link HasFilterableDataProvider} interface.
*
* @author Vaadin Ltd.
* @since 8.0
@@ -48,10 +50,9 @@ import com.vaadin.ui.declarative.DesignFormatter;
* @param <T>
* the item data type
*
- * @see Listing
*/
public abstract class AbstractListing<T> extends AbstractComponent
- implements Focusable {
+ implements Focusable, HasItems<T> {
/**
* The item icon caption provider.
*/
@@ -269,9 +270,10 @@ public abstract class AbstractListing<T> extends AbstractComponent
/**
* Writes listing specific state into the given design.
* <p>
- * This method is separated from {@link #writeDesign(Element, DesignContext)}
- * to be overridable in subclasses that need to replace this, but still must
- * be able to call {@code super.writeDesign(...)}.
+ * This method is separated from
+ * {@link #writeDesign(Element, DesignContext)} to be overridable in
+ * subclasses that need to replace this, but still must be able to call
+ * {@code super.writeDesign(...)}.
*
* @see #doReadDesign(Element, DesignContext)
*
diff --git a/server/src/main/java/com/vaadin/ui/AbstractMultiSelect.java b/server/src/main/java/com/vaadin/ui/AbstractMultiSelect.java
index e104b1c4e6..22df69da5c 100644
--- a/server/src/main/java/com/vaadin/ui/AbstractMultiSelect.java
+++ b/server/src/main/java/com/vaadin/ui/AbstractMultiSelect.java
@@ -28,7 +28,6 @@ import java.util.stream.Collectors;
import org.jsoup.nodes.Element;
import com.vaadin.data.HasValue;
-import com.vaadin.data.Listing;
import com.vaadin.data.SelectionModel;
import com.vaadin.data.SelectionModel.Multi;
import com.vaadin.data.provider.DataGenerator;
@@ -435,8 +434,8 @@ public abstract class AbstractMultiSelect<T> extends AbstractListing<T>
.map(child -> readItem(child, selected, context))
.collect(Collectors.toList());
deselectAll();
- if (!items.isEmpty() && this instanceof Listing) {
- ((Listing<T, ?>) this).setItems(items);
+ if (!items.isEmpty()) {
+ setItems(items);
}
selected.forEach(this::select);
}
@@ -471,7 +470,7 @@ public abstract class AbstractMultiSelect<T> extends AbstractListing<T>
}
private void updateSelection(SerializableConsumer<Set<T>> handler,
- boolean userOriginated) {
+ boolean userOriginated) {
LinkedHashSet<T> oldSelection = new LinkedHashSet<>(selection);
handler.accept(selection);
diff --git a/server/src/main/java/com/vaadin/ui/AbstractSingleSelect.java b/server/src/main/java/com/vaadin/ui/AbstractSingleSelect.java
index 967b84e6b6..224d6823e7 100644
--- a/server/src/main/java/com/vaadin/ui/AbstractSingleSelect.java
+++ b/server/src/main/java/com/vaadin/ui/AbstractSingleSelect.java
@@ -26,7 +26,6 @@ import java.util.stream.Collectors;
import org.jsoup.nodes.Element;
import com.vaadin.data.HasValue;
-import com.vaadin.data.Listing;
import com.vaadin.data.SelectionModel.Single;
import com.vaadin.data.provider.DataCommunicator;
import com.vaadin.event.selection.SingleSelectionEvent;
@@ -212,9 +211,9 @@ public abstract class AbstractSingleSelect<T> extends AbstractListing<T>
/**
* Sets the selection based on a client request. Does nothing if the select
- * component is {@linkplain #isReadOnly()} or if the selection
- * would not change. Otherwise updates the selection and fires a selection
- * change event with {@code isUserOriginated == true}.
+ * component is {@linkplain #isReadOnly()} or if the selection would not
+ * change. Otherwise updates the selection and fires a selection change
+ * event with {@code isUserOriginated == true}.
*
* @param key
* the key of the item to select or {@code null} to clear
@@ -332,8 +331,8 @@ public abstract class AbstractSingleSelect<T> extends AbstractListing<T>
List<T> items = design.children().stream()
.map(child -> readItem(child, selected, context))
.collect(Collectors.toList());
- if (!items.isEmpty() && this instanceof Listing) {
- ((Listing<T, ?>) this).setItems(items);
+ if (!items.isEmpty()) {
+ setItems(items);
}
selected.forEach(this::setValue);
}
diff --git a/server/src/main/java/com/vaadin/ui/CheckBoxGroup.java b/server/src/main/java/com/vaadin/ui/CheckBoxGroup.java
index a4c48f3515..15d895142a 100644
--- a/server/src/main/java/com/vaadin/ui/CheckBoxGroup.java
+++ b/server/src/main/java/com/vaadin/ui/CheckBoxGroup.java
@@ -21,7 +21,7 @@ import java.util.Set;
import org.jsoup.nodes.Element;
-import com.vaadin.data.Listing;
+import com.vaadin.data.HasDataProvider;
import com.vaadin.data.provider.DataProvider;
import com.vaadin.event.FieldEvents.BlurEvent;
import com.vaadin.event.FieldEvents.BlurListener;
@@ -46,14 +46,13 @@ import com.vaadin.ui.declarative.DesignFormatter;
* @since 8.0
*/
public class CheckBoxGroup<T> extends AbstractMultiSelect<T>
- implements FocusNotifier, BlurNotifier, Listing<T, DataProvider<T, ?>> {
+ implements FocusNotifier, BlurNotifier, HasDataProvider<T> {
/**
* Constructs a new CheckBoxGroup with caption.
*
* @param caption
* caption text
- * @see Listing#setDataProvider(DataProvider)
*/
public CheckBoxGroup(String caption) {
this();
@@ -67,7 +66,7 @@ public class CheckBoxGroup<T> extends AbstractMultiSelect<T>
* the caption text
* @param dataProvider
* the data provider, not null
- * @see Listing#setDataProvider(DataProvider)
+ * @see HasDataProvider#setDataProvider(DataProvider)
*/
public CheckBoxGroup(String caption, DataProvider<T, ?> dataProvider) {
this(caption);
@@ -82,7 +81,7 @@ public class CheckBoxGroup<T> extends AbstractMultiSelect<T>
* the caption text
* @param items
* the data items to use, not null
- * @see Listing#setDataProvider(DataProvider)
+ * @see #setItems(Collection)
*/
public CheckBoxGroup(String caption, Collection<T> items) {
this(caption, DataProvider.create(items));
@@ -90,8 +89,6 @@ public class CheckBoxGroup<T> extends AbstractMultiSelect<T>
/**
* Constructs a new CheckBoxGroup.
- *
- * @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 226269d72e..a789e2990c 100644
--- a/server/src/main/java/com/vaadin/ui/ComboBox.java
+++ b/server/src/main/java/com/vaadin/ui/ComboBox.java
@@ -16,6 +16,7 @@
package com.vaadin.ui;
+import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
@@ -24,8 +25,8 @@ import java.util.Set;
import org.jsoup.nodes.Element;
+import com.vaadin.data.HasFilterableDataProvider;
import com.vaadin.data.HasValue;
-import com.vaadin.data.Listing;
import com.vaadin.data.provider.DataCommunicator;
import com.vaadin.data.provider.DataKeyMapper;
import com.vaadin.data.provider.DataProvider;
@@ -63,7 +64,7 @@ import elemental.json.JsonObject;
@SuppressWarnings("serial")
public class ComboBox<T> extends AbstractSingleSelect<T>
implements HasValue<T>, FieldEvents.BlurNotifier,
- FieldEvents.FocusNotifier, Listing<T, DataProvider<T, String>> {
+ FieldEvents.FocusNotifier, HasFilterableDataProvider<T, String> {
/**
* Handler that adds a new item based on user input when the new items
@@ -221,14 +222,6 @@ public class ComboBox<T> extends AbstractSingleSelect<T>
setDataProvider(provider);
}
- @Override
- public void setItems(@SuppressWarnings("unchecked") T... items) {
- DataProvider<T, String> provider = DataProvider.create(items)
- .convertFilter(filterText -> item -> defaultFilterMethod
- .test(filterText, item));
- setDataProvider(provider);
- }
-
/**
* Sets the data items of this listing and a simple string filter with which
* the item string and the text the user has input are compared.
@@ -264,10 +257,7 @@ public class ComboBox<T> extends AbstractSingleSelect<T>
*/
public void setItems(CaptionFilter captionFilter,
@SuppressWarnings("unchecked") T... items) {
- DataProvider<T, String> provider = DataProvider.create(items)
- .convertFilter(filterText -> item -> captionFilter.test(
- getItemCaptionGenerator().apply(item), filterText));
- setDataProvider(provider);
+ setItems(captionFilter, Arrays.asList(items));
}
/**
diff --git a/server/src/main/java/com/vaadin/ui/Grid.java b/server/src/main/java/com/vaadin/ui/Grid.java
index 16d995b4ae..ae78d5486b 100644
--- a/server/src/main/java/com/vaadin/ui/Grid.java
+++ b/server/src/main/java/com/vaadin/ui/Grid.java
@@ -42,7 +42,7 @@ import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import com.vaadin.data.Binder;
-import com.vaadin.data.Listing;
+import com.vaadin.data.HasDataProvider;
import com.vaadin.data.ValueProvider;
import com.vaadin.data.provider.DataCommunicator;
import com.vaadin.data.provider.DataProvider;
@@ -122,8 +122,8 @@ import elemental.json.JsonValue;
* @param <T>
* the grid bean type
*/
-public class Grid<T> extends AbstractListing<T> implements HasComponents,
- Listing<T, DataProvider<T, ?>>, SortNotifier<Grid.Column<T, ?>> {
+public class Grid<T> extends AbstractListing<T>
+ implements HasComponents, HasDataProvider<T>, SortNotifier<Grid.Column<T, ?>> {
@Deprecated
private static final Method COLUMN_REORDER_METHOD = ReflectTools.findMethod(
diff --git a/server/src/main/java/com/vaadin/ui/ListSelect.java b/server/src/main/java/com/vaadin/ui/ListSelect.java
index 00679d3e5f..1e7c92f14d 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.data.Listing;
+import com.vaadin.data.HasDataProvider;
import com.vaadin.data.provider.DataProvider;
import com.vaadin.shared.ui.listselect.ListSelectState;
@@ -31,7 +31,7 @@ import com.vaadin.shared.ui.listselect.ListSelectState;
* item type
*/
public class ListSelect<T> extends AbstractMultiSelect<T>
- implements Listing<T, DataProvider<T, ?>> {
+ implements HasDataProvider<T> {
/** Default number of rows visible for select. */
// protected to allow javadoc linking
diff --git a/server/src/main/java/com/vaadin/ui/NativeSelect.java b/server/src/main/java/com/vaadin/ui/NativeSelect.java
index 2d0e805d41..9ae3409b66 100644
--- a/server/src/main/java/com/vaadin/ui/NativeSelect.java
+++ b/server/src/main/java/com/vaadin/ui/NativeSelect.java
@@ -18,7 +18,7 @@ package com.vaadin.ui;
import java.util.Collection;
-import com.vaadin.data.Listing;
+import com.vaadin.data.HasDataProvider;
import com.vaadin.data.provider.DataProvider;
import com.vaadin.event.FieldEvents.BlurEvent;
import com.vaadin.event.FieldEvents.BlurListener;
@@ -44,7 +44,7 @@ import com.vaadin.shared.ui.nativeselect.NativeSelectState;
* @see com.vaadin.ui.ComboBox
*/
public class NativeSelect<T> extends AbstractSingleSelect<T>
- implements FocusNotifier, BlurNotifier, Listing<T, DataProvider<T, ?>> {
+ implements FocusNotifier, BlurNotifier, HasDataProvider<T> {
/**
* Creates a new {@code NativeSelect} with an empty caption and no items.
diff --git a/server/src/main/java/com/vaadin/ui/RadioButtonGroup.java b/server/src/main/java/com/vaadin/ui/RadioButtonGroup.java
index 592781cc56..7f2284b08e 100644
--- a/server/src/main/java/com/vaadin/ui/RadioButtonGroup.java
+++ b/server/src/main/java/com/vaadin/ui/RadioButtonGroup.java
@@ -22,7 +22,7 @@ import java.util.Set;
import org.jsoup.nodes.Element;
-import com.vaadin.data.Listing;
+import com.vaadin.data.HasDataProvider;
import com.vaadin.data.provider.DataGenerator;
import com.vaadin.data.provider.DataProvider;
import com.vaadin.event.FieldEvents.BlurEvent;
@@ -53,7 +53,7 @@ import elemental.json.JsonObject;
* @since 8.0
*/
public class RadioButtonGroup<T> extends AbstractSingleSelect<T>
- implements FocusNotifier, BlurNotifier, Listing<T, DataProvider<T, ?>> {
+ implements FocusNotifier, BlurNotifier, HasDataProvider<T> {
private SerializablePredicate<T> itemEnabledProvider = item -> true;
@@ -62,7 +62,6 @@ public class RadioButtonGroup<T> extends AbstractSingleSelect<T>
*
* @param caption
* caption text
- * @see Listing#setDataProvider(DataProvider)
*/
public RadioButtonGroup(String caption) {
this();
@@ -76,7 +75,7 @@ public class RadioButtonGroup<T> extends AbstractSingleSelect<T>
* the caption text
* @param dataProvider
* the data provider, not null
- * @see Listing#setDataProvider(DataProvider)
+ * @see HasDataProvider#setDataProvider(DataProvider)
*/
public RadioButtonGroup(String caption, DataProvider<T, ?> dataProvider) {
this(caption);
@@ -91,7 +90,7 @@ public class RadioButtonGroup<T> extends AbstractSingleSelect<T>
* the caption text
* @param items
* the data items to use, not null
- * @see Listing#setDataProvider(DataProvider)
+ * @see #setItems(Collection)
*/
public RadioButtonGroup(String caption, Collection<T> items) {
this(caption, DataProvider.create(items));
@@ -99,8 +98,6 @@ public class RadioButtonGroup<T> extends AbstractSingleSelect<T>
/**
* Constructs a new RadioButtonGroup.
- *
- * @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 bcc8b52024..fb8a785076 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.data.Listing;
+import com.vaadin.data.HasDataProvider;
import com.vaadin.data.provider.DataProvider;
import com.vaadin.shared.ui.twincolselect.TwinColSelectState;
@@ -32,7 +32,7 @@ import com.vaadin.shared.ui.twincolselect.TwinColSelectState;
* item type
*/
public class TwinColSelect<T> extends AbstractMultiSelect<T>
- implements Listing<T, DataProvider<T, ?>> {
+ implements HasDataProvider<T> {
/**
* Constructs a new TwinColSelect.
diff --git a/server/src/test/java/com/vaadin/tests/server/component/abstractlisting/AbstractListingDeclarativeTest.java b/server/src/test/java/com/vaadin/tests/server/component/abstractlisting/AbstractListingDeclarativeTest.java
index 4da4a49cc1..a3b9e244cf 100644
--- a/server/src/test/java/com/vaadin/tests/server/component/abstractlisting/AbstractListingDeclarativeTest.java
+++ b/server/src/test/java/com/vaadin/tests/server/component/abstractlisting/AbstractListingDeclarativeTest.java
@@ -25,7 +25,6 @@ import java.util.function.Consumer;
import org.junit.Assert;
import org.junit.Test;
-import com.vaadin.data.Listing;
import com.vaadin.data.provider.Query;
import com.vaadin.server.ExternalResource;
import com.vaadin.server.FileResource;
@@ -61,7 +60,7 @@ import com.vaadin.ui.declarative.DesignContext;
* a component type
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
-public abstract class AbstractListingDeclarativeTest<T extends AbstractListing & Listing>
+public abstract class AbstractListingDeclarativeTest<T extends AbstractListing>
extends AbstractComponentDeclarativeTestBase<T> {
private static final String EXTERNAL_URL = "http://example.com/example.gif";
@@ -171,8 +170,11 @@ public abstract class AbstractListingDeclarativeTest<T extends AbstractListing &
private void testReadData(String design, T expected, T read,
DesignContext context) {
- Assert.assertEquals(read.getDataProvider().size(new Query<>()),
- expected.getDataProvider().size(new Query<>()));
+ Assert.assertEquals(
+ read.getDataCommunicator().getDataProvider()
+ .size(new Query<>()),
+ expected.getDataCommunicator().getDataProvider()
+ .size(new Query<>()));
testWrite(read, design, context);
}
diff --git a/server/src/test/java/com/vaadin/tests/server/component/abstractmultiselect/AbstractMultiSelectDeclarativeTest.java b/server/src/test/java/com/vaadin/tests/server/component/abstractmultiselect/AbstractMultiSelectDeclarativeTest.java
index e96bb4bb55..1b11ab11dc 100644
--- a/server/src/test/java/com/vaadin/tests/server/component/abstractmultiselect/AbstractMultiSelectDeclarativeTest.java
+++ b/server/src/test/java/com/vaadin/tests/server/component/abstractmultiselect/AbstractMultiSelectDeclarativeTest.java
@@ -23,7 +23,6 @@ import java.util.List;
import org.junit.Assert;
import org.junit.Test;
-import com.vaadin.data.Listing;
import com.vaadin.tests.design.DeclarativeTestBaseBase;
import com.vaadin.tests.server.component.abstractlisting.AbstractListingDeclarativeTest;
import com.vaadin.ui.AbstractMultiSelect;
@@ -44,7 +43,7 @@ import com.vaadin.ui.declarative.DesignContext;
* a component type
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
-public abstract class AbstractMultiSelectDeclarativeTest<T extends AbstractMultiSelect & Listing>
+public abstract class AbstractMultiSelectDeclarativeTest<T extends AbstractMultiSelect>
extends AbstractListingDeclarativeTest<T> {
@Override
diff --git a/server/src/test/java/com/vaadin/tests/server/component/abstractsingleselect/AbstractSingleSelectDeclarativeTest.java b/server/src/test/java/com/vaadin/tests/server/component/abstractsingleselect/AbstractSingleSelectDeclarativeTest.java
index 182b9045fd..6e46658b86 100644
--- a/server/src/test/java/com/vaadin/tests/server/component/abstractsingleselect/AbstractSingleSelectDeclarativeTest.java
+++ b/server/src/test/java/com/vaadin/tests/server/component/abstractsingleselect/AbstractSingleSelectDeclarativeTest.java
@@ -23,7 +23,6 @@ import java.util.List;
import org.junit.Assert;
import org.junit.Test;
-import com.vaadin.data.Listing;
import com.vaadin.tests.design.DeclarativeTestBaseBase;
import com.vaadin.tests.server.component.abstractlisting.AbstractListingDeclarativeTest;
import com.vaadin.ui.AbstractSingleSelect;
@@ -43,7 +42,7 @@ import com.vaadin.ui.declarative.DesignContext;
* a component type
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
-public abstract class AbstractSingleSelectDeclarativeTest<T extends AbstractSingleSelect & Listing>
+public abstract class AbstractSingleSelectDeclarativeTest<T extends AbstractSingleSelect>
extends AbstractListingDeclarativeTest<T> {
@Override
diff --git a/server/src/test/java/com/vaadin/ui/AbstractListingTest.java b/server/src/test/java/com/vaadin/ui/AbstractListingTest.java
index 212a15f32f..c6cc9a1507 100644
--- a/server/src/test/java/com/vaadin/ui/AbstractListingTest.java
+++ b/server/src/test/java/com/vaadin/ui/AbstractListingTest.java
@@ -11,7 +11,7 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
-import com.vaadin.data.Listing;
+import com.vaadin.data.HasDataProvider;
import com.vaadin.data.provider.BackEndDataProvider;
import com.vaadin.data.provider.DataProvider;
import com.vaadin.data.provider.ListDataProvider;
@@ -24,7 +24,7 @@ import elemental.json.JsonObject;
public class AbstractListingTest {
private final class TestListing extends AbstractSingleSelect<String>
- implements Listing<String, DataProvider<String, ?>> {
+ implements HasDataProvider<String> {
/**
* Used to execute data generation
diff --git a/server/src/test/java/com/vaadin/ui/AbstractMultiSelectTest.java b/server/src/test/java/com/vaadin/ui/AbstractMultiSelectTest.java
index 4b4ddbcae9..abed1563e5 100644
--- a/server/src/test/java/com/vaadin/ui/AbstractMultiSelectTest.java
+++ b/server/src/test/java/com/vaadin/ui/AbstractMultiSelectTest.java
@@ -17,6 +17,7 @@ package com.vaadin.ui;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashSet;
@@ -38,15 +39,13 @@ import org.junit.runners.Parameterized.Parameters;
import org.mockito.Mockito;
import com.vaadin.data.HasValue.ValueChangeEvent;
-import com.vaadin.data.Listing;
-import com.vaadin.data.provider.DataProvider;
import com.vaadin.event.selection.MultiSelectionEvent;
import com.vaadin.event.selection.MultiSelectionListener;
import com.vaadin.shared.Registration;
import com.vaadin.shared.data.selection.MultiSelectServerRpc;
@RunWith(Parameterized.class)
-public class AbstractMultiSelectTest<S extends AbstractMultiSelect<String> & Listing<String, DataProvider<String, ?>>> {
+public class AbstractMultiSelectTest<S extends AbstractMultiSelect<String>> {
@Parameters(name = "{0}")
public static Iterable<?> multiSelects() {
@@ -69,8 +68,7 @@ public class AbstractMultiSelectTest<S extends AbstractMultiSelect<String> & Lis
public void setUp() {
selectToTest.deselectAll();
// Intentional deviation from upcoming selection order
- selectToTest.setDataProvider(
- DataProvider.create("3", "2", "1", "5", "8", "7", "4", "6"));
+ selectToTest.setItems("3", "2", "1", "5", "8", "7", "4", "6");
rpc = ComponentTest.getRpcProxy(selectToTest,
MultiSelectServerRpc.class);
@@ -263,6 +261,12 @@ public class AbstractMultiSelectTest<S extends AbstractMultiSelect<String> & Lis
public Set<String> getSelectedItems() {
return set;
}
+
+ @Override
+ public void setItems(Collection<String> items) {
+ throw new UnsupportedOperationException(
+ "Not implemented for this test");
+ }
};
Assert.assertSame(set, select.getValue());
@@ -326,6 +330,12 @@ public class AbstractMultiSelectTest<S extends AbstractMultiSelect<String> & Lis
public Set<String> getValue() {
return set;
}
+
+ @Override
+ public void setItems(Collection<String> items) {
+ throw new UnsupportedOperationException(
+ "Not implemented for this test");
+ }
};
AtomicReference<ValueChangeEvent<?>> event = new AtomicReference<>();
diff --git a/server/src/test/java/com/vaadin/ui/AbstractSingleSelectTest.java b/server/src/test/java/com/vaadin/ui/AbstractSingleSelectTest.java
index cfcdba1f1c..fa419118ff 100644
--- a/server/src/test/java/com/vaadin/ui/AbstractSingleSelectTest.java
+++ b/server/src/test/java/com/vaadin/ui/AbstractSingleSelectTest.java
@@ -21,6 +21,7 @@ import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicReference;
@@ -31,8 +32,8 @@ import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
+import com.vaadin.data.HasDataProvider;
import com.vaadin.data.HasValue.ValueChangeEvent;
-import com.vaadin.data.Listing;
import com.vaadin.data.provider.DataProvider;
import com.vaadin.data.provider.bov.Person;
import com.vaadin.event.selection.SingleSelectionEvent;
@@ -52,7 +53,7 @@ public class AbstractSingleSelectTest {
private List<Person> oldSelections;
private static class PersonListing extends AbstractSingleSelect<Person>
- implements Listing<Person, DataProvider<Person, ?>> {
+ implements HasDataProvider<Person> {
@Override
protected Element writeItem(Element design, Person item,
@@ -267,6 +268,12 @@ public class AbstractSingleSelectTest {
protected void readItems(Element design,
DesignContext context) {
}
+
+ @Override
+ public void setItems(Collection<String> items) {
+ throw new UnsupportedOperationException(
+ "Not needed in this test");
+ }
};
AtomicReference<ValueChangeEvent<?>> event = new AtomicReference<>();