]> source.dussan.org Git - vaadin-framework.git/commitdiff
Move Vaadin 7 CheckBox to compatibility package
authorArtur Signell <artur@vaadin.com>
Tue, 23 Aug 2016 12:16:55 +0000 (15:16 +0300)
committerVaadin Code Review <review@vaadin.com>
Thu, 25 Aug 2016 10:11:30 +0000 (10:11 +0000)
Adds a v7 AbstractFieldConnector for the compatibility package
Remove dependency from core to old AbstractField

Change-Id: I5da665de69cf469adfa946cf18aae1a3e56c3486

26 files changed:
client/src/main/java/com/vaadin/client/VCaption.java
client/src/main/java/com/vaadin/client/ui/AbstractComponentConnector.java
client/src/main/java/com/vaadin/client/ui/AbstractFieldConnector.java
client/src/main/java/com/vaadin/client/ui/HasErrorIndicator.java [new file with mode: 0644]
client/src/main/java/com/vaadin/client/ui/HasRequiredIndicator.java [new file with mode: 0644]
client/src/main/java/com/vaadin/client/ui/VCustomLayout.java
client/src/main/java/com/vaadin/client/ui/VFormLayout.java
client/src/main/java/com/vaadin/client/ui/absolutelayout/AbsoluteLayoutConnector.java
client/src/main/java/com/vaadin/client/ui/checkbox/CheckBoxConnector.java
client/src/main/java/com/vaadin/client/ui/csslayout/CssLayoutConnector.java
client/src/main/java/com/vaadin/client/ui/formlayout/FormLayoutConnector.java
client/src/main/java/com/vaadin/client/ui/gridlayout/GridLayoutConnector.java
client/src/main/java/com/vaadin/client/ui/orderedlayout/AbstractOrderedLayoutConnector.java
client/src/main/java/com/vaadin/client/ui/panel/PanelConnector.java
client/src/main/java/com/vaadin/client/ui/popupview/PopupViewConnector.java
client/src/main/java/com/vaadin/client/v7/ui/checkbox/LegacyCheckBoxConnector.java [deleted file]
compatibility-client/src/main/java/com/vaadin/v7/client/ui/AbstractFieldConnector.java [new file with mode: 0644]
compatibility-client/src/main/java/com/vaadin/v7/client/ui/checkbox/CheckBoxConnector.java [new file with mode: 0644]
compatibility-client/src/main/java/com/vaadin/v7/client/ui/combobox/ComboBoxConnector.java
compatibility-client/src/main/java/com/vaadin/v7/client/ui/datefield/AbstractDateFieldConnector.java
compatibility-client/src/main/java/com/vaadin/v7/client/ui/optiongroup/OptionGroupBaseConnector.java
compatibility-client/src/main/java/com/vaadin/v7/client/ui/progressindicator/ProgressBarConnector.java
compatibility-client/src/main/java/com/vaadin/v7/client/ui/richtextarea/RichTextAreaConnector.java
compatibility-client/src/main/java/com/vaadin/v7/client/ui/table/TableConnector.java
compatibility-server/src/main/java/com/vaadin/v7/ui/CheckBox.java [new file with mode: 0644]
server/src/main/java/com/vaadin/v7/ui/CheckBox.java [deleted file]

index 3c07470c277d482adc282d82385d2133f7902d5e..7e8fd97d25cec8daad9fb50769af3b41f9a4d69a 100644 (file)
@@ -26,12 +26,12 @@ import com.google.gwt.user.client.Event;
 import com.google.gwt.user.client.ui.HTML;
 import com.google.gwt.user.client.ui.HasHTML;
 import com.vaadin.client.communication.StateChangeEvent;
-import com.vaadin.client.ui.AbstractFieldConnector;
+import com.vaadin.client.ui.HasErrorIndicator;
+import com.vaadin.client.ui.HasRequiredIndicator;
 import com.vaadin.client.ui.Icon;
 import com.vaadin.client.ui.ImageIcon;
 import com.vaadin.client.ui.aria.AriaHelper;
 import com.vaadin.shared.AbstractComponentState;
-import com.vaadin.shared.AbstractFieldState;
 import com.vaadin.shared.ComponentConstants;
 import com.vaadin.shared.ui.ComponentStateUtil;
 
@@ -158,14 +158,13 @@ public class VCaption extends HTML {
         boolean hasIcon = owner.getState().resources
                 .containsKey(ComponentConstants.ICON_RESOURCE);
         boolean showRequired = false;
-        boolean showError = owner.getState().errorMessage != null;
-        if (owner.getState() instanceof AbstractFieldState) {
-            AbstractFieldState abstractFieldState = (AbstractFieldState) owner
-                    .getState();
-            showError = showError && !abstractFieldState.hideErrors;
+        boolean showError = false;
+        if (owner instanceof HasRequiredIndicator) {
+            showRequired = ((HasRequiredIndicator) owner)
+                    .isRequiredIndicatorVisible();
         }
-        if (owner instanceof AbstractFieldConnector) {
-            showRequired = ((AbstractFieldConnector) owner).isRequired();
+        if (owner instanceof HasErrorIndicator) {
+            showError = ((HasErrorIndicator) owner).isErrorIndicatorVisible();
         }
 
         if (icon != null) {
@@ -454,24 +453,27 @@ public class VCaption extends HTML {
         }
     }
 
-    public static boolean isNeeded(AbstractComponentState state) {
+    public static boolean isNeeded(ComponentConnector connector) {
+        AbstractComponentState state = connector.getState();
         if (state.caption != null) {
             return true;
         }
         if (state.resources.containsKey(ComponentConstants.ICON_RESOURCE)) {
             return true;
         }
-        if (state.errorMessage != null) {
+        if (connector instanceof HasErrorIndicator
+                && ((HasErrorIndicator) connector).isErrorIndicatorVisible()) {
             return true;
         }
 
-        if (state instanceof AbstractFieldState) {
-            if (((AbstractFieldState) state).required) {
-                return true;
-            }
+        if (connector instanceof HasRequiredIndicator
+                && ((HasRequiredIndicator) connector)
+                        .isRequiredIndicatorVisible()) {
+            return true;
         }
 
         return false;
+
     }
 
     /**
index f59b7d581dc6d06e8072b411494613188e390032..a6d73be0c806978fb6e33a5614a72a1ef57ffb12 100644 (file)
@@ -62,7 +62,7 @@ import com.vaadin.shared.ui.ComponentStateUtil;
 import com.vaadin.shared.ui.TabIndexState;
 
 public abstract class AbstractComponentConnector extends AbstractConnector
-        implements ComponentConnector {
+        implements ComponentConnector, HasErrorIndicator {
 
     private HandlerRegistration contextHandler = null;
 
@@ -616,8 +616,7 @@ public abstract class AbstractComponentConnector extends AbstractConnector
      * primary style name of the widget returned by {@link #getWidget()}
      * <p>
      * This method can be overridden to provide additional style names for the
-     * component, for example see
-     * {@link AbstractFieldConnector#updateWidgetStyleNames()}
+     * component, for example see {@code AbstractFieldConnector}
      * </p>
      */
     protected void updateWidgetStyleNames() {
@@ -809,4 +808,9 @@ public abstract class AbstractComponentConnector extends AbstractConnector
     public void flush() {
         // No generic implementation. Override if needed
     }
+
+    @Override
+    public boolean isErrorIndicatorVisible() {
+        return getState().errorMessage != null;
+    }
 }
index 2783083a8d6586466da5d28fde020e14526cfa7e..f714023d394b8666343509cf04a428899739c2be 100644 (file)
@@ -18,8 +18,8 @@ package com.vaadin.client.ui;
 import com.vaadin.client.StyleConstants;
 import com.vaadin.shared.AbstractFieldState;
 
-public abstract class AbstractFieldConnector
-        extends AbstractComponentConnector {
+public abstract class AbstractFieldConnector extends AbstractComponentConnector
+        implements HasRequiredIndicator, HasErrorIndicator {
 
     @Override
     public AbstractFieldState getState() {
@@ -43,10 +43,16 @@ public abstract class AbstractFieldConnector
      *
      * @return true if required indicator should be shown
      */
-    public boolean isRequired() {
+    @Override
+    public boolean isRequiredIndicatorVisible() {
         return getState().required && !isReadOnly();
     }
 
+    @Override
+    public boolean isErrorIndicatorVisible() {
+        return super.isErrorIndicatorVisible() && !getState().hideErrors;
+    }
+
     @Override
     protected void updateWidgetStyleNames() {
         super.updateWidgetStyleNames();
@@ -56,8 +62,9 @@ public abstract class AbstractFieldConnector
 
         // add / remove error style name to Fields
         setWidgetStyleNameWithPrefix(getWidget().getStylePrimaryName(),
-                StyleConstants.REQUIRED_EXT, isRequired());
+                StyleConstants.REQUIRED_EXT, isRequiredIndicatorVisible());
 
-        getWidget().setStyleName(StyleConstants.REQUIRED, isRequired());
+        getWidget().setStyleName(StyleConstants.REQUIRED,
+                isRequiredIndicatorVisible());
     }
 }
diff --git a/client/src/main/java/com/vaadin/client/ui/HasErrorIndicator.java b/client/src/main/java/com/vaadin/client/ui/HasErrorIndicator.java
new file mode 100644 (file)
index 0000000..806617b
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * 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.client.ui;
+
+import com.vaadin.client.ComponentConnector;
+
+/**
+ * Implemented by connectors supporting an error indicator.
+ */
+public interface HasErrorIndicator extends ComponentConnector {
+
+    /**
+     * Checks if an error indicator should be shown for the given connector.
+     *
+     * @return <code>true</code> to show an indicator, <code>false</code>
+     *         otherwise
+     */
+    boolean isErrorIndicatorVisible();
+
+}
diff --git a/client/src/main/java/com/vaadin/client/ui/HasRequiredIndicator.java b/client/src/main/java/com/vaadin/client/ui/HasRequiredIndicator.java
new file mode 100644 (file)
index 0000000..5575c3a
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * 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.client.ui;
+
+import com.vaadin.client.ComponentConnector;
+
+/**
+ * Implemented by connectors supporting a required flag.
+ */
+public interface HasRequiredIndicator extends ComponentConnector {
+
+    /**
+     * Checks if a required indicator should be shown for the given connector.
+     *
+     * @return <code>true</code> to show an indicator, <code>false</code>
+     *         otherwise
+     */
+    boolean isRequiredIndicatorVisible();
+
+}
index 70e243cc1e7617c08c4595daea18f013f18c03b4..82140a12fef14526ed6f606d35bcc247c332429a 100644 (file)
@@ -300,20 +300,22 @@ public class VCustomLayout extends ComplexPanel {
         return res;
     }
 
-    /** Update caption for given widget */
-    public void updateCaption(ComponentConnector paintable) {
-        Widget widget = paintable.getWidget();
+    /**
+     * Update caption for the given child connector.
+     */
+    public void updateCaption(ComponentConnector childConnector) {
+        Widget widget = childConnector.getWidget();
         if (widget.getParent() != this) {
             // Widget has not been added because the location was not found
             return;
         }
         VCaptionWrapper wrapper = childWidgetToCaptionWrapper.get(widget);
-        if (VCaption.isNeeded(paintable.getState())) {
+        if (VCaption.isNeeded(childConnector)) {
             if (wrapper == null) {
                 // Add a wrapper between the layout and the child widget
                 final String loc = getLocation(widget);
                 super.remove(widget);
-                wrapper = new VCaptionWrapper(paintable, client);
+                wrapper = new VCaptionWrapper(childConnector, client);
                 super.add(wrapper, locationToElement.get(loc));
                 childWidgetToCaptionWrapper.put(widget, wrapper);
             }
index d31479d85535b8cce54264f7014ab287479c2261..550f20c7554539d779f13684a7048d2127aafa14 100644 (file)
@@ -302,8 +302,8 @@ public class VFormLayout extends SimplePanel {
                 removeStyleDependentName("hasdescription");
             }
 
-            boolean required = owner instanceof AbstractFieldConnector
-                    && ((AbstractFieldConnector) owner).isRequired();
+            boolean required = owner instanceof HasRequiredIndicator
+                    && ((HasRequiredIndicator) owner).isRequiredIndicatorVisible();
 
             AriaHelper.handleInputRequired(owner.getWidget(), required);
 
index e38cefb91f65aced3d80938f01fc85d504784bb8..0e82397261a63b448f5aa5b2d56fd80ca4e7025f 100644 (file)
@@ -116,20 +116,21 @@ public class AbsoluteLayoutConnector extends AbstractComponentContainerConnector
      * .client.ComponentConnector)
      */
     @Override
-    public void updateCaption(ComponentConnector component) {
+    public void updateCaption(ComponentConnector childConnector) {
         VAbsoluteLayout absoluteLayoutWidget = getWidget();
-        boolean captionIsNeeded = VCaption.isNeeded(component.getState());
+        boolean captionIsNeeded = VCaption.isNeeded(childConnector);
 
         VCaption caption = absoluteLayoutWidget
-                .getWidgetCaption(component.getWidget());
+                .getWidgetCaption(childConnector.getWidget());
         if (captionIsNeeded) {
             if (caption == null) {
-                caption = new VCaption(component, getConnection());
+                caption = new VCaption(childConnector, getConnection());
             }
-            absoluteLayoutWidget.setWidgetCaption(component.getWidget(),
+            absoluteLayoutWidget.setWidgetCaption(childConnector.getWidget(),
                     caption);
         } else if (caption != null) {
-            absoluteLayoutWidget.setWidgetCaption(component.getWidget(), null);
+            absoluteLayoutWidget.setWidgetCaption(childConnector.getWidget(),
+                    null);
         }
     }
 
index 706ee30cc50510c6763106d89aa320ee2e2618a9..598280cf5c0652b3a11c51b33db22dbc297a9aab 100644 (file)
@@ -82,7 +82,7 @@ public class CheckBoxConnector extends AbstractFieldConnector
             getWidget().setAriaInvalid(false);
         }
 
-        getWidget().setAriaRequired(isRequired());
+        getWidget().setAriaRequired(isRequiredIndicatorVisible());
         if (isReadOnly()) {
             getWidget().setEnabled(false);
         }
index fe5f843098da9763d6994cc2a0db7083597d4fcd..40e473c8d86f6e4c20ccbd579450128f06566859 100644 (file)
@@ -190,7 +190,7 @@ public class CssLayoutConnector extends AbstractLayoutConnector {
 
         String childId = child.getConnectorId();
         VCaption caption = childIdToCaption.get(childId);
-        if (VCaption.isNeeded(child.getState())) {
+        if (VCaption.isNeeded(child)) {
             if (caption == null) {
                 caption = new VCaption(child, getConnection());
                 childIdToCaption.put(childId, caption);
index eede83e3e91f1b31d8fadae07abe0c4befad31e3..eccec238772fd796bec1196c907b83f55b373963 100644 (file)
@@ -27,8 +27,8 @@ import com.vaadin.client.TooltipInfo;
 import com.vaadin.client.Util;
 import com.vaadin.client.WidgetUtil;
 import com.vaadin.client.communication.StateChangeEvent;
-import com.vaadin.client.ui.AbstractFieldConnector;
 import com.vaadin.client.ui.AbstractLayoutConnector;
+import com.vaadin.client.ui.HasErrorIndicator;
 import com.vaadin.client.ui.LayoutClickEventHandler;
 import com.vaadin.client.ui.PostLayoutListener;
 import com.vaadin.client.ui.VFormLayout;
@@ -248,10 +248,9 @@ public class FormLayoutConnector extends AbstractLayoutConnector
                 component.getState(), component.isEnabled());
         boolean hideErrors = false;
 
-        // FIXME This incorrectly depends on AbstractFieldConnector
-        if (component instanceof AbstractFieldConnector) {
-            hideErrors = ((AbstractFieldConnector) component)
-                    .getState().hideErrors;
+        if (component instanceof HasErrorIndicator) {
+            hideErrors = !((HasErrorIndicator) component)
+                    .isErrorIndicatorVisible();
         }
 
         getWidget().table.updateError(component.getWidget(),
index 976fbb11c52f95932c4a94541fc4d3fb0cebf94a..3113183e3ed78bb1536f834067d655c88e8503b5 100644 (file)
@@ -170,7 +170,7 @@ public class GridLayoutConnector extends AbstractComponentContainerConnector
     public void updateCaption(ComponentConnector childConnector) {
         VGridLayout layout = getWidget();
         Cell cell = layout.widgetToCell.get(childConnector.getWidget());
-        if (VCaption.isNeeded(childConnector.getState())) {
+        if (VCaption.isNeeded(childConnector)) {
             VLayoutSlot layoutSlot = cell.slot;
             VCaption caption = layoutSlot.getCaption();
             if (caption == null) {
index db6203efb36348ae9bf4b7315d0b5040183b2a1a..0e3bf733422ffeec7e37e7e097970b0d2a190e75 100644 (file)
@@ -33,14 +33,14 @@ import com.vaadin.client.Util;
 import com.vaadin.client.WidgetUtil;
 import com.vaadin.client.communication.StateChangeEvent;
 import com.vaadin.client.communication.StateChangeEvent.StateChangeHandler;
-import com.vaadin.client.ui.AbstractFieldConnector;
 import com.vaadin.client.ui.AbstractLayoutConnector;
+import com.vaadin.client.ui.HasErrorIndicator;
+import com.vaadin.client.ui.HasRequiredIndicator;
 import com.vaadin.client.ui.Icon;
 import com.vaadin.client.ui.LayoutClickEventHandler;
 import com.vaadin.client.ui.aria.AriaHelper;
 import com.vaadin.client.ui.layout.ElementResizeEvent;
 import com.vaadin.client.ui.layout.ElementResizeListener;
-import com.vaadin.shared.AbstractFieldState;
 import com.vaadin.shared.ComponentConstants;
 import com.vaadin.shared.communication.URLReference;
 import com.vaadin.shared.ui.AlignmentInfo;
@@ -260,15 +260,14 @@ public abstract class AbstractOrderedLayoutConnector
 
         List<String> styles = child.getState().styles;
         String error = child.getState().errorMessage;
-        boolean showError = error != null;
-        if (child.getState() instanceof AbstractFieldState) {
-            AbstractFieldState abstractFieldState = (AbstractFieldState) child
-                    .getState();
-            showError = showError && !abstractFieldState.hideErrors;
+        boolean showError = false;
+        if (child instanceof HasErrorIndicator) {
+            showError = ((HasErrorIndicator) child).isErrorIndicatorVisible();
         }
         boolean required = false;
-        if (child instanceof AbstractFieldConnector) {
-            required = ((AbstractFieldConnector) child).isRequired();
+        if (child instanceof HasRequiredIndicator) {
+            required = ((HasRequiredIndicator) child)
+                    .isRequiredIndicatorVisible();
         }
         boolean enabled = child.isEnabled();
 
index ab3acdfec0af1730012eeaff2c5902c7c61dc7ad..2e5237598fb0e31ec460e23bc32bc0bf1df9ef9e 100644 (file)
@@ -143,7 +143,7 @@ public class PanelConnector extends AbstractSingleComponentContainerConnector
             getWidget().setIconUri(null, client);
         }
 
-        getWidget().setErrorIndicatorVisible(null != getState().errorMessage);
+        getWidget().setErrorIndicatorVisible(isErrorIndicatorVisible());
 
         // We may have actions attached to this panel
         if (uidl.getChildCount() > 0) {
index 3916b419c1673b0d8ecbf48746c9e7ad9b44b7f2..1ee6e9b9f7d2412dccc7d7641e3ce3a75fc01354 100644 (file)
@@ -63,13 +63,13 @@ public class PopupViewConnector extends AbstractHasComponentsConnector
     }
 
     @Override
-    public void updateCaption(ComponentConnector component) {
-        if (VCaption.isNeeded(component.getState())) {
+    public void updateCaption(ComponentConnector childConnector) {
+        if (VCaption.isNeeded(childConnector)) {
             if (getWidget().popup.captionWrapper != null) {
                 getWidget().popup.captionWrapper.updateCaption();
             } else {
                 getWidget().popup.captionWrapper = new VCaptionWrapper(
-                        component, getConnection());
+                        childConnector, getConnection());
                 getWidget().popup.setWidget(getWidget().popup.captionWrapper);
                 getWidget().popup.captionWrapper.updateCaption();
             }
diff --git a/client/src/main/java/com/vaadin/client/v7/ui/checkbox/LegacyCheckBoxConnector.java b/client/src/main/java/com/vaadin/client/v7/ui/checkbox/LegacyCheckBoxConnector.java
deleted file mode 100644 (file)
index f3e46e9..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright 2000-2016 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-package com.vaadin.client.v7.ui.checkbox;
-
-import com.vaadin.client.ui.checkbox.CheckBoxConnector;
-import com.vaadin.shared.ui.Connect;
-import com.vaadin.v7.ui.CheckBox;
-
-@Connect(CheckBox.class)
-public class LegacyCheckBoxConnector extends CheckBoxConnector {
-
-}
diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/AbstractFieldConnector.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/AbstractFieldConnector.java
new file mode 100644 (file)
index 0000000..0638522
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * 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.ui;
+
+import com.vaadin.client.StyleConstants;
+import com.vaadin.client.ui.AbstractComponentConnector;
+import com.vaadin.client.ui.HasErrorIndicator;
+import com.vaadin.client.ui.HasRequiredIndicator;
+import com.vaadin.shared.AbstractFieldState;
+
+@Deprecated
+public abstract class AbstractFieldConnector extends AbstractComponentConnector
+        implements HasRequiredIndicator, HasErrorIndicator {
+
+    @Override
+    public AbstractFieldState getState() {
+        return (AbstractFieldState) super.getState();
+    }
+
+    @Override
+    public boolean isReadOnly() {
+        return super.isReadOnly() || getState().propertyReadOnly;
+    }
+
+    public boolean isModified() {
+        return getState().modified;
+    }
+
+    /**
+     * Checks whether the required indicator should be shown for the field.
+     *
+     * Required indicators are hidden if the field or its data source is
+     * read-only.
+     *
+     * @return true if required indicator should be shown
+     */
+    @Override
+    public boolean isRequiredIndicatorVisible() {
+        return getState().required && !isReadOnly();
+    }
+
+    @Override
+    public boolean isErrorIndicatorVisible() {
+        return super.isErrorIndicatorVisible() && !getState().hideErrors;
+    }
+
+    @Override
+    protected void updateWidgetStyleNames() {
+        super.updateWidgetStyleNames();
+
+        // add / remove modified style name to Fields
+        setWidgetStyleName(StyleConstants.MODIFIED, isModified());
+
+        // add / remove error style name to Fields
+        setWidgetStyleNameWithPrefix(getWidget().getStylePrimaryName(),
+                StyleConstants.REQUIRED_EXT, isRequiredIndicatorVisible());
+
+        getWidget().setStyleName(StyleConstants.REQUIRED,
+                isRequiredIndicatorVisible());
+    }
+}
diff --git a/compatibility-client/src/main/java/com/vaadin/v7/client/ui/checkbox/CheckBoxConnector.java b/compatibility-client/src/main/java/com/vaadin/v7/client/ui/checkbox/CheckBoxConnector.java
new file mode 100644 (file)
index 0000000..67e83a7
--- /dev/null
@@ -0,0 +1,155 @@
+/*
+ * 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.ui.checkbox;
+
+import com.google.gwt.dom.client.Style.Display;
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.user.client.DOM;
+import com.google.gwt.user.client.Event;
+import com.vaadin.client.MouseEventDetailsBuilder;
+import com.vaadin.client.VCaption;
+import com.vaadin.client.VTooltip;
+import com.vaadin.client.annotations.OnStateChange;
+import com.vaadin.client.communication.StateChangeEvent;
+import com.vaadin.client.ui.ConnectorFocusAndBlurHandler;
+import com.vaadin.client.ui.Icon;
+import com.vaadin.client.ui.VCheckBox;
+import com.vaadin.shared.EventId;
+import com.vaadin.shared.MouseEventDetails;
+import com.vaadin.shared.ui.Connect;
+import com.vaadin.shared.ui.checkbox.CheckBoxServerRpc;
+import com.vaadin.shared.ui.checkbox.CheckBoxState;
+import com.vaadin.v7.client.ui.AbstractFieldConnector;
+import com.vaadin.v7.ui.CheckBox;
+
+@Connect(CheckBox.class)
+public class CheckBoxConnector extends AbstractFieldConnector
+        implements ClickHandler {
+
+    @Override
+    public boolean delegateCaptionHandling() {
+        return false;
+    }
+
+    @Override
+    protected void init() {
+        super.init();
+
+        getWidget().addClickHandler(this);
+        getWidget().client = getConnection();
+        getWidget().id = getConnectorId();
+
+        ConnectorFocusAndBlurHandler.addHandlers(this);
+    }
+
+    @Override
+    public void onStateChanged(StateChangeEvent stateChangeEvent) {
+        super.onStateChanged(stateChangeEvent);
+
+        if (null != getState().errorMessage) {
+            getWidget().setAriaInvalid(true);
+
+            if (getWidget().errorIndicatorElement == null) {
+                getWidget().errorIndicatorElement = DOM.createSpan();
+                getWidget().errorIndicatorElement.setInnerHTML("&nbsp;");
+                DOM.setElementProperty(getWidget().errorIndicatorElement,
+                        "className", "v-errorindicator");
+                DOM.appendChild(getWidget().getElement(),
+                        getWidget().errorIndicatorElement);
+                DOM.sinkEvents(getWidget().errorIndicatorElement,
+                        VTooltip.TOOLTIP_EVENTS | Event.ONCLICK);
+            } else {
+                getWidget().errorIndicatorElement.getStyle().clearDisplay();
+            }
+        } else if (getWidget().errorIndicatorElement != null) {
+            getWidget().errorIndicatorElement.getStyle()
+                    .setDisplay(Display.NONE);
+
+            getWidget().setAriaInvalid(false);
+        }
+
+        getWidget().setAriaRequired(isRequiredIndicatorVisible());
+        if (isReadOnly()) {
+            getWidget().setEnabled(false);
+        }
+
+        if (getWidget().icon != null) {
+            getWidget().getElement().removeChild(getWidget().icon.getElement());
+            getWidget().icon = null;
+        }
+        Icon icon = getIcon();
+        if (icon != null) {
+            getWidget().icon = icon;
+            DOM.insertChild(getWidget().getElement(), icon.getElement(), 1);
+            icon.sinkEvents(VTooltip.TOOLTIP_EVENTS);
+            icon.sinkEvents(Event.ONCLICK);
+        }
+
+        // Set text
+        VCaption.setCaptionText(getWidget(), getState());
+
+        getWidget().setValue(getState().checked);
+        getWidget().immediate = getState().immediate;
+    }
+
+    @Override
+    public CheckBoxState getState() {
+        return (CheckBoxState) super.getState();
+    }
+
+    @Override
+    public VCheckBox getWidget() {
+        return (VCheckBox) super.getWidget();
+    }
+
+    @Override
+    public void onClick(ClickEvent event) {
+        if (!isEnabled()) {
+            return;
+        }
+
+        // We get click events also from the label text, which do not alter the
+        // actual value. The server-side is only interested in real changes to
+        // the state.
+        if (getState().checked != getWidget().getValue()) {
+            getState().checked = getWidget().getValue();
+
+            // Add mouse details
+            MouseEventDetails details = MouseEventDetailsBuilder
+                    .buildMouseEventDetails(event.getNativeEvent(),
+                            getWidget().getElement());
+            getRpcProxy(CheckBoxServerRpc.class).setChecked(getState().checked,
+                    details);
+            if (getState().immediate) {
+                getConnection().sendPendingVariableChanges();
+            }
+        }
+    }
+
+    private boolean contextEventSunk = false;
+
+    @OnStateChange("registeredEventListeners")
+    void sinkContextClickEvent() {
+        if (!contextEventSunk && hasEventListener(EventId.CONTEXT_CLICK)) {
+            // CheckBox.sinkEvents works differently than all other widgets:
+            // "Unlike other widgets the CheckBox sinks on its inputElement, not
+            // its wrapper"
+            DOM.sinkEvents(getWidget().getElement(), Event.ONCONTEXTMENU);
+            contextEventSunk = true;
+        }
+    }
+}
index 4a632b907112cb40d3fb7e955bb8449a597941d2..f9790bb94e4944136f614214ea01a5936097f711 100644 (file)
@@ -25,13 +25,13 @@ import com.vaadin.client.Profiler;
 import com.vaadin.client.UIDL;
 import com.vaadin.client.communication.RpcProxy;
 import com.vaadin.client.communication.StateChangeEvent;
-import com.vaadin.client.ui.AbstractFieldConnector;
 import com.vaadin.client.ui.SimpleManagedLayout;
 import com.vaadin.shared.EventId;
 import com.vaadin.shared.communication.FieldRpc.FocusAndBlurServerRpc;
 import com.vaadin.shared.ui.Connect;
 import com.vaadin.shared.ui.combobox.ComboBoxServerRpc;
 import com.vaadin.shared.ui.combobox.ComboBoxState;
+import com.vaadin.v7.client.ui.AbstractFieldConnector;
 import com.vaadin.v7.client.ui.VFilterSelect;
 import com.vaadin.v7.client.ui.VFilterSelect.DataReceivedHandler;
 import com.vaadin.v7.client.ui.VFilterSelect.FilterSelectSuggestion;
index e5da960a9df244e1b49fdb7d6dea58af4d30c2c9..0b110d66a4537256d8569f4f42108895762a92f3 100644 (file)
@@ -22,10 +22,10 @@ import com.vaadin.client.LocaleNotLoadedException;
 import com.vaadin.client.Paintable;
 import com.vaadin.client.UIDL;
 import com.vaadin.client.VConsole;
-import com.vaadin.client.ui.AbstractFieldConnector;
 import com.vaadin.client.ui.VDateField;
 import com.vaadin.shared.ui.datefield.DateFieldConstants;
 import com.vaadin.shared.ui.datefield.Resolution;
+import com.vaadin.v7.client.ui.AbstractFieldConnector;
 
 public class AbstractDateFieldConnector extends AbstractFieldConnector
         implements Paintable {
index 6a89498c7cecfe7d80dc1145558b02382201691c..e24ae92742b2b7f1e4c600e26e0b99f2815c12a2 100644 (file)
@@ -20,11 +20,11 @@ import com.vaadin.client.ApplicationConnection;
 import com.vaadin.client.Paintable;
 import com.vaadin.client.StyleConstants;
 import com.vaadin.client.UIDL;
-import com.vaadin.client.ui.AbstractFieldConnector;
 import com.vaadin.client.ui.VNativeButton;
 import com.vaadin.client.ui.VOptionGroupBase;
 import com.vaadin.client.v7.ui.VLegacyTextField;
 import com.vaadin.shared.ui.select.AbstractSelectState;
+import com.vaadin.v7.client.ui.AbstractFieldConnector;
 
 public abstract class OptionGroupBaseConnector extends AbstractFieldConnector
         implements Paintable {
index 9cfc910426ecddaea6408afe9d74d39c28b106c2..77602a4974cb9999e0e248a2949f400089c15cff 100644 (file)
 package com.vaadin.v7.client.ui.progressindicator;
 
 import com.vaadin.client.communication.StateChangeEvent;
-import com.vaadin.client.ui.AbstractFieldConnector;
 import com.vaadin.client.ui.VProgressBar;
 import com.vaadin.shared.ui.Connect;
 import com.vaadin.shared.ui.progressindicator.ProgressBarState;
+import com.vaadin.v7.client.ui.AbstractFieldConnector;
 import com.vaadin.v7.ui.ProgressBar;
 
 /**
index a24ac6b7dba849244a10b639172c7ff2355050ad..fc96e9b16ff9a49ca8219a9846bbe6e96e22eb32 100644 (file)
@@ -20,12 +20,12 @@ import com.google.gwt.event.dom.client.BlurHandler;
 import com.vaadin.client.ApplicationConnection;
 import com.vaadin.client.Paintable;
 import com.vaadin.client.UIDL;
-import com.vaadin.client.ui.AbstractFieldConnector;
 import com.vaadin.client.ui.SimpleManagedLayout;
 import com.vaadin.shared.ui.Connect;
 import com.vaadin.shared.ui.Connect.LoadStyle;
 import com.vaadin.shared.ui.textarea.RichTextAreaState;
 import com.vaadin.shared.util.SharedUtil;
+import com.vaadin.v7.client.ui.AbstractFieldConnector;
 import com.vaadin.v7.client.ui.VRichTextArea;
 import com.vaadin.v7.ui.RichTextArea;
 
index 69395cd8badf0f3241b50dda85180ace6d8138d2..405fdd1393508e06fa06ee410b75122ca67546a7 100644 (file)
@@ -37,12 +37,12 @@ import com.vaadin.client.ServerConnector;
 import com.vaadin.client.TooltipInfo;
 import com.vaadin.client.UIDL;
 import com.vaadin.client.WidgetUtil;
-import com.vaadin.client.ui.AbstractFieldConnector;
 import com.vaadin.client.ui.PostLayoutListener;
 import com.vaadin.shared.MouseEventDetails;
 import com.vaadin.shared.ui.Connect;
 import com.vaadin.shared.ui.table.TableConstants;
 import com.vaadin.shared.ui.table.TableConstants.Section;
+import com.vaadin.v7.client.ui.AbstractFieldConnector;
 import com.vaadin.v7.client.ui.VScrollTable;
 import com.vaadin.v7.client.ui.VScrollTable.ContextMenuDetails;
 import com.vaadin.v7.client.ui.VScrollTable.FooterCell;
diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/CheckBox.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/CheckBox.java
new file mode 100644 (file)
index 0000000..84488bc
--- /dev/null
@@ -0,0 +1,269 @@
+/*
+ * 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.ui;
+
+import java.util.Collection;
+
+import org.jsoup.nodes.Attributes;
+import org.jsoup.nodes.Element;
+
+import com.vaadin.event.FieldEvents.BlurEvent;
+import com.vaadin.event.FieldEvents.BlurListener;
+import com.vaadin.event.FieldEvents.FocusAndBlurServerRpcImpl;
+import com.vaadin.event.FieldEvents.FocusEvent;
+import com.vaadin.event.FieldEvents.FocusListener;
+import com.vaadin.shared.MouseEventDetails;
+import com.vaadin.shared.ui.checkbox.CheckBoxServerRpc;
+import com.vaadin.shared.ui.checkbox.CheckBoxState;
+import com.vaadin.ui.declarative.DesignAttributeHandler;
+import com.vaadin.ui.declarative.DesignContext;
+import com.vaadin.v7.data.Property;
+
+public class CheckBox extends AbstractField<Boolean> {
+
+    private CheckBoxServerRpc rpc = new CheckBoxServerRpc() {
+
+        @Override
+        public void setChecked(boolean checked,
+                MouseEventDetails mouseEventDetails) {
+            if (isReadOnly()) {
+                return;
+            }
+
+            /*
+             * Client side updates the state before sending the event so we need
+             * to make sure the cached state is updated to match the client. If
+             * we do not do this, a reverting setValue() call in a listener will
+             * not cause the new state to be sent to the client.
+             *
+             * See #11028, #10030.
+             */
+            getUI().getConnectorTracker().getDiffState(CheckBox.this)
+                    .put("checked", checked);
+
+            final Boolean oldValue = getValue();
+            final Boolean newValue = checked;
+
+            if (!newValue.equals(oldValue)) {
+                // The event is only sent if the switch state is changed
+                setValue(newValue);
+            }
+
+        }
+    };
+
+    FocusAndBlurServerRpcImpl focusBlurRpc = new FocusAndBlurServerRpcImpl(
+            this) {
+        @Override
+        protected void fireEvent(Event event) {
+            CheckBox.this.fireEvent(event);
+        }
+    };
+
+    /**
+     * Creates a new checkbox.
+     */
+    public CheckBox() {
+        registerRpc(rpc);
+        registerRpc(focusBlurRpc);
+        setValue(Boolean.FALSE);
+    }
+
+    /**
+     * Creates a new checkbox with a set caption.
+     *
+     * @param caption
+     *            the Checkbox caption.
+     */
+    public CheckBox(String caption) {
+        this();
+        setCaption(caption);
+    }
+
+    /**
+     * Creates a new checkbox with a caption and a set initial state.
+     *
+     * @param caption
+     *            the caption of the checkbox
+     * @param initialState
+     *            the initial state of the checkbox
+     */
+    public CheckBox(String caption, boolean initialState) {
+        this(caption);
+        setValue(initialState);
+    }
+
+    /**
+     * Creates a new checkbox that is connected to a boolean property.
+     *
+     * @param state
+     *            the Initial state of the switch-button.
+     * @param dataSource
+     */
+    public CheckBox(String caption, Property<?> dataSource) {
+        this(caption);
+        setPropertyDataSource(dataSource);
+    }
+
+    @Override
+    public Class<Boolean> getType() {
+        return Boolean.class;
+    }
+
+    @Override
+    protected CheckBoxState getState() {
+        return (CheckBoxState) super.getState();
+    }
+
+    /*
+     * Overridden to keep the shared state in sync with the LegacyAbstractField
+     * internal value. Should be removed once LegacyAbstractField is refactored
+     * to use shared state.
+     *
+     * See tickets #10921 and #11064.
+     */
+    @Override
+    protected void setInternalValue(Boolean newValue) {
+        super.setInternalValue(newValue);
+        if (newValue == null) {
+            newValue = false;
+        }
+        getState().checked = newValue;
+    }
+
+    public void addBlurListener(BlurListener listener) {
+        addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener,
+                BlurListener.blurMethod);
+    }
+
+    /**
+     * @deprecated As of 7.0, replaced by {@link #addBlurListener(BlurListener)}
+     **/
+    @Deprecated
+    public void addListener(BlurListener listener) {
+        addBlurListener(listener);
+    }
+
+    public void removeBlurListener(BlurListener listener) {
+        removeListener(BlurEvent.EVENT_ID, BlurEvent.class, listener);
+    }
+
+    /**
+     * @deprecated As of 7.0, replaced by
+     *             {@link #removeBlurListener(BlurListener)}
+     **/
+    @Deprecated
+    public void removeListener(BlurListener listener) {
+        removeBlurListener(listener);
+    }
+
+    public void addFocusListener(FocusListener listener) {
+        addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener,
+                FocusListener.focusMethod);
+    }
+
+    /**
+     * @deprecated As of 7.0, replaced by
+     *             {@link #addFocusListener(FocusListener)}
+     **/
+    @Deprecated
+    public void addListener(FocusListener listener) {
+        addFocusListener(listener);
+    }
+
+    public void removeFocusListener(FocusListener listener) {
+        removeListener(FocusEvent.EVENT_ID, FocusEvent.class, listener);
+    }
+
+    /**
+     * @deprecated As of 7.0, replaced by
+     *             {@link #removeFocusListener(FocusListener)}
+     **/
+    @Deprecated
+    public void removeListener(FocusListener listener) {
+        removeFocusListener(listener);
+    }
+
+    /**
+     * Get the boolean value of the button state.
+     *
+     * @return True iff the button is pressed down or checked.
+     *
+     * @deprecated As of 7.0, use {@link #getValue()} instead and, if needed,
+     *             handle null values.
+     */
+    @Deprecated
+    public boolean booleanValue() {
+        Boolean value = getValue();
+        return (null == value) ? false : value.booleanValue();
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see com.vaadin.ui.AbstractField#readDesign(org.jsoup.nodes.Element,
+     * com.vaadin.ui.declarative.DesignContext)
+     */
+    @Override
+    public void readDesign(Element design, DesignContext designContext) {
+        super.readDesign(design, designContext);
+        if (design.hasAttr("checked")) {
+            this.setValue(DesignAttributeHandler.readAttribute("checked",
+                    design.attributes(), Boolean.class), false, true);
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see com.vaadin.ui.AbstractField#getCustomAttributes()
+     */
+    @Override
+    protected Collection<String> getCustomAttributes() {
+        Collection<String> attributes = super.getCustomAttributes();
+        attributes.add("checked");
+        return attributes;
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see com.vaadin.ui.AbstractField#writeDesign(org.jsoup.nodes.Element,
+     * com.vaadin.ui.declarative.DesignContext)
+     */
+    @Override
+    public void writeDesign(Element design, DesignContext designContext) {
+        super.writeDesign(design, designContext);
+        CheckBox def = (CheckBox) designContext
+                .getDefaultInstance(this);
+        Attributes attr = design.attributes();
+        DesignAttributeHandler.writeAttribute("checked", attr, getValue(),
+                def.getValue(), Boolean.class);
+    }
+
+    @Override
+    public void clear() {
+        setValue(Boolean.FALSE);
+    }
+
+    @Override
+    public boolean isEmpty() {
+        return getValue() == null || getValue().equals(Boolean.FALSE);
+
+    }
+
+}
diff --git a/server/src/main/java/com/vaadin/v7/ui/CheckBox.java b/server/src/main/java/com/vaadin/v7/ui/CheckBox.java
deleted file mode 100644 (file)
index 84488bc..0000000
+++ /dev/null
@@ -1,269 +0,0 @@
-/*
- * Copyright 2000-2016 Vaadin Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package com.vaadin.v7.ui;
-
-import java.util.Collection;
-
-import org.jsoup.nodes.Attributes;
-import org.jsoup.nodes.Element;
-
-import com.vaadin.event.FieldEvents.BlurEvent;
-import com.vaadin.event.FieldEvents.BlurListener;
-import com.vaadin.event.FieldEvents.FocusAndBlurServerRpcImpl;
-import com.vaadin.event.FieldEvents.FocusEvent;
-import com.vaadin.event.FieldEvents.FocusListener;
-import com.vaadin.shared.MouseEventDetails;
-import com.vaadin.shared.ui.checkbox.CheckBoxServerRpc;
-import com.vaadin.shared.ui.checkbox.CheckBoxState;
-import com.vaadin.ui.declarative.DesignAttributeHandler;
-import com.vaadin.ui.declarative.DesignContext;
-import com.vaadin.v7.data.Property;
-
-public class CheckBox extends AbstractField<Boolean> {
-
-    private CheckBoxServerRpc rpc = new CheckBoxServerRpc() {
-
-        @Override
-        public void setChecked(boolean checked,
-                MouseEventDetails mouseEventDetails) {
-            if (isReadOnly()) {
-                return;
-            }
-
-            /*
-             * Client side updates the state before sending the event so we need
-             * to make sure the cached state is updated to match the client. If
-             * we do not do this, a reverting setValue() call in a listener will
-             * not cause the new state to be sent to the client.
-             *
-             * See #11028, #10030.
-             */
-            getUI().getConnectorTracker().getDiffState(CheckBox.this)
-                    .put("checked", checked);
-
-            final Boolean oldValue = getValue();
-            final Boolean newValue = checked;
-
-            if (!newValue.equals(oldValue)) {
-                // The event is only sent if the switch state is changed
-                setValue(newValue);
-            }
-
-        }
-    };
-
-    FocusAndBlurServerRpcImpl focusBlurRpc = new FocusAndBlurServerRpcImpl(
-            this) {
-        @Override
-        protected void fireEvent(Event event) {
-            CheckBox.this.fireEvent(event);
-        }
-    };
-
-    /**
-     * Creates a new checkbox.
-     */
-    public CheckBox() {
-        registerRpc(rpc);
-        registerRpc(focusBlurRpc);
-        setValue(Boolean.FALSE);
-    }
-
-    /**
-     * Creates a new checkbox with a set caption.
-     *
-     * @param caption
-     *            the Checkbox caption.
-     */
-    public CheckBox(String caption) {
-        this();
-        setCaption(caption);
-    }
-
-    /**
-     * Creates a new checkbox with a caption and a set initial state.
-     *
-     * @param caption
-     *            the caption of the checkbox
-     * @param initialState
-     *            the initial state of the checkbox
-     */
-    public CheckBox(String caption, boolean initialState) {
-        this(caption);
-        setValue(initialState);
-    }
-
-    /**
-     * Creates a new checkbox that is connected to a boolean property.
-     *
-     * @param state
-     *            the Initial state of the switch-button.
-     * @param dataSource
-     */
-    public CheckBox(String caption, Property<?> dataSource) {
-        this(caption);
-        setPropertyDataSource(dataSource);
-    }
-
-    @Override
-    public Class<Boolean> getType() {
-        return Boolean.class;
-    }
-
-    @Override
-    protected CheckBoxState getState() {
-        return (CheckBoxState) super.getState();
-    }
-
-    /*
-     * Overridden to keep the shared state in sync with the LegacyAbstractField
-     * internal value. Should be removed once LegacyAbstractField is refactored
-     * to use shared state.
-     *
-     * See tickets #10921 and #11064.
-     */
-    @Override
-    protected void setInternalValue(Boolean newValue) {
-        super.setInternalValue(newValue);
-        if (newValue == null) {
-            newValue = false;
-        }
-        getState().checked = newValue;
-    }
-
-    public void addBlurListener(BlurListener listener) {
-        addListener(BlurEvent.EVENT_ID, BlurEvent.class, listener,
-                BlurListener.blurMethod);
-    }
-
-    /**
-     * @deprecated As of 7.0, replaced by {@link #addBlurListener(BlurListener)}
-     **/
-    @Deprecated
-    public void addListener(BlurListener listener) {
-        addBlurListener(listener);
-    }
-
-    public void removeBlurListener(BlurListener listener) {
-        removeListener(BlurEvent.EVENT_ID, BlurEvent.class, listener);
-    }
-
-    /**
-     * @deprecated As of 7.0, replaced by
-     *             {@link #removeBlurListener(BlurListener)}
-     **/
-    @Deprecated
-    public void removeListener(BlurListener listener) {
-        removeBlurListener(listener);
-    }
-
-    public void addFocusListener(FocusListener listener) {
-        addListener(FocusEvent.EVENT_ID, FocusEvent.class, listener,
-                FocusListener.focusMethod);
-    }
-
-    /**
-     * @deprecated As of 7.0, replaced by
-     *             {@link #addFocusListener(FocusListener)}
-     **/
-    @Deprecated
-    public void addListener(FocusListener listener) {
-        addFocusListener(listener);
-    }
-
-    public void removeFocusListener(FocusListener listener) {
-        removeListener(FocusEvent.EVENT_ID, FocusEvent.class, listener);
-    }
-
-    /**
-     * @deprecated As of 7.0, replaced by
-     *             {@link #removeFocusListener(FocusListener)}
-     **/
-    @Deprecated
-    public void removeListener(FocusListener listener) {
-        removeFocusListener(listener);
-    }
-
-    /**
-     * Get the boolean value of the button state.
-     *
-     * @return True iff the button is pressed down or checked.
-     *
-     * @deprecated As of 7.0, use {@link #getValue()} instead and, if needed,
-     *             handle null values.
-     */
-    @Deprecated
-    public boolean booleanValue() {
-        Boolean value = getValue();
-        return (null == value) ? false : value.booleanValue();
-    }
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see com.vaadin.ui.AbstractField#readDesign(org.jsoup.nodes.Element,
-     * com.vaadin.ui.declarative.DesignContext)
-     */
-    @Override
-    public void readDesign(Element design, DesignContext designContext) {
-        super.readDesign(design, designContext);
-        if (design.hasAttr("checked")) {
-            this.setValue(DesignAttributeHandler.readAttribute("checked",
-                    design.attributes(), Boolean.class), false, true);
-        }
-    }
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see com.vaadin.ui.AbstractField#getCustomAttributes()
-     */
-    @Override
-    protected Collection<String> getCustomAttributes() {
-        Collection<String> attributes = super.getCustomAttributes();
-        attributes.add("checked");
-        return attributes;
-    }
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see com.vaadin.ui.AbstractField#writeDesign(org.jsoup.nodes.Element,
-     * com.vaadin.ui.declarative.DesignContext)
-     */
-    @Override
-    public void writeDesign(Element design, DesignContext designContext) {
-        super.writeDesign(design, designContext);
-        CheckBox def = (CheckBox) designContext
-                .getDefaultInstance(this);
-        Attributes attr = design.attributes();
-        DesignAttributeHandler.writeAttribute("checked", attr, getValue(),
-                def.getValue(), Boolean.class);
-    }
-
-    @Override
-    public void clear() {
-        setValue(Boolean.FALSE);
-    }
-
-    @Override
-    public boolean isEmpty() {
-        return getValue() == null || getValue().equals(Boolean.FALSE);
-
-    }
-
-}