]> source.dussan.org Git - vaadin-framework.git/commitdiff
Replace Listing with HasDataProvider and HasFilterableDataProvider (#8122)
authorLeif Åstrand <legioth@gmail.com>
Fri, 13 Jan 2017 08:08:01 +0000 (10:08 +0200)
committerGitHub <noreply@github.com>
Fri, 13 Jan 2017 08:08:01 +0000 (10:08 +0200)
* 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.

26 files changed:
server/src/main/java/com/vaadin/data/HasDataProvider.java [new file with mode: 0644]
server/src/main/java/com/vaadin/data/HasFilterableDataProvider.java [new file with mode: 0644]
server/src/main/java/com/vaadin/data/HasItems.java [new file with mode: 0644]
server/src/main/java/com/vaadin/data/Listing.java [deleted file]
server/src/main/java/com/vaadin/data/provider/DataProvider.java
server/src/main/java/com/vaadin/ui/AbstractListing.java
server/src/main/java/com/vaadin/ui/AbstractMultiSelect.java
server/src/main/java/com/vaadin/ui/AbstractSingleSelect.java
server/src/main/java/com/vaadin/ui/CheckBoxGroup.java
server/src/main/java/com/vaadin/ui/ComboBox.java
server/src/main/java/com/vaadin/ui/Grid.java
server/src/main/java/com/vaadin/ui/ListSelect.java
server/src/main/java/com/vaadin/ui/NativeSelect.java
server/src/main/java/com/vaadin/ui/RadioButtonGroup.java
server/src/main/java/com/vaadin/ui/TwinColSelect.java
server/src/test/java/com/vaadin/tests/server/component/abstractlisting/AbstractListingDeclarativeTest.java
server/src/test/java/com/vaadin/tests/server/component/abstractmultiselect/AbstractMultiSelectDeclarativeTest.java
server/src/test/java/com/vaadin/tests/server/component/abstractsingleselect/AbstractSingleSelectDeclarativeTest.java
server/src/test/java/com/vaadin/ui/AbstractListingTest.java
server/src/test/java/com/vaadin/ui/AbstractMultiSelectTest.java
server/src/test/java/com/vaadin/ui/AbstractSingleSelectTest.java
uitest/src/main/java/com/vaadin/tests/components/AbstractListingFocusBlurTest.java
uitest/src/main/java/com/vaadin/tests/components/abstractlisting/AbstractListingTestUI.java
uitest/src/main/java/com/vaadin/tests/components/abstractlisting/AbstractMultiSelectTestUI.java
uitest/src/main/java/com/vaadin/tests/components/abstractlisting/AbstractSingleSelectTestUI.java
uitest/src/main/java/com/vaadin/tests/data/DummyData.java

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 (file)
index 0000000..142ef29
--- /dev/null
@@ -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 (file)
index 0000000..03e2e30
--- /dev/null
@@ -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 (file)
index 0000000..22023d5
--- /dev/null
@@ -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 (file)
index 064948e..0000000
+++ /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));
-    }
-
-}
index 8bc4aa3d4bc6300b72026a690c097a50f3156b9e..cdf3387212c1c200173f335a43411d170997c550 100644 (file)
@@ -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}
index cacc9240f27782cc64f1da58adea1b25097af500..c3328683a15d6c54a87c50527c523ac4c4c2b5a5 100644 (file)
@@ -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)
      *
index e104b1c4e669fcca4fcca6d7c86fdb1fbaaa369c..22df69da5cf8a3f0e1a2e02418081e4a29a3297a 100644 (file)
@@ -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);
 
index 967b84e6b6257a1ae5fcb166b786e3726271fb17..224d6823e70fea8de53bb21e528fdeb494ec8c90 100644 (file)
@@ -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);
     }
index a4c48f35155bd8ed548319a546d10114abc5b3f7..15d895142ac2db2f44390f0902252fd16ea2945c 100644 (file)
@@ -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));
index 226269d72e8aa31a849cee9ea1ef6795a2436657..a789e2990ccdd97cfba766924e98962fb70b151c 100644 (file)
@@ -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));
     }
 
     /**
index 16d995b4ae785fb583df72613f11fe0c7ecd8a52..ae78d5486b5a34c1c04347df30e8a4795e4d5a0e 100644 (file)
@@ -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(
index 00679d3e5f8d3c803089dcb8f162b5f3395d10a6..1e7c92f14d416ed18393d70ecfc73350b3b058a4 100644 (file)
@@ -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
index 2d0e805d41c70edfd4c531fbc3180624b715bc04..9ae3409b66b58b21dece537b935ebca31041f722 100644 (file)
@@ -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.
index 592781cc56ec568ae8ba378ee7c1f04007950781..7f2284b08e3da6fdfb67f703b8bc15ad8774d630 100644 (file)
@@ -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));
index bcc8b52024aff00cf036ffc6ad2420d198520ab7..fb8a785076548908a3854d965ae949cdd31517fb 100644 (file)
@@ -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.
index 4da4a49cc1ccbe2ae3500b4132ce05f47a64c7c6..a3b9e244cfc3a4650504123aa31042c27a25db27 100644 (file)
@@ -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);
     }
 
index e96bb4bb55a6d52a069756f0764cf66c61f6e340..1b11ab11dc79cfe0a7f1497826d8bb07e3a4da2d 100644 (file)
@@ -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
index 182b9045fd5ace43b5acd8cb5ea3420c71e484ff..6e46658b86615c57cfb79f18984e947ae1d8609f 100644 (file)
@@ -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
index 212a15f32f33b06d1c989a78af7320b72d982545..c6cc9a150736d86b24e733a714a77486232e5f7b 100644 (file)
@@ -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
index 4b4ddbcae94aea6aaa08b67d4b792e19149e364e..abed1563e5268ef5263559fdb1e626ad3e4ed3a9 100644 (file)
@@ -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<>();
index cfcdba1f1c6b10c5b7d04ae541db68737d20f0e4..fa419118ffbbbe3daa053cdef8e555dfebda644d 100644 (file)
@@ -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<>();
index 7e35bbb3865b24e598d8c6fb74f60a15048f45f5..1d7bd7ac0b9a3ec8f5915868b9d9491a7fbf6bf2 100644 (file)
@@ -21,7 +21,6 @@ import java.util.stream.Collectors;
 import java.util.stream.IntStream;
 
 import com.googlecode.gentyref.GenericTypeReflector;
-import com.vaadin.data.Listing;
 import com.vaadin.event.FieldEvents.BlurNotifier;
 import com.vaadin.event.FieldEvents.FocusNotifier;
 import com.vaadin.server.VaadinRequest;
@@ -31,7 +30,7 @@ import com.vaadin.ui.AbstractListing;
  * @author Vaadin Ltd
  *
  */
-public abstract class AbstractListingFocusBlurTest<T extends AbstractListing<Integer> & FocusNotifier & BlurNotifier & Listing<Integer, ?>>
+public abstract class AbstractListingFocusBlurTest<T extends AbstractListing<Integer> & FocusNotifier & BlurNotifier>
         extends AbstractTestUIWithLog {
 
     @Override
index 8a46738e5db40263fca03f269c3f17763df9d7fa..9d2ca4f6ea609a248475a6fdc3871751b2d72e8a 100644 (file)
@@ -4,12 +4,11 @@ import java.util.LinkedHashMap;
 import java.util.stream.IntStream;
 
 import com.vaadin.annotations.Widgetset;
-import com.vaadin.data.Listing;
 import com.vaadin.tests.components.AbstractComponentTest;
 import com.vaadin.ui.AbstractListing;
 
 @Widgetset("com.vaadin.DefaultWidgetSet")
-public abstract class AbstractListingTestUI<T extends AbstractListing<Object> & Listing<Object, ?>>
+public abstract class AbstractListingTestUI<T extends AbstractListing<Object>>
         extends AbstractComponentTest<T> {
 
     @Override
index 2417bdfcdedca37228802c4d3582a0bf52a6976b..c405a2af524fd47434d78847c6e179fa3bed6979 100644 (file)
@@ -5,11 +5,10 @@ import java.util.List;
 import java.util.stream.Collectors;
 import java.util.stream.IntStream;
 
-import com.vaadin.data.Listing;
 import com.vaadin.ui.AbstractMultiSelect;
 import com.vaadin.ui.ItemCaptionGenerator;
 
-public abstract class AbstractMultiSelectTestUI<MULTISELECT extends AbstractMultiSelect<Object> & Listing<Object, ?>>
+public abstract class AbstractMultiSelectTestUI<MULTISELECT extends AbstractMultiSelect<Object>>
         extends AbstractListingTestUI<MULTISELECT> {
 
     protected final String selectionCategory = "Selection";
@@ -33,7 +32,8 @@ public abstract class AbstractMultiSelectTestUI<MULTISELECT extends AbstractMult
                 "None", (abstractMultiSelect, captionGenerator, data) -> {
                     abstractMultiSelect
                             .setItemCaptionGenerator(captionGenerator);
-                    abstractMultiSelect.getDataProvider().refreshAll();
+                    abstractMultiSelect.getDataCommunicator().getDataProvider()
+                            .refreshAll();
                 }, true);
     }
 
index 3b51b0985c2fc95fd1ffc39e4d5ec1b00dfcbf50..4c773283ecd67a77445f54bb6df195f334e4b6e7 100644 (file)
@@ -17,10 +17,9 @@ package com.vaadin.tests.components.abstractlisting;
 
 import java.util.LinkedHashMap;
 
-import com.vaadin.data.Listing;
 import com.vaadin.ui.AbstractSingleSelect;
 
-public abstract class AbstractSingleSelectTestUI<T extends AbstractSingleSelect<Object> & Listing<Object, ?>>
+public abstract class AbstractSingleSelectTestUI<T extends AbstractSingleSelect<Object>>
         extends AbstractListingTestUI<T> {
 
     @Override
index ed13a2300e8bfac18da21321f19073a84f966fe1..f31348863a530e64ce44d12761c9fbfb54e7cc7a 100644 (file)
@@ -8,7 +8,7 @@ import java.util.Optional;
 import java.util.stream.Stream;
 
 import com.vaadin.annotations.Widgetset;
-import com.vaadin.data.Listing;
+import com.vaadin.data.HasDataProvider;
 import com.vaadin.data.provider.DataProvider;
 import com.vaadin.data.provider.ListDataProvider;
 import com.vaadin.data.provider.Query;
@@ -45,7 +45,7 @@ public class DummyData extends AbstractTestUIWithLog {
      * shown as bold text.
      */
     public static class DummyComponent extends AbstractSingleSelect<String>
-            implements Listing<String, DataProvider<String, ?>> {
+            implements HasDataProvider<String> {
 
         private String selected;