]> source.dussan.org Git - vaadin-framework.git/commitdiff
Move select all visible to multi selection model interface (#8627)
authorPekka Hyvönen <pekka@vaadin.com>
Mon, 27 Mar 2017 13:06:27 +0000 (16:06 +0300)
committerAleksi Hietanen <aleksi@vaadin.com>
Mon, 27 Mar 2017 13:06:27 +0000 (16:06 +0300)
server/src/main/java/com/vaadin/ui/components/grid/MultiSelectionModel.java
server/src/main/java/com/vaadin/ui/components/grid/MultiSelectionModelImpl.java
server/src/test/java/com/vaadin/tests/components/grid/GridMultiSelectionModelTest.java
uitest/src/main/java/com/vaadin/tests/components/grid/GridMultiSelectionOnInit.java
uitest/src/main/java/com/vaadin/tests/components/grid/basics/GridBasics.java

index 4c5da97a5db4041313db1215144b96049d430932..c535789ea79cbc5819ce2e7c79c786a07ce96102 100644 (file)
@@ -16,6 +16,7 @@
 package com.vaadin.ui.components.grid;
 
 import com.vaadin.data.Binder;
+import com.vaadin.data.provider.DataProvider;
 import com.vaadin.event.selection.MultiSelectionListener;
 import com.vaadin.event.selection.SelectionListener;
 import com.vaadin.shared.Registration;
@@ -33,6 +34,39 @@ import com.vaadin.ui.MultiSelect;
 public interface MultiSelectionModel<T>
         extends GridSelectionModel<T>, com.vaadin.data.SelectionModel.Multi<T> {
 
+    /**
+     * State for showing the select all checkbox in the grid's default header
+     * row for the selection column.
+     * <p>
+     * Default value is {@link #DEFAULT}, which means that the select all is
+     * only visible if an in-memory data provider is used
+     * {@link DataProvider#isInMemory()}.
+     */
+    public enum SelectAllCheckBoxVisibility {
+        /**
+         * Shows the select all checkbox, regardless of data provider used.
+         * <p>
+         * <b>For a lazy data provider, selecting all will result in to all rows
+         * being fetched from backend to application memory!</b>
+         */
+        VISIBLE,
+        /**
+         * Never shows the select all checkbox, regardless of data provider
+         * used.
+         */
+        HIDDEN,
+        /**
+         * By default select all checkbox depends on the grid's dataprovider.
+         * <ul>
+         * <li>Visible, if the data provider is in-memory</li>
+         * <li>Hidden, if the data provider is NOT in-memory (lazy)</li>
+         * </ul>
+         *
+         * @see DataProvider#isInMemory()}.
+         */
+        DEFAULT;
+    }
+
     /**
      * Gets a wrapper to use this multiselection model as a multiselect in
      * {@link Binder}.
@@ -65,4 +99,39 @@ public interface MultiSelectionModel<T>
      */
     public Registration addMultiSelectionListener(
             MultiSelectionListener<T> listener);
+
+    /**
+     * Sets the select all checkbox visibility mode.
+     * <p>
+     * The default value is {@link SelectAllCheckBoxVisibility#DEFAULT}, which
+     * means that the checkbox is only visible if the grid's data provider is
+     * in- memory.
+     *
+     * @param selectAllCheckBoxVisibility
+     *            the visiblity mode to use
+     * @see SelectAllCheckBoxVisibility
+     */
+    public void setSelectAllCheckBoxVisibility(
+            SelectAllCheckBoxVisibility selectAllCheckBoxVisibility);
+
+    /**
+     * Gets the current mode for the select all checkbox visibility.
+     *
+     * @return the select all checkbox visibility mode
+     * @see SelectAllCheckBoxVisibility
+     * @see #isSelectAllCheckBoxVisible()
+     */
+    public SelectAllCheckBoxVisibility getSelectAllCheckBoxVisibility();
+
+    /**
+     * Returns whether the select all checkbox will be visible with the current
+     * setting of
+     * {@link #setSelectAllCheckBoxVisibility(SelectAllCheckBoxVisibility)}.
+     *
+     * @return {@code true} if the checkbox will be visible with the current
+     *         settings
+     * @see SelectAllCheckBoxVisibility
+     * @see #setSelectAllCheckBoxVisibility(SelectAllCheckBoxVisibility)
+     */
+    public boolean isSelectAllCheckBoxVisible();
 }
index 122abadc5a5b1e99f2f24f8cf576175a12d468e1..01635302f0d26dcf01d0ade36793461dff2d5c33 100644 (file)
@@ -55,39 +55,6 @@ import com.vaadin.ui.MultiSelect;
 public class MultiSelectionModelImpl<T> extends AbstractSelectionModel<T>
         implements MultiSelectionModel<T> {
 
-    /**
-     * State for showing the select all checkbox in the grid's default header
-     * row for the selection column.
-     * <p>
-     * Default value is {@link #DEFAULT}, which means that the select all is
-     * only visible if an in-memory data provider is used
-     * {@link DataProvider#isInMemory()}.
-     */
-    public enum SelectAllCheckBoxVisibility {
-        /**
-         * Shows the select all checkbox, regardless of data provider used.
-         * <p>
-         * <b>For a lazy data provider, selecting all will result in to all rows
-         * being fetched from backend to application memory!</b>
-         */
-        VISIBLE,
-        /**
-         * Never shows the select all checkbox, regardless of data provider
-         * used.
-         */
-        HIDDEN,
-        /**
-         * By default select all checkbox depends on the grid's dataprovider.
-         * <ul>
-         * <li>Visible, if the data provider is in-memory</li>
-         * <li>Hidden, if the data provider is NOT in-memory (lazy)</li>
-         * </ul>
-         *
-         * @see DataProvider#isInMemory()}.
-         */
-        DEFAULT;
-    }
-
     private class GridMultiSelectServerRpcImpl
             implements GridMultiSelectServerRpc {
 
@@ -141,17 +108,7 @@ public class MultiSelectionModelImpl<T> extends AbstractSelectionModel<T>
         return (MultiSelectionModelState) super.getState(markAsDirty);
     }
 
-    /**
-     * Sets the select all checkbox visibility mode.
-     * <p>
-     * The default value is {@link SelectAllCheckBoxVisibility#DEFAULT}, which
-     * means that the checkbox is only visible if the grid's data provider is
-     * in- memory.
-     *
-     * @param selectAllCheckBoxVisibility
-     *            the visiblity mode to use
-     * @see SelectAllCheckBoxVisibility
-     */
+    @Override
     public void setSelectAllCheckBoxVisibility(
             SelectAllCheckBoxVisibility selectAllCheckBoxVisibility) {
         if (this.selectAllCheckBoxVisibility != selectAllCheckBoxVisibility) {
@@ -160,27 +117,12 @@ public class MultiSelectionModelImpl<T> extends AbstractSelectionModel<T>
         }
     }
 
-    /**
-     * Gets the current mode for the select all checkbox visibility.
-     *
-     * @return the select all checkbox visibility mode
-     * @see SelectAllCheckBoxVisibility
-     * @see #isSelectAllCheckBoxVisible()
-     */
+    @Override
     public SelectAllCheckBoxVisibility getSelectAllCheckBoxVisibility() {
         return selectAllCheckBoxVisibility;
     }
 
-    /**
-     * Returns whether the select all checkbox will be visible with the current
-     * setting of
-     * {@link #setSelectAllCheckBoxVisibility(SelectAllCheckBoxVisibility)}.
-     *
-     * @return {@code true} if the checkbox will be visible with the current
-     *         settings
-     * @see SelectAllCheckBoxVisibility
-     * @see #setSelectAllCheckBoxVisibility(SelectAllCheckBoxVisibility)
-     */
+    @Override
     public boolean isSelectAllCheckBoxVisible() {
         updateCanSelectAll();
         return getState(false).selectAllCheckBoxVisible;
index c45bad66f0f8780fc71ae426e7301c51b57b9a73..3b107d6c9bbdfe0009c5f4f288f43a4cec298c8a 100644 (file)
@@ -34,8 +34,9 @@ import com.vaadin.ui.Grid;
 import com.vaadin.ui.Grid.SelectionMode;
 import com.vaadin.ui.UI;
 import com.vaadin.ui.components.grid.GridSelectionModel;
+import com.vaadin.ui.components.grid.MultiSelectionModel;
+import com.vaadin.ui.components.grid.MultiSelectionModel.SelectAllCheckBoxVisibility;
 import com.vaadin.ui.components.grid.MultiSelectionModelImpl;
-import com.vaadin.ui.components.grid.MultiSelectionModelImpl.SelectAllCheckBoxVisibility;
 
 import elemental.json.JsonObject;
 
@@ -616,7 +617,7 @@ public class GridMultiSelectionModelTest {
         UI ui = new MockUI();
 
         Grid<String> grid = new Grid<>();
-        MultiSelectionModelImpl<String> model = (MultiSelectionModelImpl<String>) grid
+        MultiSelectionModel<String> model = (MultiSelectionModel<String>) grid
                 .setSelectionMode(SelectionMode.MULTI);
 
         ui.setContent(grid);
@@ -655,7 +656,7 @@ public class GridMultiSelectionModelTest {
         UI ui = new MockUI();
         ui.setContent(grid);
 
-        MultiSelectionModelImpl<String> model = (MultiSelectionModelImpl<String>) grid
+        MultiSelectionModel<String> model = (MultiSelectionModel<String>) grid
                 .setSelectionMode(SelectionMode.MULTI);
 
         // no items yet, default data provider is empty not in memory one
index 77d2bd5a84b316475728f106aaf9982ba384d62d..f9e9e63151e077a554cb0005e16659a0e755bb8c 100644 (file)
@@ -23,8 +23,8 @@ import com.vaadin.ui.Button;
 import com.vaadin.ui.Grid;
 import com.vaadin.ui.Grid.SelectionMode;
 import com.vaadin.ui.RadioButtonGroup;
+import com.vaadin.ui.components.grid.MultiSelectionModel.SelectAllCheckBoxVisibility;
 import com.vaadin.ui.components.grid.MultiSelectionModelImpl;
-import com.vaadin.ui.components.grid.MultiSelectionModelImpl.SelectAllCheckBoxVisibility;
 
 public class GridMultiSelectionOnInit extends AbstractTestUI {
 
index eabf281bbdec35059195f9bc444274874d05883f..4c7283dfcc3b6ee80e050f5af686b1d588f71451 100644 (file)
@@ -48,8 +48,8 @@ import com.vaadin.ui.components.grid.FooterRow;
 import com.vaadin.ui.components.grid.HeaderCell;
 import com.vaadin.ui.components.grid.HeaderRow;
 import com.vaadin.ui.components.grid.MultiSelectionModel;
+import com.vaadin.ui.components.grid.MultiSelectionModel.SelectAllCheckBoxVisibility;
 import com.vaadin.ui.components.grid.MultiSelectionModelImpl;
-import com.vaadin.ui.components.grid.MultiSelectionModelImpl.SelectAllCheckBoxVisibility;
 import com.vaadin.ui.components.grid.SingleSelectionModelImpl;
 import com.vaadin.ui.renderers.DateRenderer;
 import com.vaadin.ui.renderers.HtmlRenderer;