]> source.dussan.org Git - vaadin-framework.git/commitdiff
Synchronize code between V7 and compatibility package
authorTeemu Suo-Anttila <teemusa@vaadin.com>
Wed, 1 Mar 2017 12:27:49 +0000 (14:27 +0200)
committerHenri Sara <henri.sara@gmail.com>
Tue, 7 Mar 2017 13:43:00 +0000 (15:43 +0200)
92 files changed:
compatibility-client/src/main/java/com/vaadin/v7/client/connectors/AbstractRendererConnector.java
compatibility-client/src/main/java/com/vaadin/v7/client/connectors/GridConnector.java
compatibility-client/src/main/java/com/vaadin/v7/client/connectors/JavaScriptRendererConnector.java
compatibility-client/src/main/java/com/vaadin/v7/client/connectors/MultiSelectionModelConnector.java
compatibility-client/src/main/java/com/vaadin/v7/client/connectors/SingleSelectionModelConnector.java
compatibility-client/src/main/java/com/vaadin/v7/client/renderers/ImageRenderer.java
compatibility-client/src/main/java/com/vaadin/v7/client/ui/VCalendarPanel.java
compatibility-client/src/main/java/com/vaadin/v7/client/ui/VFilterSelect.java
compatibility-client/src/main/java/com/vaadin/v7/client/ui/VLabel.java
compatibility-client/src/main/java/com/vaadin/v7/client/ui/VOptionGroupBase.java
compatibility-client/src/main/java/com/vaadin/v7/client/ui/VPopupCalendar.java
compatibility-client/src/main/java/com/vaadin/v7/client/ui/VScrollTable.java
compatibility-client/src/main/java/com/vaadin/v7/client/ui/VTextArea.java
compatibility-client/src/main/java/com/vaadin/v7/client/ui/VTwinColSelect.java
compatibility-client/src/main/java/com/vaadin/v7/client/ui/VUpload.java
compatibility-client/src/main/java/com/vaadin/v7/client/ui/form/FormConnector.java
compatibility-client/src/main/java/com/vaadin/v7/client/ui/optiongroup/OptionGroupBaseConnector.java
compatibility-client/src/main/java/com/vaadin/v7/client/ui/optiongroup/OptionGroupConnector.java
compatibility-client/src/main/java/com/vaadin/v7/client/ui/table/TableConnector.java
compatibility-client/src/main/java/com/vaadin/v7/client/ui/tree/TreeConnector.java
compatibility-client/src/main/java/com/vaadin/v7/client/widget/escalator/ScrollbarBundle.java
compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/EditorHandler.java
compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/GridEventHandler.java
compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/selection/ClickSelectHandler.java
compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/selection/HasUserSelectionAllowed.java [new file with mode: 0644]
compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/selection/MultiSelectionRenderer.java
compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/selection/SelectionModelMulti.java
compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/selection/SelectionModelSingle.java
compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/selection/SpaceSelectHandler.java
compatibility-client/src/main/java/com/vaadin/v7/client/widgets/Escalator.java
compatibility-client/src/main/java/com/vaadin/v7/client/widgets/Grid.java
compatibility-server/src/main/java/com/vaadin/server/GAEVaadinServlet.java
compatibility-server/src/main/java/com/vaadin/v7/data/Buffered.java
compatibility-server/src/main/java/com/vaadin/v7/data/Validator.java
compatibility-server/src/main/java/com/vaadin/v7/data/fieldgroup/DefaultFieldGroupFieldFactory.java
compatibility-server/src/main/java/com/vaadin/v7/data/fieldgroup/FieldGroup.java
compatibility-server/src/main/java/com/vaadin/v7/data/fieldgroup/FieldGroupFieldFactory.java
compatibility-server/src/main/java/com/vaadin/v7/data/util/AbstractBeanContainer.java
compatibility-server/src/main/java/com/vaadin/v7/data/util/AbstractInMemoryContainer.java
compatibility-server/src/main/java/com/vaadin/v7/data/util/AbstractProperty.java
compatibility-server/src/main/java/com/vaadin/v7/data/util/BeanItem.java
compatibility-server/src/main/java/com/vaadin/v7/data/util/HierarchicalContainer.java
compatibility-server/src/main/java/com/vaadin/v7/data/util/IndexedContainer.java
compatibility-server/src/main/java/com/vaadin/v7/data/util/MethodProperty.java
compatibility-server/src/main/java/com/vaadin/v7/data/util/NestedMethodProperty.java
compatibility-server/src/main/java/com/vaadin/v7/data/util/NestedPropertyDescriptor.java
compatibility-server/src/main/java/com/vaadin/v7/data/util/PropertysetItem.java
compatibility-server/src/main/java/com/vaadin/v7/data/util/converter/ConverterUtil.java
compatibility-server/src/main/java/com/vaadin/v7/data/util/sqlcontainer/ColumnProperty.java
compatibility-server/src/main/java/com/vaadin/v7/data/util/sqlcontainer/SQLContainer.java
compatibility-server/src/main/java/com/vaadin/v7/data/validator/DoubleValidator.java
compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractField.java
compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractTextField.java
compatibility-server/src/main/java/com/vaadin/v7/ui/Calendar.java
compatibility-server/src/main/java/com/vaadin/v7/ui/CheckBox.java
compatibility-server/src/main/java/com/vaadin/v7/ui/DateField.java
compatibility-server/src/main/java/com/vaadin/v7/ui/DefaultFieldFactory.java
compatibility-server/src/main/java/com/vaadin/v7/ui/Field.java
compatibility-server/src/main/java/com/vaadin/v7/ui/Form.java
compatibility-server/src/main/java/com/vaadin/v7/ui/FormFieldFactory.java
compatibility-server/src/main/java/com/vaadin/v7/ui/Grid.java
compatibility-server/src/main/java/com/vaadin/v7/ui/HorizontalLayout.java
compatibility-server/src/main/java/com/vaadin/v7/ui/Label.java
compatibility-server/src/main/java/com/vaadin/v7/ui/ListSelect.java
compatibility-server/src/main/java/com/vaadin/v7/ui/ProgressBar.java
compatibility-server/src/main/java/com/vaadin/v7/ui/Table.java
compatibility-server/src/main/java/com/vaadin/v7/ui/TableFieldFactory.java
compatibility-server/src/main/java/com/vaadin/v7/ui/TextField.java
compatibility-server/src/main/java/com/vaadin/v7/ui/Tree.java
compatibility-server/src/main/java/com/vaadin/v7/ui/TwinColSelect.java
compatibility-server/src/main/java/com/vaadin/v7/ui/components/calendar/ContainerEventProvider.java
compatibility-server/src/main/java/com/vaadin/v7/ui/components/colorpicker/ColorPickerPreview.java
compatibility-server/src/main/java/com/vaadin/v7/ui/components/colorpicker/ColorPickerSelect.java
compatibility-server/src/main/java/com/vaadin/v7/ui/renderers/AbstractJavaScriptRenderer.java
compatibility-server/src/test/java/com/vaadin/tests/server/component/AbstractListenerMethodsTestBase.java
compatibility-server/src/test/java/com/vaadin/tests/server/component/slider/SliderTest.java
compatibility-server/src/test/java/com/vaadin/v7/data/util/PerformanceTestIndexedContainerTest.java
compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/SQLContainerTableQueryTest.java
compatibility-server/src/test/java/com/vaadin/v7/data/util/sqlcontainer/generator/SQLGeneratorsTest.java
compatibility-server/src/test/java/com/vaadin/v7/tests/design/WriteLegacyDesignTest.java
compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/AbsFieldValidatorsTest.java
compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/AbsFieldValueConversionsTest.java
compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/abstractfield/AbstractFieldListenersTest.java
compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/ItemSetChangeDuringEditorCommit.java
compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/MultiSelectionModelTest.java
compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/grid/SingleSelectionModelTest.java
compatibility-server/src/test/java/com/vaadin/v7/tests/server/component/table/TableDeclarativeTestBase.java
compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/ColumnResizeMode.java
compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/selection/MultiSelectionModelState.java
compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/grid/selection/SingleSelectionModelState.java
compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/optiongroup/OptionGroupConstants.java
compatibility-shared/src/main/java/com/vaadin/v7/shared/ui/progressindicator/ProgressBarState.java

index 284cc225e0b85231f3445f4e4d143f3c03a90f22..fe0c561d5cda3a61082734c3a1bb2c4c79ca63c9 100644 (file)
@@ -124,5 +124,4 @@ public abstract class AbstractRendererConnector<T>
     protected void extend(ServerConnector target) {
         // NOOP
     }
-
 }
index c59ec0afe43fcc972c788643842637a6de9cc301..87a4c9036021397abc51a3dfb492292811b7bf8a 100644 (file)
@@ -153,7 +153,7 @@ public class GridConnector extends AbstractHasComponentsConnector
     }
 
     /**
-     * Custom implementation of the custom grid column using a JSONObject to
+     * Custom implementation of the custom grid column using a JSONObject to
      * represent the cell value and String as a column type.
      */
     private class CustomGridColumn extends Grid.Column<Object, JsonObject> {
index 6a94416ad9ba52d7473d1994ce7ccbbcf93e0c7d..51071e2c502c577b495965b345df5778740d221c 100644 (file)
@@ -17,6 +17,7 @@ package com.vaadin.v7.client.connectors;
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.logging.Logger;
 
 import com.google.gwt.core.client.JavaScriptObject;
 import com.google.gwt.core.client.JsArrayString;
@@ -135,8 +136,16 @@ public class JavaScriptRendererConnector
                             + " must have a function named 'render'");
         }
 
+        if (hasFunction("destory")) {
+            getLogger().severe("Your JavaScript connector ("
+                    + helper.getInitFunctionName()
+                    + ") has a typo. The destory method should be renamed to destroy.");
+
+        }
+
         final boolean hasInit = hasFunction("init");
-        final boolean hasDestroy = hasFunction("destroy");
+        final boolean hasDestroy = hasFunction("destroy")
+                || hasFunction("destory");
         final boolean hasOnActivate = hasFunction("onActivate");
         final boolean hasGetConsumedEvents = hasFunction("getConsumedEvents");
         final boolean hasOnBrowserEvent = hasFunction("onBrowserEvent");
@@ -183,16 +192,20 @@ public class JavaScriptRendererConnector
             @Override
             public void destroy(RendererCellReference cell) {
                 if (hasDestroy) {
-                    destory(helper.getConnectorWrapper(), getJsCell(cell));
+                    destroy(helper.getConnectorWrapper(), getJsCell(cell));
                 } else {
                     super.destroy(cell);
                 }
             }
 
-            private native void destory(JavaScriptObject wrapper,
+            private native void destroy(JavaScriptObject wrapper,
                     JavaScriptObject cell)
             /*-{
-                wrapper.destory(cell);
+                if (wrapper.destroy) {
+                    wrapper.destroy(cell);
+                } else  {
+                    wrapper.destory(cell);
+                }
             }-*/;
 
             @Override
@@ -258,6 +271,10 @@ public class JavaScriptRendererConnector
         };
     }
 
+    private Logger getLogger() {
+        return Logger.getLogger(JavaScriptRendererConnector.class.getName());
+    }
+
     @Override
     public Object decode(JsonValue value) {
         // Let the js logic decode the raw json that the server sent
index 5103abb2852c3c524906092ac8147a3e018aa323..035498db611a52d13e217991d452baa45c90aa7e 100644 (file)
@@ -22,6 +22,7 @@ import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
+import java.util.logging.Logger;
 
 import com.google.gwt.event.shared.HandlerRegistration;
 import com.google.gwt.user.client.ui.CheckBox;
@@ -37,12 +38,15 @@ import com.vaadin.v7.client.widget.grid.DataAvailableEvent;
 import com.vaadin.v7.client.widget.grid.DataAvailableHandler;
 import com.vaadin.v7.client.widget.grid.events.SelectAllEvent;
 import com.vaadin.v7.client.widget.grid.events.SelectAllHandler;
+import com.vaadin.v7.client.widget.grid.selection.HasUserSelectionAllowed;
 import com.vaadin.v7.client.widget.grid.selection.MultiSelectionRenderer;
 import com.vaadin.v7.client.widget.grid.selection.SelectionModel;
 import com.vaadin.v7.client.widget.grid.selection.SelectionModel.Multi;
 import com.vaadin.v7.client.widget.grid.selection.SpaceSelectHandler;
 import com.vaadin.v7.client.widgets.Grid;
+import com.vaadin.v7.client.widgets.Grid.Column;
 import com.vaadin.v7.client.widgets.Grid.HeaderCell;
+import com.vaadin.v7.client.widgets.Grid.SelectionColumn;
 import com.vaadin.v7.shared.ui.grid.GridState;
 import com.vaadin.v7.shared.ui.grid.selection.MultiSelectionModelServerRpc;
 import com.vaadin.v7.shared.ui.grid.selection.MultiSelectionModelState;
@@ -94,8 +98,30 @@ public class MultiSelectionModelConnector extends
         }
     }
 
+    @OnStateChange("userSelectionAllowed")
+    void updateUserSelectionAllowed() {
+        if (selectionModel instanceof HasUserSelectionAllowed) {
+            ((HasUserSelectionAllowed) selectionModel)
+                    .setUserSelectionAllowed(getState().userSelectionAllowed);
+        } else {
+            getLogger().warning("userSelectionAllowed set to "
+                    + getState().userSelectionAllowed
+                    + " but the selection model does not implement "
+                    + HasUserSelectionAllowed.class.getSimpleName());
+        }
+    }
+
+    private static Logger getLogger() {
+        return Logger.getLogger(MultiSelectionModelConnector.class.getName());
+    }
+
+    /**
+     * The default multi selection model used for this connector.
+     *
+     */
     protected class MultiSelectionModel extends AbstractSelectionModel
-            implements SelectionModel.Multi.Batched<JsonObject> {
+            implements SelectionModel.Multi.Batched<JsonObject>,
+            HasUserSelectionAllowed<JsonObject> {
 
         private ComplexRenderer<Boolean> renderer = null;
         private Set<RowHandle<JsonObject>> selected = new HashSet<RowHandle<JsonObject>>();
@@ -104,6 +130,7 @@ public class MultiSelectionModelConnector extends
         private HandlerRegistration dataAvailable;
         private Range availableRows;
         private boolean batchSelect = false;
+        private boolean userSelectionAllowed = true;
 
         @Override
         public void setGrid(Grid<JsonObject> grid) {
@@ -382,5 +409,21 @@ public class MultiSelectionModelConnector extends
         public Collection<JsonObject> getDeselectedRowsBatch() {
             return Collections.unmodifiableSet(getRows(deselected));
         }
+
+        @Override
+        public boolean isUserSelectionAllowed() {
+            return userSelectionAllowed;
+        }
+
+        @Override
+        public void setUserSelectionAllowed(boolean userSelectionAllowed) {
+            this.userSelectionAllowed = userSelectionAllowed;
+            for (Column<?, JsonObject> c : getGrid().getColumns()) {
+                if (c instanceof SelectionColumn) {
+                    ((SelectionColumn) c)
+                            .setUserSelectionAllowed(userSelectionAllowed);
+                }
+            }
+        }
     }
 }
index 059278c311517f841e807055257dc8bca2e275f6..d922166451e2f3b85ec1f2a66696d4fff26f2235 100644 (file)
  */
 package com.vaadin.v7.client.connectors;
 
+import java.util.logging.Logger;
+
 import com.vaadin.client.ServerConnector;
 import com.vaadin.client.annotations.OnStateChange;
 import com.vaadin.client.data.DataSource.RowHandle;
 import com.vaadin.shared.ui.Connect;
 import com.vaadin.v7.client.renderers.Renderer;
 import com.vaadin.v7.client.widget.grid.selection.ClickSelectHandler;
+import com.vaadin.v7.client.widget.grid.selection.HasUserSelectionAllowed;
 import com.vaadin.v7.client.widget.grid.selection.SelectionModel;
 import com.vaadin.v7.client.widget.grid.selection.SelectionModel.Single;
 import com.vaadin.v7.client.widget.grid.selection.SpaceSelectHandler;
@@ -75,14 +78,34 @@ public class SingleSelectionModelConnector extends
         selectionModel.setDeselectAllowed(getState().deselectAllowed);
     }
 
+    @OnStateChange("userSelectionAllowed")
+    void updateUserSelectionAllowed() {
+
+        if (selectionModel instanceof HasUserSelectionAllowed) {
+            ((HasUserSelectionAllowed) selectionModel)
+                    .setUserSelectionAllowed(getState().userSelectionAllowed);
+        } else {
+            getLogger().warning("userSelectionAllowed set to "
+                    + getState().userSelectionAllowed
+                    + " but the selection model does not implement "
+                    + HasUserSelectionAllowed.class.getSimpleName());
+        }
+    }
+
+    private static Logger getLogger() {
+        return Logger.getLogger(SingleSelectionModelConnector.class.getName());
+    }
+
     /**
      * SingleSelectionModel without a selection column renderer.
      */
     public class SingleSelectionModel extends AbstractSelectionModel
-            implements SelectionModel.Single<JsonObject> {
+            implements SelectionModel.Single<JsonObject>,
+            HasUserSelectionAllowed<JsonObject> {
 
         private RowHandle<JsonObject> selectedRow;
         private boolean deselectAllowed;
+        private boolean userSelectionAllowed = true;
 
         @Override
         public Renderer<Boolean> getSelectionColumnRenderer() {
@@ -153,8 +176,14 @@ public class SingleSelectionModelConnector extends
 
         @Override
         public boolean deselect(JsonObject row) {
-            if (getRowHandle(row).equals(selectedRow)) {
-                select(null);
+            if (isSelected(row)) {
+                // If no selection has happened client side, then selectedRow is
+                // null but must be set so that a deselection event with the
+                // correct key can be sent to the server
+                selectedRow = getRowHandle(row);
+                selectedRow.pin();
+
+                return select(null);
             }
             return false;
         }
@@ -176,5 +205,15 @@ public class SingleSelectionModelConnector extends
         public boolean isDeselectAllowed() {
             return deselectAllowed;
         }
+
+        @Override
+        public boolean isUserSelectionAllowed() {
+            return userSelectionAllowed;
+        }
+
+        @Override
+        public void setUserSelectionAllowed(boolean userSelectionAllowed) {
+            this.userSelectionAllowed = userSelectionAllowed;
+        }
     }
-}
\ No newline at end of file
+}
index a29b4f2cfd14e62550f2794b0d8419aeaac589bd..a151d3ff683b00b7cfbd17df15d7bcfc2e65265c 100644 (file)
@@ -29,7 +29,7 @@ import com.vaadin.v7.client.widget.grid.RendererCellReference;
  */
 public class ImageRenderer extends ClickableRenderer<String, Image> {
 
-    public static final String TRANSPARENT_GIF_1PX = "data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=";
+    public static final String TRANSPARENT_GIF_1PX = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
 
     @Override
     public Image createWidget() {
index a27f2c80cd300c87a6de51596f12bffc74c0c82e..8780c980ab420980a39967a0d3498293209faa0b 100644 (file)
@@ -1677,7 +1677,7 @@ public class VCalendarPanel extends FocusableFlexTable implements
 
         private ListBox createListBox() {
             ListBox lb = new ListBox();
-            lb.setStyleName("v-select");
+            lb.setStyleName(VNativeSelect.CLASSNAME);
             lb.addChangeHandler(this);
             lb.addBlurHandler(VCalendarPanel.this);
             lb.addFocusHandler(VCalendarPanel.this);
index aa47481e6a8adee4c11ff327f07abdcb9333e6cb..0daaff47f9b97d47881b3fc7166586b2a4ea97fb 100644 (file)
@@ -1450,7 +1450,10 @@ public class VFilterSelect extends Composite
     };
 
     private class IconWidget extends Widget {
+        private Icon icon;
+
         IconWidget(Icon icon) {
+            this.icon = icon;
             setElement(icon.getElement());
             addDomHandler(VFilterSelect.this, ClickEvent.getType());
         }
@@ -1908,25 +1911,59 @@ public class VFilterSelect extends Composite
                 afterSelectedItemIconChange();
             }
         } else {
+            IconWidget newIcon = new IconWidget(client.getIcon(iconUri));
+            if (iconEquals(newIcon, selectedItemIcon)) {
+                /*
+                 * Do not update the icon if nothing has changed. Otherwise we
+                 * can cause problems such as not being able to click in the
+                 * icon to open the popup (blur might occur and call this
+                 * method, icon is replaced and the click event is not delivered
+                 * to the new icon)
+                 */
+                return;
+            }
+
             if (selectedItemIcon != null) {
                 panel.remove(selectedItemIcon);
             }
-            selectedItemIcon = new IconWidget(client.getIcon(iconUri));
+
             // Older IE versions don't scale icon correctly if DOM
             // contains height and width attributes.
-            selectedItemIcon.getElement().removeAttribute("height");
-            selectedItemIcon.getElement().removeAttribute("width");
-            selectedItemIcon.addDomHandler(new LoadHandler() {
+            newIcon.getElement().removeAttribute("height");
+            newIcon.getElement().removeAttribute("width");
+            newIcon.addDomHandler(new LoadHandler() {
                 @Override
                 public void onLoad(LoadEvent event) {
                     afterSelectedItemIconChange();
                 }
             }, LoadEvent.getType());
-            panel.insert(selectedItemIcon, 0);
+            panel.insert(newIcon, 0);
+            selectedItemIcon = newIcon;
             afterSelectedItemIconChange();
         }
     }
 
+    /**
+     * Checks if the icon widgets show the same icon.
+     *
+     * @param icon1
+     *            the first widget
+     * @param icon2
+     *            the second widget
+     * @return <code>true</code> if they show the same icon, <code>false</code>
+     *         otherwise
+     */
+    private static boolean iconEquals(IconWidget icon1, IconWidget icon2) {
+        if (icon1 == null) {
+            return icon2 == null;
+        } else if (icon2 == null) {
+            return false;
+        } else {
+            return icon1.icon.getUri().equals(icon2.icon.getUri());
+        }
+
+    }
+
     private void afterSelectedItemIconChange() {
         if (BrowserInfo.get().isWebkit() || BrowserInfo.get().isIE8()) {
             // Some browsers need a nudge to reposition the text field
@@ -2392,6 +2429,7 @@ public class VFilterSelect extends Composite
                 }
             } else if (currentSuggestion != null) {
                 setPromptingOff(currentSuggestion.caption);
+                setSelectedItemIcon(currentSuggestion.getIconUri());
             }
         }
         removeStyleDependentName("focus");
index ebe28c0d314a49ff90cf405461c067e0be21b2b6..6022135d90ed874f9ef156d1b9f6f4eee6cf11d8 100644 (file)
@@ -57,4 +57,5 @@ public class VLabel extends HTML {
         }
     }
 
+    // Vaadin 8 does not support IE8, no override for setText
 }
index 94a92e29806313f8c495dc3743bd2444b2f9fa99..239e6ff53aff680d7e26b903a5d4e613923013a1 100644 (file)
@@ -60,6 +60,8 @@ public abstract class VOptionGroupBase extends Composite implements Field,
 
     private boolean readonly;
 
+    // Intentional removal of cols in compatibility package
+
     /** For internal use only. May be removed or replaced in the future. */
     public int rows = 0;
 
@@ -134,6 +136,8 @@ public abstract class VOptionGroupBase extends Composite implements Field,
         return nullSelectionItemAvailable;
     }
 
+    // Intentional removal of getColumns in compatibility package
+
     /**
      * For internal use only. May be removed or replaced in the future.
      *
index 832c03e99cd0a4e8d82621af0d741292fb0295ca..e93ce4c04c75934064842ef3bf62b6316151d341 100644 (file)
@@ -62,8 +62,7 @@ import com.vaadin.v7.shared.ui.datefield.Resolution;
  * selector.
  *
  * <b>Note:</b> To change the keyboard assignments used in the popup dialog you
- * should extend <code>com.vaadin.v7.client.ui.VCalendarPanel</code> and then
- * pass set it by calling the
+ * should extend <code>VCalendarPanel</code> and then pass set it by calling the
  * <code>setCalendarPanel(VCalendarPanel panel)</code> method.
  *
  */
@@ -270,9 +269,9 @@ public class VPopupCalendar extends VTextualDate
      * Sets the state of the text field of this component. By default the text
      * field is enabled. Disabling it causes only the button for date selection
      * to be active, thus preventing the user from entering invalid dates. See
-     * {@link http://dev.vaadin.com/ticket/6790}.
+     * <a href="http://dev.vaadin.com/ticket/6790">6790</a>.
      *
-     * @param state
+     * @param textFieldEnabled
      */
     public void setTextFieldEnabled(boolean textFieldEnabled) {
         this.textFieldEnabled = textFieldEnabled;
@@ -366,12 +365,6 @@ public class VPopupCalendar extends VTextualDate
         }
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * com.google.gwt.user.client.ui.UIObject#setStyleName(java.lang.String)
-     */
     @Override
     public void setStyleName(String style) {
         super.setStyleName(style);
@@ -419,13 +412,6 @@ public class VPopupCalendar extends VTextualDate
         }
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * com.google.gwt.event.dom.client.ClickHandler#onClick(com.google.gwt.event
-     * .dom.client.ClickEvent)
-     */
     @Override
     public void onClick(ClickEvent event) {
         if (event.getSource() == calendarToggle && isEnabled()) {
@@ -438,13 +424,6 @@ public class VPopupCalendar extends VTextualDate
         }
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * com.google.gwt.event.logical.shared.CloseHandler#onClose(com.google.gwt
-     * .event.logical.shared.CloseEvent)
-     */
     @Override
     public void onClose(CloseEvent<PopupPanel> event) {
         if (event.getSource() == popup) {
@@ -531,12 +510,6 @@ public class VPopupCalendar extends VTextualDate
         buildDate();
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see com.vaadin.client.ui.VDateField#onBrowserEvent(com.google
-     * .gwt.user.client.Event)
-     */
     @Override
     public void onBrowserEvent(com.google.gwt.user.client.Event event) {
         super.onBrowserEvent(event);
@@ -617,7 +590,7 @@ public class VPopupCalendar extends VTextualDate
      * and it depends on the current resolution, what is considered inside the
      * range.
      *
-     * @param startDate
+     * @param rangeStart
      *            - the allowed range's start date
      */
     public void setRangeStart(Date rangeStart) {
@@ -628,7 +601,7 @@ public class VPopupCalendar extends VTextualDate
      * Sets the end range for this component. The end range is inclusive, and it
      * depends on the current resolution, what is considered inside the range.
      *
-     * @param endDate
+     * @param rangeEnd
      *            - the allowed range's end date
      */
     public void setRangeEnd(Date rangeEnd) {
index a6be4dc61a86c39fc2fd2511766b7a16ba927e75..3affa940fc647e811ddaae21fe0b8fac1bc60b14 100644 (file)
@@ -3665,6 +3665,7 @@ public class VScrollTable extends FlowPanel
                     }
                 } else {
                     c.setText(caption);
+                    // IE10 is no longer supported
                 }
 
                 c.setSorted(false);
index c5d229e153f5da33e1aeba85a504d7b0f55efe74..b42f04f9b9887c3ac565cb33377dbbf59b5f5ed7 100644 (file)
@@ -230,6 +230,7 @@ public class VTextArea extends VTextField implements DragImageModifier {
         if (info.isSafari()) {
             return true;
         }
+        // Vaadin 8 no longer supports IE10
         if (info.isIE11() || info.isEdge()) {
             return true;
         }
index 32bc14d330627298f1020e12536ba07082905768..2403750b034926df70c80c4d9238f7a98bb058ea 100644 (file)
@@ -367,6 +367,7 @@ public class VTwinColSelect extends VOptionGroupBase implements KeyDownHandler,
 
     /** For internal use only. May be removed or replaced in the future. */
     public void clearInternalWidths() {
+        // Intentional removal of cols in compatibility package
         int cols = DEFAULT_COLUMN_COUNT;
 
         if (cols >= 0) {
index 16108792b451fdaee08b3f5ad00bb4dea8c5dfe3..8f892e377eb539a35aea132bd703cb630dc57507 100644 (file)
@@ -161,6 +161,7 @@ public class VUpload extends SimplePanel {
     private static native void setEncoding(Element form, String encoding)
     /*-{
       form.enctype = encoding;
+      // IE8 not supported in Vaadin 8
     }-*/;
 
     /** For internal use only. May be removed or replaced in the future. */
index dcc83008b90655f6d2b2258afdfe360427a25007..e904cd68035f98b89d2cf6033042ac5f20689c41 100644 (file)
@@ -180,6 +180,7 @@ public class FormConnector extends AbstractComponentContainerConnector
 
     @Override
     public boolean isReadOnly() {
+        // Class hierarchy has changed for FormConnector
         return getState().readOnly || getState().propertyReadOnly;
     }
 
index 53c0c0d06aa651b08f1a02e9fbaa2cc8ffc1aad1..6fe94fa5a5bdb51cfc4946ad14d1d6d30225c954 100644 (file)
@@ -43,6 +43,7 @@ public abstract class OptionGroupBaseConnector extends AbstractFieldConnector
         getWidget().selectedKeys = uidl.getStringArrayVariableAsSet("selected");
 
         getWidget().setReadonly(isReadOnly());
+        // Intentional change to use state over UIDL in compatibility package
         getWidget().multiselect = getState().multiSelect;
         getWidget().immediate = getState().immediate;
         getWidget().nullSelectionAllowed = uidl
@@ -50,12 +51,16 @@ public abstract class OptionGroupBaseConnector extends AbstractFieldConnector
         getWidget().nullSelectionItemAvailable = uidl
                 .getBooleanAttribute("nullselectitem");
 
+        // Support for cols has been dropped.
+
         if (uidl.hasAttribute("rows")) {
             getWidget().rows = uidl.getIntAttribute("rows");
         }
 
         final UIDL ops = uidl.getChildUIDL(0);
 
+        // Method getColumns has been removed
+
         getWidget().buildOptions(ops);
 
         if (uidl.getBooleanAttribute("allownewitem")) {
index e88a2070bca2c817e1a3488886960fef9a95f19f..dbed217598a3bd68d827ae54fdab24fbfd025840 100644 (file)
@@ -34,6 +34,7 @@ public class OptionGroupConnector extends OptionGroupBaseConnector {
 
     @Override
     public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
+        // HTML Content has been moved to state.
         super.updateFromUIDL(uidl, client);
 
         getWidget().sendFocusEvents = client.hasEventListeners(this,
index 9d2677af548539c13dc718ffcac41af4eab697dc..091951bc8b4e2ccf2457d8b339bdebf35ef99303 100644 (file)
@@ -386,6 +386,8 @@ public class TableConnector extends AbstractFieldConnector
     public void updateEnabledState(boolean enabledState) {
         super.updateEnabledState(enabledState);
         getWidget().enabled = isEnabled();
+
+        // IE8 is no longer supported
     }
 
     @Override
@@ -416,6 +418,7 @@ public class TableConnector extends AbstractFieldConnector
             Scheduler.get().scheduleFinally(new ScheduledCommand() {
                 @Override
                 public void execute() {
+                    // IE8 is no longer supported
                     getLayoutManager().setNeedsMeasure(TableConnector.this);
                     ServerConnector parent = getParent();
                     if (parent instanceof ComponentConnector) {
index a589e75697c8512fc9d3e81b56db5bf9d8916fcf..d03c0bf55ac3d8cf0c40550a7b99e53c514b6b2c 100644 (file)
@@ -66,6 +66,8 @@ public class TreeConnector extends AbstractLegacyComponentConnector
         if (uidl.hasAttribute("partialUpdate")) {
             handleUpdate(uidl);
 
+            // IE8 is no longer supported with Vaadin 8
+
             getWidget().rendering = false;
             return;
         }
@@ -175,6 +177,8 @@ public class TreeConnector extends AbstractLegacyComponentConnector
             getWidget().focusedNode.setFocused(false);
         }
 
+        // IE8 is no longer supported with Vaadin 8
+
         getWidget().rendering = false;
 
     }
index 20b1e5d1b98d85ebf31cf7ccb889fe512e2acbf5..8e6d9a524358d157ed2bd6072f7c2a0bc0cc8164 100644 (file)
@@ -362,6 +362,7 @@ public abstract class ScrollbarBundle implements DeferredWorker {
 
     private HandlerRegistration scrollSizeTemporaryScrollHandler;
     private HandlerRegistration offsetSizeTemporaryScrollHandler;
+    private HandlerRegistration scrollInProgress;
 
     private ScrollbarBundle() {
         root.appendChild(scrollSizeElement);
@@ -435,6 +436,9 @@ public abstract class ScrollbarBundle implements DeferredWorker {
         boolean offsetSizeBecomesGreaterThanScrollSize = showsScrollHandle()
                 && newOffsetSizeIsGreaterThanScrollSize;
         if (offsetSizeBecomesGreaterThanScrollSize && getScrollPos() != 0) {
+            if (offsetSizeTemporaryScrollHandler != null) {
+                offsetSizeTemporaryScrollHandler.removeHandler();
+            }
             // must be a field because Java insists.
             offsetSizeTemporaryScrollHandler = addScrollHandler(
                     new ScrollHandler() {
@@ -523,6 +527,17 @@ public abstract class ScrollbarBundle implements DeferredWorker {
         scrollPos = Math.max(0, Math.min(maxScrollPos, truncate(px)));
 
         if (!WidgetUtil.pixelValuesEqual(oldScrollPos, scrollPos)) {
+            if (scrollInProgress == null) {
+                // Only used for tracking that there is "workPending"
+                scrollInProgress = addScrollHandler(new ScrollHandler() {
+                    @Override
+                    public void onScroll(ScrollEvent event) {
+                        scrollInProgress.removeHandler();
+                        scrollInProgress = null;
+                    }
+                });
+            }
+
             if (isInvisibleScrollbar) {
                 invisibleScrollbarTemporaryResizer.show();
             }
@@ -631,7 +646,7 @@ public abstract class ScrollbarBundle implements DeferredWorker {
          * This needs to be made step-by-step because IE8 flat-out refuses to
          * fire a scroll event when the scroll size becomes smaller than the
          * offset size. All other browser need to suffer alongside.
-         * 
+         *
          * This really should be changed to not use any temporary scroll
          * handlers at all once IE8 support is dropped, like now done only for
          * Firefox.
@@ -649,7 +664,11 @@ public abstract class ScrollbarBundle implements DeferredWorker {
              * 'delayedSizeSet'
              */
             boolean delayedSizeSet = !BrowserInfo.get().isFirefox();
+            // must be a field because Java insists.
             if (delayedSizeSet) {
+                if (scrollSizeTemporaryScrollHandler != null) {
+                    scrollSizeTemporaryScrollHandler.removeHandler();
+                }
                 scrollSizeTemporaryScrollHandler = addScrollHandler(
                         new ScrollHandler() {
                             @Override
@@ -911,6 +930,6 @@ public abstract class ScrollbarBundle implements DeferredWorker {
         // requestAnimationFrame - which is not automatically checked
         return scrollSizeTemporaryScrollHandler != null
                 || offsetSizeTemporaryScrollHandler != null
-                || scrollEventFirer.isBeingFired;
+                || scrollInProgress != null || scrollEventFirer.isBeingFired;
     }
 }
index a0fee4c7fc8127133f33200110902844f8f1d4cf..7777b821bc8e54dc8a8ed431ebe840d9e1ab605b 100644 (file)
@@ -54,9 +54,9 @@ public interface EditorHandler<T> {
         public int getRowIndex();
 
         /**
-         * Returns the index of the column being focused.
+         * Returns the DOM index of the column being focused.
          *
-         * @return the column index
+         * @return the column index (excluding hidden columns)
          */
         public int getColumnIndex();
 
index 0e3e65179ea31cff9c32c03013809c726ecc7d9b..1e792f97961333ecde5a03df0fc488acd5f6a6b7 100644 (file)
@@ -27,8 +27,8 @@ public interface GridEventHandler<T> {
     /**
      * Attempts to handle the given grid event.
      *
-     * @param gridEvent
+     * @param event
      *            the event that occurred
      */
-    public void onEvent(GridEvent<T> gridEvent);
-}
\ No newline at end of file
+    public void onEvent(GridEvent<T> event);
+}
index 588d8a354b88dacaa828b20661fd9efa3ad6e2c6..6887f571b5aaeeebf1d8afb5f479d824763dd104 100644 (file)
@@ -36,6 +36,10 @@ public class ClickSelectHandler<T> {
 
         @Override
         public void onClick(GridClickEvent event) {
+            if (!grid.isUserSelectionAllowed()) {
+                return;
+            }
+
             T row = (T) event.getTargetCell().getRow();
             if (!grid.isSelected(row)) {
                 grid.select(row);
diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/selection/HasUserSelectionAllowed.java b/compatibility-client/src/main/java/com/vaadin/v7/client/widget/grid/selection/HasUserSelectionAllowed.java
new file mode 100644 (file)
index 0000000..82aa86f
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * 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.v7.client.widget.grid.selection;
+
+/**
+ * Interface implemented by selection models which support disabling client side
+ * selection while still allowing programmatic selection on the server.
+ *
+ * @param <T>
+ *            Grid's row type
+ *
+ * @since 7.7.7
+ */
+public interface HasUserSelectionAllowed<T> extends SelectionModel<T> {
+
+    /**
+     * Checks if the user is allowed to change the selection.
+     *
+     * @return <code>true</code> if the user is allowed to change the selection,
+     *         <code>false</code> otherwise
+     */
+    public boolean isUserSelectionAllowed();
+
+    /**
+     * Sets whether the user is allowed to change the selection.
+     *
+     * @param userSelectionAllowed
+     *            <code>true</code> if the user is allowed to change the
+     *            selection, <code>false</code> otherwise
+     */
+    public void setUserSelectionAllowed(boolean userSelectionAllowed);
+
+}
index a7c974aeadb4daadb0cd4d5287c5399f7204ef6c..86d5e0a32307de9bc5a5951fa3dcf94567fd277c 100644 (file)
@@ -632,7 +632,8 @@ public class MultiSelectionRenderer<T>
     public void render(final RendererCellReference cell, final Boolean data,
             CheckBox checkBox) {
         checkBox.setValue(data, false);
-        checkBox.setEnabled(grid.isEnabled() && !grid.isEditorActive());
+        checkBox.setEnabled(grid.isEnabled() && !grid.isEditorActive()
+                && grid.isUserSelectionAllowed());
     }
 
     @Override
@@ -770,6 +771,10 @@ public class MultiSelectionRenderer<T>
     }
 
     protected void setSelected(final int logicalRow, final boolean select) {
+        if (!grid.isUserSelectionAllowed()) {
+            return;
+        }
+
         T row = grid.getDataSource().getRow(logicalRow);
         if (select) {
             grid.select(row);
index 8629a5af3ac64e11bdac1801806da49413d6e367..a93360d77aacd96a41763c259c441e192752803e 100644 (file)
@@ -33,7 +33,7 @@ import com.vaadin.v7.client.widgets.Grid;
  * @since 7.4
  */
 public class SelectionModelMulti<T> extends AbstractRowHandleSelectionModel<T>
-        implements SelectionModel.Multi.Batched<T> {
+        implements SelectionModel.Multi.Batched<T>, HasUserSelectionAllowed<T> {
 
     private final LinkedHashSet<RowHandle<T>> selectedRows;
     private Renderer<Boolean> renderer;
@@ -45,6 +45,7 @@ public class SelectionModelMulti<T> extends AbstractRowHandleSelectionModel<T>
 
     /* Event handling for selection with space key */
     private SpaceSelectHandler<T> spaceSelectHandler;
+    private boolean userSelectionAllowed = true;
 
     public SelectionModelMulti() {
         grid = null;
@@ -270,4 +271,14 @@ public class SelectionModelMulti<T> extends AbstractRowHandleSelectionModel<T>
         }
         return rows;
     }
+
+    @Override
+    public boolean isUserSelectionAllowed() {
+        return userSelectionAllowed;
+    }
+
+    @Override
+    public void setUserSelectionAllowed(boolean userSelectionAllowed) {
+        this.userSelectionAllowed = userSelectionAllowed;
+    }
 }
index 6467759d6efc66988b2805042dc2dbd255d0f878..d78fbc2ba151f62d30eada224398f94cfc4f1844 100644 (file)
@@ -29,7 +29,7 @@ import com.vaadin.v7.client.widgets.Grid;
  * @since 7.4
  */
 public class SelectionModelSingle<T> extends AbstractRowHandleSelectionModel<T>
-        implements SelectionModel.Single<T> {
+        implements SelectionModel.Single<T>, HasUserSelectionAllowed<T> {
 
     private Grid<T> grid;
     private RowHandle<T> selectedRow;
@@ -41,6 +41,7 @@ public class SelectionModelSingle<T> extends AbstractRowHandleSelectionModel<T>
     private ClickSelectHandler<T> clickSelectHandler;
 
     private boolean deselectAllowed = true;
+    private boolean userSelectionAllowed = true;
 
     @Override
     public boolean isSelected(T row) {
@@ -172,4 +173,13 @@ public class SelectionModelSingle<T> extends AbstractRowHandleSelectionModel<T>
         }
     }
 
+    @Override
+    public boolean isUserSelectionAllowed() {
+        return userSelectionAllowed;
+    }
+
+    @Override
+    public void setUserSelectionAllowed(boolean userSelectionAllowed) {
+        this.userSelectionAllowed = userSelectionAllowed;
+    }
 }
index d4c0f2219fddf23b92fe1c4c9a520aff7da4126f..8de75dde2b9ab44efe3e7c4cb1a7e96cdd2879c6 100644 (file)
@@ -44,6 +44,10 @@ public class SpaceSelectHandler<T> {
 
         @Override
         public void onKeyDown(GridKeyDownEvent event) {
+            if (!grid.isUserSelectionAllowed()) {
+                return;
+            }
+
             if (event.getNativeKeyCode() != KeyCodes.KEY_SPACE || spaceDown) {
                 return;
             }
index cb2786a4cfe49b49a61fba455668db22c3061ac4..e9879b9b237d77429edb6a7ae6fadc5bca7d85fa 100644 (file)
@@ -308,6 +308,8 @@ public class Escalator extends Widget
     static class JsniUtil {
         public static class TouchHandlerBundle {
 
+            public static final String POINTER_EVENT_TYPE_TOUCH = "touch";
+
             /**
              * A <a href=
              * "http://www.gwtproject.org/doc/latest/DevGuideCodingBasicsOverlay.html"
@@ -340,6 +342,11 @@ public class Escalator extends Widget
                 /*-{
                     return this.targetTouches[0].pageY;
                 }-*/;
+
+                public native String getPointerType()
+                /*-{
+                    return this.pointerType;
+                }-*/;
             }
 
             private final Escalator escalator;
@@ -457,6 +464,15 @@ public class Escalator extends Widget
                 }
 
                 int pagePosition(CustomTouchEvent event) {
+                    // Use native event's screen x and y for IE11 and Edge
+                    // since there is no touches for these browsers (#18737)
+                    if (isCurrentBrowserIE11OrEdge()) {
+                        return vertical
+                                ? event.getNativeEvent().getClientY()
+                                        + Window.getScrollTop()
+                                : event.getNativeEvent().getClientX()
+                                        + Window.getScrollLeft();
+                    }
                     JsArray<Touch> a = event.getNativeEvent().getTouches();
                     return vertical ? a.get(0).getPageY() : a.get(0).getPageX();
                 }
@@ -496,7 +512,7 @@ public class Escalator extends Widget
             };
 
             public void touchStart(final CustomTouchEvent event) {
-                if (event.getNativeEvent().getTouches().length() == 1) {
+                if (allowTouch(event)) {
                     if (yMov == null) {
                         yMov = new Movement(true);
                         xMov = new Movement(false);
@@ -544,6 +560,20 @@ public class Escalator extends Widget
                 }
             }
 
+            // Allow touchStart for IE11 and Edge even though there is no touch
+            // (#18737),
+            // otherwise allow touch only if there is a single touch in the
+            // event
+            private boolean allowTouch(
+                    final TouchHandlerBundle.CustomTouchEvent event) {
+                if (isCurrentBrowserIE11OrEdge()) {
+                    return (POINTER_EVENT_TYPE_TOUCH
+                            .equals(event.getPointerType()));
+                } else {
+                    return (event.getNativeEvent().getTouches().length() == 1);
+                }
+            }
+
             private double easingInOutCos(double val, double max) {
                 return 0.5 - 0.5 * Math.cos(Math.PI * Math.signum(val)
                         * Math.min(Math.abs(val), max) / max);
@@ -859,8 +889,8 @@ public class Escalator extends Widget
                 if (position instanceof AbsolutePosition) {
                     /*
                      * we don't want to put "top: 0" on the footer, since it'll
-                     * render wrong, as we already have "bottom: $footer-height"
-                     * .
+                     * render wrong, as we already have
+                     * "bottom: $footer-height".
                      */
                     footElem.getStyle().setLeft(-scrollLeft, Unit.PX);
                 } else {
@@ -901,7 +931,7 @@ public class Escalator extends Widget
 
         public native void detachScrollListener(Element element)
         /*
-         * Attaching events with JSNI instead of the GWT event mechanism because
+         * Detaching events with JSNI instead of the GWT event mechanism because
          * GWT didn't provide enough details in events, or triggering the event
          * handlers with GWT bindings was unsuccessful. Maybe, with more time
          * and skill, it could be done with better success. JavaScript overlay
@@ -978,6 +1008,50 @@ public class Escalator extends Widget
             element.removeEventListener("touchcancel", this.@com.vaadin.v7.client.widgets.JsniWorkaround::touchEndFunction);
         }-*/;
 
+        /**
+         * Using pointerdown, pointermove, pointerup, and pointercancel for IE11
+         * and Edge instead of touch* listeners (#18737)
+         *
+         * @param element
+         */
+        public native void attachPointerEventListeners(Element element)
+        /*
+         * Attaching events with JSNI instead of the GWT event mechanism because
+         * GWT didn't provide enough details in events, or triggering the event
+         * handlers with GWT bindings was unsuccessful. Maybe, with more time
+         * and skill, it could be done with better success. JavaScript overlay
+         * types might work. This might also get rid of the JsniWorkaround
+         * class.
+         */
+        /*-{
+            element.addEventListener("pointerdown", this.@com.vaadin.client.widgets.JsniWorkaround::touchStartFunction);
+            element.addEventListener("pointermove", this.@com.vaadin.client.widgets.JsniWorkaround::touchMoveFunction);
+            element.addEventListener("pointerup", this.@com.vaadin.client.widgets.JsniWorkaround::touchEndFunction);
+            element.addEventListener("pointercancel", this.@com.vaadin.client.widgets.JsniWorkaround::touchEndFunction);
+        }-*/;
+
+        /**
+         * Using pointerdown, pointermove, pointerup, and pointercancel for IE11
+         * and Edge instead of touch* listeners (#18737)
+         *
+         * @param element
+         */
+        public native void detachPointerEventListeners(Element element)
+        /*
+         * Detaching events with JSNI instead of the GWT event mechanism because
+         * GWT didn't provide enough details in events, or triggering the event
+         * handlers with GWT bindings was unsuccessful. Maybe, with more time
+         * and skill, it could be done with better success. JavaScript overlay
+         * types might work. This might also get rid of the JsniWorkaround
+         * class.
+         */
+        /*-{
+            element.removeEventListener("pointerdown", this.@com.vaadin.client.widgets.JsniWorkaround::touchStartFunction);
+            element.removeEventListener("pointermove", this.@com.vaadin.client.widgets.JsniWorkaround::touchMoveFunction);
+            element.removeEventListener("pointerup", this.@com.vaadin.client.widgets.JsniWorkaround::touchEndFunction);
+            element.removeEventListener("pointercancel", this.@com.vaadin.client.widgets.JsniWorkaround::touchEndFunction);
+         }-*/;
+
         public void scrollToColumn(final int columnIndex,
                 final ScrollDestination destination, final int padding) {
             assert columnIndex >= columnConfiguration.frozenColumns : "Can't scroll to a frozen column";
@@ -4197,6 +4271,11 @@ public class Escalator extends Widget
                 frozenColumns += numberOfColumns;
             }
 
+            // Add to DOM
+            header.paintInsertColumns(index, numberOfColumns, frozen);
+            body.paintInsertColumns(index, numberOfColumns, frozen);
+            footer.paintInsertColumns(index, numberOfColumns, frozen);
+
             // this needs to be before the scrollbar adjustment.
             boolean scrollbarWasNeeded = horizontalScrollbar
                     .getOffsetSize() < horizontalScrollbar.getScrollSize();
@@ -4204,14 +4283,12 @@ public class Escalator extends Widget
             boolean scrollbarIsNowNeeded = horizontalScrollbar
                     .getOffsetSize() < horizontalScrollbar.getScrollSize();
             if (!scrollbarWasNeeded && scrollbarIsNowNeeded) {
+                // This might as a side effect move rows around (when scrolled
+                // all the way down) and require the DOM to be up to date, i.e.
+                // the column to be added
                 body.verifyEscalatorCount();
             }
 
-            // Add to DOM
-            header.paintInsertColumns(index, numberOfColumns, frozen);
-            body.paintInsertColumns(index, numberOfColumns, frozen);
-            footer.paintInsertColumns(index, numberOfColumns, frozen);
-
             // fix initial width
             if (header.getRowCount() > 0 || body.getRowCount() > 0
                     || footer.getRowCount() > 0) {
@@ -5741,7 +5818,13 @@ public class Escalator extends Widget
         scroller.attachScrollListener(verticalScrollbar.getElement());
         scroller.attachScrollListener(horizontalScrollbar.getElement());
         scroller.attachMousewheelListener(getElement());
-        scroller.attachTouchListeners(getElement());
+
+        if (isCurrentBrowserIE11OrEdge()) {
+            // Touch listeners doesn't work for IE11 and Edge (#18737)
+            scroller.attachPointerEventListeners(getElement());
+        } else {
+            scroller.attachTouchListeners(getElement());
+        }
     }
 
     @Override
@@ -5750,7 +5833,13 @@ public class Escalator extends Widget
         scroller.detachScrollListener(verticalScrollbar.getElement());
         scroller.detachScrollListener(horizontalScrollbar.getElement());
         scroller.detachMousewheelListener(getElement());
-        scroller.detachTouchListeners(getElement());
+
+        if (isCurrentBrowserIE11OrEdge()) {
+            // Touch listeners doesn't work for IE11 and Edge (#18737)
+            scroller.detachPointerEventListeners(getElement());
+        } else {
+            scroller.detachTouchListeners(getElement());
+        }
 
         /*
          * We can call paintRemoveRows here, because static ranges are simple to
@@ -6807,4 +6896,13 @@ public class Escalator extends Widget
     double getMinCellWidth(int colIndex) {
         return columnConfiguration.getMinCellWidth(colIndex);
     }
+
+    /**
+     * Internal method for checking whether the browser is IE11 or Edge
+     *
+     * @return true only if the current browser is IE11, or Edge
+     */
+    private static boolean isCurrentBrowserIE11OrEdge() {
+        return BrowserInfo.get().isIE11() || BrowserInfo.get().isEdge();
+    }
 }
index 5e481881287fad07cced14965bb0dc1ab1aa7946..ea7901773dee2d6cbf21d9ebe0b6e2fce6bd5e87 100644 (file)
@@ -81,6 +81,7 @@ import com.vaadin.client.BrowserInfo;
 import com.vaadin.client.DeferredWorker;
 import com.vaadin.client.Focusable;
 import com.vaadin.client.WidgetUtil;
+import com.vaadin.client.data.AbstractRemoteDataSource;
 import com.vaadin.client.data.DataChangeHandler;
 import com.vaadin.client.data.DataSource;
 import com.vaadin.client.data.DataSource.RowHandle;
@@ -96,7 +97,9 @@ import com.vaadin.shared.Registration;
 import com.vaadin.shared.data.sort.SortDirection;
 import com.vaadin.shared.util.SharedUtil;
 import com.vaadin.v7.client.renderers.ComplexRenderer;
+import com.vaadin.v7.client.renderers.ProgressBarRenderer;
 import com.vaadin.v7.client.renderers.Renderer;
+import com.vaadin.v7.client.renderers.TextRenderer;
 import com.vaadin.v7.client.renderers.WidgetRenderer;
 import com.vaadin.v7.client.widget.escalator.Cell;
 import com.vaadin.v7.client.widget.escalator.ColumnConfiguration;
@@ -128,6 +131,7 @@ import com.vaadin.v7.client.widget.grid.HeightAwareDetailsGenerator;
 import com.vaadin.v7.client.widget.grid.RendererCellReference;
 import com.vaadin.v7.client.widget.grid.RowReference;
 import com.vaadin.v7.client.widget.grid.RowStyleGenerator;
+import com.vaadin.v7.client.widget.grid.datasources.ListDataSource;
 import com.vaadin.v7.client.widget.grid.events.AbstractGridKeyEventHandler;
 import com.vaadin.v7.client.widget.grid.events.AbstractGridMouseEventHandler;
 import com.vaadin.v7.client.widget.grid.events.BodyClickHandler;
@@ -163,6 +167,7 @@ import com.vaadin.v7.client.widget.grid.events.ScrollHandler;
 import com.vaadin.v7.client.widget.grid.events.SelectAllEvent;
 import com.vaadin.v7.client.widget.grid.events.SelectAllHandler;
 import com.vaadin.v7.client.widget.grid.selection.HasSelectionHandlers;
+import com.vaadin.v7.client.widget.grid.selection.HasUserSelectionAllowed;
 import com.vaadin.v7.client.widget.grid.selection.MultiSelectionRenderer;
 import com.vaadin.v7.client.widget.grid.selection.SelectionEvent;
 import com.vaadin.v7.client.widget.grid.selection.SelectionHandler;
@@ -201,12 +206,10 @@ import com.vaadin.v7.shared.ui.grid.ScrollDestination;
  * <p>
  * Each column also has a Renderer. Its function is to take the value that is
  * given by the {@code GridColumn} and display it to the user. A simple column
- * might have a {@link com.vaadin.v7.client.renderers.TextRenderer TextRenderer}
- * that simply takes in a {@code String} and displays it as the cell's content.
- * A more complex renderer might be
- * {@link com.vaadin.v7.client.renderers.ProgressBarRenderer
- * ProgressBarRenderer} that takes in a floating point number, and displays a
- * progress bar instead, based on the given number.
+ * might have a {@link TextRenderer} that simply takes in a {@code String} and
+ * displays it as the cell's content. A more complex renderer might be
+ * {@link ProgressBarRenderer} that takes in a floating point number, and
+ * displays a progress bar instead, based on the given number.
  * <p>
  * <em>See:</em> {@link #addColumn(Column)}, {@link #addColumn(Column, int)} and
  * {@link #addColumns(Column...)}. <em>Also</em>
@@ -216,10 +219,8 @@ import com.vaadin.v7.shared.ui.grid.ScrollDestination;
  * <p>
  * Grid gets its data from a {@link DataSource}, providing row objects to Grid
  * from a user-defined endpoint. It can be either a local in-memory data source
- * (e.g. {@link com.vaadin.v7.client.widget.grid.datasources.ListDataSource
- * ListDataSource}) or even a remote one, retrieving data from e.g. a REST API
- * (see {@link com.vaadin.client.data.AbstractRemoteDataSource
- * AbstractRemoteDataSource}).
+ * (e.g. {@link ListDataSource}) or even a remote one, retrieving data from e.g.
+ * a REST API (see {@link AbstractRemoteDataSource}).
  *
  *
  * @param <T>
@@ -445,14 +446,14 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
          */
         public abstract static class StaticRow<CELLTYPE extends StaticCell> {
 
-            private Map<Column<?, ?>, CELLTYPE> cells = new HashMap<>();
+            private Map<Column<?, ?>, CELLTYPE> cells = new HashMap<Column<?, ?>, CELLTYPE>();
 
             private StaticSection<?> section;
 
             /**
              * Map from set of spanned columns to cell meta data.
              */
-            private Map<Set<Column<?, ?>>, CELLTYPE> cellGroups = new HashMap<>();
+            private Map<Set<Column<?, ?>>, CELLTYPE> cellGroups = new HashMap<Set<Column<?, ?>>, CELLTYPE>();
 
             /**
              * A custom style name for the row or null if none is set.
@@ -500,7 +501,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
                             "You can't merge less than 2 columns together.");
                 }
 
-                HashSet<Column<?, ?>> columnGroup = new HashSet<>();
+                HashSet<Column<?, ?>> columnGroup = new HashSet<Column<?, ?>>();
                 // NOTE: this doesn't care about hidden columns, those are
                 // filtered in calculateColspans()
                 for (Column<?, ?> column : columns) {
@@ -594,7 +595,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
             private boolean checkMergedCellIsContinuous(
                     Set<Column<?, ?>> mergedCell) {
                 // no matter if hidden or not, just check for continuous order
-                final List<Column<?, ?>> columnOrder = new ArrayList<>(
+                final List<Column<?, ?>> columnOrder = new ArrayList<Column<?, ?>>(
                         section.grid.getColumns());
 
                 if (!columnOrder.containsAll(mergedCell)) {
@@ -664,7 +665,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
              */
             void detach() {
                 // Avoid calling detach twice for a merged cell
-                HashSet<CELLTYPE> cells = new HashSet<>();
+                HashSet<CELLTYPE> cells = new HashSet<CELLTYPE>();
                 for (Column<?, ?> column : getSection().grid.getColumns()) {
                     cells.add(getCell(column));
                 }
@@ -676,7 +677,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
 
         private Grid<?> grid;
 
-        private List<ROWTYPE> rows = new ArrayList<>();
+        private List<ROWTYPE> rows = new ArrayList<ROWTYPE>();
 
         private boolean visible = true;
 
@@ -1100,15 +1101,15 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
 
         private Grid<T> grid;
         private final int rowIndex;
-        private final int columnIndex;
+        private final int columnIndexDOM;
         private RequestCallback<T> callback;
         private boolean completed = false;
 
-        public EditorRequestImpl(Grid<T> grid, int rowIndex, int columnIndex,
+        public EditorRequestImpl(Grid<T> grid, int rowIndex, int columnIndexDOM,
                 RequestCallback<T> callback) {
             this.grid = grid;
             this.rowIndex = rowIndex;
-            this.columnIndex = columnIndex;
+            this.columnIndexDOM = columnIndexDOM;
             this.callback = callback;
         }
 
@@ -1119,7 +1120,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
 
         @Override
         public int getColumnIndex() {
-            return columnIndex;
+            return columnIndexDOM;
         }
 
         @Override
@@ -1289,13 +1290,13 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
         }
 
         /**
-         * Returns the column index the editor was opened at. If the editor is
-         * not open, returns -1.
+         * Returns the DOM column index (excluding hidden columns) the editor
+         * was opened at. If the editor is not open, returns -1.
          *
          * @return the column index or -1 if editor is not open
          */
         public int getFocusedColumnIndex() {
-            return getEditor().focusedColumnIndex;
+            return getEditor().focusedColumnIndexDOM;
         }
     }
 
@@ -1315,6 +1316,23 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
         private static final String ERROR_CLASS_NAME = "error";
         private static final String NOT_EDITABLE_CLASS_NAME = "not-editable";
 
+        ScheduledCommand fieldFocusCommand = new ScheduledCommand() {
+            private int count = 0;
+
+            @Override
+            public void execute() {
+                Element focusedElement = WidgetUtil.getFocusedElement();
+                if (focusedElement == grid.getElement()
+                        || focusedElement == Document.get().getBody()
+                        || count > 2) {
+                    focusColumn(focusedColumnIndexDOM);
+                } else {
+                    ++count;
+                    Scheduler.get().scheduleDeferred(this);
+                }
+            }
+        };
+
         /**
          * A handler for events related to the Grid editor. Responsible for
          * opening, moving or closing the editor based on the received event.
@@ -1360,13 +1378,13 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
         // Should only be added to the DOM when there's a message to show
         private DivElement message = DivElement.as(DOM.createDiv());
 
-        private Map<Column<?, T>, Widget> columnToWidget = new HashMap<>();
-        private List<HandlerRegistration> focusHandlers = new ArrayList<>();
+        private Map<Column<?, T>, Widget> columnToWidget = new HashMap<Column<?, T>, Widget>();
+        private List<HandlerRegistration> focusHandlers = new ArrayList<HandlerRegistration>();
 
         private boolean enabled = false;
         private State state = State.INACTIVE;
         private int rowIndex = -1;
-        private int focusedColumnIndex = -1;
+        private int focusedColumnIndexDOM = -1;
         private String styleName = null;
 
         private HandlerRegistration hScrollHandler;
@@ -1431,10 +1449,10 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
                     bindTimeout.cancel();
 
                     rowIndex = request.getRowIndex();
-                    focusedColumnIndex = request.getColumnIndex();
-                    if (focusedColumnIndex >= 0) {
+                    focusedColumnIndexDOM = request.getColumnIndex();
+                    if (focusedColumnIndexDOM >= 0) {
                         // Update internal focus of Grid
-                        grid.focusCell(rowIndex, focusedColumnIndex);
+                        grid.focusCell(rowIndex, focusedColumnIndexDOM);
                     }
 
                     showOverlay();
@@ -1456,7 +1474,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
         };
 
         /** A set of all the columns that display an error flag. */
-        private final Set<Column<?, T>> columnErrors = new HashSet<>();
+        private final Set<Column<?, T>> columnErrors = new HashSet<Column<?, T>>();
         private boolean buffered = true;
 
         /** Original position of editor */
@@ -1543,9 +1561,10 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
          *
          * @param rowIndex
          *            the index of the row to be edited
-         * @param columnIndex
-         *            the column index of the editor widget that should be
-         *            initially focused or -1 to not set focus
+         * @param columnIndexDOM
+         *            the column index (excluding hidden columns) of the editor
+         *            widget that should be initially focused or -1 to not set
+         *            focus
          *
          * @throws IllegalStateException
          *             if this editor is not enabled
@@ -1555,7 +1574,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
          *
          * @since 7.5
          */
-        public void editRow(final int rowIndex, final int columnIndex) {
+        public void editRow(final int rowIndex, final int columnIndexDOM) {
             if (!enabled) {
                 throw new IllegalStateException(
                         "Cannot edit row: editor is not enabled");
@@ -1580,35 +1599,35 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
                     return;
                 }
             }
-            if (columnIndex >= grid.getVisibleColumns().size()) {
+            if (columnIndexDOM >= grid.getVisibleColumns().size()) {
                 throw new IllegalArgumentException(
-                        "Edited column index " + columnIndex
+                        "Edited column index " + columnIndexDOM
                                 + " was bigger than visible column count.");
             }
 
             if (this.rowIndex == rowIndex
-                    && focusedColumnIndex == columnIndex) {
+                    && focusedColumnIndexDOM == columnIndexDOM) {
                 // NO-OP
                 return;
             }
 
             if (this.rowIndex == rowIndex) {
-                if (focusedColumnIndex != columnIndex) {
-                    if (columnIndex >= grid.getFrozenColumnCount()) {
+                if (focusedColumnIndexDOM != columnIndexDOM) {
+                    if (columnIndexDOM >= grid.getFrozenColumnCount()) {
                         // Scroll to new focused column.
-                        grid.getEscalator().scrollToColumn(columnIndex,
+                        grid.getEscalator().scrollToColumn(columnIndexDOM,
                                 ScrollDestination.ANY, 0);
                     }
 
-                    focusedColumnIndex = columnIndex;
+                    focusedColumnIndexDOM = columnIndexDOM;
                 }
 
                 updateHorizontalScrollPosition();
 
                 // Update Grid internal focus and focus widget if possible
-                if (focusedColumnIndex >= 0) {
-                    grid.focusCell(rowIndex, focusedColumnIndex);
-                    focusColumn(focusedColumnIndex);
+                if (focusedColumnIndexDOM >= 0) {
+                    grid.focusCell(rowIndex, focusedColumnIndexDOM);
+                    focusColumn(focusedColumnIndexDOM);
                 }
 
                 // No need to request anything from the editor handler.
@@ -1618,13 +1637,13 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
 
             final Escalator escalator = grid.getEscalator();
             if (escalator.getVisibleRowRange().contains(rowIndex)) {
-                show(rowIndex, columnIndex);
+                show(rowIndex, columnIndexDOM);
             } else {
                 vScrollHandler = grid.addScrollHandler(new ScrollHandler() {
                     @Override
                     public void onScroll(ScrollEvent event) {
                         if (escalator.getVisibleRowRange().contains(rowIndex)) {
-                            show(rowIndex, columnIndex);
+                            show(rowIndex, columnIndexDOM);
                             vScrollHandler.removeHandler();
                         }
                     }
@@ -1652,8 +1671,8 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
                 throw new IllegalStateException(
                         "Cannot cancel edit: editor is not in edit mode");
             }
-            handler.cancel(new EditorRequestImpl<>(grid, rowIndex,
-                    focusedColumnIndex, null));
+            handler.cancel(new EditorRequestImpl<T>(grid, rowIndex,
+                    focusedColumnIndexDOM, null));
             doCancel();
         }
 
@@ -1661,7 +1680,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
             hideOverlay();
             state = State.INACTIVE;
             rowIndex = -1;
-            focusedColumnIndex = -1;
+            focusedColumnIndexDOM = -1;
             grid.getEscalator().setScrollLocked(Direction.VERTICAL, false);
             updateSelectionCheckboxesAsNeeded(true);
         }
@@ -1698,8 +1717,8 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
             state = State.SAVING;
             setButtonsEnabled(false);
             saveTimeout.schedule(SAVE_TIMEOUT_MS);
-            EditorRequest<T> request = new EditorRequestImpl<>(grid, rowIndex,
-                    focusedColumnIndex, saveRequestCallback);
+            EditorRequest<T> request = new EditorRequestImpl<T>(grid, rowIndex,
+                    focusedColumnIndexDOM, saveRequestCallback);
             handler.save(request);
             updateSelectionCheckboxesAsNeeded(true);
         }
@@ -1762,7 +1781,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
             if (state == State.ACTIVATING) {
                 state = State.BINDING;
                 bindTimeout.schedule(BIND_TIMEOUT_MS);
-                EditorRequest<T> request = new EditorRequestImpl<>(grid,
+                EditorRequest<T> request = new EditorRequestImpl<T>(grid,
                         rowIndex, columnIndex, bindRequestCallback);
                 handler.bind(request);
                 grid.getEscalator().setScrollLocked(Direction.VERTICAL,
@@ -1871,8 +1890,8 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
                         grid.attachWidget(editor, cell);
                     }
 
-                    if (i == focusedColumnIndex) {
-                        focusColumn(focusedColumnIndex);
+                    if (i == focusedColumnIndexDOM) {
+                        focusColumn(focusedColumnIndexDOM);
                     }
                 } else {
                     cell.addClassName(NOT_EDITABLE_CLASS_NAME);
@@ -1902,6 +1921,9 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
                         checkBox.addClickHandler(new ClickHandler() {
                             @Override
                             public void onClick(ClickEvent event) {
+                                if (!grid.isUserSelectionAllowed()) {
+                                    return;
+                                }
                                 T row = pinnedRowHandle.getRow();
                                 if (grid.isSelected(row)) {
                                     grid.deselect(row);
@@ -1975,13 +1997,14 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
                     Unit.PX);
         }
 
-        private void focusColumn(int colIndex) {
-            if (colIndex < 0 || colIndex >= grid.getVisibleColumns().size()) {
+        private void focusColumn(int columnIndexDOM) {
+            if (columnIndexDOM < 0
+                    || columnIndexDOM >= grid.getVisibleColumns().size()) {
                 // NO-OP
                 return;
             }
 
-            Widget editor = getWidget(grid.getVisibleColumn(colIndex));
+            Widget editor = getWidget(grid.getVisibleColumn(columnIndexDOM));
             if (editor instanceof Focusable) {
                 ((Focusable) editor).focus();
             } else if (editor instanceof com.google.gwt.user.client.ui.Focusable) {
@@ -2293,7 +2316,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
             extends KeyEvent<HANDLER> {
 
         private Grid<?> grid;
-        private final Type<HANDLER> associatedType = new Type<>(
+        private final Type<HANDLER> associatedType = new Type<HANDLER>(
                 getBrowserEventType(), this);
         private final CellReference<?> targetCell;
 
@@ -2353,7 +2376,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
 
         private Grid<?> grid;
         private final CellReference<?> targetCell;
-        private final Type<HANDLER> associatedType = new Type<>(
+        private final Type<HANDLER> associatedType = new Type<HANDLER>(
                 getBrowserEventType(), this);
 
         public AbstractGridMouseEvent(Grid<?> grid,
@@ -2431,7 +2454,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
      */
     private static final double DETAILS_ROW_INITIAL_HEIGHT = 50;
 
-    private EventCellReference<T> eventCell = new EventCellReference<>(this);
+    private EventCellReference<T> eventCell = new EventCellReference<T>(this);
     private GridKeyDownEvent keyDown = new GridKeyDownEvent(this, eventCell);
     private GridKeyUpEvent keyUp = new GridKeyUpEvent(this, eventCell);
     private GridKeyPressEvent keyPress = new GridKeyPressEvent(this, eventCell);
@@ -2514,8 +2537,8 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
                     setStyleName(rowWithFocusStyle, rowFocusStyleName, true);
                 }
             } else if (rowWithFocusStyle == row.getElement()
-                    || (containerWithFocus != escalator.getBody()
-                            && rowWithFocusStyle != null)) {
+                    || containerWithFocus != escalator.getBody()
+                            && rowWithFocusStyle != null) {
                 // Remove focus style.
                 setStyleName(rowWithFocusStyle, rowFocusStyleName, false);
                 rowWithFocusStyle = null;
@@ -2566,9 +2589,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
                     ++i;
                 } while (cell != null);
             }
-            int columnIndex = getColumns()
-                    .indexOf(getVisibleColumn(columnIndexDOM));
-            if (columnIndex >= escalator.getColumnConfiguration()
+            if (columnIndexDOM >= escalator.getColumnConfiguration()
                     .getFrozenColumnCount()) {
                 escalator.scrollToColumn(columnIndexDOM, ScrollDestination.ANY,
                         10);
@@ -2812,9 +2833,9 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
          *            a range of added rows
          */
         public void rowsAddedToBody(Range added) {
-            boolean bodyHasFocus = (containerWithFocus == escalator.getBody());
-            boolean insertionIsAboveFocusedCell = (added
-                    .getStart() <= rowWithFocus);
+            boolean bodyHasFocus = containerWithFocus == escalator.getBody();
+            boolean insertionIsAboveFocusedCell = added
+                    .getStart() <= rowWithFocus;
             if (bodyHasFocus && insertionIsAboveFocusedCell) {
                 rowWithFocus += added.length();
                 rowWithFocus = Math.min(rowWithFocus,
@@ -2860,12 +2881,12 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
         }
     }
 
-    private final List<GridEventHandler<T>> browserEventHandlers = new ArrayList<>();
+    private final List<GridEventHandler<T>> browserEventHandlers = new ArrayList<GridEventHandler<T>>();
 
     private CellStyleGenerator<T> cellStyleGenerator;
     private RowStyleGenerator<T> rowStyleGenerator;
-    private RowReference<T> rowReference = new RowReference<>(this);
-    private CellReference<T> cellReference = new CellReference<>(rowReference);
+    private RowReference<T> rowReference = new RowReference<T>(this);
+    private CellReference<T> cellReference = new CellReference<T>(rowReference);
     private RendererCellReference rendererCellReference = new RendererCellReference(
             (RowReference<Object>) rowReference);
 
@@ -2875,6 +2896,8 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
         private boolean initDone = false;
         private boolean selected = false;
         private CheckBox selectAllCheckBox;
+        private boolean userSelectionAllowed = true;
+        private boolean enabled = true;
 
         SelectionColumn(final Renderer<Boolean> selectColumnRenderer) {
             super(selectColumnRenderer);
@@ -2905,6 +2928,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
 
             if (selectAllCheckBox == null) {
                 selectAllCheckBox = GWT.create(CheckBox.class);
+                selectAllCheckBox.setEnabled(enabled && userSelectionAllowed);
                 selectAllCheckBox.setStylePrimaryName(
                         getStylePrimaryName() + SELECT_ALL_CHECKBOX_CLASSNAME);
                 selectAllCheckBox.addValueChangeHandler(
@@ -2913,8 +2937,11 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
                             @Override
                             public void onValueChange(
                                     ValueChangeEvent<Boolean> event) {
+                                if (!isUserSelectionAllowed()) {
+                                    return;
+                                }
                                 if (event.getValue()) {
-                                    fireEvent(new SelectAllEvent<>(model));
+                                    fireEvent(new SelectAllEvent<T>(model));
                                     selected = true;
                                 } else {
                                     model.deselectAll();
@@ -2927,6 +2954,10 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
                 addHeaderClickHandler(new HeaderClickHandler() {
                     @Override
                     public void onClick(GridClickEvent event) {
+                        if (!userSelectionAllowed) {
+                            return;
+                        }
+
                         CellReference<?> targetCell = event.getTargetCell();
                         int defaultRowIndex = getHeader().getRows()
                                 .indexOf(getDefaultHeaderRow());
@@ -2946,6 +2977,10 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
                         if (event.getNativeKeyCode() != KeyCodes.KEY_SPACE) {
                             return;
                         }
+                        if (!isUserSelectionAllowed()) {
+                            return;
+                        }
+
                         HeaderRow targetHeaderRow = getHeader()
                                 .getRow(event.getFocusedCell().getRowIndex());
                         if (!targetHeaderRow.isDefault()) {
@@ -3041,8 +3076,9 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
          *            to disable it.
          */
         public void setEnabled(boolean enabled) {
+            this.enabled = enabled;
             if (selectAllCheckBox != null) {
-                selectAllCheckBox.setEnabled(enabled);
+                selectAllCheckBox.setEnabled(enabled && userSelectionAllowed);
             }
         }
 
@@ -3050,6 +3086,27 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
         public void onEnabled(boolean enabled) {
             setEnabled(enabled);
         }
+
+        /**
+         * Sets whether the user is allowed to change the selection.
+         *
+         * @param userSelectionAllowed
+         *            <code>true</code> if the user is allowed to change the
+         *            selection, <code>false</code> otherwise
+         * @since 7.7.7
+         */
+        public void setUserSelectionAllowed(boolean userSelectionAllowed) {
+            if (userSelectionAllowed == this.userSelectionAllowed) {
+                return;
+            }
+
+            this.userSelectionAllowed = userSelectionAllowed;
+            // Update checkbox state
+            setEnabled(enabled);
+            // Re-render select checkboxes
+            getEscalator().getBody().refreshRows(0,
+                    getEscalator().getBody().getRowCount());
+        }
     }
 
     /**
@@ -3201,6 +3258,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
                     }
                 } else if (currentDataAvailable.isEmpty()
                         && dataSource.isWaitingForData()) {
+                    // No data available yet but something is incoming soon
                     Scheduler.get().scheduleDeferred(this);
                 } else {
                     calculate();
@@ -3235,7 +3293,6 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
         private void calculate() {
             isScheduled = false;
             rescheduleCount = 0;
-
             assert !(currentDataAvailable.isEmpty() && dataSource
                     .isWaitingForData()) : "Trying to calculate column widths without data while data is still being fetched.";
 
@@ -3266,7 +3323,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
 
             /* Step 1: Apply all column widths as they are. */
 
-            Map<Integer, Double> selfWidths = new LinkedHashMap<>();
+            Map<Integer, Double> selfWidths = new LinkedHashMap<Integer, Double>();
             List<Column<?, T>> columns = getVisibleColumns();
             for (int index = 0; index < columns.size(); index++) {
                 selfWidths.put(index, columns.get(index).getWidth());
@@ -3280,7 +3337,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
              * violated, fix it.
              */
 
-            Map<Integer, Double> constrainedWidths = new LinkedHashMap<>();
+            Map<Integer, Double> constrainedWidths = new LinkedHashMap<Integer, Double>();
             for (int index = 0; index < columns.size(); index++) {
                 Column<?, T> column = columns.get(index);
 
@@ -3305,9 +3362,9 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
             boolean defaultExpandRatios = true;
             int totalRatios = 0;
             double reservedPixels = 0;
-            final Set<Column<?, T>> columnsToExpand = new HashSet<>();
-            List<Column<?, T>> nonFixedColumns = new ArrayList<>();
-            Map<Integer, Double> columnSizes = new HashMap<>();
+            final Set<Column<?, T>> columnsToExpand = new HashSet<Column<?, T>>();
+            List<Column<?, T>> nonFixedColumns = new ArrayList<Column<?, T>>();
+            Map<Integer, Double> columnSizes = new HashMap<Integer, Double>();
             final List<Column<?, T>> visibleColumns = getVisibleColumns();
 
             /*
@@ -3340,8 +3397,8 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
             setColumnSizes(columnSizes);
 
             for (Column<?, T> column : nonFixedColumns) {
-                final int expandRatio = (defaultExpandRatios ? 1
-                        : column.getExpandRatio());
+                final int expandRatio = defaultExpandRatios ? 1
+                        : column.getExpandRatio();
                 final double maxWidth = getMaxWidth(column);
                 final double newWidth = Math.min(maxWidth,
                         column.getWidthActual());
@@ -3473,8 +3530,8 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
                     boolean hasAutoWidth = column.getWidth() < 0;
                     if (hasAutoWidth && currentWidth < minWidth) {
                         columnSizes.put(columnIndex, minWidth);
-                        pixelsToRemoveFromOtherColumns += (minWidth
-                                - currentWidth);
+                        pixelsToRemoveFromOtherColumns += minWidth
+                                - currentWidth;
                         minWidthsCausedReflows = true;
 
                         /*
@@ -3570,7 +3627,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
 
         private static final String STRIPE_CLASSNAME = "stripe";
 
-        private final Map<Element, Widget> elementToWidgetMap = new HashMap<>();
+        private final Map<Element, Widget> elementToWidgetMap = new HashMap<Element, Widget>();
 
         @Override
         public void init(Spacer spacer) {
@@ -3893,7 +3950,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
                     .getFirstChildElement();
             double height = WidgetUtil
                     .getRequiredHeightBoundingClientRectDouble(firstHeaderCell)
-                    - (WidgetUtil.measureVerticalBorder(getElement()) / 2);
+                    - WidgetUtil.measureVerticalBorder(getElement()) / 2;
             openCloseButton.setHeight(height + "px");
         }
 
@@ -3952,7 +4009,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
     private final class ColumnHider {
 
         /** Map from columns to their hiding toggles, component might change */
-        private HashMap<Column<?, T>, MenuItem> columnToHidingToggleMap = new HashMap<>();
+        private HashMap<Column<?, T>, MenuItem> columnToHidingToggleMap = new HashMap<Column<?, T>, MenuItem>();
 
         /**
          * When column is being hidden with a toggle, do not refresh toggles for
@@ -3969,7 +4026,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
                 toggle.setStyleName("hidden", column.isHidden());
             } else if (columnToHidingToggleMap.containsKey(column)) {
                 sidebar.menuBar
-                        .removeItem((columnToHidingToggleMap.remove(column)));
+                        .removeItem(columnToHidingToggleMap.remove(column));
             }
             updateTogglesOrder();
         }
@@ -4051,7 +4108,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
     /**
      * List of columns in the grid. Order defines the visible order.
      */
-    private List<Column<?, T>> columns = new ArrayList<>();
+    private List<Column<?, T>> columns = new ArrayList<Column<?, T>>();
 
     /**
      * The datasource currently in use. <em>Note:</em> it is <code>null</code>
@@ -4075,7 +4132,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
      * Current sort order. The (private) sort() method reads this list to
      * determine the order in which to present rows.
      */
-    private List<SortOrder> sortOrder = new ArrayList<>();
+    private List<SortOrder> sortOrder = new ArrayList<SortOrder>();
 
     private Renderer<Boolean> selectColumnRenderer = null;
 
@@ -4127,9 +4184,9 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
     private DetailsGenerator detailsGenerator = DetailsGenerator.NULL;
     private GridSpacerUpdater gridSpacerUpdater = new GridSpacerUpdater();
     /** A set keeping track of the indices of all currently open details */
-    private Set<Integer> visibleDetails = new HashSet<>();
+    private Set<Integer> visibleDetails = new HashSet<Integer>();
     /** A set of indices of details to reopen after detach and on attach */
-    private final Set<Integer> reattachVisibleDetails = new HashSet<>();
+    private final Set<Integer> reattachVisibleDetails = new HashSet<Integer>();
 
     private boolean columnReorderingAllowed;
 
@@ -4181,7 +4238,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
          * Map of possible drop positions for the column and the corresponding
          * column index.
          */
-        private final TreeMap<Double, Integer> possibleDropPositions = new TreeMap<>();
+        private final TreeMap<Double, Integer> possibleDropPositions = new TreeMap<Double, Integer>();
         /**
          * Makes sure that drag cancel doesn't cause anything unwanted like sort
          */
@@ -4377,10 +4434,9 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
             final int colspan = header.getRow(eventCell.getRowIndex())
                     .getCell(eventCell.getColumn()).getColspan();
             if (latestColumnDropIndex != draggedColumnIndex
-                    && latestColumnDropIndex != (draggedColumnIndex
-                            + colspan)) {
+                    && latestColumnDropIndex != draggedColumnIndex + colspan) {
                 List<Column<?, T>> columns = getColumns();
-                List<Column<?, T>> reordered = new ArrayList<>();
+                List<Column<?, T>> reordered = new ArrayList<Column<?, T>>();
                 if (draggedColumnIndex < latestColumnDropIndex) {
                     reordered.addAll(columns.subList(0, draggedColumnIndex));
                     reordered.addAll(
@@ -4399,12 +4455,8 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
                     reordered.addAll(columns.subList(
                             draggedColumnIndex + colspan, columns.size()));
                 }
-                reordered.remove(selectionColumn); // since
-                                                   // setColumnOrder
-                                                   // will
-                                                   // add
-                                                   // it
-                                                   // anyway!
+                reordered.remove(selectionColumn); // since setColumnOrder will
+                                                   // add it anyway!
 
                 // capture focused cell column before reorder
                 Cell focusedCell = cellFocusHandler.getFocusedCell();
@@ -4418,9 +4470,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
                         .toArray(new Column[reordered.size()]);
                 setColumnOrder(array);
                 transferCellFocusOnDrop();
-            } // else
-              // no
-              // reordering
+            } // else no reordering
         }
 
         private void transferCellFocusOnDrop() {
@@ -4514,8 +4564,8 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
             int leftBound = -1;
             int rightBound = getColumnCount() + 1;
 
-            final HashSet<Integer> unavailableColumnDropIndices = new HashSet<>();
-            final List<StaticRow<?>> rows = new ArrayList<>();
+            final HashSet<Integer> unavailableColumnDropIndices = new HashSet<Integer>();
+            final List<StaticRow<?>> rows = new ArrayList<StaticRow<?>>();
             rows.addAll(header.getRows());
             rows.addAll(footer.getRows());
             for (StaticRow<?> row : rows) {
@@ -4573,7 +4623,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
                 }
             }
 
-            if (leftBound == (rightBound - 1)) {
+            if (leftBound == rightBound - 1) {
                 return;
             }
 
@@ -5101,7 +5151,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
                 grid.header.updateColSpans();
                 grid.footer.updateColSpans();
                 scheduleColumnWidthRecalculator();
-                this.grid.fireEvent(new ColumnVisibilityChangeEvent<>(this,
+                this.grid.fireEvent(new ColumnVisibilityChangeEvent<T>(this,
                         hidden, userOriginated));
             }
         }
@@ -5495,7 +5545,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
                 setStyleName(rowElement, rowHasDataStyleName, hasData);
             }
 
-            boolean isEvenIndex = (row.getRow() % 2 == 0);
+            boolean isEvenIndex = row.getRow() % 2 == 0;
             setStyleName(rowElement, rowStripeStyleName, !isEvenIndex);
 
             rowReference.set(rowIndex, rowData, rowElement);
@@ -5766,7 +5816,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
 
                                 if (c.getWidth() < 0) {
                                     c.setWidth(c.getWidthActual());
-                                    fireEvent(new ColumnResizeEvent<>(c));
+                                    fireEvent(new ColumnResizeEvent<T>(c));
                                 }
                             }
 
@@ -5821,7 +5871,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
                             dragEnded();
 
                             col.setWidth(width);
-                            fireEvent(new ColumnResizeEvent<>(col));
+                            fireEvent(new ColumnResizeEvent<T>(col));
                         }
                     };
 
@@ -5848,7 +5898,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
                         public void onComplete() {
                             dragEnded();
                             col.setWidth(width);
-                            fireEvent(new ColumnResizeEvent<>(col));
+                            fireEvent(new ColumnResizeEvent<T>(col));
                         }
                     };
 
@@ -5958,7 +6008,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
                 escalator.getColumnConfiguration().setColumnWidth(colIndex,
                         minWidth);
 
-                fireEvent(new ColumnResizeEvent<>(column));
+                fireEvent(new ColumnResizeEvent<T>(column));
             }
         }
 
@@ -6128,7 +6178,6 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
                 new RendererEventHandler(),
                 // Moving cell focus by keyboard or mouse
                 new CellFocusEventHandler()));
-
     }
 
     @Override
@@ -6136,29 +6185,6 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
         return enabled;
     }
 
-    /**
-     * Sets the column resize mode to use. The default mode is
-     * {@link ColumnResizeMode.ANIMATED}.
-     *
-     * @param mode
-     *            a ColumnResizeMode value
-     * @since 7.7.5
-     */
-    public void setColumnResizeMode(ColumnResizeMode mode) {
-        columnResizeMode = mode;
-    }
-
-    /**
-     * Returns the current column resize mode. The default mode is
-     * {@link ColumnResizeMode.ANIMATED}.
-     *
-     * @return a ColumnResizeMode value
-     * @since 7.7.5
-     */
-    public ColumnResizeMode getColumnResizeMode() {
-        return columnResizeMode;
-    }
-
     @Override
     public void setEnabled(boolean enabled) {
         if (enabled == this.enabled) {
@@ -6206,6 +6232,29 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
         }
     }
 
+    /**
+     * Sets the column resize mode to use. The default mode is
+     * {@link ColumnResizeMode.ANIMATED}.
+     *
+     * @param mode
+     *            a ColumnResizeMode value
+     * @since 7.7.5
+     */
+    public void setColumnResizeMode(ColumnResizeMode mode) {
+        columnResizeMode = mode;
+    }
+
+    /**
+     * Returns the current column resize mode. The default mode is
+     * {@link ColumnResizeMode.ANIMATED}.
+     *
+     * @return a ColumnResizeMode value
+     * @since 7.7.5
+     */
+    public ColumnResizeMode getColumnResizeMode() {
+        return columnResizeMode;
+    }
+
     /**
      * Creates the escalator updater used to update the header rows in this
      * grid. The updater is invoked when header rows or columns are added or
@@ -6279,21 +6328,22 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
      *
      * @param rowIndex
      *            index of row to focus
-     * @param columnIndex
-     *            index of cell to focus
+     * @param columnIndexDOM
+     *            index (excluding hidden columns) of cell to focus
      */
-    void focusCell(int rowIndex, int columnIndex) {
+    void focusCell(int rowIndex, int columnIndexDOM) {
         final Range rowRange = Range.between(0, dataSource.size());
         final Range columnRange = Range.between(0, getVisibleColumns().size());
 
         assert rowRange.contains(
                 rowIndex) : "Illegal row index. Should be in range " + rowRange;
         assert columnRange.contains(
-                columnIndex) : "Illegal column index. Should be in range "
+                columnIndexDOM) : "Illegal column index. Should be in range "
                         + columnRange;
 
-        if (rowRange.contains(rowIndex) && columnRange.contains(columnIndex)) {
-            cellFocusHandler.setCellFocus(rowIndex, columnIndex,
+        if (rowRange.contains(rowIndex)
+                && columnRange.contains(columnIndexDOM)) {
+            cellFocusHandler.setCellFocus(rowIndex, columnIndexDOM,
                     escalator.getBody());
             WidgetUtil.focus(getElement());
         }
@@ -6398,7 +6448,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
         column.reapplyWidth();
 
         // Sink all renderer events
-        Set<String> events = new HashSet<>();
+        Set<String> events = new HashSet<String>();
         events.addAll(getConsumedEventsForRenderer(column.getRenderer()));
 
         if (column.isHidable()) {
@@ -6496,7 +6546,8 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
      * @return A unmodifiable list of the columns in the grid
      */
     public List<Column<?, T>> getColumns() {
-        return Collections.unmodifiableList(new ArrayList<>(columns));
+        return Collections
+                .unmodifiableList(new ArrayList<Column<?, T>>(columns));
     }
 
     /**
@@ -6508,7 +6559,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
      * @return A unmodifiable list of the currently visible columns in the grid
      */
     public List<Column<?, T>> getVisibleColumns() {
-        ArrayList<Column<?, T>> visible = new ArrayList<>();
+        ArrayList<Column<?, T>> visible = new ArrayList<Column<?, T>>();
         for (Column<?, T> c : columns) {
             if (!c.isHidden()) {
                 visible.add(c);
@@ -6535,13 +6586,13 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
         return columns.get(index);
     }
 
-    private Column<?, T> getVisibleColumn(int index)
+    private Column<?, T> getVisibleColumn(int columnIndexDOM)
             throws IllegalArgumentException {
         List<Column<?, T>> visibleColumns = getVisibleColumns();
-        if (index < 0 || index >= visibleColumns.size()) {
+        if (columnIndexDOM < 0 || columnIndexDOM >= visibleColumns.size()) {
             throw new IllegalStateException("Column not found.");
         }
-        return visibleColumns.get(index);
+        return visibleColumns.get(columnIndexDOM);
     }
 
     /**
@@ -6928,7 +6979,8 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
                         int oldSize = body.getRowCount();
 
                         // Hide all details.
-                        Set<Integer> oldDetails = new HashSet<>(visibleDetails);
+                        Set<Integer> oldDetails = new HashSet<Integer>(
+                                visibleDetails);
                         for (int i : oldDetails) {
                             setDetailsVisible(i, false);
                         }
@@ -7300,7 +7352,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
     }
 
     private Set<String> getConsumedEventsForRenderer(Renderer<?> renderer) {
-        Set<String> events = new HashSet<>();
+        Set<String> events = new HashSet<String>();
         if (renderer instanceof ComplexRenderer) {
             Collection<String> consumedEvents = ((ComplexRenderer<?>) renderer)
                     .getConsumedEvents();
@@ -7386,7 +7438,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
                 + "-event with a null cell target";
         eventCell.set(cell, getSectionFromContainer(container));
 
-        GridEvent<T> gridEvent = new GridEvent<>(event, eventCell);
+        GridEvent<T> gridEvent = new GridEvent<T>(event, eventCell);
         for (GridEventHandler<T> handler : browserEventHandlers) {
             handler.onEvent(gridEvent);
         }
@@ -7450,13 +7502,14 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
             }
 
             Widget widget;
-            if (editor.focusedColumnIndex < 0) {
+            if (editor.focusedColumnIndexDOM < 0) {
                 widget = null;
             } else {
-                widget = editor.getWidget(getColumn(editor.focusedColumnIndex));
+                widget = editor.getWidget(
+                        getVisibleColumn(editor.focusedColumnIndexDOM));
             }
 
-            EditorDomEvent<T> editorEvent = new EditorDomEvent<>(
+            EditorDomEvent<T> editorEvent = new EditorDomEvent<T>(
                     event.getDomEvent(), event.getCell(), widget);
 
             event.setHandled(
@@ -7559,8 +7612,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
             if (!event.getCell().isHeader()) {
                 return;
             }
-            if (event.getCell().getColumnIndex() < escalator
-                    .getColumnConfiguration().getFrozenColumnCount()) {
+            if (event.getCell().getColumnIndex() < getFrozenColumnCount()) {
                 return;
             }
 
@@ -7939,8 +7991,6 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
     /**
      * Deselect all rows using the current selection model.
      *
-     * @param row
-     *            a row object
      * @return <code>true</code> iff the current selection changed
      * @throws IllegalStateException
      *             if the current selection model is not an instance of
@@ -7948,7 +7998,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
      */
     public boolean deselectAll() {
         if (selectionModel instanceof SelectionModel.Single<?>) {
-            Single<T> single = ((SelectionModel.Single<T>) selectionModel);
+            Single<T> single = (SelectionModel.Single<T>) selectionModel;
             if (single.getSelectedRow() != null) {
                 return single.deselect(single.getSelectedRow());
             } else {
@@ -8418,8 +8468,8 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
      */
     private void sort(boolean userOriginated) {
         refreshHeader();
-        fireEvent(new SortEvent<>(this, Collections.unmodifiableList(sortOrder),
-                userOriginated));
+        fireEvent(new SortEvent<T>(this,
+                Collections.unmodifiableList(sortOrder), userOriginated));
     }
 
     private int getLastVisibleRowIndex() {
@@ -8500,7 +8550,7 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
         // Trigger ComplexRenderer.destroy for old content
         conf.removeColumns(0, conf.getColumnCount());
 
-        List<Column<?, T>> newOrder = new ArrayList<>();
+        List<Column<?, T>> newOrder = new ArrayList<Column<?, T>>();
         if (selectionColumn != null) {
             newOrder.add(selectionColumn);
         }
@@ -8774,11 +8824,15 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
 
         // Grid was just attached to DOM. Column widths should be calculated.
         recalculateColumnWidths();
+        for (int row : reattachVisibleDetails) {
+            setDetailsVisible(row, true);
+        }
+        reattachVisibleDetails.clear();
     }
 
     @Override
     protected void onDetach() {
-        Set<Integer> details = new HashSet<>(visibleDetails);
+        Set<Integer> details = new HashSet<Integer>(visibleDetails);
         reattachVisibleDetails.clear();
         reattachVisibleDetails.addAll(details);
         for (int row : details) {
@@ -9190,11 +9244,28 @@ public class Grid<T> extends ResizeComposite implements HasSelectionHandlers<T>,
         if (container != null) {
             Cell cell = container.getCell(element);
             if (cell != null) {
-                EventCellReference<T> cellRef = new EventCellReference<>(this);
+                EventCellReference<T> cellRef = new EventCellReference<T>(this);
                 cellRef.set(cell, getSectionFromContainer(container));
                 return cellRef;
             }
         }
         return null;
     }
+
+    /**
+     * Checks if selection by the user is allowed in the grid.
+     *
+     * @return <code>true</code> if selection by the user is allowed by the
+     *         selection model (the default), <code>false</code> otherwise
+     * @since 7.7.7
+     */
+    public boolean isUserSelectionAllowed() {
+        if (!(getSelectionModel() instanceof HasUserSelectionAllowed)) {
+            // Selection model does not support toggling user selection allowed
+            // - old default is to always allow selection
+            return true;
+        }
+        return ((HasUserSelectionAllowed) getSelectionModel())
+                .isUserSelectionAllowed();
+    }
 }
index 6cc933e670f139b7c141ff3d2a717981c592ef73..5b25a48ba956a4290c535a05e1f243606ff58580 100644 (file)
@@ -344,7 +344,13 @@ public class GAEVaadinServlet extends VaadinServlet {
                 VaadinSession vaadinSession = (VaadinSession) ois.readObject();
                 getService().storeSession(vaadinSession,
                         new WrappedHttpSession(session));
-            } catch (IOException | ClassNotFoundException e) {
+            } catch (IOException e) {
+                getLogger().log(Level.WARNING,
+                        "Could not de-serialize ApplicationContext for "
+                                + session.getId()
+                                + " A new one will be created. ",
+                        e);
+            } catch (ClassNotFoundException e) {
                 getLogger().log(Level.WARNING,
                         "Could not de-serialize ApplicationContext for "
                                 + session.getId()
index 2bd55555b302ae902009488b8fd1f1313dcabdfa..438376923e747b600db7f7cc1bb1178283f2883a 100644 (file)
@@ -180,6 +180,7 @@ public interface Buffered extends Serializable {
             return source;
         }
 
+        // Intentional change in compatibility package
         @Override
         public ErrorMessage getErrorMessage() {
             // no message, only the causes to be painted
index 200ed937791daadb20d6ad7f5a1819dba15ee3b8..9167dd2c677afeb1c6e533e1eb8388ab1184a5e0 100644 (file)
@@ -167,6 +167,7 @@ public interface Validator extends Serializable {
             return causes;
         }
 
+        // Intentional change in compatibility package
         @Override
         public ErrorMessage getErrorMessage() {
             UserError error = new UserError(getHtmlMessage(), ContentMode.HTML,
index 0fd03c21ad424bcde67590aa13f43ad339f48bd4..3a2d5cd526907d7eac19dfe76f7c9c9e32b11517 100644 (file)
@@ -160,7 +160,7 @@ public class DefaultFieldGroupFieldFactory implements FieldGroupFieldFactory {
      * @since 7.4
      * @param fieldType
      *            the type of the field
-     * @return true if any LegacyAbstractField can be assigned to the field
+     * @return true if any AbstractField can be assigned to the field
      */
     protected boolean anyField(Class<?> fieldType) {
         return fieldType == Field.class || fieldType == AbstractField.class;
index a56703090fb111ec1447589534320d087f2687f7..40802512cb78deba6342649778a09640b60de4e0 100644 (file)
@@ -39,8 +39,10 @@ import com.vaadin.v7.ui.Field;
  * FieldGroup provides an easy way of binding fields to data and handling
  * commits of these fields.
  * <p>
- * The typical use case is to create a layout outside the FieldGroup and then
- * use FieldGroup to bind the fields to a data source.
+ * The functionality of FieldGroup is similar to {@link Form} but
+ * {@link FieldGroup} does not handle layouts in any way. The typical use case
+ * is to create a layout outside the FieldGroup and then use FieldGroup to bind
+ * the fields to a data source.
  * </p>
  * <p>
  * {@link FieldGroup} is not a UI component so it cannot be added to a layout.
@@ -991,7 +993,7 @@ public class FieldGroup implements Serializable {
                             .createCaptionByPropertyId(propertyId);
                 }
 
-                // Create the component (LegacyField)
+                // Create the component (Field)
                 field = build(caption, propertyType, fieldType);
 
                 // Store it in the field
@@ -1217,7 +1219,7 @@ public class FieldGroup implements Serializable {
      * <p>
      * The data type is the type that we want to edit using the field. The field
      * type is the type of field we want to create, can be {@link Field} if any
-     * LegacyField is good.
+     * Field is good.
      * </p>
      *
      * @param caption
@@ -1226,7 +1228,7 @@ public class FieldGroup implements Serializable {
      *            The data model type that we want to edit using the field
      * @param fieldType
      *            The type of field that we want to create
-     * @return A LegacyField capable of editing the given type
+     * @return A Field capable of editing the given type
      * @throws BindException
      *             If the field could not be created
      */
@@ -1244,9 +1246,9 @@ public class FieldGroup implements Serializable {
     }
 
     /**
-     * Returns an array containing LegacyField objects reflecting all the fields
-     * of the class or interface represented by this Class object. The elements
-     * in the array returned are sorted in declare order from sub class to super
+     * Returns an array containing Field objects reflecting all the fields of
+     * the class or interface represented by this Class object. The elements in
+     * the array returned are sorted in declare order from sub class to super
      * class.
      *
      * @param searchClass
index cf9c4d8fcc737d942dd3c433d8b0e7aeabcd538c..4a62a19aaa5ba6089697063a66fe135bf1a4fd56 100644 (file)
@@ -20,8 +20,8 @@ import java.io.Serializable;
 import com.vaadin.v7.ui.Field;
 
 /**
- * Factory interface for creating new LegacyField-instances based on the data
- * type that should be edited.
+ * Factory interface for creating new Field-instances based on the data type
+ * that should be edited.
  *
  * @author Vaadin Ltd.
  * @since 7.0
index 70ce6424567b4fc4008efccc3071f0c33adb8f53..1ec6bad129adeb52a470cff78f5cd54017b975f3 100644 (file)
@@ -174,11 +174,6 @@ public abstract class AbstractBeanContainer<IDTYPE, BEANTYPE>
         model = BeanItem.getPropertyDescriptors((Class<BEANTYPE>) type);
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see com.vaadin.data.Container#getType(java.lang.Object)
-     */
     @Override
     public Class<?> getType(Object propertyId) {
         VaadinPropertyDescriptor<BEANTYPE> descriptor = model.get(propertyId);
@@ -211,21 +206,11 @@ public abstract class AbstractBeanContainer<IDTYPE, BEANTYPE>
         return type;
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see com.vaadin.data.Container#getContainerPropertyIds()
-     */
     @Override
     public Collection<String> getContainerPropertyIds() {
         return model.keySet();
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see com.vaadin.data.Container#removeAllItems()
-     */
     @Override
     public boolean removeAllItems() {
         int origSize = size();
@@ -248,11 +233,6 @@ public abstract class AbstractBeanContainer<IDTYPE, BEANTYPE>
         return true;
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see com.vaadin.data.Container#getItem(java.lang.Object)
-     */
     @Override
     public BeanItem<BEANTYPE> getItem(Object itemId) {
         // TODO return only if visible?
@@ -264,23 +244,12 @@ public abstract class AbstractBeanContainer<IDTYPE, BEANTYPE>
         return itemIdToItem.get(itemId);
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see com.vaadin.data.Container#getItemIds()
-     */
     @Override
     @SuppressWarnings("unchecked")
     public List<IDTYPE> getItemIds() {
         return (List<IDTYPE>) super.getItemIds();
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see com.vaadin.data.Container#getContainerProperty(java.lang.Object,
-     * java.lang.Object)
-     */
     @Override
     public Property getContainerProperty(Object itemId, Object propertyId) {
         Item item = getItem(itemId);
@@ -290,11 +259,6 @@ public abstract class AbstractBeanContainer<IDTYPE, BEANTYPE>
         return item.getItemProperty(propertyId);
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see com.vaadin.data.Container#removeItem(java.lang.Object)
-     */
     @Override
     public boolean removeItem(Object itemId) {
         // TODO should also remove items that are filtered out
@@ -330,13 +294,6 @@ public abstract class AbstractBeanContainer<IDTYPE, BEANTYPE>
         filterAll();
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * com.vaadin.data.Container.Filterable#addContainerFilter(java.lang.Object,
-     * java.lang.String, boolean, boolean)
-     */
     @Override
     public void addContainerFilter(Object propertyId, String filterString,
             boolean ignoreCase, boolean onlyMatchPrefix) {
@@ -349,11 +306,6 @@ public abstract class AbstractBeanContainer<IDTYPE, BEANTYPE>
         }
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see com.vaadin.data.Container.Filterable#removeAllContainerFilters()
-     */
     @Override
     public void removeAllContainerFilters() {
         if (!getFilters().isEmpty()) {
@@ -364,13 +316,6 @@ public abstract class AbstractBeanContainer<IDTYPE, BEANTYPE>
         }
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * com.vaadin.data.Container.Filterable#removeContainerFilters(java.lang
-     * .Object)
-     */
     @Override
     public void removeContainerFilters(Object propertyId) {
         Collection<Filter> removedFilters = super.removeFilters(propertyId);
@@ -393,21 +338,11 @@ public abstract class AbstractBeanContainer<IDTYPE, BEANTYPE>
         removeFilter(filter);
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see com.vaadin.data.util.AbstractInMemoryContainer#hasContainerFilters()
-     */
     @Override
     public boolean hasContainerFilters() {
         return super.hasContainerFilters();
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see com.vaadin.data.util.AbstractInMemoryContainer#getContainerFilters()
-     */
     @Override
     public Collection<Filter> getContainerFilters() {
         return super.getContainerFilters();
@@ -461,22 +396,11 @@ public abstract class AbstractBeanContainer<IDTYPE, BEANTYPE>
         }
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see com.vaadin.data.Container.Sortable#getSortableContainerPropertyIds()
-     */
     @Override
     public Collection<?> getSortableContainerPropertyIds() {
         return getSortablePropertyIds();
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see com.vaadin.data.Container.Sortable#sort(java.lang.Object[],
-     * boolean[])
-     */
     @Override
     public void sort(Object[] propertyId, boolean[] ascending) {
         sortContainer(propertyId, ascending);
index 2f7346d2dbd0ff6a27d553e3b4078dc58a6754bd..ea7b1ca570c61d935b65b5b57b870ead608a9406 100644 (file)
@@ -595,11 +595,6 @@ public abstract class AbstractInMemoryContainer<ITEMIDTYPE, PROPERTYIDCLASS, ITE
         return !getContainerFilters().isEmpty();
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see com.vaadin.data.Container.Filterable#getContainerFilters()
-     */
     protected Collection<Filter> getContainerFilters() {
         return Collections.unmodifiableCollection(filters);
     }
index 86d6b85bc8a359adfe3398f38b0e4b95da102814..9c084f4bbb620c58a593de46d5fa2717087a5ba9 100644 (file)
@@ -70,6 +70,8 @@ public abstract class AbstractProperty<T> implements Property<T>,
         }
     }
 
+    // LegacyPropertyHelper has been removed in Vaadin 8
+
     /* Events */
 
     /**
index 28213d77dca796c99c5727eed3a5b29325676839..3a175ac9ee7d1bb2d630d3dee82e313e14ff4885 100644 (file)
@@ -253,7 +253,7 @@ public class BeanItem<BT> extends PropertysetItem {
      */
     public void addNestedProperty(String nestedPropertyId) {
         addItemProperty(nestedPropertyId,
-                new NestedMethodProperty<BT>(getBean(), nestedPropertyId));
+                new NestedMethodProperty<Object>(getBean(), nestedPropertyId));
     }
 
     /**
@@ -278,6 +278,7 @@ public class BeanItem<BT> extends PropertysetItem {
      *
      * @param bean
      *            The new bean to use for this item, not <code>null</code>
+     * @since 7.7.7
      */
     public void setBean(BT bean) {
         if (bean == null) {
index e0b95bfe14883377cea2406bb8b1157defc2742a..8e33aee66e202c2af2f652151f0cbba46dea366f 100644 (file)
@@ -402,11 +402,6 @@ public class HierarchicalContainer extends IndexedContainer
 
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see com.vaadin.data.util.IndexedContainer#addItem()
-     */
     @Override
     public Object addItem() {
         disableContentsChangeEvents();
@@ -463,11 +458,6 @@ public class HierarchicalContainer extends IndexedContainer
         }
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see com.vaadin.data.util.IndexedContainer#addItem(java.lang.Object)
-     */
     @Override
     public Item addItem(Object itemId) {
         disableContentsChangeEvents();
@@ -490,11 +480,6 @@ public class HierarchicalContainer extends IndexedContainer
         }
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see com.vaadin.data.util.IndexedContainer#removeAllItems()
-     */
     @Override
     public boolean removeAllItems() {
         disableContentsChangeEvents();
@@ -522,11 +507,6 @@ public class HierarchicalContainer extends IndexedContainer
         }
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see com.vaadin.data.util.IndexedContainer#removeItem(java.lang.Object )
-     */
     @Override
     public boolean removeItem(Object itemId) {
         disableContentsChangeEvents();
@@ -647,11 +627,6 @@ public class HierarchicalContainer extends IndexedContainer
 
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see com.vaadin.data.util.IndexedContainer#doSort()
-     */
     @Override
     protected void doSort() {
         super.doSort();
@@ -693,13 +668,6 @@ public class HierarchicalContainer extends IndexedContainer
         }
     }
 
-    /*
-     * Overridden to provide filtering for root & children items.
-     *
-     * (non-Javadoc)
-     *
-     * @see com.vaadin.data.util.IndexedContainer#updateContainerFiltering()
-     */
     @Override
     protected boolean doFilterContainer(boolean hasFilters) {
         if (!hasFilters) {
@@ -839,12 +807,6 @@ public class HierarchicalContainer extends IndexedContainer
 
     private Set<Object> filterOverride = null;
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * com.vaadin.data.util.IndexedContainer#passesFilters(java.lang.Object)
-     */
     @Override
     protected boolean passesFilters(Object itemId) {
         if (filterOverride != null) {
index 1e755f1a54cf5224d5110a521ef07cd5549255b7..3fada7957701ca3e8a0c9cffe82d11f23b00bd8c 100644 (file)
@@ -869,6 +869,8 @@ public class IndexedContainer
             firePropertyValueChange(this);
         }
 
+        // LegacyPropertyHelper has been removed in Vaadin 8
+
         /**
          * Calculates a integer hash-code for the Property that's unique inside
          * the Item containing the Property. Two different Properties inside the
@@ -982,13 +984,13 @@ public class IndexedContainer
                 ? (ListSet<Object>) ((ListSet<Object>) getAllItemIds()).clone()
                 : null);
         nc.setItemSetChangeListeners(getItemSetChangeListeners() != null
-                ? new LinkedList<ItemSetChangeListener>(
+                ? new LinkedList<Container.ItemSetChangeListener>(
                         getItemSetChangeListeners())
                 : null);
         nc.propertyIds = propertyIds != null
                 ? (ArrayList<Object>) propertyIds.clone() : null;
         nc.setPropertySetChangeListeners(getPropertySetChangeListeners() != null
-                ? new LinkedList<PropertySetChangeListener>(
+                ? new LinkedList<Container.PropertySetChangeListener>(
                         getPropertySetChangeListeners())
                 : null);
         nc.propertyValueChangeListeners = propertyValueChangeListeners != null
index e3651d0272f8a9c7a25b25c0df1918af7fe576b6..87d56bb4c934b8d67f53cdf875815ac8584b6915 100644 (file)
@@ -773,6 +773,7 @@ public class MethodProperty<T> extends AbstractProperty<T> {
      * The instance used by this property
      *
      * @return the instance used for fetching the property value
+     * @since 7.7.7
      */
     public Object getInstance() {
         return instance;
@@ -788,6 +789,7 @@ public class MethodProperty<T> extends AbstractProperty<T> {
      *
      * @param instance
      *            the instance to use
+     * @since 7.7.7
      */
     public void setInstance(Object instance) {
         if (this.instance.getClass() != instance.getClass()) {
index de1561034c4ef36b3e599509947261e4aeca700f..3657a70266b3dabfafba32480e7ddf199d2f2218 100644 (file)
@@ -272,6 +272,7 @@ public class NestedMethodProperty<T> extends AbstractProperty<T> {
      * The instance used by this property
      *
      * @return the instance used for fetching the property value
+     * @since 7.7.7
      */
     public Object getInstance() {
         return instance;
@@ -287,6 +288,7 @@ public class NestedMethodProperty<T> extends AbstractProperty<T> {
      *
      * @param instance
      *            the instance to use
+     * @since 7.7.7
      */
     public void setInstance(Object instance) {
         if (this.instance.getClass() != instance.getClass()) {
index a0cfae040ce2a600d9273409d330fc2b7ba49f2a..cd41d887eda1e78fc9abc23c1179737b12a3f770 100644 (file)
@@ -50,7 +50,7 @@ public class NestedPropertyDescriptor<BT>
     public NestedPropertyDescriptor(String name, Class<BT> beanType)
             throws IllegalArgumentException {
         this.name = name;
-        NestedMethodProperty<?> property = new NestedMethodProperty<BT>(
+        NestedMethodProperty<?> property = new NestedMethodProperty<Object>(
                 beanType, name);
         this.propertyType = property.getType();
     }
@@ -67,7 +67,7 @@ public class NestedPropertyDescriptor<BT>
 
     @Override
     public Property<?> createProperty(BT bean) {
-        return new NestedMethodProperty<BT>(bean, name);
+        return new NestedMethodProperty<Object>(bean, name);
     }
 
 }
index 05a2b55ea76a7bc1bafc32a3d68e6020bdb5f890..b60b0ed98bec18807dafe43a48854468c2e186f7 100644 (file)
@@ -205,7 +205,7 @@ public class PropertysetItem
     public void addPropertySetChangeListener(
             Item.PropertySetChangeListener listener) {
         if (propertySetChangeListeners == null) {
-            propertySetChangeListeners = new LinkedList<Item.PropertySetChangeListener>();
+            propertySetChangeListeners = new LinkedList<PropertySetChangeListener>();
         }
         propertySetChangeListeners.add(listener);
     }
index a93489a0b4a8216418d8ccdc07e72184de5819d1..9d1580af9ed6ad72bc23e1bdc17566eb95a819bd 100644 (file)
@@ -52,6 +52,7 @@ public class ConverterUtil implements Serializable {
         }
 
         if (session != null) {
+            // Intentional change in compatibility package
             ConverterFactory factory = (ConverterFactory) session
                     .getConverterFactory();
             if (factory == null) {
index 3440179e6a13c00218b63151fd99eec427d9409e..4013915aa7f02b0dd558b33e198239276c1ef5c1 100644 (file)
@@ -254,6 +254,8 @@ final public class ColumnProperty implements Property {
         return propertyId;
     }
 
+    // LegacyPropertyHelper has been removed in Vaadin 8
+
     private static Logger getLogger() {
         return Logger.getLogger(ColumnProperty.class.getName());
     }
index f18940da8bac822a59208ea47fbeda7b82746da8..38542272ee90cd23f57b34cb54463932a564e13d 100644 (file)
@@ -1419,7 +1419,7 @@ public class SQLContainer implements Container, Container.Filterable,
     public void addItemSetChangeListener(
             Container.ItemSetChangeListener listener) {
         if (itemSetChangeListeners == null) {
-            itemSetChangeListeners = new LinkedList<ItemSetChangeListener>();
+            itemSetChangeListeners = new LinkedList<Container.ItemSetChangeListener>();
         }
         itemSetChangeListeners.add(listener);
     }
index 7354a9aa0648af702b39c9f421616a7318c4aea9..ef8dde86f4ebe828f6056fe1ace4827e136c727b 100644 (file)
@@ -28,8 +28,8 @@ import com.vaadin.v7.data.util.converter.StringToDoubleConverter;
  *             field instead or bind the field to a {@link Property} of type
  *             {@link Double}.
  */
-@SuppressWarnings("serial")
 @Deprecated
+@SuppressWarnings("serial")
 public class DoubleValidator extends AbstractStringValidator {
 
     /**
index 59e078e37886f81c8cda7be6169075528ca5e4ea..3f2b1d5c1f1c06a2e2d2a834ec6c48ede1b91a96 100644 (file)
@@ -55,16 +55,15 @@ import com.vaadin.v7.shared.AbstractFieldState;
  * <p>
  * Abstract field component for implementing buffered property editors. The
  * field may hold an internal value, or it may be connected to any data source
- * that implements the {@link Property}interface.
- * <code>LegacyAbstractField</code> implements that interface itself, too, so
- * accessing the Property value represented by it is straightforward.
+ * that implements the {@link Property} interface. <code>AbstractField</code>
+ * implements that interface itself, too, so accessing the Property value
+ * represented by it is straightforward.
  * </p>
  *
  * <p>
- * LegacyAbstractField also provides the {@link Buffered} interface for
- * buffering the data source value. By default the LegacyField is in write
- * through-mode and {@link #setWriteThrough(boolean)}should be called to enable
- * buffering.
+ * AbstractField also provides the {@link Buffered} interface for buffering the
+ * data source value. By default the Field is in write through-mode and
+ * {@link #setWriteThrough(boolean)}should be called to enable buffering.
  * </p>
  *
  * <p>
@@ -193,13 +192,13 @@ public abstract class AbstractField<T> extends AbstractLegacyComponent
     }
 
     /**
-     * Returns the type of the LegacyField. The methods <code>getValue</code>
-     * and <code>setValue</code> must be compatible with this type: one must be
-     * able to safely cast the value returned from <code>getValue</code> to the
-     * given type and pass any variable assignable to this type as an argument
-     * to <code>setValue</code>.
+     * Returns the type of the Field. The methods <code>getValue</code> and
+     * <code>setValue</code> must be compatible with this type: one must be able
+     * to safely cast the value returned from <code>getValue</code> to the given
+     * type and pass any variable assignable to this type as an argument to
+     * <code>setValue</code>.
      *
-     * @return the type of the LegacyField
+     * @return the type of the Field
      */
     @Override
     public abstract Class<? extends T> getType();
@@ -348,7 +347,7 @@ public abstract class AbstractField<T> extends AbstractLegacyComponent
     }
 
     /**
-     * Sets the buffered mode of this LegacyField.
+     * Sets the buffered mode of this Field.
      * <p>
      * When the field is in buffered mode, changes will not be committed to the
      * property data source until {@link #commit()} is called.
@@ -376,7 +375,7 @@ public abstract class AbstractField<T> extends AbstractLegacyComponent
     }
 
     /**
-     * Checks the buffered mode of this LegacyField.
+     * Checks the buffered mode of this Field.
      *
      * @return true if buffered mode is on, false otherwise
      */
@@ -385,6 +384,8 @@ public abstract class AbstractField<T> extends AbstractLegacyComponent
         return buffered;
     }
 
+    // LegacyPropertyHelper has been removed in Vaadin 8
+
     /* Property interface implementation */
 
     /**
@@ -913,7 +914,7 @@ public abstract class AbstractField<T> extends AbstractLegacyComponent
     }
 
     /**
-     * Checks the validity of the LegacyField.
+     * Checks the validity of the Field.
      *
      * A field is invalid if it is set as required (using
      * {@link #setRequired(boolean)} and is empty, if one or several of the
@@ -1079,7 +1080,7 @@ public abstract class AbstractField<T> extends AbstractLegacyComponent
         } catch (final java.lang.NoSuchMethodException e) {
             // This should never happen
             throw new java.lang.RuntimeException(
-                    "Internal error finding methods in LegacyAbstractField");
+                    "Internal error finding methods in AbstractField");
         }
     }
 
@@ -1152,7 +1153,7 @@ public abstract class AbstractField<T> extends AbstractLegacyComponent
         } catch (final java.lang.NoSuchMethodException e) {
             // This should never happen
             throw new java.lang.RuntimeException(
-                    "Internal error finding methods in LegacyAbstractField");
+                    "Internal error finding methods in AbstractField");
         }
     }
 
@@ -1348,10 +1349,10 @@ public abstract class AbstractField<T> extends AbstractLegacyComponent
     }
 
     /**
-     * Sets the internal field value. This is purely used by LegacyAbstractField
-     * to change the internal LegacyField value. It does not trigger valuechange
-     * events. It can be overridden by the inheriting classes to update all
-     * dependent variables.
+     * Sets the internal field value. This is purely used by AbstractField to
+     * change the internal Field value. It does not trigger valuechange events.
+     * It can be overridden by the inheriting classes to update all dependent
+     * variables.
      *
      * Subclasses can also override {@link #getInternalValue()} if necessary.
      *
index 482dd0b2afcfba14c655e31ee16622b4db1b1a69..5fa82535bcd09a4069a6b4850040c6210fa805a6 100644 (file)
@@ -460,8 +460,8 @@ public abstract class AbstractTextField extends AbstractField<String> implements
          * Make sure w reset lastKnownTextContent field on value change. The
          * clearing must happen here as well because TextChangeListener can
          * revert the original value. Client must respect the value in this
-         * case. LegacyAbstractField optimizes value change if the existing
-         * value is reset. Also we need to force repaint if the flag is on.
+         * case. AbstractField optimizes value change if the existing value is
+         * reset. Also we need to force repaint if the flag is on.
          */
         if (lastKnownTextContent != null) {
             lastKnownTextContent = null;
index 6e5c1df7f86fc5e9fddd60fa5168b564089c4b15..259de0d0ad4a94d4b838a3389bdebd5c6de5067a 100644 (file)
@@ -942,16 +942,13 @@ public class Calendar extends AbstractLegacyComponent
     }
 
     /**
-     * <p>
      * This method restricts the hours that are shown per day. This affects the
      * weekly view. The general contract is that <b>firstHour < lastHour</b>.
-     * </p>
-     *
      * <p>
      * Note that this only affects the rendering process. Events are still
      * requested by the dates set by {@link #setStartDate(Date)} and
      * {@link #setEndDate(Date)}.
-     * </p>
+     * <p>
      * You can use {@link #autoScaleVisibleHoursOfDay()} for automatic scaling
      * of the visible hours based on current events.
      *
index 9aabd6293e41c39589256567a620d0750dc3a79c..736626678745a5927bc138af8ad7b572eb0628cb 100644 (file)
@@ -129,9 +129,9 @@ public class CheckBox extends AbstractField<Boolean> {
     }
 
     /*
-     * Overridden to keep the shared state in sync with the LegacyAbstractField
-     * internal value. Should be removed once LegacyAbstractField is refactored
-     * to use shared state.
+     * Overridden to keep the shared state in sync with the AbstractField
+     * internal value. Should be removed once AbstractField is refactored to use
+     * shared state.
      *
      * See tickets #10921 and #11064.
      */
index 33ca986fa182a107cf18647a854f9eb1e536cdf9..05b6f950ca2b9c6fcc74dd67fc1d850976091c93 100644 (file)
@@ -56,8 +56,8 @@ import com.vaadin.v7.shared.ui.datefield.TextualDateFieldState;
  * compatible with <code>java.util.Date</code>.
  * </p>
  * <p>
- * Since <code>DateField</code> extends <code>LegacyAbstractField</code> it
- * implements the {@link Buffered}interface.
+ * Since <code>DateField</code> extends <code>AbstractField</code> it implements
+ * the {@link Buffered}interface.
  * </p>
  * <p>
  * A <code>DateField</code> is in write-through mode by default, so
@@ -717,6 +717,21 @@ public class DateField extends AbstractField<Date> implements
              * and flags about invalid input.
              */
             setInternalValue(null);
+
+            /*
+             * Due to DateField's special implementation of isValid(),
+             * datefields validity may change although the logical value does
+             * not change. This is an issue for Form which expects that validity
+             * of Fields cannot change unless actual value changes.
+             *
+             * So we check if this field is inside a form and the form has
+             * registered this as a field. In this case we repaint the form.
+             * Without this hacky solution the form might not be able to clean
+             * validation errors etc. We could avoid this by firing an extra
+             * value change event, but feels like at least as bad solution as
+             * this.
+             */
+            notifyFormOfValidityChange();
             markAsDirty();
             return;
         }
index b8756c3d7f3e1130b8baca4baaac394c289f9a68..f42000a1193f949fb0a6b6da98e9f2ee71e0ffe0 100644 (file)
@@ -86,13 +86,13 @@ public class DefaultFieldFactory
     /**
      * Creates fields based on the property type.
      * <p>
-     * The default field type is {@link LegacyTextField}. Other field types
-     * generated by this method:
+     * The default field type is {@link TextField}. Other field types generated
+     * by this method:
      * <p>
      * <b>Boolean</b>: {@link CheckBox}.<br/>
-     * <b>Date</b>: {@link LegacyDateField}(resolution: day).<br/>
+     * <b>Date</b>: {@link DateField}(resolution: day).<br/>
      * <b>Item</b>: {@link Form}. <br/>
-     * <b>default field type</b>: {@link LegacyTextField}.
+     * <b>default field type</b>: {@link TextField}.
      * <p>
      *
      * @param type
index 1e3a4fa7a369f319cf604df391dadcc1db4f59e6..6cb08af5f00ed6750ee0d8b693f3872b45523c3e 100644 (file)
@@ -22,14 +22,14 @@ import com.vaadin.v7.data.BufferedValidatable;
 import com.vaadin.v7.data.Property;
 
 /**
- * LegacyField interface is implemented by all legacy field components that have
- * value that the user can change through the user interface.
+ * Field interface is implemented by all classes (field components) that have a
+ * value that the user can change through the user interface.
  *
- * LegacyField components are built upon the framework defined in the
- * LegacyField interface and the {@link AbstractField} base class.
+ * Field components are built upon the framework defined in the Field interface
+ * and the {@link AbstractField} base class.
  *
- * The LegacyField interface inherits the {@link Component} superinterface and
- * also the {@link Property} interface to have a value for the field.
+ * The Field interface inherits the {@link Component} superinterface and also
+ * the {@link Property} interface to have a value for the field.
  *
  * @author Vaadin Ltd.
  *
@@ -85,8 +85,8 @@ public interface Field<T> extends Component, BufferedValidatable, Property<T>,
     public String getRequiredError();
 
     /**
-     * An <code>Event</code> object specifying the LegacyField whose value has
-     * been changed.
+     * An <code>Event</code> object specifying the Field whose value has been
+     * changed.
      *
      * @author Vaadin Ltd.
      * @since 3.0
index c671caea934fccf529867ea2ec6ee0a54038694d..4fc9a63789599a04e4adf0d97173b9461c15333f 100644 (file)
@@ -49,6 +49,7 @@ import com.vaadin.v7.data.Item;
 import com.vaadin.v7.data.Property;
 import com.vaadin.v7.data.Validatable;
 import com.vaadin.v7.data.Validator;
+import com.vaadin.v7.data.Validator.InvalidValueException;
 import com.vaadin.v7.data.fieldgroup.FieldGroup;
 import com.vaadin.v7.data.util.BeanItem;
 import com.vaadin.v7.shared.form.FormState;
@@ -190,7 +191,7 @@ public class Form extends AbstractField<Object>
      * @param formLayout
      *            the layout of the form.
      * @param fieldFactory
-     *            the TableFieldFactory of the form.
+     *            the FieldFactory of the form.
      */
     public Form(Layout formLayout, FormFieldFactory fieldFactory) {
         super();
@@ -317,7 +318,7 @@ public class Form extends AbstractField<Object>
      */
     @Override
     public void commit()
-            throws Buffered.SourceException, Validator.InvalidValueException {
+            throws Buffered.SourceException, InvalidValueException {
 
         LinkedList<SourceException> problems = null;
 
@@ -961,7 +962,7 @@ public class Form extends AbstractField<Object>
      * @see Validatable#validate()
      */
     @Override
-    public void validate() throws Validator.InvalidValueException {
+    public void validate() throws InvalidValueException {
         super.validate();
         for (final Iterator<Object> i = propertyIds.iterator(); i.hasNext();) {
             fields.get(i.next()).validate();
index a2c963c0a4d5746b01d5451d17a82afabd2a0caa..390b77eaac70efafbf9605f66922839187a530d3 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * 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
@@ -26,9 +26,9 @@ import com.vaadin.v7.data.fieldgroup.FieldGroup;
  * property id and uiContext (the component responsible for displaying fields).
  * Currently this interface is used by {@link Form}, but might later be used by
  * some other components for {@link Field} generation.
- * 
+ *
  * <p>
- * 
+ *
  * @author Vaadin Ltd.
  * @since 6.0
  * @see TableFieldFactory
@@ -40,7 +40,7 @@ public interface FormFieldFactory extends Serializable {
     /**
      * Creates a field based on the item, property id and the component (most
      * commonly {@link Form}) where the Field will be presented.
-     * 
+     *
      * @param item
      *            the item where the property belongs to.
      * @param propertyId
index 207132f364ecbaecaf90aae0fd62ccb49b3d9c66..f9a5062ac17d0974161081b7e563eebbdeaaecc3 100644 (file)
@@ -123,6 +123,7 @@ import com.vaadin.v7.shared.ui.grid.selection.MultiSelectionModelServerRpc;
 import com.vaadin.v7.shared.ui.grid.selection.MultiSelectionModelState;
 import com.vaadin.v7.shared.ui.grid.selection.SingleSelectionModelServerRpc;
 import com.vaadin.v7.shared.ui.grid.selection.SingleSelectionModelState;
+import com.vaadin.v7.ui.Grid.SelectionModel.HasUserSelectionAllowed;
 import com.vaadin.v7.ui.renderers.HtmlRenderer;
 import com.vaadin.v7.ui.renderers.Renderer;
 import com.vaadin.v7.ui.renderers.TextRenderer;
@@ -1141,6 +1142,35 @@ public class Grid extends AbstractComponent
      */
     @Deprecated
     public interface SelectionModel extends Serializable, Extension {
+
+        /**
+         * Interface implemented by selection models which support disabling
+         * client side selection while still allowing programmatic selection on
+         * the server.
+         *
+         * @since 7.7.7
+         */
+        public interface HasUserSelectionAllowed extends SelectionModel {
+
+            /**
+             * Checks if the user is allowed to change the selection.
+             *
+             * @return <code>true</code> if the user is allowed to change the
+             *         selection, <code>false</code> otherwise
+             */
+            public boolean isUserSelectionAllowed();
+
+            /**
+             * Sets whether the user is allowed to change the selection.
+             *
+             * @param userSelectionAllowed
+             *            <code>true</code> if the user is allowed to change the
+             *            selection, <code>false</code> otherwise
+             */
+            public void setUserSelectionAllowed(boolean userSelectionAllowed);
+
+        }
+
         /**
          * Checks whether an item is selected or not.
          *
@@ -1505,7 +1535,7 @@ public class Grid extends AbstractComponent
      */
     @Deprecated
     public static class SingleSelectionModel extends AbstractSelectionModel
-            implements SelectionModel.Single {
+            implements SelectionModel.Single, HasUserSelectionAllowed {
 
         @Override
         protected void extend(AbstractClientConnector target) {
@@ -1514,6 +1544,11 @@ public class Grid extends AbstractComponent
 
                 @Override
                 public void select(String rowKey) {
+                    if (!isUserSelectionAllowed()) {
+                        throw new IllegalStateException(
+                                "Client tried to select '" + rowKey
+                                        + "' although user selection is disallowed");
+                    }
                     SingleSelectionModel.this.select(getItemId(rowKey), false);
                 }
             });
@@ -1604,6 +1639,21 @@ public class Grid extends AbstractComponent
         protected SingleSelectionModelState getState() {
             return (SingleSelectionModelState) super.getState();
         }
+
+        @Override
+        protected SingleSelectionModelState getState(boolean markAsDirty) {
+            return (SingleSelectionModelState) super.getState(markAsDirty);
+        }
+
+        @Override
+        public boolean isUserSelectionAllowed() {
+            return getState(false).userSelectionAllowed;
+        }
+
+        @Override
+        public void setUserSelectionAllowed(boolean userSelectionAllowed) {
+            getState().userSelectionAllowed = userSelectionAllowed;
+        }
     }
 
     /**
@@ -1639,7 +1689,8 @@ public class Grid extends AbstractComponent
      */
     @Deprecated
     public static class MultiSelectionModel extends AbstractSelectionModel
-            implements SelectionModel.Multi {
+            implements SelectionModel.Multi,
+            SelectionModel.HasUserSelectionAllowed {
 
         /**
          * The default selection size limit.
@@ -1657,6 +1708,12 @@ public class Grid extends AbstractComponent
 
                 @Override
                 public void select(List<String> rowKeys) {
+                    if (!isUserSelectionAllowed()) {
+                        throw new IllegalStateException(
+                                "Client tried to select '" + rowKeys
+                                        + "' although user selection is disallowed");
+                    }
+
                     List<Object> items = new ArrayList<Object>();
                     for (String rowKey : rowKeys) {
                         items.add(getItemId(rowKey));
@@ -1666,6 +1723,12 @@ public class Grid extends AbstractComponent
 
                 @Override
                 public void deselect(List<String> rowKeys) {
+                    if (!isUserSelectionAllowed()) {
+                        throw new IllegalStateException(
+                                "Client tried to deselect '" + rowKeys
+                                        + "' although user selection is disallowed");
+                    }
+
                     List<Object> items = new ArrayList<Object>();
                     for (String rowKey : rowKeys) {
                         items.add(getItemId(rowKey));
@@ -1675,11 +1738,21 @@ public class Grid extends AbstractComponent
 
                 @Override
                 public void selectAll() {
+                    if (!isUserSelectionAllowed()) {
+                        throw new IllegalStateException(
+                                "Client tried to select all although user selection is disallowed");
+                    }
+
                     MultiSelectionModel.this.selectAll(false);
                 }
 
                 @Override
                 public void deselectAll() {
+                    if (!isUserSelectionAllowed()) {
+                        throw new IllegalStateException(
+                                "Client tried to deselect all although user selection is disallowed");
+                    }
+
                     MultiSelectionModel.this.deselectAll(false);
                 }
             });
@@ -1963,6 +2036,21 @@ public class Grid extends AbstractComponent
         protected MultiSelectionModelState getState() {
             return (MultiSelectionModelState) super.getState();
         }
+
+        @Override
+        protected MultiSelectionModelState getState(boolean markAsDirty) {
+            return (MultiSelectionModelState) super.getState(markAsDirty);
+        }
+
+        @Override
+        public boolean isUserSelectionAllowed() {
+            return getState(false).userSelectionAllowed;
+        }
+
+        @Override
+        public void setUserSelectionAllowed(boolean userSelectionAllowed) {
+            getState().userSelectionAllowed = userSelectionAllowed;
+        }
     }
 
     /**
@@ -2390,14 +2478,17 @@ public class Grid extends AbstractComponent
             }
 
             /**
-             * Merges columns cells in a row
+             * Merges columns cells in a row.
              *
              * @param propertyIds
              *            The property ids of columns to merge
              * @return The remaining visible cell after the merge
              */
             public CELLTYPE join(Object... propertyIds) {
-                assert propertyIds.length > 1 : "You need to merge at least 2 properties";
+                if (propertyIds.length < 2) {
+                    throw new IllegalArgumentException(
+                            "You need to merge at least 2 properties");
+                }
 
                 Set<CELLTYPE> cells = new HashSet<CELLTYPE>();
                 for (int i = 0; i < propertyIds.length; ++i) {
@@ -2408,14 +2499,17 @@ public class Grid extends AbstractComponent
             }
 
             /**
-             * Merges columns cells in a row
+             * Merges columns cells in a row.
              *
              * @param cells
              *            The cells to merge. Must be from the same row.
              * @return The remaining visible cell after the merge
              */
             public CELLTYPE join(CELLTYPE... cells) {
-                assert cells.length > 1 : "You need to merge at least 2 cells";
+                if (cells.length < 2) {
+                    throw new IllegalArgumentException(
+                            "You need to merge at least 2 cells");
+                }
 
                 return join(new HashSet<CELLTYPE>(Arrays.asList(cells)));
             }
@@ -4637,7 +4731,7 @@ public class Grid extends AbstractComponent
      * own Container.
      *
      * @see #setContainerDataSource(Indexed)
-     * @see #LegacyGrid()
+     * @see #Grid()
      */
     private boolean defaultContainer = true;
 
@@ -5150,7 +5244,7 @@ public class Grid extends AbstractComponent
      * @return unmodifiable copy of current columns in visual order
      */
     public List<Column> getColumns() {
-        List<Column> columns = new ArrayList<Column>();
+        List<Column> columns = new ArrayList<Grid.Column>();
         for (String columnId : getState(false).columnOrder) {
             columns.add(getColumnByColumnId(columnId));
         }
@@ -6830,6 +6924,15 @@ public class Grid extends AbstractComponent
         }
     }
 
+    /**
+     * Refreshes, i.e. causes the client side to re-render all rows.
+     *
+     * @since 7.7.7
+     */
+    public void refreshAllRows() {
+        datasourceExtension.refreshCache();
+    }
+
     private static Logger getLogger() {
         return Logger.getLogger(Grid.class.getName());
     }
index de5ae3ab384a6d1d84da966cd27abcc03278a013..f7598637b67adc18ac8534638f39df632e2bfc21 100644 (file)
@@ -35,6 +35,7 @@ import com.vaadin.ui.Component;
  *             spacing on by default
  */
 @Deprecated
+@SuppressWarnings("serial")
 public class HorizontalLayout extends com.vaadin.ui.HorizontalLayout {
     /**
      * Constructs an empty HorizontalLayout.
index bb273dab465f7da1511f0e21623a0151f9fffeec..a5cb55d54caba8483e060d193a5a82044fea41e8 100644 (file)
@@ -549,6 +549,8 @@ public class Label extends AbstractLegacyComponent implements Property<String>,
         markAsDirty();
     }
 
+    // LegacyPropertyHelper has been removed in Vaadin 8
+
     /*
      * (non-Javadoc)
      *
index b5ae1cd396c5db2cd9f7fb6df0508f65e648a3ea..16619afdf5685926feed81d2a806fef6f5f26715 100644 (file)
@@ -51,6 +51,8 @@ public class ListSelect extends AbstractSelect {
         super(caption);
     }
 
+    // Columns are no longer used for width.
+
     public int getRows() {
         return rows;
     }
@@ -75,6 +77,7 @@ public class ListSelect extends AbstractSelect {
 
     @Override
     public void paintContent(PaintTarget target) throws PaintException {
+        // Width is no longer based on columns
         // Adds the number of rows
         if (rows != 0) {
             target.addAttribute("rows", rows);
index b23cf99097adcdc2336ef867e9bdb69d093f1a0a..99cdf97f041377fbee443c73c99d3d72d3051b09 100644 (file)
@@ -144,9 +144,9 @@ public class ProgressBar extends AbstractField<Float>
     }
 
     /*
-     * Overridden to keep the shared state in sync with the LegacyAbstractField
-     * internal value. Should be removed once LegacyAbstractField is refactored
-     * to use shared state.
+     * Overridden to keep the shared state in sync with the AbstractField
+     * internal value. Should be removed once AbstractField is refactored to use
+     * shared state.
      *
      * See tickets #10921 and #11064.
      */
index 8b6ad8dbfbc88f0f0da3975de0b10a9f20827fed..e3f122f25da23f945bc41fe3c6a919b15accb485 100644 (file)
@@ -4124,7 +4124,7 @@ public class Table extends AbstractSelect implements Action.Container,
 
     /**
      * Binds an item property to a field generated by TableFieldFactory. The
-     * default behavior is to bind property straight to LegacyField. If
+     * default behavior is to bind property straight to Field. If
      * Property.Viewer type property (e.g. PropertyFormatter) is already set for
      * field, the property is bound to that Property.Viewer.
      *
@@ -4783,7 +4783,7 @@ public class Table extends AbstractSelect implements Action.Container,
      *
      * The FieldFactory is only used if the Table is editable.
      *
-     * @return TableFieldFactory used to create the LegacyField instances.
+     * @return TableFieldFactory used to create the Field instances.
      * @see #isEditable
      */
     public TableFieldFactory getTableFieldFactory() {
@@ -4793,8 +4793,8 @@ public class Table extends AbstractSelect implements Action.Container,
     /**
      * Is table editable.
      *
-     * If table is editable a editor of type LegacyField is created for each
-     * table cell. The assigned FieldFactory is used to create the instances.
+     * If table is editable a editor of type Field is created for each table
+     * cell. The assigned FieldFactory is used to create the instances.
      *
      * To provide custom editors for table cells create a class implementing the
      * FieldFactory interface, and assign it to table, and set the editable
@@ -4812,8 +4812,8 @@ public class Table extends AbstractSelect implements Action.Container,
     /**
      * Sets the editable property.
      *
-     * If table is editable a editor of type LegacyField is created for each
-     * table cell. The assigned FieldFactory is used to create the instances.
+     * If table is editable a editor of type Field is created for each table
+     * cell. The assigned FieldFactory is used to create the instances.
      *
      * To provide custom editors for table cells create a class implementing the
      * FieldFactory interface, and assign it to table, and set the editable
index 8bdec4ca66a126cde94cf2267b4bda6620f7723d..1f3d14c8dd201fe967faffe6fd7e70ecc8157182 100644 (file)
@@ -21,7 +21,7 @@ import com.vaadin.ui.Component;
 import com.vaadin.v7.data.Container;
 
 /**
- * Factory interface for creating new LegacyField-instances based on Container
+ * Factory interface for creating new Field-instances based on Container
  * (datasource), item id, property id and uiContext (the component responsible
  * for displaying fields). Currently this interface is used by {@link Table},
  * but might later be used by some other components for {@link Field}
index a78cb3b0d619a19696ddf1eb1937208f5037e82d..3e7be6c7f40fbf653b43ef104086bde7cda44995 100644 (file)
@@ -32,11 +32,10 @@ import com.vaadin.v7.data.Property;
  * </p>
  *
  * <p>
- * Since <code>TextField</code> extends <code>LegacyAbstractField</code> it
- * implements the {@link Buffered} interface. A <code>TextField</code> is in
- * write-through mode by default, so
- * {@link AbstractField#setWriteThrough(boolean)} must be called to enable
- * buffering.
+ * Since <code>TextField</code> extends <code>AbstractField</code> it implements
+ * the {@link Buffered} interface. A <code>TextField</code> is in write-through
+ * mode by default, so {@link AbstractField#setWriteThrough(boolean)} must be
+ * called to enable buffering.
  * </p>
  *
  * @author Vaadin Ltd.
index 67da52df51e7d4e65f4e6d16eb976840456bb6fc..5f114c06cb68276b772535f5d4586aca283998bc 100644 (file)
@@ -1242,7 +1242,7 @@ public class Tree extends AbstractSelect implements Container.Hierarchical,
         if (actionHandler != null) {
 
             if (actionHandlers == null) {
-                actionHandlers = new LinkedList<Handler>();
+                actionHandlers = new LinkedList<Action.Handler>();
                 actionMapper = new KeyMapper<Action>();
             }
 
index d1ddaa4f0823070d4df458aed8b18183fbe2321d..5f585962ff6ed607d2a0df4eb0c4764b1b1cb01e 100644 (file)
@@ -65,6 +65,8 @@ public class TwinColSelect extends AbstractSelect {
         setMultiSelect(true);
     }
 
+    // Columns are no longer used for width.
+
     public int getRows() {
         return rows;
     }
@@ -104,7 +106,7 @@ public class TwinColSelect extends AbstractSelect {
 
     @Override
     public void paintContent(PaintTarget target) throws PaintException {
-        // Adds the number of columns
+        // Width is no longer based on columns
         // Adds the number of rows
         if (rows != 0) {
             target.addAttribute("rows", rows);
index d00439cbb8939fe9dc99c5996ca8651abf8f0616..a559b09bacd5112fb55b7dd8d679c6e9043c4f0d 100644 (file)
@@ -240,13 +240,6 @@ public class ContainerEventProvider
         return event;
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * com.vaadin.addon.calendar.event.CalendarEventProvider#getEvents(java.
-     * util.Date, java.util.Date)
-     */
     @Override
     public List<CalendarEvent> getEvents(Date startDate, Date endDate) {
         eventCache.clear();
@@ -279,14 +272,6 @@ public class ContainerEventProvider
         return Collections.unmodifiableList(eventCache);
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see com.vaadin.addon.calendar.event.CalendarEventProvider.
-     * EventSetChangeNotifier
-     * #addListener(com.vaadin.addon.calendar.event.CalendarEventProvider.
-     * EventSetChangeListener)
-     */
     @Override
     public void addEventSetChangeListener(EventSetChangeListener listener) {
         if (!eventSetChangeListeners.contains(listener)) {
@@ -294,26 +279,11 @@ public class ContainerEventProvider
         }
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see com.vaadin.addon.calendar.event.CalendarEventProvider.
-     * EventSetChangeNotifier
-     * #removeListener(com.vaadin.addon.calendar.event.CalendarEventProvider.
-     * EventSetChangeListener)
-     */
     @Override
     public void removeEventSetChangeListener(EventSetChangeListener listener) {
         eventSetChangeListeners.remove(listener);
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see com.vaadin.addon.calendar.event.CalendarEvent.EventChangeNotifier#
-     * addListener
-     * (com.vaadin.addon.calendar.event.CalendarEvent.EventChangeListener)
-     */
     @Override
     public void addEventChangeListener(EventChangeListener listener) {
         if (eventChangeListeners.contains(listener)) {
@@ -321,13 +291,6 @@ public class ContainerEventProvider
         }
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see com.vaadin.addon.calendar.event.CalendarEvent.EventChangeNotifier#
-     * removeListener
-     * (com.vaadin.addon.calendar.event.CalendarEvent.EventChangeListener)
-     */
     @Override
     public void removeEventChangeListener(EventChangeListener listener) {
         eventChangeListeners.remove(listener);
@@ -421,13 +384,6 @@ public class ContainerEventProvider
         return allDayProperty;
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * com.vaadin.data.Container.ItemSetChangeListener#containerItemSetChange
-     * (com.vaadin.data.Container.ItemSetChangeEvent)
-     */
     @Override
     public void containerItemSetChange(ItemSetChangeEvent event) {
         if (event.getContainer() == container) {
@@ -438,13 +394,6 @@ public class ContainerEventProvider
         }
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * com.vaadin.data.Property.ValueChangeListener#valueChange(com.vaadin.data
-     * .Property.ValueChangeEvent)
-     */
     @Override
     public void valueChange(ValueChangeEvent event) {
         /*
@@ -454,14 +403,6 @@ public class ContainerEventProvider
          */
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventMoveHandler
-     * #eventMove
-     * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.MoveEvent)
-     */
     @Override
     public void eventMove(MoveEvent event) {
         CalendarEvent ce = event.getCalendarEvent();
@@ -485,14 +426,6 @@ public class ContainerEventProvider
         }
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventResizeHandler
-     * #eventResize
-     * (com.vaadin.addon.calendar.ui.CalendarComponentEvents.EventResize)
-     */
     @Override
     public void eventResize(EventResize event) {
         CalendarEvent ce = event.getCalendarEvent();
@@ -522,13 +455,6 @@ public class ContainerEventProvider
         ignoreContainerEvents();
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * com.vaadin.addon.calendar.event.CalendarEditableEventProvider#addEvent
-     * (com.vaadin.addon.calendar.event.CalendarEvent)
-     */
     @Override
     public void addEvent(CalendarEvent event) {
         Item item;
@@ -552,13 +478,6 @@ public class ContainerEventProvider
         }
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * com.vaadin.addon.calendar.event.CalendarEditableEventProvider#removeEvent
-     * (com.vaadin.addon.calendar.event.CalendarEvent)
-     */
     @Override
     public void removeEvent(CalendarEvent event) {
         container.removeItem(event);
index 9a6e3598e823d12eb7cedc163867d799256cfb17..3b2ec99d9776b10532b2e042326502a4ee60fc20 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * 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
@@ -26,12 +26,12 @@ import com.vaadin.v7.ui.TextField;
 
 /**
  * A component that represents color selection preview within a color picker.
- * 
+ *
  * @since 7.0.0
  */
 @Deprecated
-public class ColorPickerPreview extends CssLayout implements ColorSelector,
-        ValueChangeListener {
+public class ColorPickerPreview extends CssLayout
+        implements ColorSelector, ValueChangeListener {
 
     private static final String STYLE_DARK_COLOR = "v-textfield-dark";
     private static final String STYLE_LIGHT_COLOR = "v-textfield-light";
@@ -98,8 +98,8 @@ public class ColorPickerPreview extends CssLayout implements ColorSelector,
         // Set the text color
         field.removeStyleName(STYLE_DARK_COLOR);
         field.removeStyleName(STYLE_LIGHT_COLOR);
-        if (this.color.getRed() + this.color.getGreen() + this.color
-                .getBlue() < 3 * 128) {
+        if (this.color.getRed() + this.color.getGreen()
+                + this.color.getBlue() < 3 * 128) {
             field.addStyleName(STYLE_DARK_COLOR);
         } else {
             field.addStyleName(STYLE_LIGHT_COLOR);
@@ -161,8 +161,8 @@ public class ColorPickerPreview extends CssLayout implements ColorSelector,
                             value.length() - 1).split(",");
 
                     int hue = Integer.parseInt(colors[0]);
-                    int saturation = Integer.parseInt(colors[1]
-                            .replace("%", ""));
+                    int saturation = Integer
+                            .parseInt(colors[1].replace("%", ""));
                     int lightness = Integer
                             .parseInt(colors[2].replace("%", ""));
                     int rgb = Color.HSLtoRGB(hue, saturation, lightness);
index 63d46d6cc4dd89318d5b55ed704ed5cc4464ce16..79dfdf3b49de60414a6d40aaae4ca7342e585e21 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * 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
@@ -24,12 +24,12 @@ import com.vaadin.v7.ui.ComboBox;
 
 /**
  * A component that represents color selection swatches within a color picker.
- * 
+ *
  * @since 7.0.0
  */
 @Deprecated
-public class ColorPickerSelect extends CustomComponent implements
-        ColorSelector, ValueChangeListener {
+public class ColorPickerSelect extends CustomComponent
+        implements ColorSelector, ValueChangeListener {
 
     /** The range. */
     private final ComboBox range;
@@ -49,7 +49,7 @@ public class ColorPickerSelect extends CustomComponent implements
 
         /**
          * Instantiates a new color range property id.
-         * 
+         *
          * @param caption
          *            the caption
          */
@@ -65,7 +65,7 @@ public class ColorPickerSelect extends CustomComponent implements
 
     /**
      * Instantiates a new color picker select.
-     * 
+     *
      * @param rows
      *            the rows
      * @param columns
@@ -102,12 +102,12 @@ public class ColorPickerSelect extends CustomComponent implements
 
     /**
      * Creates the all colors.
-     * 
+     *
      * @param rows
      *            the rows
      * @param columns
      *            the columns
-     * 
+     *
      * @return the color[][]
      */
     private Color[][] createAllColors(int rows, int columns) {
@@ -131,8 +131,8 @@ public class ColorPickerSelect extends CustomComponent implements
                         value = 1f - ((row - (rows / 2f)) / (rows / 2f));
                     }
 
-                    colors[row][col] = new Color(Color.HSVtoRGB(hue,
-                            saturation, value));
+                    colors[row][col] = new Color(
+                            Color.HSVtoRGB(hue, saturation, value));
                 }
 
                 // The last row should have the black&white gradient
@@ -141,8 +141,8 @@ public class ColorPickerSelect extends CustomComponent implements
                     float saturation = 0f;
                     float value = 1f - ((float) col / (float) columns);
 
-                    colors[row][col] = new Color(Color.HSVtoRGB(hue,
-                            saturation, value));
+                    colors[row][col] = new Color(
+                            Color.HSVtoRGB(hue, saturation, value));
                 }
             }
         }
@@ -152,14 +152,14 @@ public class ColorPickerSelect extends CustomComponent implements
 
     /**
      * Creates the color.
-     * 
+     *
      * @param color
      *            the color
      * @param rows
      *            the rows
      * @param columns
      *            the columns
-     * 
+     *
      * @return the color[][]
      */
     private Color[][] createColors(Color color, int rows, int columns) {
@@ -183,12 +183,12 @@ public class ColorPickerSelect extends CustomComponent implements
                             / (((float) rows * (float) columns) / 2f);
                 } else {
                     index -= ((rows * columns) / 2);
-                    value = 1f - index
-                            / (((float) rows * (float) columns) / 2f);
+                    value = 1f
+                            - index / (((float) rows * (float) columns) / 2f);
                 }
 
-                colors[row][col] = new Color(Color.HSVtoRGB(hue, saturation,
-                        value));
+                colors[row][col] = new Color(
+                        Color.HSVtoRGB(hue, saturation, value));
             }
         }
 
index 755c3fcc60843ae8f63a7091635de808f73e12c2..b41b6c26202b504d0d80f1f0d346353d0f5deeeb 100644 (file)
@@ -71,7 +71,7 @@ import elemental.json.JsonValue;
  * <li><code>init(cell)</code> - Prepares a cell for rendering. Corresponds to
  * {@link com.vaadin.client.renderers.ComplexRenderer#init(com.vaadin.client.widget.grid.RendererCellReference)}
  * .</li>
- * <li><code>destory(cell)</code> - Allows the renderer to release resources
+ * <li><code>destroy(cell)</code> - Allows the renderer to release resources
  * allocate for a cell that will no longer be used. Corresponds to
  * {@link com.vaadin.client.renderers.ComplexRenderer#destroy(com.vaadin.client.widget.grid.RendererCellReference)}
  * .</li>
index 66e68573d816874c87c75fb22747b443703de548..7924b36f7e2de2137cbfac215247364c5d644080 100644 (file)
@@ -30,6 +30,7 @@ public abstract class AbstractListenerMethodsTestBase {
         for (Class<?> c : classes) {
             boolean found = false;
             for (Method m : c.getDeclaredMethods()) {
+                // Intentional change in compatibility package
                 String methodName = m.getName();
                 if (methodName.startsWith("add")
                         && methodName.endsWith("Listener")
@@ -154,6 +155,7 @@ public abstract class AbstractListenerMethodsTestBase {
 
     private Method getAddListenerMethod(Class<?> cls, Class<?> listenerClass)
             throws SecurityException, NoSuchMethodException {
+        // Intentional change in compatibility package
         return cls.getMethod("add" + listenerClass.getSimpleName(),
                 listenerClass);
 
@@ -161,6 +163,7 @@ public abstract class AbstractListenerMethodsTestBase {
 
     private Method getRemoveListenerMethod(Class<?> cls, Class<?> listenerClass)
             throws SecurityException, NoSuchMethodException {
+        // Intentional change in compatibility package
         return cls.getMethod("remove" + listenerClass.getSimpleName(),
                 listenerClass);
 
@@ -178,4 +181,4 @@ public abstract class AbstractListenerMethodsTestBase {
                 registeredListeners.toArray());
 
     }
-}
\ No newline at end of file
+}
index 8c093fdf72fef518f64b5fd2c042cf35f91b9054..1f7783dda5a6c55fdb7bbeaf419eb4f1b8611f4a 100644 (file)
@@ -41,8 +41,8 @@ public class SliderTest {
 
             slider.setValue(-1.0);
         } catch (Slider.ValueOutOfBoundsException e) {
-            assertThat(e.getMessage(),
-                    containsString("Value -1.0 is out of bounds: [0.0, 100.0]"));
+            assertThat(e.getMessage(), containsString(
+                    "Value -1.0 is out of bounds: [0.0, 100.0]"));
         }
     }
 
index 3f174eb649644c6294e9286723b5bac6aa604776..516e4eb63d67a8f1c4e5dad3ce0a1193c72655eb 100644 (file)
@@ -17,6 +17,8 @@ public class PerformanceTestIndexedContainerTest {
     // TODO should improve performance of these methods
     private static final long ADD_ITEM_AT_FAIL_THRESHOLD = 5000;
     private static final long ADD_ITEM_AFTER_FAIL_THRESHOLD = 5000;
+    // FIXME: Vaadin 7 compatibility version fails this check with original
+    // value of 5000
     private static final long ADD_ITEM_AFTER_LAST_FAIL_THRESHOLD = 6000;
     private static final long ADD_ITEMS_CONSTRUCTOR_FAIL_THRESHOLD = 200;
 
index fe1e7e181302f3af47c7a1cbf305b04621f24bce..d39d6048526092a4c9dc4e1f6dec25e88a6112bb 100644 (file)
@@ -187,7 +187,7 @@ public class SQLContainerTableQueryTest {
         container.commit();
 
         Item item = getItem(container.lastItemId());
-        assertThat(item.getItemProperty(NAME).getValue(), is("foo"));
+        assertThat(item.getItemProperty(NAME).getValue().toString(), is("foo"));
     }
 
     @Test
@@ -196,8 +196,8 @@ public class SQLContainerTableQueryTest {
 
         container.refresh();
 
-        assertThat(getItem(existingItemId).getItemProperty(NAME).getValue(),
-                is("foo"));
+        assertThat(getItem(existingItemId).getItemProperty(NAME).getValue()
+                .toString(), is("foo"));
     }
 
     @Test
index 7f27d2a2fd7840e542d396b4a48fcfbafa248079..078363af19c5d78cfb09421ae430df59b11109f2 100644 (file)
@@ -75,7 +75,7 @@ public class SQLGeneratorsTest {
     @Test
     public void generateSelectQuery_filtersAndOrderingSet_shouldSucceed() {
         SQLGenerator sg = new DefaultSQLGenerator();
-        List<com.vaadin.v7.data.Container.Filter> f = new ArrayList<Filter>();
+        List<Filter> f = new ArrayList<Filter>();
         f.add(new Like("name", "%lle"));
         List<OrderBy> ob = Arrays.asList(new OrderBy("name", true));
         StatementHelper sh = sg.generateSelectQuery("TABLE", f, ob, 0, 0, null);
index 046b365601d97c8dee174f0f007b31711f1bbfb5..c6652b77d91de40a22b8e284a5f19521ad73aaaf 100644 (file)
@@ -88,7 +88,7 @@ public class WriteLegacyDesignTest {
 
     private void checkNode(Node node) {
         if (node instanceof Element) {
-            assertTrue("Expected " + node.nodeName() + " to start with v-",
+            assertTrue("Wrong design element prefix",
                     node.nodeName().startsWith("v-"));
             for (Node child : node.childNodes()) {
                 checkNode(child);
index 09ab8fe65f9eb2e932736437f213de61b2100dd8..5aee75af36ab2b308f9dde0b4d7fe023215c018c 100644 (file)
@@ -68,6 +68,15 @@ public class AbsFieldValidatorsTest {
         assertFalse(field.getValidators().contains(validator2));
     }
 
+    @Test
+    public void validatorShouldMakeImmediate() {
+        assertFalse("field should not be immediate by default",
+                field.isImmediate());
+        field.addValidator(validator);
+        assertTrue("field should be immediate when it has a validator",
+                field.isImmediate());
+    }
+
     @Test
     public void nonImmediateFieldWithValidator() {
         field.setImmediate(false);
@@ -76,4 +85,30 @@ public class AbsFieldValidatorsTest {
                 field.isImmediate());
     }
 
+    @Test
+    public void removeValidatorMakesNonImmediate() {
+        field.addValidator(validator);
+        field.removeValidator(validator);
+        assertFalse("field should be non-immediate after validator was removed",
+                field.isImmediate());
+    }
+
+    @Test
+    public void requiredMakesImmediate() {
+        assertFalse("field should not be immediate by default",
+                field.isImmediate());
+        field.setRequired(true);
+        assertTrue("field should be immediate when it is required",
+                field.isImmediate());
+    }
+
+    @Test
+    public void removeRequiredMakesNonImmediate() {
+        assertFalse("field should not be immediate by default",
+                field.isImmediate());
+        field.setRequired(true);
+        field.setRequired(false);
+        assertFalse("field should not be immediate even though it was required",
+                field.isImmediate());
+    }
 }
index 6594ed9351c124475b02344470f83dd5bd12add6..d4bdb4fe53ecd3d0c5b6284d0375c67223ddc44b 100644 (file)
@@ -1,6 +1,7 @@
 package com.vaadin.v7.tests.server.component.abstractfield;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
 import java.util.Locale;
@@ -19,6 +20,7 @@ import com.vaadin.v7.data.util.ObjectProperty;
 import com.vaadin.v7.data.util.converter.Converter;
 import com.vaadin.v7.data.util.converter.Converter.ConversionException;
 import com.vaadin.v7.data.util.converter.StringToIntegerConverter;
+import com.vaadin.v7.ui.CheckBox;
 import com.vaadin.v7.ui.TextField;
 
 public class AbsFieldValueConversionsTest {
@@ -153,6 +155,65 @@ public class AbsFieldValueConversionsTest {
                 tf.getValue());
     }
 
+    @Test
+    public void testBooleanNullConversion() {
+        CheckBox cb = new CheckBox();
+        cb.setConverter(new Converter<Boolean, Boolean>() {
+
+            @Override
+            public Boolean convertToModel(Boolean value,
+                    Class<? extends Boolean> targetType, Locale locale) {
+                // value from a CheckBox should never be null as long as it is
+                // not set to null (handled by conversion below).
+                assertNotNull(value);
+                return value;
+            }
+
+            @Override
+            public Boolean convertToPresentation(Boolean value,
+                    Class<? extends Boolean> targetType, Locale locale) {
+                // Datamodel -> field
+                if (value == null) {
+                    return false;
+                }
+
+                return value;
+            }
+
+            @Override
+            public Class<Boolean> getModelType() {
+                return Boolean.class;
+            }
+
+            @Override
+            public Class<Boolean> getPresentationType() {
+                return Boolean.class;
+            }
+
+        });
+        MethodProperty<Boolean> property = new MethodProperty<Boolean>(
+                paulaBean, "deceased");
+        cb.setPropertyDataSource(property);
+        assertEquals(Boolean.FALSE, property.getValue());
+        assertEquals(Boolean.FALSE, cb.getValue());
+        Boolean newDmValue = cb.getConverter().convertToPresentation(
+                cb.getValue(), Boolean.class, new Locale("fi", "FI"));
+        assertEquals(Boolean.FALSE, newDmValue);
+
+        // FIXME: Should be able to set to false here to cause datamodel to be
+        // set to false but the change will not be propagated to the Property
+        // (field value is already false)
+
+        cb.setValue(true);
+        assertEquals(Boolean.TRUE, cb.getValue());
+        assertEquals(Boolean.TRUE, property.getValue());
+
+        cb.setValue(false);
+        assertEquals(Boolean.FALSE, cb.getValue());
+        assertEquals(Boolean.FALSE, property.getValue());
+
+    }
+
     // Now specific to Integer because StringToNumberConverter has been removed
     public static class NumberBean {
         private Integer number;
index f284229e28b397e261fb72c853332e2982494b6d..ece14756cb84b97f6d47948d4936708ea10b8e7f 100644 (file)
@@ -7,7 +7,7 @@ import com.vaadin.v7.data.Property.ReadOnlyStatusChangeEvent;
 import com.vaadin.v7.data.Property.ReadOnlyStatusChangeListener;
 import com.vaadin.v7.data.Property.ValueChangeEvent;
 import com.vaadin.v7.data.Property.ValueChangeListener;
-import com.vaadin.v7.ui.Table;
+import com.vaadin.v7.ui.CheckBox;
 
 public class AbstractFieldListenersTest
         extends AbstractListenerMethodsTestBase {
@@ -15,13 +15,14 @@ public class AbstractFieldListenersTest
     @Test
     public void testReadOnlyStatusChangeListenerAddGetRemove()
             throws Exception {
-        testListenerAddGetRemove(Table.class, ReadOnlyStatusChangeEvent.class,
+        testListenerAddGetRemove(CheckBox.class,
+                ReadOnlyStatusChangeEvent.class,
                 ReadOnlyStatusChangeListener.class);
     }
 
     @Test
     public void testValueChangeListenerAddGetRemove() throws Exception {
-        testListenerAddGetRemove(Table.class, ValueChangeEvent.class,
+        testListenerAddGetRemove(CheckBox.class, ValueChangeEvent.class,
                 ValueChangeListener.class);
     }
 }
index 044124bc8acc34efc20afee1bf2fa6c6e535fb05..b4ccb094d0767ca9493cd22f636474f1723804c2 100644 (file)
@@ -24,10 +24,12 @@ import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 
+import com.vaadin.ui.ComponentTest;
 import com.vaadin.v7.data.Container;
 import com.vaadin.v7.data.util.IndexedContainer;
 import com.vaadin.v7.event.SelectionEvent;
 import com.vaadin.v7.event.SelectionEvent.SelectionListener;
+import com.vaadin.v7.shared.ui.grid.selection.MultiSelectionModelServerRpc;
 import com.vaadin.v7.shared.ui.grid.selection.MultiSelectionModelState;
 import com.vaadin.v7.ui.Grid;
 
@@ -187,4 +189,40 @@ public class MultiSelectionModelTest {
         }
         Assert.fail("Not all items were correctly selected");
     }
+
+    @Test(expected = IllegalStateException.class)
+    public void refuseSelectWhenUserSelectionDisallowed() {
+        ((HasUserSelectionAllowed) grid.getSelectionModel())
+                .setUserSelectionAllowed(false);
+        MultiSelectionModelServerRpc serverRpc = ComponentTest.getRpcProxy(
+                grid.getSelectionModel(), MultiSelectionModelServerRpc.class);
+        serverRpc.select(Collections.singletonList("a"));
+    }
+
+    @Test(expected = IllegalStateException.class)
+    public void refuseDeselectWhenUserSelectionDisallowed() {
+        ((HasUserSelectionAllowed) grid.getSelectionModel())
+                .setUserSelectionAllowed(false);
+        MultiSelectionModelServerRpc serverRpc = ComponentTest.getRpcProxy(
+                grid.getSelectionModel(), MultiSelectionModelServerRpc.class);
+        serverRpc.deselect(Collections.singletonList("a"));
+    }
+
+    @Test(expected = IllegalStateException.class)
+    public void refuseSelectAllWhenUserSelectionDisallowed() {
+        ((HasUserSelectionAllowed) grid.getSelectionModel())
+                .setUserSelectionAllowed(false);
+        MultiSelectionModelServerRpc serverRpc = ComponentTest.getRpcProxy(
+                grid.getSelectionModel(), MultiSelectionModelServerRpc.class);
+        serverRpc.selectAll();
+    }
+
+    @Test(expected = IllegalStateException.class)
+    public void refuseDeselectAllWhenUserSelectionDisallowed() {
+        ((HasUserSelectionAllowed) grid.getSelectionModel())
+                .setUserSelectionAllowed(false);
+        MultiSelectionModelServerRpc serverRpc = ComponentTest.getRpcProxy(
+                grid.getSelectionModel(), MultiSelectionModelServerRpc.class);
+        serverRpc.deselectAll();
+    }
 }
index e18c5bbe8b3b8191a48480ea1a8dee83c2ecb024..ffb07b986ba31d77eab0445ea314ef06b02cc83c 100644 (file)
@@ -20,10 +20,12 @@ import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 
+import com.vaadin.ui.ComponentTest;
 import com.vaadin.v7.data.Container;
 import com.vaadin.v7.data.util.IndexedContainer;
 import com.vaadin.v7.event.SelectionEvent;
 import com.vaadin.v7.event.SelectionEvent.SelectionListener;
+import com.vaadin.v7.shared.ui.grid.selection.SingleSelectionModelServerRpc;
 import com.vaadin.v7.ui.Grid;
 import com.vaadin.v7.ui.Grid.SelectionMode;
 import com.vaadin.v7.ui.Grid.SingleSelectionModel;
@@ -150,4 +152,13 @@ public class SingleSelectionModelTest {
             }
         });
     }
+
+    @Test(expected = IllegalStateException.class)
+    public void refuseSelectionWhenUserSelectionDisallowed() {
+        ((HasUserSelectionAllowed) grid.getSelectionModel())
+                .setUserSelectionAllowed(false);
+        SingleSelectionModelServerRpc serverRpc = ComponentTest.getRpcProxy(
+                grid.getSelectionModel(), SingleSelectionModelServerRpc.class);
+        serverRpc.select("a");
+    }
 }
index c8b3e8116bdd8c1884de0a350c51ef11ab990603..814160782f6aa8bbb03af7fabac1b7c8a1153156 100644 (file)
@@ -36,6 +36,7 @@ public abstract class TableDeclarativeTestBase
     }
 
     protected String getTag() {
+        // Compatibility classes have a different prefix
         return "vaadin7-table";
     }
 
index 63eacd1fc12f61c0b20d4823bde060d80bb30dcb..d05166cec9a192e9ff3a779d260c63ee34292724 100644 (file)
@@ -17,7 +17,7 @@ package com.vaadin.v7.shared.ui.grid;
 
 /**
  * Collection of modes used for resizing columns in the Grid.
- * 
+ *
  * @since 7.7.5
  */
 public enum ColumnResizeMode {
@@ -35,4 +35,4 @@ public enum ColumnResizeMode {
      */
     SIMPLE
 
-}
\ No newline at end of file
+}
index c04d9aaff5d03ba6b41904e938a17e99895bf811..f57399f6f8f6ce6e66b23d20fa745f8be34df208 100644 (file)
@@ -27,5 +27,5 @@ public class MultiSelectionModelState extends SharedState {
 
     /* Select All -checkbox status */
     public boolean allSelected;
-
+    public boolean userSelectionAllowed = true;
 }
index a9fb816449cba47903bc14491719ecf8634c4ec4..82f77e9bfb639825210bf60e1a9fc9da6c4bea92 100644 (file)
@@ -27,4 +27,5 @@ public class SingleSelectionModelState extends SharedState {
 
     /* Allow deselecting rows */
     public boolean deselectAllowed = true;
+    public boolean userSelectionAllowed = true;
 }
index 6c0a74b7ead4926129aafe00ce9456e2587f5093..01f41174bdb1c28d1b57086b3c64f4d3746cc760 100644 (file)
@@ -18,6 +18,7 @@ package com.vaadin.v7.shared.ui.optiongroup;
 import java.io.Serializable;
 
 public class OptionGroupConstants implements Serializable {
+    // Vaadin 8 option group uses state for HTML content
     public static final String ATTRIBUTE_OPTION_DISABLED = "disabled";
 
 }
index b3e510b43dad715b124ede4055a698263fa9df19..a9a98e3395d2f3d9811a5704ae5ba6ab5daef492 100644 (file)
@@ -34,6 +34,6 @@ public class ProgressBarState extends AbstractFieldState {
     }
     public boolean indeterminate = false;
     @NoLayout
-    public float state = 0.0f;
+    public Float state = 0.0f;
 
 }