]> source.dussan.org Git - vaadin-framework.git/commitdiff
Convert CheckBox from legacy to AbstractField
authorHenri Sara <hesara@vaadin.com>
Tue, 9 Aug 2016 12:11:02 +0000 (15:11 +0300)
committerHenri Sara <hesara@vaadin.com>
Thu, 11 Aug 2016 12:45:59 +0000 (15:45 +0300)
Add LegacyCheckBox for old field factories, Grid editor etc.

Change-Id: Ic40790049421268c6de3d26730d1955d56aa86c4

113 files changed:
client/src/main/java/com/vaadin/client/legacy/ui/checkbox/LegacyCheckBoxConnector.java [new file with mode: 0644]
server/src/main/java/com/vaadin/data/fieldgroup/DefaultFieldGroupFieldFactory.java
server/src/main/java/com/vaadin/legacy/ui/LegacyCheckBox.java [new file with mode: 0644]
server/src/main/java/com/vaadin/ui/CheckBox.java
server/src/main/java/com/vaadin/ui/DefaultFieldFactory.java
server/src/main/java/com/vaadin/ui/Grid.java
server/src/test/java/com/vaadin/tests/server/component/AbstractListenerMethodsTestBase.java
server/src/test/java/com/vaadin/tests/server/component/abstractfield/AbsFieldValueConversionsTest.java
server/src/test/java/com/vaadin/tests/server/component/abstractfield/AbstractFieldListenersTest.java [deleted file]
server/src/test/java/com/vaadin/tests/server/component/abstractfield/LegacyAbstractFieldListenersTest.java [new file with mode: 0644]
server/src/test/java/com/vaadin/ui/CheckBoxTest.java
uitest/src/main/java/com/vaadin/tests/TestForRichTextEditor.java
uitest/src/main/java/com/vaadin/tests/application/CommErrorEmulatorUI.java
uitest/src/main/java/com/vaadin/tests/components/ComponentTestCase.java
uitest/src/main/java/com/vaadin/tests/components/abstractcomponent/EnableState.java
uitest/src/main/java/com/vaadin/tests/components/abstractcomponent/TooltipTests.java
uitest/src/main/java/com/vaadin/tests/components/abstractfield/RequiredIndicatorForFieldsWithoutCaption.java
uitest/src/main/java/com/vaadin/tests/components/button/ButtonUpdateAltText.java
uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarHtmlInEvents.java
uitest/src/main/java/com/vaadin/tests/components/calendar/CalendarTest.java
uitest/src/main/java/com/vaadin/tests/components/checkbox/CheckBoxImmediate.java
uitest/src/main/java/com/vaadin/tests/components/checkbox/CheckBoxNullValue.java [deleted file]
uitest/src/main/java/com/vaadin/tests/components/checkbox/CheckBoxRevertValueChange.java
uitest/src/main/java/com/vaadin/tests/components/checkbox/CheckBoxRpcCount.java
uitest/src/main/java/com/vaadin/tests/components/checkbox/CheckBoxes2.java
uitest/src/main/java/com/vaadin/tests/components/colorpicker/ColorPickerTestUI.java
uitest/src/main/java/com/vaadin/tests/components/combobox/ComboBoxNoTextInput.java
uitest/src/main/java/com/vaadin/tests/components/combobox/WidthToggleReadOnly.java
uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldRangeValidation.java
uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldRanges.java
uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldWhenChangingValueAndEnablingParent.java
uitest/src/main/java/com/vaadin/tests/components/datefield/LowResolution.java
uitest/src/main/java/com/vaadin/tests/components/datefield/PopupDateFieldTextEnabled.java
uitest/src/main/java/com/vaadin/tests/components/draganddropwrapper/DragAndDropDisable.java
uitest/src/main/java/com/vaadin/tests/components/formlayout/NestedFormLayouts.java
uitest/src/main/java/com/vaadin/tests/components/grid/GridDetailsLocation.java
uitest/src/main/java/com/vaadin/tests/components/grid/GridSwitchRenderers.java
uitest/src/main/java/com/vaadin/tests/components/gridlayout/GridLayoutExtraSpacing.java
uitest/src/main/java/com/vaadin/tests/components/gridlayout/GridLayoutScrollPosition.java
uitest/src/main/java/com/vaadin/tests/components/javascriptcomponent/JavaScriptResizeListener.java
uitest/src/main/java/com/vaadin/tests/components/media/AudioTest.java
uitest/src/main/java/com/vaadin/tests/components/optiongroup/ReadOnlyOptionGroup.java
uitest/src/main/java/com/vaadin/tests/components/orderedlayout/BoxLayoutTest.java
uitest/src/main/java/com/vaadin/tests/components/panel/BasicPanelTest.java
uitest/src/main/java/com/vaadin/tests/components/richtextarea/RichTextAreaPreventsTextFieldAccess.java
uitest/src/main/java/com/vaadin/tests/components/select/OptionGroupBaseSelects.java
uitest/src/main/java/com/vaadin/tests/components/splitpanel/GridLayoutWithCheckbox.java
uitest/src/main/java/com/vaadin/tests/components/table/AddItemToEmptyTable.java
uitest/src/main/java/com/vaadin/tests/components/table/ColumnHeaderAlignments.java
uitest/src/main/java/com/vaadin/tests/components/table/DoublesInTable.java
uitest/src/main/java/com/vaadin/tests/components/table/EditableTableLeak.java
uitest/src/main/java/com/vaadin/tests/components/table/Footer.java
uitest/src/main/java/com/vaadin/tests/components/table/FooterClick.java
uitest/src/main/java/com/vaadin/tests/components/table/HeaderClick.java
uitest/src/main/java/com/vaadin/tests/components/table/HeaderFooterClickLeftRightMiddle.java
uitest/src/main/java/com/vaadin/tests/components/table/HeaderPositionWhenSorting.java
uitest/src/main/java/com/vaadin/tests/components/table/HeaderUpdateWhenNoRows.java
uitest/src/main/java/com/vaadin/tests/components/table/ItemClickEvents.java
uitest/src/main/java/com/vaadin/tests/components/table/SelectAllConstantViewport.java
uitest/src/main/java/com/vaadin/tests/components/table/TableAndBrowserContextMenu.java
uitest/src/main/java/com/vaadin/tests/components/table/TableContextMenuTouch.java
uitest/src/main/java/com/vaadin/tests/components/table/TableHeightWhenHidingHeaders.java
uitest/src/main/java/com/vaadin/tests/components/table/TableItemDescriptionGeneratorUI.java
uitest/src/main/java/com/vaadin/tests/components/table/TableScrollOnFocus.java
uitest/src/main/java/com/vaadin/tests/components/table/TableSqlContainer.java
uitest/src/main/java/com/vaadin/tests/components/table/TableUndefinedSize.java
uitest/src/main/java/com/vaadin/tests/components/table/TableWithBrokenGeneratorAndContainer.java
uitest/src/main/java/com/vaadin/tests/components/table/ValueAfterClearingContainer.java
uitest/src/main/java/com/vaadin/tests/components/textarea/Wordwrap.java
uitest/src/main/java/com/vaadin/tests/components/textfield/SelectionAndCursorPosition.java
uitest/src/main/java/com/vaadin/tests/components/textfield/SetTabIndex.java
uitest/src/main/java/com/vaadin/tests/components/textfield/TextFieldInputPromptAndClickShortcut.java
uitest/src/main/java/com/vaadin/tests/components/tree/TreeConnectors.java
uitest/src/main/java/com/vaadin/tests/components/tree/TreeFiltering.java
uitest/src/main/java/com/vaadin/tests/components/tree/TreeHtmlContentAllowed.java
uitest/src/main/java/com/vaadin/tests/components/window/LazyWindowResize.java
uitest/src/main/java/com/vaadin/tests/components/window/WindowMaximizeRestoreTest.java
uitest/src/main/java/com/vaadin/tests/components/window/WindowResizeListener.java
uitest/src/main/java/com/vaadin/tests/containers/BeanItemContainerFilteringTest.java
uitest/src/main/java/com/vaadin/tests/containers/IndexedContainerFilteringTest.java
uitest/src/main/java/com/vaadin/tests/dd/TreeDragStart.java
uitest/src/main/java/com/vaadin/tests/fieldgroup/BasicPersonForm.java
uitest/src/main/java/com/vaadin/tests/integration/EmbedSizeTest.java
uitest/src/main/java/com/vaadin/tests/layouts/CaptionsInLayouts.java
uitest/src/main/java/com/vaadin/tests/layouts/CaptionsInLayoutsWaiAria.java
uitest/src/main/java/com/vaadin/tests/layouts/CssLayoutCustomCss.java
uitest/src/main/java/com/vaadin/tests/layouts/FormLayoutWithInvisibleComponent.java
uitest/src/main/java/com/vaadin/tests/layouts/LayoutPerformanceTests.java
uitest/src/main/java/com/vaadin/tests/push/PushRemoveConnectors.java
uitest/src/main/java/com/vaadin/tests/push/TogglePush.java
uitest/src/main/java/com/vaadin/tests/serialization/NoLayout.java
uitest/src/main/java/com/vaadin/tests/themes/ButtonsTest.java
uitest/src/main/java/com/vaadin/tests/themes/valo/CalendarTest.java
uitest/src/main/java/com/vaadin/tests/themes/valo/CommonParts.java
uitest/src/main/java/com/vaadin/tests/themes/valo/Tables.java
uitest/src/main/java/com/vaadin/tests/themes/valo/Tabsheets.java
uitest/src/main/java/com/vaadin/tests/tickets/Ticket1710.java
uitest/src/main/java/com/vaadin/tests/tickets/Ticket1857.java
uitest/src/main/java/com/vaadin/tests/tickets/Ticket1983.java
uitest/src/main/java/com/vaadin/tests/tickets/Ticket20.java
uitest/src/main/java/com/vaadin/tests/tickets/Ticket2001.java
uitest/src/main/java/com/vaadin/tests/tickets/Ticket2038.java
uitest/src/main/java/com/vaadin/tests/tickets/Ticket2104.java
uitest/src/main/java/com/vaadin/tests/tickets/Ticket2107.java
uitest/src/main/java/com/vaadin/tests/tickets/Ticket2125.java
uitest/src/main/java/com/vaadin/tests/tickets/Ticket2151.java
uitest/src/main/java/com/vaadin/tests/tickets/Ticket736.java
uitest/src/main/java/com/vaadin/tests/tickets/Ticket846.java
uitest/src/main/java/com/vaadin/tests/util/CheckBoxWithPropertyDataSource.java [new file with mode: 0644]
uitest/src/main/java/com/vaadin/tests/validation/ValidationOfRequiredEmptyFields.java
uitest/src/test/java/com/vaadin/tests/components/checkbox/CheckBoxNullValueTest.java [deleted file]
uitest/src/test/java/com/vaadin/tests/components/grid/GridCheckBoxDisplayTest.java
uitest/src/test/java/com/vaadin/tests/legacyelements/LegacyCheckBoxElement.java [new file with mode: 0644]

diff --git a/client/src/main/java/com/vaadin/client/legacy/ui/checkbox/LegacyCheckBoxConnector.java b/client/src/main/java/com/vaadin/client/legacy/ui/checkbox/LegacyCheckBoxConnector.java
new file mode 100644 (file)
index 0000000..bb05f97
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2000-2014 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.legacy.ui.checkbox;
+
+import com.vaadin.client.ui.checkbox.CheckBoxConnector;
+import com.vaadin.legacy.ui.LegacyCheckBox;
+import com.vaadin.shared.ui.Connect;
+
+@Connect(LegacyCheckBox.class)
+public class LegacyCheckBoxConnector extends CheckBoxConnector {
+
+}
index 27f4628bae11037649c763d6a2b8fbb3b3006c14..a82da7ef51553065688334ed39d36cc187315302 100644 (file)
@@ -20,11 +20,11 @@ import java.util.EnumSet;
 
 import com.vaadin.data.Item;
 import com.vaadin.data.fieldgroup.FieldGroup.BindException;
-import com.vaadin.legacy.ui.LegacyField;
 import com.vaadin.legacy.ui.LegacyAbstractField;
+import com.vaadin.legacy.ui.LegacyCheckBox;
+import com.vaadin.legacy.ui.LegacyField;
 import com.vaadin.ui.AbstractSelect;
 import com.vaadin.ui.AbstractTextField;
-import com.vaadin.ui.CheckBox;
 import com.vaadin.ui.ComboBox;
 import com.vaadin.ui.DateField;
 import com.vaadin.ui.InlineDateField;
@@ -174,8 +174,8 @@ public class DefaultFieldGroupFieldFactory implements FieldGroupFieldFactory {
     }
 
     protected <T extends LegacyField> T createBooleanField(Class<T> fieldType) {
-        if (fieldType.isAssignableFrom(CheckBox.class)) {
-            CheckBox cb = new CheckBox(null);
+        if (fieldType.isAssignableFrom(LegacyCheckBox.class)) {
+            LegacyCheckBox cb = new LegacyCheckBox(null);
             cb.setImmediate(true);
             return (T) cb;
         } else if (AbstractTextField.class.isAssignableFrom(fieldType)) {
diff --git a/server/src/main/java/com/vaadin/legacy/ui/LegacyCheckBox.java b/server/src/main/java/com/vaadin/legacy/ui/LegacyCheckBox.java
new file mode 100644 (file)
index 0000000..baa98a4
--- /dev/null
@@ -0,0 +1,268 @@
+/*
+ * Copyright 2000-2014 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.legacy.ui;
+
+import java.util.Collection;
+
+import org.jsoup.nodes.Attributes;
+import org.jsoup.nodes.Element;
+
+import com.vaadin.data.Property;
+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;
+
+public class LegacyCheckBox extends LegacyAbstractField<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(LegacyCheckBox.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) {
+            LegacyCheckBox.this.fireEvent(event);
+        }
+    };
+
+    /**
+     * Creates a new checkbox.
+     */
+    public LegacyCheckBox() {
+        registerRpc(rpc);
+        registerRpc(focusBlurRpc);
+        setValue(Boolean.FALSE);
+    }
+
+    /**
+     * Creates a new checkbox with a set caption.
+     *
+     * @param caption
+     *            the Checkbox caption.
+     */
+    public LegacyCheckBox(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 LegacyCheckBox(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 LegacyCheckBox(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);
+        LegacyCheckBox def = (LegacyCheckBox) 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);
+
+    }
+
+}
index e9e9b0d4b9406be238b241f30b422704b35cd944..1519c6495597ad6f848199b28cc3ce511eae97e2 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * Copyright 2000-2014 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
@@ -21,20 +21,18 @@ import java.util.Collection;
 import org.jsoup.nodes.Attributes;
 import org.jsoup.nodes.Element;
 
-import com.vaadin.data.Property;
 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.legacy.ui.LegacyAbstractField;
 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;
 
-public class CheckBox extends LegacyAbstractField<Boolean> {
+public class CheckBox extends AbstractField<Boolean> {
 
     private CheckBoxServerRpc rpc = new CheckBoxServerRpc() {
 
@@ -50,7 +48,7 @@ public class CheckBox extends LegacyAbstractField<Boolean> {
              * 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)
@@ -85,7 +83,7 @@ public class CheckBox extends LegacyAbstractField<Boolean> {
 
     /**
      * Creates a new checkbox with a set caption.
-     * 
+     *
      * @param caption
      *            the Checkbox caption.
      */
@@ -96,7 +94,7 @@ public class CheckBox extends LegacyAbstractField<Boolean> {
 
     /**
      * Creates a new checkbox with a caption and a set initial state.
-     * 
+     *
      * @param caption
      *            the caption of the checkbox
      * @param initialState
@@ -107,21 +105,27 @@ public class CheckBox extends LegacyAbstractField<Boolean> {
         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 Boolean getValue() {
+        return getState(false).checked;
     }
 
+    /**
+     * Sets the value of this ComboBox. If the new value is not equal to
+     * {@code getValue()}, fires a value change event. Throws
+     * {@code IllegalArgumentException} if the value is null.
+     *
+     * @param value
+     *            the new value
+     * @throws IllegalArgumentException
+     *             if the value is null
+     */
     @Override
-    public Class<Boolean> getType() {
-        return Boolean.class;
+    public void setValue(Boolean value) {
+        if (value == null) {
+            throw new IllegalArgumentException("CheckBox value must not be null");
+        }
+        super.setValue(value);
     }
 
     @Override
@@ -129,20 +133,14 @@ public class CheckBox extends LegacyAbstractField<Boolean> {
         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;
+    protected CheckBoxState getState(boolean markAsDirty) {
+        return (CheckBoxState) super.getState(markAsDirty);
+    }
+
+    @Override
+    protected void doSetValue(Boolean value) {
+        getState().checked = value;
     }
 
     public void addBlurListener(BlurListener listener) {
@@ -150,71 +148,22 @@ public class CheckBox extends LegacyAbstractField<Boolean> {
                 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)
      */
@@ -224,13 +173,13 @@ public class CheckBox extends LegacyAbstractField<Boolean> {
         if (design.hasAttr("checked")) {
             this.setValue(
                     DesignAttributeHandler.readAttribute("checked",
-                            design.attributes(), Boolean.class), false, true);
+                            design.attributes(), Boolean.class), false);
         }
     }
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see com.vaadin.ui.AbstractField#getCustomAttributes()
      */
     @Override
@@ -242,7 +191,7 @@ public class CheckBox extends LegacyAbstractField<Boolean> {
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see com.vaadin.ui.AbstractField#writeDesign(org.jsoup.nodes.Element,
      * com.vaadin.ui.declarative.DesignContext)
      */
@@ -255,15 +204,4 @@ public class CheckBox extends LegacyAbstractField<Boolean> {
                 def.getValue(), Boolean.class);
     }
 
-    @Override
-    public void clear() {
-        setValue(Boolean.FALSE);
-    }
-
-    @Override
-    public boolean isEmpty() {
-        return getValue() == null || getValue().equals(Boolean.FALSE);
-
-    }
-
 }
index 85ad1743ea33068810bdae0fe15ada0e63884c1b..3e44a901fc4fceed2722cc4a17e691d08628715a 100644 (file)
@@ -20,6 +20,7 @@ import java.util.Date;
 import com.vaadin.data.Container;
 import com.vaadin.data.Item;
 import com.vaadin.data.Property;
+import com.vaadin.legacy.ui.LegacyCheckBox;
 import com.vaadin.legacy.ui.LegacyField;
 import com.vaadin.shared.util.SharedUtil;
 
@@ -116,7 +117,7 @@ public class DefaultFieldFactory implements FormFieldFactory, TableFieldFactory
 
         // Boolean field
         if (Boolean.class.isAssignableFrom(type)) {
-            return new CheckBox();
+            return new LegacyCheckBox();
         }
 
         return new TextField();
index 1319f868c79cd5441cb70787888a5a91345aa3a3..c9887c1db3af17dc96d9a97a236e257a8e7b3760 100644 (file)
@@ -73,6 +73,7 @@ import com.vaadin.event.SortEvent.SortNotifier;
 import com.vaadin.legacy.data.Validator.InvalidValueException;
 import com.vaadin.legacy.data.util.converter.LegacyConverter;
 import com.vaadin.legacy.data.util.converter.LegacyConverterUtil;
+import com.vaadin.legacy.ui.LegacyCheckBox;
 import com.vaadin.legacy.ui.LegacyField;
 import com.vaadin.server.AbstractClientConnector;
 import com.vaadin.server.AbstractExtension;
@@ -545,7 +546,7 @@ public class Grid extends AbstractFocusable implements SelectionNotifier,
                 Class<?> dataType,
                 Class<T> fieldType) throws BindException {
             T field = super.build(caption, dataType, fieldType);
-            if (field instanceof CheckBox) {
+            if (field instanceof LegacyCheckBox) {
                 field.setCaption(null);
             }
             return field;
index 24201ce51dd8707d976015b416dff322aa4fc1f2..b3a28426561694ab35414e0ef7210eb2d7084511 100644 (file)
@@ -30,7 +30,10 @@ public abstract class AbstractListenerMethodsTestBase {
         for (Class<?> c : classes) {
             boolean found = false;
             for (Method m : c.getDeclaredMethods()) {
-                if (m.getName().equals("addListener")) {
+                String methodName = m.getName();
+                if (methodName.startsWith("add")
+                        && methodName.endsWith("Listener")
+                        && !"addListener".equals(methodName)) {
                     if (m.getParameterTypes().length != 1) {
                         continue;
                     }
@@ -47,19 +50,22 @@ public abstract class AbstractListenerMethodsTestBase {
 
                         System.out.println("import "
                                 + AbstractListenerMethodsTestBase.class
-                                        .getName() + ";");
+                                        .getName()
+                                + ";");
                         System.out.println("import " + c.getName() + ";");
-                        System.out.println("public class "
-                                + c.getSimpleName()
-                                + "Listeners extends "
-                                + AbstractListenerMethodsTestBase.class
-                                        .getSimpleName() + " {");
+                        System.out
+                                .println(
+                                        "public class " + c.getSimpleName()
+                                                + "Listeners extends "
+                                                + AbstractListenerMethodsTestBase.class
+                                                        .getSimpleName()
+                                                + " {");
                     }
 
                     String listenerClassName = m.getParameterTypes()[0]
                             .getSimpleName();
-                    String eventClassName = listenerClassName.replaceFirst(
-                            "Listener$", "Event");
+                    String eventClassName = listenerClassName
+                            .replaceFirst("Listener$", "Event");
                     System.out.println("public void test" + listenerClassName
                             + "() throws Exception {");
                     System.out.println("    testListener(" + c.getSimpleName()
@@ -127,14 +133,16 @@ public abstract class AbstractListenerMethodsTestBase {
 
     private void addListener(Object c, Object listener1, Class<?> listenerClass)
             throws IllegalArgumentException, IllegalAccessException,
-            InvocationTargetException, SecurityException, NoSuchMethodException {
+            InvocationTargetException, SecurityException,
+            NoSuchMethodException {
         Method method = getAddListenerMethod(c.getClass(), listenerClass);
         method.invoke(c, listener1);
     }
 
     private Collection<?> getListeners(Object c, Class<?> eventType)
             throws IllegalArgumentException, IllegalAccessException,
-            InvocationTargetException, SecurityException, NoSuchMethodException {
+            InvocationTargetException, SecurityException,
+            NoSuchMethodException {
         Method method = getGetListenersMethod(c.getClass());
         return (Collection<?>) method.invoke(c, eventType);
     }
@@ -146,13 +154,15 @@ public abstract class AbstractListenerMethodsTestBase {
 
     private Method getAddListenerMethod(Class<?> cls, Class<?> listenerClass)
             throws SecurityException, NoSuchMethodException {
-        return cls.getMethod("addListener", listenerClass);
+        return cls.getMethod("add" + listenerClass.getSimpleName(),
+                listenerClass);
 
     }
 
     private Method getRemoveListenerMethod(Class<?> cls, Class<?> listenerClass)
             throws SecurityException, NoSuchMethodException {
-        return cls.getMethod("removeListener", listenerClass);
+        return cls.getMethod("remove" + listenerClass.getSimpleName(),
+                listenerClass);
 
     }
 
index cc06a2466ecb93dddd308257265418471cdaaab9..03fb91679b6b51ea5dae59b12fbcb5148c5169ba 100644 (file)
@@ -1,7 +1,6 @@
 package com.vaadin.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;
@@ -12,15 +11,14 @@ import org.junit.Test;
 import com.vaadin.data.util.MethodProperty;
 import com.vaadin.data.util.ObjectProperty;
 import com.vaadin.legacy.data.util.converter.LegacyConverter;
-import com.vaadin.legacy.data.util.converter.LegacyStringToIntegerConverter;
 import com.vaadin.legacy.data.util.converter.LegacyConverter.ConversionException;
+import com.vaadin.legacy.data.util.converter.LegacyStringToIntegerConverter;
 import com.vaadin.server.VaadinSession;
 import com.vaadin.tests.data.bean.Address;
 import com.vaadin.tests.data.bean.Country;
 import com.vaadin.tests.data.bean.Person;
 import com.vaadin.tests.data.bean.Sex;
 import com.vaadin.tests.util.AlwaysLockedVaadinSession;
-import com.vaadin.ui.CheckBox;
 import com.vaadin.ui.TextField;
 
 public class AbsFieldValueConversionsTest {
@@ -155,65 +153,6 @@ public class AbsFieldValueConversionsTest {
                 tf.getValue());
     }
 
-    @Test
-    public void testBooleanNullConversion() {
-        CheckBox cb = new CheckBox();
-        cb.setConverter(new LegacyConverter<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;
diff --git a/server/src/test/java/com/vaadin/tests/server/component/abstractfield/AbstractFieldListenersTest.java b/server/src/test/java/com/vaadin/tests/server/component/abstractfield/AbstractFieldListenersTest.java
deleted file mode 100644 (file)
index d23d63e..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-package com.vaadin.tests.server.component.abstractfield;
-
-import org.junit.Test;
-
-import com.vaadin.data.Property.ReadOnlyStatusChangeEvent;
-import com.vaadin.data.Property.ReadOnlyStatusChangeListener;
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
-import com.vaadin.tests.server.component.AbstractListenerMethodsTestBase;
-import com.vaadin.ui.CheckBox;
-
-public class AbstractFieldListenersTest extends AbstractListenerMethodsTestBase {
-
-    @Test
-    public void testReadOnlyStatusChangeListenerAddGetRemove() throws Exception {
-        testListenerAddGetRemove(CheckBox.class,
-                ReadOnlyStatusChangeEvent.class,
-                ReadOnlyStatusChangeListener.class);
-    }
-
-    @Test
-    public void testValueChangeListenerAddGetRemove() throws Exception {
-        testListenerAddGetRemove(CheckBox.class, ValueChangeEvent.class,
-                ValueChangeListener.class);
-    }
-}
diff --git a/server/src/test/java/com/vaadin/tests/server/component/abstractfield/LegacyAbstractFieldListenersTest.java b/server/src/test/java/com/vaadin/tests/server/component/abstractfield/LegacyAbstractFieldListenersTest.java
new file mode 100644 (file)
index 0000000..e341a4c
--- /dev/null
@@ -0,0 +1,26 @@
+package com.vaadin.tests.server.component.abstractfield;
+
+import org.junit.Test;
+
+import com.vaadin.data.Property.ReadOnlyStatusChangeEvent;
+import com.vaadin.data.Property.ReadOnlyStatusChangeListener;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.tests.server.component.AbstractListenerMethodsTestBase;
+import com.vaadin.ui.Table;
+
+public class LegacyAbstractFieldListenersTest extends AbstractListenerMethodsTestBase {
+
+    @Test
+    public void testReadOnlyStatusChangeListenerAddGetRemove() throws Exception {
+        testListenerAddGetRemove(Table.class,
+                ReadOnlyStatusChangeEvent.class,
+                ReadOnlyStatusChangeListener.class);
+    }
+
+    @Test
+    public void testValueChangeListenerAddGetRemove() throws Exception {
+        testListenerAddGetRemove(Table.class, ValueChangeEvent.class,
+                ValueChangeListener.class);
+    }
+}
index 7d699998de7ee92d38baaa970263f33b06e53ee0..59e2423c89d9cd1def9a078e0b6006939baaed45 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * Copyright 2000-2014 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
@@ -18,31 +18,20 @@ package com.vaadin.ui;
 import org.junit.Assert;
 import org.junit.Test;
 
-import com.vaadin.data.util.ObjectProperty;
-
 public class CheckBoxTest {
     @Test
-    public void initiallyEmpty() {
-        CheckBox tf = new CheckBox();
-        Assert.assertTrue(tf.isEmpty());
-    }
-
-    @Test
-    public void emptyAfterClearUsingPDS() {
-        CheckBox tf = new CheckBox();
-        tf.setPropertyDataSource(new ObjectProperty<Boolean>(Boolean.TRUE));
-        Assert.assertFalse(tf.isEmpty());
-        tf.clear();
-        Assert.assertTrue(tf.isEmpty());
+    public void initiallyFalse() {
+        CheckBox cb = new CheckBox();
+        Assert.assertFalse(cb.getValue());
     }
 
     @Test
-    public void emptyAfterClear() {
-        CheckBox tf = new CheckBox();
-        tf.setValue(true);
-        Assert.assertFalse(tf.isEmpty());
-        tf.clear();
-        Assert.assertTrue(tf.isEmpty());
+    public void testSetValue() {
+        CheckBox cb = new CheckBox();
+        cb.setValue(true);
+        Assert.assertTrue(cb.getValue());
+        cb.setValue(false);
+        Assert.assertFalse(cb.getValue());
     }
 
 }
index 1963dfbf12549581fb4c38f755884c37aa829d86..af2cceedecca83fcf1958d69fdc714b94c590f78 100644 (file)
@@ -1,12 +1,12 @@
-/* 
+/*
  * Copyright 2000-2014 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
@@ -16,7 +16,6 @@
 
 package com.vaadin.tests;
 
-import com.vaadin.data.Property;
 import com.vaadin.data.Property.ValueChangeEvent;
 import com.vaadin.data.Property.ValueChangeListener;
 import com.vaadin.shared.ui.label.ContentMode;
@@ -28,7 +27,7 @@ import com.vaadin.ui.RichTextArea;
 import com.vaadin.ui.VerticalLayout;
 
 /**
- * 
+ *
  * @author Vaadin Ltd.
  */
 public class TestForRichTextEditor extends CustomComponent implements
@@ -63,13 +62,7 @@ public class TestForRichTextEditor extends CustomComponent implements
 
         CheckBox b = new CheckBox("enabled");
         b.setImmediate(true);
-        b.addListener(new Property.ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                rte.setEnabled(!rte.isEnabled());
-            }
-        });
+        b.addValueChangeListener(event -> rte.setEnabled(!rte.isEnabled()));
         main.addComponent(b);
 
     }
index 080d36fa485dcaaba4f9147d256f4dc37dd7f839..9d598dab0f687958b373a9499f3ef7fed9ab466e 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * Copyright 2000-2014 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
@@ -34,7 +34,7 @@ import com.vaadin.ui.TextField;
 import com.vaadin.ui.VerticalLayout;
 
 /**
- * 
+ *
  * @since
  * @author Vaadin Ltd
  */
@@ -208,13 +208,9 @@ public class CommErrorEmulatorUI extends AbstractTestUIWithLog {
                 "Reconnect dialog modality");
         reconnectDialogModal.setValue(getReconnectDialogConfiguration()
                 .isDialogModal());
-        reconnectDialogModal.addValueChangeListener(new ValueChangeListener() {
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                getReconnectDialogConfiguration().setDialogModal(
-                        reconnectDialogModal.getValue());
-            }
-        });
+        reconnectDialogModal.addValueChangeListener(
+                event -> getReconnectDialogConfiguration()
+                        .setDialogModal(reconnectDialogModal.getValue()));
 
         VerticalLayout vl = new VerticalLayout();
         vl.setMargin(true);
index 6c051c64200c931c54bb175c717a61f5eb22c53f..323705f466812bdbfc0b9f07234080df3d50852c 100644 (file)
@@ -7,7 +7,6 @@ import java.util.List;
 import com.vaadin.data.Item;
 import com.vaadin.data.Property;
 import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
 import com.vaadin.legacy.ui.LegacyField;
 import com.vaadin.ui.AbstractComponent;
 import com.vaadin.ui.Alignment;
@@ -51,7 +50,7 @@ public abstract class ComponentTestCase<T extends AbstractComponent> extends
 
     /**
      * Override to provide custom actions for the test case.
-     * 
+     *
      * @param actions
      *            Array with default actions. Add custom actions to this. Never
      *            null.
@@ -64,7 +63,7 @@ public abstract class ComponentTestCase<T extends AbstractComponent> extends
      * Method that creates the "actions" shown in the upper part of the screen.
      * Override this only if you do not want the default actions. Custom actions
      * can be added through #createCustomActions();
-     * 
+     *
      * @return A List with actions to which more actions can be added.
      */
     protected List<Component> createActions() {
@@ -112,14 +111,8 @@ public abstract class ComponentTestCase<T extends AbstractComponent> extends
             boolean initialState, final Command<T, Boolean> command) {
 
         CheckBox checkBox = new CheckBox(caption);
-        checkBox.addListener(new ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                boolean enabled = (Boolean) event.getProperty().getValue();
-                doCommand(command, enabled);
-            }
-        });
+        checkBox.addValueChangeListener(
+                event -> doCommand(command, event.getValue()));
 
         checkBox.setValue(initialState);
         checkBox.setImmediate(true);
index b299490d034bb77aec4f5ac228dd473926bb3f9c..eb84f689a59b99438a3ecece0a94ed88f06ae22c 100644 (file)
@@ -1,7 +1,5 @@
 package com.vaadin.tests.components.abstractcomponent;
 
-import com.vaadin.data.Property;
-import com.vaadin.data.Property.ValueChangeEvent;
 import com.vaadin.tests.components.AbstractTestCase;
 import com.vaadin.ui.Button;
 import com.vaadin.ui.CheckBox;
@@ -21,48 +19,23 @@ public class EnableState extends AbstractTestCase {
         panelLayout.addComponent(button);
 
         CheckBox enable = new CheckBox("Toggle button enabled", true);
-        enable.addListener(new Property.ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                boolean enabled = (Boolean) event.getProperty().getValue();
-                button.setEnabled(enabled);
-                // button.requestRepaint();
-            }
+        enable.addValueChangeListener(event -> {
+            boolean enabled = event.getValue();
+            button.setEnabled(enabled);
+            // button.requestRepaint();
         });
         enable.setImmediate(true);
 
         CheckBox caption = new CheckBox("Toggle button caption", true);
-        caption.addListener(new Property.ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                button.setCaption(button.getCaption() + "+");
-            }
-        });
+        caption.addValueChangeListener(event -> button.setCaption(button.getCaption() + "+"));
         caption.setImmediate(true);
 
         CheckBox visible = new CheckBox("Toggle panel visibility", true);
-        visible.addListener(new Property.ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                boolean visible = (Boolean) event.getProperty().getValue();
-
-                panel.setVisible(visible);
-            }
-        });
+        visible.addValueChangeListener(event -> panel.setVisible(event.getValue()));
         visible.setImmediate(true);
 
         CheckBox panelEnable = new CheckBox("Toggle panel enabled", true);
-        panelEnable.addListener(new Property.ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                boolean enabled = (Boolean) event.getProperty().getValue();
-                panel.setEnabled(enabled);
-            }
-        });
+        panelEnable.addValueChangeListener(event -> panel.setEnabled(event.getValue()));
         panelEnable.setImmediate(true);
 
         mainWindow.addComponent(enable);
index 01c7ab83ae7762cbb30bc29247fa5ef488c361e1..52d1ed5f565a9373f75a3c5e702a2c73815fb8f4 100644 (file)
@@ -1,7 +1,6 @@
 package com.vaadin.tests.components.abstractcomponent;
 
-import com.vaadin.data.Property;
-import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.HasValue;
 import com.vaadin.tests.components.TestBase;
 import com.vaadin.ui.CheckBox;
 import com.vaadin.ui.HorizontalLayout;
@@ -30,14 +29,14 @@ public class TooltipTests extends TestBase {
         HorizontalLayout topLayout = new HorizontalLayout();
         addComponent(topLayout);
         CheckBox panelCbox = new CheckBox("Panel");
-        panelCbox.addListener(panelListener);
+        panelCbox.addValueChangeListener(panelListener);
         topLayout.addComponent(panelCbox);
         CheckBox layoutCbox = new CheckBox("Layout");
-        layoutCbox.addListener(layoutListener);
+        layoutCbox.addValueChangeListener(layoutListener);
         topLayout.addComponent(layoutCbox);
         CheckBox labelCbox = new CheckBox("Label");
         topLayout.addComponent(labelCbox);
-        labelCbox.addListener(labelListener);
+        labelCbox.addValueChangeListener(labelListener);
 
         panel = new Panel();
         panel.setCaption("Panel caption");
@@ -55,46 +54,28 @@ public class TooltipTests extends TestBase {
         layout.addComponent(label);
     }
 
-    private final Property.ValueChangeListener panelListener = new Property.ValueChangeListener() {
-
-        @Override
-        public void valueChange(ValueChangeEvent event) {
-            boolean value = (Boolean) (event.getProperty().getValue());
-            if (value) {
-                panel.setDescription("I'm panel!");
-            } else {
-                panel.setDescription("");
-            }
+    private final HasValue.ValueChangeListener<Boolean> panelListener = event -> {
+        if (event.getValue()) {
+            panel.setDescription("I'm panel!");
+        } else {
+            panel.setDescription("");
         }
-
     };
 
-    private final Property.ValueChangeListener layoutListener = new Property.ValueChangeListener() {
-
-        @Override
-        public void valueChange(ValueChangeEvent event) {
-            boolean value = (Boolean) (event.getProperty().getValue());
-            if (value) {
-                layout.setDescription("I'm layout!");
-            } else {
-                layout.setDescription("");
-            }
+    private final HasValue.ValueChangeListener<Boolean> layoutListener = event -> {
+        if (event.getValue()) {
+            layout.setDescription("I'm layout!");
+        } else {
+            layout.setDescription("");
         }
-
     };
 
-    private final Property.ValueChangeListener labelListener = new Property.ValueChangeListener() {
-
-        @Override
-        public void valueChange(ValueChangeEvent event) {
-            boolean value = (Boolean) (event.getProperty().getValue());
-            if (value) {
-                label.setDescription("I'm label!");
-            } else {
-                label.setDescription("");
-            }
+    private final HasValue.ValueChangeListener<Boolean> labelListener = event -> {
+        if (event.getValue()) {
+            label.setDescription("I'm label!");
+        } else {
+            label.setDescription("");
         }
-
     };
 
 }
index a669e70739c425e6425889f6c088efd332483b5f..255ce612791cb85c436ecbc9e2466df72f31d1f4 100644 (file)
@@ -3,8 +3,6 @@ package com.vaadin.tests.components.abstractfield;
 import java.util.HashSet;
 import java.util.Set;
 
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
 import com.vaadin.legacy.ui.LegacyField;
 import com.vaadin.server.VaadinRequest;
 import com.vaadin.tests.components.AbstractTestUI;
@@ -27,14 +25,10 @@ public class RequiredIndicatorForFieldsWithoutCaption extends AbstractTestUI {
 
         CheckBox required = new CheckBox("Fields required", true);
         required.setImmediate(true);
-        required.addValueChangeListener(new ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                boolean required = (Boolean) event.getProperty().getValue();
-                for (LegacyField f : fields) {
-                    f.setRequired(required);
-                }
+        required.addValueChangeListener(event -> {
+            boolean newRequired = event.getValue();
+            for (LegacyField f : fields) {
+                f.setRequired(newRequired);
             }
         });
         addComponent(required);
@@ -72,7 +66,7 @@ public class RequiredIndicatorForFieldsWithoutCaption extends AbstractTestUI {
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription()
      */
     @Override
@@ -82,7 +76,7 @@ public class RequiredIndicatorForFieldsWithoutCaption extends AbstractTestUI {
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber()
      */
     @Override
index dd89d1b9a7c73dce72fe7aa0b6fd6d5b1b026ed1..3e8f03495031343bbb98d62c5f9d8903343f6005 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * Copyright 2000-2014 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
  */
 
 /**
- * 
+ *
  */
 package com.vaadin.tests.components.button;
 
-import com.vaadin.data.Property;
-import com.vaadin.data.Property.ValueChangeEvent;
 import com.vaadin.server.ThemeResource;
 import com.vaadin.server.VaadinRequest;
 import com.vaadin.tests.components.AbstractTestUI;
@@ -28,7 +26,7 @@ import com.vaadin.ui.Button;
 import com.vaadin.ui.CheckBox;
 
 /**
- * 
+ *
  * @since
  * @author Vaadin Ltd
  */
@@ -39,7 +37,7 @@ public class ButtonUpdateAltText extends AbstractTestUI {
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server.
      * VaadinRequest)
      */
@@ -52,15 +50,11 @@ public class ButtonUpdateAltText extends AbstractTestUI {
 
         final CheckBox enable = new CheckBox("Enable alt text", true);
         enable.setImmediate(true);
-        enable.addValueChangeListener(new Property.ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                if (enable.booleanValue()) {
-                    btn.setIconAlternateText("alt text");
-                } else {
-                    btn.setIconAlternateText("");
-                }
+        enable.addValueChangeListener(event -> {
+            if (event.getValue()) {
+                btn.setIconAlternateText("alt text");
+            } else {
+                btn.setIconAlternateText("");
             }
         });
         addComponent(enable);
@@ -68,7 +62,7 @@ public class ButtonUpdateAltText extends AbstractTestUI {
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription()
      */
     @Override
@@ -78,7 +72,7 @@ public class ButtonUpdateAltText extends AbstractTestUI {
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber()
      */
     @Override
index 15cde71838a8cbed81742ac55e5f3f2035a1dab4..8d0950cc61af79ef63850a7cb7c0cb90a119248b 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * Copyright 2000-2014 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
@@ -21,7 +21,6 @@ import java.util.List;
 
 import com.vaadin.data.Property.ValueChangeEvent;
 import com.vaadin.data.Property.ValueChangeListener;
-import com.vaadin.data.util.MethodProperty;
 import com.vaadin.server.VaadinRequest;
 import com.vaadin.tests.components.AbstractTestUIWithLog;
 import com.vaadin.ui.Alignment;
@@ -57,14 +56,13 @@ public class CalendarHtmlInEvents extends AbstractTestUIWithLog {
             }
         });
         ns.setValue("Month");
-        final CheckBox allowHtml = new CheckBox("Allow HTML in event caption",
-                new MethodProperty<Boolean>(calendar, "eventCaptionAsHtml"));
-        allowHtml.addValueChangeListener(new ValueChangeListener() {
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                log("HTML in event caption: " + allowHtml.getValue());
-            }
-        });
+        final CheckBox allowHtml = new CheckBox("Allow HTML in event caption");
+        allowHtml.setValue(calendar.isEventCaptionAsHtml());
+        allowHtml.addValueChangeListener(
+                event -> {
+                    calendar.setEventCaptionAsHtml(event.getValue());
+                    log("HTML in event caption: " + event.getValue());
+                });
         HorizontalLayout hl = new HorizontalLayout();
         hl.setDefaultComponentAlignment(Alignment.BOTTOM_LEFT);
         hl.addComponents(ns, allowHtml);
index b56f92962a28ab7ba56096a4193f12a4e5f8acbf..6b79a444370e9a3ebebb651939b51e8e1843d122 100644 (file)
@@ -23,8 +23,8 @@ import java.util.Map;
 import java.util.TimeZone;
 
 import com.vaadin.annotations.Theme;
+import com.vaadin.data.Binder;
 import com.vaadin.data.Item;
-import com.vaadin.data.Property;
 import com.vaadin.data.Property.ValueChangeEvent;
 import com.vaadin.data.Property.ValueChangeListener;
 import com.vaadin.data.fieldgroup.FieldGroup;
@@ -116,6 +116,7 @@ public class CalendarTest extends UI {
 
     private final FormLayout scheduleEventFieldLayout = new FormLayout();
     private FieldGroup scheduleEventFieldGroup = new FieldGroup();
+    private Binder<CalendarEvent> scheduledEventBinder = new Binder<>();
 
     private Button deleteEventButton;
 
@@ -435,16 +436,8 @@ public class CalendarTest extends UI {
     private void initHideWeekEndButton() {
         hideWeekendsButton = new CheckBox("Hide weekends");
         hideWeekendsButton.setImmediate(true);
-        hideWeekendsButton
-                .addValueChangeListener(new Property.ValueChangeListener() {
-
-                    private static final long serialVersionUID = 1L;
-
-                    @Override
-                    public void valueChange(ValueChangeEvent event) {
-                        setWeekendsHidden(hideWeekendsButton.getValue());
-                    }
-                });
+        hideWeekendsButton.addValueChangeListener(
+                event -> setWeekendsHidden(hideWeekendsButton.getValue()));
     }
 
     private void setWeekendsHidden(boolean weekendsHidden) {
@@ -463,31 +456,15 @@ public class CalendarTest extends UI {
     private void initReadOnlyButton() {
         readOnlyButton = new CheckBox("Read-only mode");
         readOnlyButton.setImmediate(true);
-        readOnlyButton
-                .addValueChangeListener(new Property.ValueChangeListener() {
-
-                    private static final long serialVersionUID = 1L;
-
-                    @Override
-                    public void valueChange(ValueChangeEvent event) {
-                        calendarComponent.setReadOnly(readOnlyButton.getValue());
-                    }
-                });
+        readOnlyButton.addValueChangeListener(event -> calendarComponent
+                .setReadOnly(readOnlyButton.getValue()));
     }
 
     private void initDisabledButton() {
         disabledButton = new CheckBox("Disabled");
         disabledButton.setImmediate(true);
-        disabledButton
-                .addValueChangeListener(new Property.ValueChangeListener() {
-
-                    private static final long serialVersionUID = 1L;
-
-                    @Override
-                    public void valueChange(ValueChangeEvent event) {
-                        calendarComponent.setEnabled(!disabledButton.getValue());
-                    }
-                });
+        disabledButton.addValueChangeListener(event -> calendarComponent
+                .setEnabled(!disabledButton.getValue()));
     }
 
     public void initAddNewEventButton() {
@@ -517,21 +494,12 @@ public class CalendarTest extends UI {
         endDateField = createDateField("End date");
 
         final CheckBox allDayField = createCheckBox("All-day");
-        allDayField.addValueChangeListener(new Property.ValueChangeListener() {
-
-            private static final long serialVersionUID = -7104996493482558021L;
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                Object value = event.getProperty().getValue();
-                if (value instanceof Boolean && Boolean.TRUE.equals(value)) {
-                    setFormDateResolution(Resolution.DAY);
-
-                } else {
-                    setFormDateResolution(Resolution.MINUTE);
-                }
+        allDayField.addValueChangeListener(event -> {
+            if (event.getValue()) {
+                setFormDateResolution(Resolution.DAY);
+            } else {
+                setFormDateResolution(Resolution.MINUTE);
             }
-
         });
 
         captionField = createTextField("Caption");
@@ -559,7 +527,7 @@ public class CalendarTest extends UI {
             scheduleEventFieldGroup.bind(whereField, "where");
         }
         scheduleEventFieldGroup.bind(styleNameField, "styleName");
-        scheduleEventFieldGroup.bind(allDayField, "allDay");
+        scheduledEventBinder.bind(allDayField, CalendarEvent::isAllDay, null);
     }
 
     private CheckBox createCheckBox(String caption) {
@@ -1064,6 +1032,7 @@ public class CalendarTest extends UI {
         initFormFields(scheduleEventFieldLayout, event.getClass());
         scheduleEventFieldGroup.setBuffered(true);
         scheduleEventFieldGroup.setItemDataSource(item);
+        scheduledEventBinder.load(event);
     }
 
     private void setFormDateResolution(Resolution resolution) {
@@ -1096,6 +1065,7 @@ public class CalendarTest extends UI {
     private void commitCalendarEvent() throws CommitException {
         scheduleEventFieldGroup.commit();
         BasicEvent event = getFormCalendarEvent();
+        scheduledEventBinder.save(event);
         if (event.getEnd() == null) {
             event.setEnd(event.getStart());
         }
@@ -1108,6 +1078,7 @@ public class CalendarTest extends UI {
 
     private void discardCalendarEvent() {
         scheduleEventFieldGroup.discard();
+        scheduledEventBinder.load(getFormCalendarEvent());
         removeWindow(scheduleEventPopup);
     }
 
index fec753d5afdfe64b6831f2e28613d83cb7304da7..8039fcb5cce4a668adf87c80c2619e67e920adfc 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * Copyright 2000-2014 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
@@ -15,8 +15,7 @@
  */
 package com.vaadin.tests.components.checkbox;
 
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.data.HasValue;
 import com.vaadin.server.VaadinRequest;
 import com.vaadin.tests.components.AbstractTestUI;
 import com.vaadin.ui.CheckBox;
@@ -32,12 +31,9 @@ public class CheckBoxImmediate extends AbstractTestUI {
         addComponent(status);
 
         CheckBox cb = new CheckBox("Non-immediate");
-        ValueChangeListener listener = new ValueChangeListener() {
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                count++;
-                status.setValue("Events received: " + count);
-            }
+        HasValue.ValueChangeListener<Boolean> listener = event -> {
+            count++;
+            status.setValue("Events received: " + count);
         };
         cb.addValueChangeListener(listener);
         cb.setImmediate(false);
diff --git a/uitest/src/main/java/com/vaadin/tests/components/checkbox/CheckBoxNullValue.java b/uitest/src/main/java/com/vaadin/tests/components/checkbox/CheckBoxNullValue.java
deleted file mode 100644 (file)
index 6ee9bf9..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-package com.vaadin.tests.components.checkbox;
-
-import com.vaadin.legacy.data.Validator.InvalidValueException;
-import com.vaadin.server.AbstractErrorMessage;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.CheckBox;
-import com.vaadin.ui.Label;
-
-public class CheckBoxNullValue extends TestBase {
-
-    @Override
-    protected void setup() {
-        // workaround for #6919
-        getLayout().setWidth("100%");
-
-        final CheckBox checkbox = new CheckBox("A checkbox");
-        checkbox.setValue(null);
-        addComponent(checkbox);
-
-        final CheckBox requiredCheckbox = new CheckBox("A required checkbox");
-        requiredCheckbox.setRequired(true);
-        requiredCheckbox.setValue(null);
-        addComponent(requiredCheckbox);
-
-        final Label valueLabel = new Label("");
-
-        final Button button = new Button("Validate");
-        addComponent(button);
-        button.addListener(new Button.ClickListener() {
-            @Override
-            public void buttonClick(ClickEvent event) {
-                checkbox.setComponentError(null);
-                requiredCheckbox.setComponentError(null);
-                try {
-                    checkbox.validate();
-                } catch (InvalidValueException e) {
-                    checkbox.setComponentError(AbstractErrorMessage
-                            .getErrorMessageForException(e));
-                }
-                try {
-                    requiredCheckbox.validate();
-                } catch (InvalidValueException e) {
-                    requiredCheckbox.setComponentError(AbstractErrorMessage
-                            .getErrorMessageForException(e));
-                }
-                valueLabel.setValue("Checkbox: " + checkbox.getValue()
-                        + "; Required checkbox: " + requiredCheckbox.getValue());
-            }
-        });
-        addComponent(valueLabel);
-    }
-
-    @Override
-    protected String getDescription() {
-        return "CheckBox should support null values.";
-    }
-
-    @Override
-    protected Integer getTicketNumber() {
-        return 6918;
-    }
-
-}
index 0513c9db4fcffc716ad886d04da2f7eed7a4fdfd..0870bf1c03174c2adb9b5b663280793cfbdd8fac 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * Copyright 2000-2014 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
@@ -16,7 +16,6 @@
 package com.vaadin.tests.components.checkbox;
 
 import com.vaadin.annotations.PreserveOnRefresh;
-import com.vaadin.data.Property;
 import com.vaadin.server.VaadinRequest;
 import com.vaadin.tests.components.AbstractTestUIWithLog;
 import com.vaadin.ui.CheckBox;
@@ -27,28 +26,20 @@ public class CheckBoxRevertValueChange extends AbstractTestUIWithLog {
     @Override
     protected void setup(VaadinRequest request) {
         final CheckBox alwaysUnchecked = new CheckBox("You may not check me");
-        alwaysUnchecked
-                .addValueChangeListener(new Property.ValueChangeListener() {
-                    @Override
-                    public void valueChange(Property.ValueChangeEvent event) {
-                        if (alwaysUnchecked.getValue()) {
-                            log("I said no checking!");
-                            alwaysUnchecked.setValue(false);
-                        }
-                    }
-                });
+        alwaysUnchecked.addValueChangeListener(event -> {
+            if (alwaysUnchecked.getValue()) {
+                log("I said no checking!");
+                alwaysUnchecked.setValue(false);
+            }
+        });
         final CheckBox alwaysChecked = new CheckBox("You may not uncheck me");
         alwaysChecked.setValue(true);
-        alwaysChecked
-                .addValueChangeListener(new Property.ValueChangeListener() {
-                    @Override
-                    public void valueChange(Property.ValueChangeEvent event) {
-                        if (!alwaysChecked.getValue()) {
-                            log("I said no unchecking!");
-                            alwaysChecked.setValue(true);
-                        }
-                    }
-                });
+        alwaysChecked.addValueChangeListener(event -> {
+            if (!alwaysChecked.getValue()) {
+                log("I said no unchecking!");
+                alwaysChecked.setValue(true);
+            }
+        });
 
         addComponent(alwaysUnchecked);
         addComponent(alwaysChecked);
index f909f97996ca54cca9130a9e4571bf766adcde96..e360e410996a2b0287ed5e52b0d45f46dd7dd492 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * Copyright 2000-2014 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
@@ -15,8 +15,6 @@
  */
 package com.vaadin.tests.components.checkbox;
 
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
 import com.vaadin.server.VaadinRequest;
 import com.vaadin.shared.MouseEventDetails;
 import com.vaadin.shared.ui.checkbox.CheckBoxServerRpc;
@@ -48,14 +46,6 @@ public class CheckBoxRpcCount extends AbstractTestUI {
                 });
             }
         };
-        cb.addValueChangeListener(new ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                // Adding an empty ValueChangeListener just to ensure that
-                // immediate mode is set to true
-            }
-        });
         addComponent(cb);
     }
 
index 8ef88114453c981ce935cb9719fcc29e053df451..14bea90206c3769e02c419b8433e95efde9cf1aa 100644 (file)
@@ -1,11 +1,11 @@
 package com.vaadin.tests.components.checkbox;
 
-import com.vaadin.tests.components.abstractfield.LegacyAbstractFieldTest;
+import com.vaadin.tests.components.abstractfield.AbstractFieldTest;
 import com.vaadin.ui.Button.ClickEvent;
 import com.vaadin.ui.Button.ClickListener;
 import com.vaadin.ui.CheckBox;
 
-public class CheckBoxes2 extends LegacyAbstractFieldTest<CheckBox> implements
+public class CheckBoxes2 extends AbstractFieldTest<CheckBox, Boolean> implements
         ClickListener {
 
     @Override
index 544cdafaf044a56754e191ca97dcd79c605afddd..daae6bc2e5ae753c0fc93b7e1b0a2da041bece56 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * Copyright 2000-2014 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,7 +26,6 @@ import java.util.Date;
 
 import javax.imageio.ImageIO;
 
-import com.vaadin.data.Property.ValueChangeEvent;
 import com.vaadin.server.StreamResource;
 import com.vaadin.server.VaadinRequest;
 import com.vaadin.shared.ui.colorpicker.Color;
@@ -104,7 +103,7 @@ public class ColorPickerTestUI extends AbstractTestUI implements
 
         /**
          * Instantiates a new my image source.
-         * 
+         *
          * @param fg
          *            the foreground
          * @param bg
@@ -226,60 +225,45 @@ public class ColorPickerTestUI extends AbstractTestUI implements
         optLayout.setSpacing(true);
 
         rgbBox.setValue(rgbVisible);
-        rgbBox.addValueChangeListener(new CheckBox.ValueChangeListener() {
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                rgbVisible = (Boolean) event.getProperty().getValue();
-                setPopupVisibilities();
-            }
+        rgbBox.addValueChangeListener(event -> {
+            rgbVisible = event.getValue();
+            setPopupVisibilities();
         });
         rgbBox.setImmediate(true);
         rgbBox.setId("rgbBox");
         optLayout.addComponent(rgbBox);
 
         hsvBox.setValue(hsvVisible);
-        hsvBox.addValueChangeListener(new CheckBox.ValueChangeListener() {
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                hsvVisible = (Boolean) event.getProperty().getValue();
-                setPopupVisibilities();
-            }
+        hsvBox.addValueChangeListener(event -> {
+            hsvVisible = event.getValue();
+            setPopupVisibilities();
         });
         hsvBox.setImmediate(true);
         hsvBox.setId("hsvBox");
         optLayout.addComponent(hsvBox);
 
         swaBox.setValue(swaVisible);
-        swaBox.addValueChangeListener(new CheckBox.ValueChangeListener() {
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                swaVisible = (Boolean) event.getProperty().getValue();
-                setPopupVisibilities();
-            }
+        swaBox.addValueChangeListener(event -> {
+            swaVisible = event.getValue();
+            setPopupVisibilities();
         });
         swaBox.setImmediate(true);
         swaBox.setId("swaBox");
         optLayout.addComponent(swaBox);
 
         hisBox.setValue(historyVisible);
-        hisBox.addValueChangeListener(new CheckBox.ValueChangeListener() {
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                historyVisible = (Boolean) event.getProperty().getValue();
-                setPopupVisibilities();
-            }
+        hisBox.addValueChangeListener(event -> {
+            historyVisible = event.getValue();
+            setPopupVisibilities();
         });
         hisBox.setImmediate(true);
         hisBox.setId("hisBox");
         optLayout.addComponent(hisBox);
 
         txtBox.setValue(txtfieldVisible);
-        txtBox.addValueChangeListener(new CheckBox.ValueChangeListener() {
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                txtfieldVisible = (Boolean) event.getProperty().getValue();
-                setPopupVisibilities();
-            }
+        txtBox.addValueChangeListener(event -> {
+            txtfieldVisible = event.getValue();
+            setPopupVisibilities();
         });
         txtBox.setImmediate(true);
         txtBox.setId("txtBox");
@@ -444,7 +428,7 @@ public class ColorPickerTestUI extends AbstractTestUI implements
     // This is called whenever a colorpicker popup is closed
     /**
      * Update display.
-     * 
+     *
      * @param fg
      *            the fg
      * @param bg
index 6b0e42666f056742d06a10ab33adc26e510e1f2e..7c014570a1b67b4bd68208dc0bcec76db27ce68d 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * Copyright 2000-2014 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
@@ -15,8 +15,6 @@
  */
 package com.vaadin.tests.components.combobox;
 
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
 import com.vaadin.server.VaadinRequest;
 import com.vaadin.ui.CheckBox;
 
@@ -29,12 +27,8 @@ public class ComboBoxNoTextInput extends ComboBoxSelecting {
 
         final CheckBox textInputCheckBox = new CheckBox("Text Input", true);
         textInputCheckBox.setId("textInput");
-        textInputCheckBox.addValueChangeListener(new ValueChangeListener() {
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                comboBox.setTextInputAllowed(textInputCheckBox.getValue());
-            }
-        });
+        textInputCheckBox.addValueChangeListener(event -> comboBox
+                .setTextInputAllowed(textInputCheckBox.getValue()));
         addComponent(textInputCheckBox);
     }
 
index 654f42e233a4e650517abae1304e3289b3c6668a..1b1e256ead06d666249e49938963fbf2cf8f2128 100644 (file)
@@ -1,6 +1,5 @@
 package com.vaadin.tests.components.combobox;
 
-import com.vaadin.data.util.MethodProperty;
 import com.vaadin.tests.components.TestBase;
 import com.vaadin.ui.CheckBox;
 import com.vaadin.ui.ComboBox;
@@ -28,8 +27,10 @@ public class WidthToggleReadOnly extends TestBase {
     }
 
     private CheckBox createReadOnlyForComboBox(ComboBox combo) {
-        CheckBox readonly = new CheckBox("Second combobox is read only",
-                new MethodProperty(combo, "readOnly"));
+        CheckBox readonly = new CheckBox("Second combobox is read only");
+        readonly.setValue(combo.isReadOnly());
+        readonly.addValueChangeListener(
+                event -> combo.setReadOnly(event.getValue()));
         readonly.setImmediate(true);
         addComponent(readonly);
         return readonly;
index 0e8ccd937fc631b1f6c4bca7a6750a8ace01383b..c4008fdb3a21fc9d30eadee79aab85fa6572cf8b 100644 (file)
@@ -3,12 +3,12 @@ package com.vaadin.tests.components.datefield;
 import java.util.Date;
 import java.util.Locale;
 
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.data.HasValue;
 import com.vaadin.data.util.BeanItem;
 import com.vaadin.legacy.data.validator.LegacyRangeValidator;
 import com.vaadin.shared.ui.datefield.Resolution;
 import com.vaadin.tests.components.TestBase;
+import com.vaadin.tests.util.CheckBoxWithPropertyDataSource;
 import com.vaadin.ui.CheckBox;
 import com.vaadin.ui.PopupDateField;
 
@@ -54,15 +54,9 @@ public class DateFieldRangeValidation extends TestBase {
     }
 
     private Range range = new Range();
-    private ValueChangeListener refreshField = new ValueChangeListener() {
-
-        @Override
-        public void valueChange(ValueChangeEvent event) {
-            actualDateField.markAsDirty();
-        }
-    };
 
     private PopupDateField actualDateField;
+    private HasValue.ValueChangeListener<Boolean> refreshField = event -> actualDateField.markAsDirty();
 
     @Override
     protected void setup() {
@@ -72,14 +66,14 @@ public class DateFieldRangeValidation extends TestBase {
 
         PopupDateField fromField = createDateField();
         fromField.setPropertyDataSource(bi.getItemProperty("from"));
-        CheckBox fromInclusive = new CheckBox("From inclusive",
-                bi.getItemProperty("fromInclusive"));
-        CheckBox toInclusive = new CheckBox("To inclusive",
-                bi.getItemProperty("toInclusive"));
+        CheckBox fromInclusive = new CheckBoxWithPropertyDataSource(
+                "From inclusive", bi.getItemProperty("fromInclusive"));
+        CheckBox toInclusive = new CheckBoxWithPropertyDataSource(
+                "To inclusive", bi.getItemProperty("toInclusive"));
         fromInclusive.setImmediate(true);
-        fromInclusive.addListener(refreshField);
+        fromInclusive.addValueChangeListener(refreshField);
         toInclusive.setImmediate(true);
-        toInclusive.addListener(refreshField);
+        toInclusive.addValueChangeListener(refreshField);
 
         PopupDateField toField = createDateField();
         toField.setPropertyDataSource(bi.getItemProperty("to"));
index 2daa3e3f968c2439555532b9e6ad784f7cf03276..3e52dfa516f6253345981a8bc08618cd49f4566d 100644 (file)
@@ -114,15 +114,9 @@ public class DateFieldRanges extends AbstractTestUI {
 
         immediateCB.setValue(true);
         immediateCB.setImmediate(true);
-        immediateCB.addValueChangeListener(new ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-
-                inlineDynamicDateField.setImmediate(immediateCB.getValue());
-                dynamicDateField.setImmediate(immediateCB.getValue());
-
-            }
+        immediateCB.addValueChangeListener(event -> {
+            inlineDynamicDateField.setImmediate(immediateCB.getValue());
+            dynamicDateField.setImmediate(immediateCB.getValue());
         });
 
         recreate.addClickListener(new Button.ClickListener() {
index 2c5e9e251b4415e317ae67298e4fa4375c2ecfe6..7ff59ecf1ca496edc3be5cc2cbd94ee934a80bd3 100644 (file)
@@ -2,8 +2,6 @@ package com.vaadin.tests.components.datefield;
 
 import java.util.Date;
 
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
 import com.vaadin.server.VaadinRequest;
 import com.vaadin.tests.components.AbstractTestUI;
 import com.vaadin.ui.CheckBox;
@@ -39,18 +37,14 @@ public class DateFieldWhenChangingValueAndEnablingParent extends AbstractTestUI
         main.addComponent(chk);
         main.addComponent(sub);
 
-        chk.addValueChangeListener(new ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                df1.setValue(new Date());
-                df2.setValue(new Date());
-                pdf1.setValue(new Date());
-                pdf2.setValue(new Date());
-                pdf3.setValue(new Date());
-                pdf4.setValue(new Date());
-                sub.setEnabled(chk.getValue());
-            }
+        chk.addValueChangeListener(event -> {
+            df1.setValue(new Date());
+            df2.setValue(new Date());
+            pdf1.setValue(new Date());
+            pdf2.setValue(new Date());
+            pdf3.setValue(new Date());
+            pdf4.setValue(new Date());
+            sub.setEnabled(chk.getValue());
         });
     }
 
index 9c2d3d7d512883712a1d3c5d6f48b06a752dec57..17b916ba5663408a9f8cc5a0328aa7b24ef7b9c8 100644 (file)
@@ -54,14 +54,11 @@ public class LowResolution extends TestBase {
         CheckBox immediate = new CheckBox(
                 "Immediate (use sync button to change fields) ");
         immediate.setValue(true);
-        immediate.addListener(new CheckBox.ValueChangeListener() {
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                boolean immediate = !dateField.isImmediate();
-                dateField.setImmediate(immediate);
-                dateField2.setImmediate(immediate);
-                dateField3.setImmediate(immediate);
-            }
+        immediate.addListener(event -> {
+            boolean newImmediate = !dateField.isImmediate();
+            dateField.setImmediate(newImmediate);
+            dateField2.setImmediate(newImmediate);
+            dateField3.setImmediate(newImmediate);
         });
 
         getLayout().addComponent(immediate);
index 130ed8f3c57f8db854af7633b42dc4a2f5216b8d..e1470797bc15a6d1d93612dde33b2eb3b4e2360d 100644 (file)
@@ -1,6 +1,5 @@
 package com.vaadin.tests.components.datefield;
 
-import com.vaadin.data.Property;
 import com.vaadin.tests.components.TestBase;
 import com.vaadin.ui.CheckBox;
 import com.vaadin.ui.PopupDateField;
@@ -14,17 +13,12 @@ public class PopupDateFieldTextEnabled extends TestBase {
     public void setup() {
         final PopupDateField field = new PopupDateField();
         final CheckBox box = new CheckBox(ENABLED, true);
-        box.addListener(new Property.ValueChangeListener() {
-
-            @Override
-            public void valueChange(Property.ValueChangeEvent event) {
-                field.setTextFieldEnabled((Boolean) event.getProperty()
-                        .getValue());
-                if (field.isTextFieldEnabled()) {
-                    box.setCaption(ENABLED);
-                } else {
-                    box.setCaption(DISABLED);
-                }
+        box.addValueChangeListener(event -> {
+            field.setTextFieldEnabled(event.getValue());
+            if (field.isTextFieldEnabled()) {
+                box.setCaption(ENABLED);
+            } else {
+                box.setCaption(DISABLED);
             }
         });
         addComponent(box);
index 02dc326ed8ea8796783a3e327113a0355ef50d31..570c8c0732d09593b7466f21951e8654569d77ec 100644 (file)
@@ -1,7 +1,5 @@
 package com.vaadin.tests.components.draganddropwrapper;
 
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
 import com.vaadin.event.dd.DragAndDropEvent;
 import com.vaadin.event.dd.DropHandler;
 import com.vaadin.event.dd.acceptcriteria.AcceptAll;
@@ -41,13 +39,8 @@ public class DragAndDropDisable extends AbstractTestUI {
             final CheckBox enabled = new CheckBox("Enabled", true);
             addComponent(enabled);
             enabled.setImmediate(true);
-            enabled.addListener(new ValueChangeListener() {
-
-                @Override
-                public void valueChange(ValueChangeEvent event) {
-                    dnd.setEnabled(enabled.booleanValue());
-                }
-            });
+            enabled.addValueChangeListener(
+                    event -> dnd.setEnabled(event.getValue()));
 
             dnd.setDropHandler(new DropHandler() {
 
@@ -80,13 +73,8 @@ public class DragAndDropDisable extends AbstractTestUI {
             final CheckBox enabled = new CheckBox("Enabled", true);
             addComponent(enabled);
             enabled.setImmediate(true);
-            enabled.addListener(new ValueChangeListener() {
-
-                @Override
-                public void valueChange(ValueChangeEvent event) {
-                    dnd.setEnabled(enabled.booleanValue());
-                }
-            });
+            enabled.addValueChangeListener(
+                    event -> dnd.setEnabled(event.getValue()));
 
             dnd.setDropHandler(new DropHandler() {
 
@@ -129,13 +117,8 @@ public class DragAndDropDisable extends AbstractTestUI {
             final CheckBox enabled = new CheckBox("Enabled", true);
             addComponent(enabled);
             enabled.setImmediate(true);
-            enabled.addListener(new ValueChangeListener() {
-
-                @Override
-                public void valueChange(ValueChangeEvent event) {
-                    tbl.setEnabled(enabled.booleanValue());
-                }
-            });
+            enabled.addValueChangeListener(
+                    event -> tbl.setEnabled(event.getValue()));
         }
     }
 
index 147f2dcec7d084ff0f989829574bbd547791da16..725ac65c0b627b23ea0f691768b9ac4854bfbb72 100644 (file)
@@ -1,7 +1,5 @@
 package com.vaadin.tests.components.formlayout;
 
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
 import com.vaadin.server.VaadinRequest;
 import com.vaadin.tests.components.AbstractTestUI;
 import com.vaadin.ui.CheckBox;
@@ -63,23 +61,15 @@ public class NestedFormLayouts extends AbstractTestUI {
         final CheckBox spacingCheckBox = new CheckBox("Spacings", false);
         spacingCheckBox.setId("spacings");
         spacingCheckBox.setImmediate(true);
-        spacingCheckBox.addValueChangeListener(new ValueChangeListener() {
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                setLayoutSpacing(spacingCheckBox.getValue());
-            }
-        });
+        spacingCheckBox.addValueChangeListener(
+                event -> setLayoutSpacing(spacingCheckBox.getValue()));
         addComponent(spacingCheckBox);
 
         final CheckBox marginCheckBox = new CheckBox("Margins", false);
         marginCheckBox.setId("margins");
         marginCheckBox.setImmediate(true);
-        marginCheckBox.addValueChangeListener(new ValueChangeListener() {
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                setLayoutMargin(marginCheckBox.getValue());
-            }
-        });
+        marginCheckBox.addValueChangeListener(
+                event -> setLayoutMargin(marginCheckBox.getValue()));
         addComponent(marginCheckBox);
 
         setLayoutSpacing(false);
index 2880df44b0bd6750430c8b1aa5a01c8ff7366141..df52d161fc3596935a6d87f727831d71246744b6 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * Copyright 2000-2014 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
@@ -16,8 +16,6 @@
 package com.vaadin.tests.components.grid;
 
 import com.vaadin.annotations.Theme;
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
 import com.vaadin.server.VaadinRequest;
 import com.vaadin.tests.util.Person;
 import com.vaadin.tests.util.PersonContainer;
@@ -65,15 +63,11 @@ public class GridDetailsLocation extends UI {
         layout.addComponent(grid);
 
         final CheckBox checkbox = new CheckBox("Details generator");
-        checkbox.addValueChangeListener(new ValueChangeListener() {
-            @Override
-            @SuppressWarnings("boxing")
-            public void valueChange(ValueChangeEvent event) {
-                if (checkbox.getValue()) {
-                    grid.setDetailsGenerator(detailsGenerator);
-                } else {
-                    grid.setDetailsGenerator(DetailsGenerator.NULL);
-                }
+        checkbox.addValueChangeListener(event -> {
+            if (checkbox.getValue()) {
+                grid.setDetailsGenerator(detailsGenerator);
+            } else {
+                grid.setDetailsGenerator(DetailsGenerator.NULL);
             }
         });
         layout.addComponent(checkbox);
index e233edc5d0baf15215582456c3269a6731d7f7f4..23c075136deae033ceaf09a8818bec0189c8c118 100644 (file)
@@ -5,8 +5,6 @@ import java.util.Random;
 
 import com.vaadin.annotations.Theme;
 import com.vaadin.data.Item;
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
 import com.vaadin.data.util.IndexedContainer;
 import com.vaadin.server.VaadinRequest;
 import com.vaadin.tests.components.AbstractTestUIWithLog;
@@ -71,17 +69,14 @@ public class GridSwitchRenderers extends AbstractTestUIWithLog {
 
         final CheckBox changeRenderer = new CheckBox(
                 "SetHtmlRenderer for Column 2", false);
-        changeRenderer.addValueChangeListener(new ValueChangeListener() {
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                Column column = grid.getColumn(getColumnProperty(1));
-                if (changeRenderer.getValue()) {
-                    column.setRenderer(new HtmlRenderer());
-                } else {
-                    column.setRenderer(new TextRenderer());
-                }
-                grid.markAsDirty();
+        changeRenderer.addValueChangeListener(event -> {
+            Column column = grid.getColumn(getColumnProperty(1));
+            if (changeRenderer.getValue()) {
+                column.setRenderer(new HtmlRenderer());
+            } else {
+                column.setRenderer(new TextRenderer());
             }
+            grid.markAsDirty();
         });
         addComponent(changeRenderer);
     }
index ce59f9c89fc10d4cca37add4ed7a8ebd5fe67017..d5644336e340b21de04afa6210c83fb7dc01c129 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * Copyright 2000-2014 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
@@ -15,8 +15,6 @@
  */
 package com.vaadin.tests.components.gridlayout;
 
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
 import com.vaadin.server.VaadinRequest;
 import com.vaadin.tests.components.AbstractTestUI;
 import com.vaadin.ui.CheckBox;
@@ -34,24 +32,13 @@ public class GridLayoutExtraSpacing extends AbstractTestUI {
         final GridLayout gl = new GridLayout(4, 4);
 
         final CheckBox cb = new CheckBox("spacing");
-        cb.addValueChangeListener(new ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                gl.setSpacing(cb.getValue());
-            }
-        });
+        cb.addValueChangeListener(event -> gl.setSpacing(cb.getValue()));
         cb.setValue(true);
         addComponent(cb);
 
         final CheckBox cb2 = new CheckBox("hide empty rows/columns");
-        cb2.addValueChangeListener(new ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                gl.setHideEmptyRowsAndColumns(cb2.getValue());
-            }
-        });
+        cb2.addValueChangeListener(
+                event -> gl.setHideEmptyRowsAndColumns(cb2.getValue()));
         addComponent(cb2);
         gl.setWidth("1000px");
         gl.setHeight("500px");
@@ -68,7 +55,7 @@ public class GridLayoutExtraSpacing extends AbstractTestUI {
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription()
      */
     @Override
@@ -79,7 +66,7 @@ public class GridLayoutExtraSpacing extends AbstractTestUI {
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber()
      */
     @Override
index 9bc29b5c8233fe8a9ff048a1184aed6a3183c832..ccdf676a880b4c84c1656f12de485cefb8634528 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * Copyright 2000-2014 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
@@ -15,8 +15,6 @@
  */
 package com.vaadin.tests.components.gridlayout;
 
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
 import com.vaadin.server.VaadinRequest;
 import com.vaadin.tests.components.AbstractTestUI;
 import com.vaadin.ui.CheckBox;
@@ -55,14 +53,8 @@ public class GridLayoutScrollPosition extends AbstractTestUI {
         toggleableLabel.setVisible(false); // Initially hidden
         gridLayout.addComponent(toggleableLabel);
 
-        visibilityToggleCheckBox
-                .addValueChangeListener(new ValueChangeListener() {
-                    @Override
-                    public void valueChange(ValueChangeEvent event) {
-                        toggleableLabel.setVisible(visibilityToggleCheckBox
-                                .getValue());
-                    }
-                });
+        visibilityToggleCheckBox.addValueChangeListener(event -> toggleableLabel
+                .setVisible(visibilityToggleCheckBox.getValue()));
 
     }
 
index b9071ec44c3c904202845518570d4e2851a8638d..06edbb913f8993289110b17bfdd27599a4d4757f 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * Copyright 2000-2014 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
@@ -17,7 +17,6 @@
 package com.vaadin.tests.components.javascriptcomponent;
 
 import com.vaadin.annotations.JavaScript;
-import com.vaadin.data.Property;
 import com.vaadin.server.VaadinRequest;
 import com.vaadin.tests.components.AbstractTestUI;
 import com.vaadin.ui.AbstractJavaScriptComponent;
@@ -52,13 +51,8 @@ public class JavaScriptResizeListener extends AbstractTestUI {
         addComponent(new CheckBox("Listener active") {
             {
                 setImmediate(true);
-                addValueChangeListener(new ValueChangeListener() {
-                    @Override
-                    public void valueChange(Property.ValueChangeEvent event) {
-                        resizeJsComponent.setListenerEnabled(event
-                                .getProperty().getValue() == Boolean.TRUE);
-                    }
-                });
+                addValueChangeListener(event -> resizeJsComponent
+                        .setListenerEnabled(event.getValue()));
             }
         });
 
index 1e1e26346c9980ee04b6411fd72ecec23cf3582d..6e065088165e64ffd833ecf1bc15046f6a274f93 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * Copyright 2000-2014 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
@@ -16,7 +16,6 @@
 
 package com.vaadin.tests.components.media;
 
-import com.vaadin.data.util.MethodProperty;
 import com.vaadin.server.ClassResource;
 import com.vaadin.server.Resource;
 import com.vaadin.tests.components.TestBase;
@@ -48,20 +47,28 @@ public class AudioTest extends TestBase {
 
         addComponent(audio);
 
-        CheckBox checkBox = new CheckBox("Show controls",
-                new MethodProperty<Boolean>(audio, "showControls"));
+        CheckBox checkBox = new CheckBox("Show controls");
+        checkBox.setValue(audio.isShowControls());
+        checkBox.addValueChangeListener(
+                event -> audio.setShowControls(event.getValue()));
         checkBox.setImmediate(true);
         addComponent(checkBox);
-        checkBox = new CheckBox("HtmlContentAllowed",
-                new MethodProperty<Boolean>(audio, "htmlContentAllowed"));
+        checkBox = new CheckBox("HtmlContentAllowed");
+        checkBox.setValue(audio.isHtmlContentAllowed());
+        checkBox.addValueChangeListener(
+                event -> audio.setHtmlContentAllowed(event.getValue()));
         checkBox.setImmediate(true);
         addComponent(checkBox);
-        checkBox = new CheckBox("muted", new MethodProperty<Boolean>(audio,
-                "muted"));
+        checkBox = new CheckBox("muted");
+        checkBox.setValue(audio.isMuted());
+        checkBox.addValueChangeListener(
+                event -> audio.setMuted(event.getValue()));
         checkBox.setImmediate(true);
         addComponent(checkBox);
-        checkBox = new CheckBox("autoplay", new MethodProperty<Boolean>(audio,
-                "autoplay"));
+        checkBox = new CheckBox("autoplay");
+        checkBox.setValue(audio.isAutoplay());
+        checkBox.addValueChangeListener(
+                event -> audio.setAutoplay(event.getValue()));
         checkBox.setImmediate(true);
         addComponent(checkBox);
 
index 76258e574e50afc45add71e997626f50109b2e11..063e5ef3dafbf0a2831a4fdbfebedce418cbda9d 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * Copyright 2000-2014 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
@@ -17,7 +17,6 @@ package com.vaadin.tests.components.optiongroup;
 
 import java.util.Collections;
 
-import com.vaadin.data.Property;
 import com.vaadin.server.VaadinRequest;
 import com.vaadin.tests.components.AbstractTestUI;
 import com.vaadin.ui.CheckBox;
@@ -25,7 +24,7 @@ import com.vaadin.ui.OptionGroup;
 
 /**
  * Test UI for unset read-only flag of Option group with new items allowed.
- * 
+ *
  * @author Vaadin Ltd
  */
 public class ReadOnlyOptionGroup extends AbstractTestUI {
@@ -38,13 +37,8 @@ public class ReadOnlyOptionGroup extends AbstractTestUI {
 
         final CheckBox readOnlyCheckbox = new CheckBox("read-only");
         readOnlyCheckbox.setImmediate(true);
-        readOnlyCheckbox
-                .addValueChangeListener(new Property.ValueChangeListener() {
-                    @Override
-                    public void valueChange(Property.ValueChangeEvent event) {
-                        optionGroup.setReadOnly(readOnlyCheckbox.getValue());
-                    }
-                });
+        readOnlyCheckbox.addValueChangeListener(
+                event -> optionGroup.setReadOnly(readOnlyCheckbox.getValue()));
         readOnlyCheckbox.setValue(Boolean.TRUE);
 
         addComponent(optionGroup);
index 1b07cf8f8144d1c7950eb908769e53257f885656..6763e88ae720fbfee3d975d3865de60634f57665 100644 (file)
@@ -103,19 +103,15 @@ public class BoxLayoutTest extends AbstractTestUI {
 
         final CheckBox vertical = new CheckBox("Vertical", !horizontal);
         vertical.setImmediate(true);
-        vertical.addListener(new ValueChangeListener() {
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                view.removeAllComponents();
-
-                view.addComponent(createControls(!vertical.getValue()
-                        .booleanValue()));
-                view.addComponent(createTestLayout(!vertical.getValue()
-                        .booleanValue()));
+        vertical.addValueChangeListener(event -> {
+            view.removeAllComponents();
 
-                view.setExpandRatio(view.getComponent(1), 1);
+            view.addComponent(createControls(!vertical.getValue()
+                    .booleanValue()));
+            view.addComponent(createTestLayout(!vertical.getValue()
+                    .booleanValue()));
 
-            }
+            view.setExpandRatio(view.getComponent(1), 1);
         });
         header.addComponent(vertical);
 
@@ -201,23 +197,13 @@ public class BoxLayoutTest extends AbstractTestUI {
         layout.addComponent(height);
 
         final CheckBox margin = new CheckBox("Margin", false);
-        margin.addListener(new ValueChangeListener() {
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                l.setMargin(margin.getValue().booleanValue());
-            }
-        });
+        margin.addValueChangeListener(event -> l.setMargin(event.getValue()));
         margin.setImmediate(true);
         layout.addComponent(margin);
         layout.addComponent(margin);
 
         final CheckBox spacing = new CheckBox("Spacing", false);
-        spacing.addListener(new ValueChangeListener() {
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                l.setSpacing(spacing.getValue().booleanValue());
-            }
-        });
+        spacing.addValueChangeListener(event -> l.setSpacing(event.getValue()));
         spacing.setImmediate(true);
         layout.addComponent(spacing);
 
@@ -258,12 +244,9 @@ public class BoxLayoutTest extends AbstractTestUI {
         expand = new CheckBox("Expand");
         expand.setImmediate(true);
         expand.setEnabled(false);
-        expand.addListener(new ValueChangeListener() {
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                if (target != null) {
-                    l.setExpandRatio(target, expand.getValue() ? 1 : 0);
-                }
+        expand.addValueChangeListener(event -> {
+            if (target != null) {
+                l.setExpandRatio(target, expand.getValue() ? 1 : 0);
             }
         });
         cell.addComponent(expand);
@@ -359,13 +342,10 @@ public class BoxLayoutTest extends AbstractTestUI {
         componentError = new CheckBox("Error");
         componentError.setImmediate(true);
         componentError.setEnabled(false);
-        componentError.addListener(new ValueChangeListener() {
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                if (target != null) {
-                    target.setComponentError(componentError.getValue() ? new UserError(
-                            "Error message") : null);
-                }
+        componentError.addValueChangeListener(event -> {
+            if (target != null) {
+                target.setComponentError(componentError.getValue() ? new UserError(
+                        "Error message") : null);
             }
         });
         component.addComponent(componentError);
@@ -373,13 +353,10 @@ public class BoxLayoutTest extends AbstractTestUI {
         componentRequired = new CheckBox("Required");
         componentRequired.setImmediate(true);
         componentRequired.setEnabled(false);
-        componentRequired.addListener(new ValueChangeListener() {
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                if (target != null && target instanceof LegacyAbstractField) {
-                    ((LegacyAbstractField<?>) target).setRequired(componentRequired
-                            .getValue());
-                }
+        componentRequired.addValueChangeListener(event -> {
+            if (target != null && target instanceof LegacyAbstractField) {
+                ((LegacyAbstractField<?>) target).setRequired(componentRequired
+                        .getValue());
             }
         });
         component.addComponent(componentRequired);
index d9a9c144253fb58786463988256127a94db2946c..9111668dc74336b13b56c0c696a615d9c6c120a0 100644 (file)
@@ -2,8 +2,6 @@ package com.vaadin.tests.components.panel;
 
 import java.util.Map;
 
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
 import com.vaadin.tests.components.TestBase;
 import com.vaadin.ui.Button;
 import com.vaadin.ui.CheckBox;
@@ -41,14 +39,11 @@ public class BasicPanelTest extends TestBase {
 
         final CheckBox heightSelection = new CheckBox("Undefined height");
         heightSelection.setImmediate(true);
-        heightSelection.addListener(new ValueChangeListener() {
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                if (heightSelection.getValue() == Boolean.TRUE) {
-                    panel.setHeight(null);
-                } else {
-                    panel.setHeight("100%");
-                }
+        heightSelection.addValueChangeListener(event -> {
+            if (heightSelection.getValue() == Boolean.TRUE) {
+                panel.setHeight(null);
+            } else {
+                panel.setHeight("100%");
             }
         });
         actions.addComponent(heightSelection);
index c3433c305470fd4795b419519ca5c3f899322931..4b881fc3a18658299865442ce7909f9112b1b9f1 100644 (file)
@@ -1,7 +1,5 @@
 package com.vaadin.tests.components.richtextarea;
 
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
 import com.vaadin.shared.ui.label.ContentMode;
 import com.vaadin.tests.components.TestBase;
 import com.vaadin.ui.Button;
@@ -93,13 +91,8 @@ public class RichTextAreaPreventsTextFieldAccess extends TestBase {
 
         CheckBox cb = new CheckBox("close");
         cb.setImmediate(true);
-        cb.addValueChangeListener(new ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                getMainWindow().removeWindow(subWindow);
-            }
-        });
+        cb.addValueChangeListener(
+                event -> getMainWindow().removeWindow(subWindow));
         wLayout.addComponent(cb);
 
     }
index 2f58e35dc7b395f20a6bfea308a665941d6ea944..33edc470c76cb4bc2a6b12e5d8def1c4e62d229d 100644 (file)
@@ -1,9 +1,5 @@
 package com.vaadin.tests.components.select;
 
-import java.util.Iterator;
-
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
 import com.vaadin.tests.components.ComponentTestCase;
 import com.vaadin.ui.AbstractSelect;
 import com.vaadin.ui.CheckBox;
@@ -27,34 +23,22 @@ public class OptionGroupBaseSelects extends ComponentTestCase<HorizontalLayout>
     protected void initializeComponents() {
 
         CheckBox cb = new CheckBox("Switch Selects ReadOnly", false);
-        cb.addListener(new ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                for (Iterator<Component> it = layout.getComponentIterator(); it
-                        .hasNext();) {
-                    Component c = it.next();
-                    if (c instanceof AbstractSelect) {
-                        c.setReadOnly(!c.isReadOnly());
-                    }
+        cb.addValueChangeListener(event -> {
+            for (Component c : layout) {
+                if (c instanceof AbstractSelect) {
+                    c.setReadOnly(!c.isReadOnly());
                 }
             }
         });
         CheckBox cb2 = new CheckBox("Switch Selects Enabled", true);
-        cb2.addListener(new ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                for (Iterator<Component> it = layout.getComponentIterator(); it
-                        .hasNext();) {
-                    Component c = it.next();
-                    if (c instanceof AbstractSelect) {
-                        boolean enabled = !c.isEnabled();
-                        c.setEnabled(enabled);
-                        c.setCaption(c.getCaption().replace(
-                                (enabled ? "disabled" : "enabled"),
-                                (enabled ? "enabled" : "disabled")));
-                    }
+        cb2.addValueChangeListener(event -> {
+            for (Component c : layout) {
+                if (c instanceof AbstractSelect) {
+                    boolean enabled = !c.isEnabled();
+                    c.setEnabled(enabled);
+                    c.setCaption(c.getCaption().replace(
+                            (enabled ? "disabled" : "enabled"),
+                            (enabled ? "enabled" : "disabled")));
                 }
             }
         });
index 0dc371e57cf26933a28e944f4afaa74e513abea0..c6a23fe73ec9a4c6c1871668add41e5cc10edb4d 100644 (file)
@@ -1,8 +1,6 @@
 package com.vaadin.tests.components.splitpanel;
 
 import com.vaadin.annotations.Theme;
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
 import com.vaadin.event.FieldEvents.TextChangeEvent;
 import com.vaadin.event.FieldEvents.TextChangeListener;
 import com.vaadin.server.VaadinRequest;
@@ -39,13 +37,6 @@ public class GridLayoutWithCheckbox extends UI {
         grid.addComponent(l, 0, 1);
         CheckBox checkBox = new CheckBox();
         grid.addComponent(checkBox, 1, 2);
-        checkBox.addValueChangeListener(new ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-
-            }
-        });
         Window window = new Window();
         window.setWidth(300.0f, Unit.PIXELS);
         window.setContent(grid);
index bde50af01341957ac2143aaf741a5d61e8e7719f..fa981aebe94d1927b4fd5250f03b48e8c04ea355 100644 (file)
@@ -1,8 +1,6 @@
 package com.vaadin.tests.components.table;
 
 import com.vaadin.data.Item;
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
 import com.vaadin.tests.components.TestBase;
 import com.vaadin.ui.Button;
 import com.vaadin.ui.Button.ClickEvent;
@@ -18,16 +16,11 @@ public class AddItemToEmptyTable extends TestBase {
         CheckBox cb = new CheckBox("Set first column width");
         cb.setValue(false);
         cb.setImmediate(true);
-        cb.addListener(new ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                if ((Boolean) event.getProperty().getValue()) {
-                    rightTable.setColumnWidth("name", 150);
-                } else {
-                    rightTable.setColumnWidth("name", -1);
-                }
-
+        cb.addValueChangeListener(event -> {
+            if (event.getValue()) {
+                rightTable.setColumnWidth("name", 150);
+            } else {
+                rightTable.setColumnWidth("name", -1);
             }
         });
         addComponent(cb);
@@ -35,16 +28,11 @@ public class AddItemToEmptyTable extends TestBase {
         cb = new CheckBox("Set second column width");
         cb.setValue(true);
         cb.setImmediate(true);
-        cb.addListener(new ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                if ((Boolean) event.getProperty().getValue()) {
-                    rightTable.setColumnWidth("info", 20);
-                } else {
-                    rightTable.setColumnWidth("info", -1);
-                }
-
+        cb.addValueChangeListener(event -> {
+            if (event.getValue()) {
+                rightTable.setColumnWidth("info", 20);
+            } else {
+                rightTable.setColumnWidth("info", -1);
             }
         });
         addComponent(cb);
index 529d74344693370972a45fcf2869193699caf13a..1330475e074bb06656cb15e52bffd6050ee84497 100644 (file)
@@ -36,15 +36,11 @@ public class ColumnHeaderAlignments extends TestBase {
         });
         addComponent(theme);
         CheckBox footers = new CheckBox("Show footers");
-        footers.addListener(new ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                boolean visible = (Boolean) event.getProperty().getValue();
-                fooTable.setFooterVisible(visible);
-                barTable.setFooterVisible(visible);
-                bazTable.setFooterVisible(visible);
-            }
+        footers.addValueChangeListener(event -> {
+            boolean visible = event.getValue();
+            fooTable.setFooterVisible(visible);
+            barTable.setFooterVisible(visible);
+            bazTable.setFooterVisible(visible);
         });
         footers.setImmediate(true);
         addComponent(footers);
index 3565196778ce14e0fa7893bd7a6d3db7f1227064..7cc9b8cd88a96eac2bcf7cdd4038d617138e344e 100644 (file)
@@ -38,24 +38,12 @@ public class DoublesInTable extends TestBase {
     protected void setup() {
         editMode = new CheckBox("Edit mode");
         editMode.setImmediate(true);
-        editMode.addListener(new ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                table.setEditable(editMode.getValue());
-
-            }
-        });
+        editMode.addValueChangeListener(
+                event -> table.setEditable(editMode.getValue()));
 
         useCustomConverters = new CheckBox("Use custom converters");
         useCustomConverters.setImmediate(true);
-        useCustomConverters.addListener(new ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                recreateTable();
-            }
-        });
+        useCustomConverters.addValueChangeListener(event -> recreateTable());
 
         localeSelect = createLocaleSelect();
         personBeanItemContainer = createContainer(100);
index 84eb646fa6f4f331973b553d1cacf3d484a1efe4..3994029b436d8083e342ef6ea1bcb051f2505322 100644 (file)
@@ -7,8 +7,6 @@ import java.io.Serializable;
 import java.util.HashMap;
 
 import com.vaadin.data.Container;
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
 import com.vaadin.legacy.ui.LegacyField;
 import com.vaadin.shared.ui.label.ContentMode;
 import com.vaadin.tests.components.TestBase;
@@ -86,15 +84,11 @@ public class EditableTableLeak extends TestBase {
     protected void setup() {
         addComponent(useFieldFactory);
         useFieldFactory.setImmediate(true);
-        useFieldFactory.addListener(new ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                if (useFieldFactory.getValue()) {
-                    table.setTableFieldFactory(new CachingFieldFactory());
-                } else {
-                    table.setTableFieldFactory(DefaultFieldFactory.get());
-                }
+        useFieldFactory.addValueChangeListener(event -> {
+            if (useFieldFactory.getValue()) {
+                table.setTableFieldFactory(new CachingFieldFactory());
+            } else {
+                table.setTableFieldFactory(DefaultFieldFactory.get());
             }
         });
         addComponent(table);
index 5d2d68898ce65c49ba759cd75531d13548c43a59..3927cd8eb6cd7624b037457f9476e2862e894975 100644 (file)
@@ -2,8 +2,6 @@ package com.vaadin.tests.components.table;
 
 import com.vaadin.data.Container;
 import com.vaadin.data.Item;
-import com.vaadin.data.Property;
-import com.vaadin.data.Property.ValueChangeEvent;
 import com.vaadin.data.util.IndexedContainer;
 import com.vaadin.server.VaadinRequest;
 import com.vaadin.tests.components.AbstractTestUI;
@@ -49,13 +47,8 @@ public class Footer extends AbstractTestUI {
 
         final CheckBox visible = new CheckBox("Footers Visible", true);
         visible.setImmediate(true);
-        visible.addValueChangeListener(new Property.ValueChangeListener() {
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                table.setFooterVisible(visible.getValue());
-
-            }
-        });
+        visible.addValueChangeListener(
+                event -> table.setFooterVisible(visible.getValue()));
 
         options.addComponent(visible);
 
index 8d6a32c9bba3340dca0ccf59b60f525fd53cd0c4..520b9ea1d14037698763522325697bc4da643b9a 100644 (file)
@@ -2,8 +2,6 @@ package com.vaadin.tests.components.table;
 
 import com.vaadin.data.Container;
 import com.vaadin.data.Item;
-import com.vaadin.data.Property;
-import com.vaadin.data.Property.ValueChangeEvent;
 import com.vaadin.data.util.IndexedContainer;
 import com.vaadin.server.VaadinRequest;
 import com.vaadin.tests.components.AbstractTestUIWithLog;
@@ -48,29 +46,15 @@ public class FooterClick extends AbstractTestUIWithLog {
         CheckBox immediateCheckbox = new CheckBox("Immediate");
         immediateCheckbox.setImmediate(true);
         immediateCheckbox.setValue(table.isImmediate());
-        immediateCheckbox
-                .addValueChangeListener(new Property.ValueChangeListener() {
-
-                    @Override
-                    public void valueChange(ValueChangeEvent event) {
-                        table.setImmediate((Boolean) event.getProperty()
-                                .getValue());
-                    }
-                });
+        immediateCheckbox.addValueChangeListener(
+                event -> table.setImmediate(event.getValue()));
 
         CheckBox columnReorderingCheckbox = new CheckBox(
                 "Column reordering allowed");
         columnReorderingCheckbox.setImmediate(true);
         columnReorderingCheckbox.setValue(table.isColumnReorderingAllowed());
-        columnReorderingCheckbox
-                .addValueChangeListener(new Property.ValueChangeListener() {
-
-                    @Override
-                    public void valueChange(ValueChangeEvent event) {
-                        table.setColumnReorderingAllowed((Boolean) event
-                                .getProperty().getValue());
-                    }
-                });
+        columnReorderingCheckbox.addValueChangeListener(
+                event -> table.setColumnReorderingAllowed(event.getValue()));
 
         addComponent(immediateCheckbox);
         addComponent(columnReorderingCheckbox);
index 2bb48a2b403165e538b0e0f6e6a16488dc4bd514..d89cdff4de9bbee202adff93f12c8b1f8e79ae6b 100644 (file)
@@ -2,8 +2,6 @@ package com.vaadin.tests.components.table;
 
 import com.vaadin.data.Container;
 import com.vaadin.data.Item;
-import com.vaadin.data.Property;
-import com.vaadin.data.Property.ValueChangeEvent;
 import com.vaadin.data.util.IndexedContainer;
 import com.vaadin.server.VaadinRequest;
 import com.vaadin.tests.components.AbstractTestUI;
@@ -37,42 +35,21 @@ public class HeaderClick extends AbstractTestUI {
         CheckBox immediateCheckbox = new CheckBox("Immediate");
         immediateCheckbox.setImmediate(true);
         immediateCheckbox.setValue(table.isImmediate());
-        immediateCheckbox
-                .addValueChangeListener(new Property.ValueChangeListener() {
-
-                    @Override
-                    public void valueChange(ValueChangeEvent event) {
-                        table.setImmediate((Boolean) event.getProperty()
-                                .getValue());
-                    }
-                });
+        immediateCheckbox.addValueChangeListener(
+                event -> table.setImmediate(event.getValue()));
 
         CheckBox sortEnabledCheckbox = new CheckBox("Sortable");
         sortEnabledCheckbox.setImmediate(true);
         sortEnabledCheckbox.setValue(table.isSortEnabled());
-        sortEnabledCheckbox
-                .addValueChangeListener(new Property.ValueChangeListener() {
-
-                    @Override
-                    public void valueChange(ValueChangeEvent event) {
-                        table.setSortEnabled((Boolean) event.getProperty()
-                                .getValue());
-                    }
-                });
+        sortEnabledCheckbox.addValueChangeListener(
+                event -> table.setSortEnabled(event.getValue()));
 
         CheckBox columnReorderingCheckbox = new CheckBox(
                 "Column reordering allowed");
         columnReorderingCheckbox.setImmediate(true);
         columnReorderingCheckbox.setValue(table.isColumnReorderingAllowed());
-        columnReorderingCheckbox
-                .addValueChangeListener(new Property.ValueChangeListener() {
-
-                    @Override
-                    public void valueChange(ValueChangeEvent event) {
-                        table.setColumnReorderingAllowed((Boolean) event
-                                .getProperty().getValue());
-                    }
-                });
+        columnReorderingCheckbox.addValueChangeListener(
+                event -> table.setColumnReorderingAllowed(event.getValue()));
 
         addComponent(immediateCheckbox);
         addComponent(sortEnabledCheckbox);
index 09b3dde32cc022570920a4d8a8a423be56e324c0..a42135dc85953a9f07e9369934dfac08d64f731b 100644 (file)
@@ -1,9 +1,9 @@
 package com.vaadin.tests.components.table;
 
 import com.vaadin.data.Container;
+import com.vaadin.data.HasValue;
+import com.vaadin.data.HasValue.ValueChange;
 import com.vaadin.data.Item;
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
 import com.vaadin.data.util.IndexedContainer;
 import com.vaadin.server.VaadinRequest;
 import com.vaadin.tests.components.AbstractTestUIWithLog;
@@ -29,19 +29,14 @@ public class HeaderFooterClickLeftRightMiddle extends AbstractTestUIWithLog {
         CheckBox immediateCheckbox = new CheckBox("Immediate");
         immediateCheckbox.setImmediate(true);
         immediateCheckbox.setValue(table.isImmediate());
-        immediateCheckbox.addValueChangeListener(new ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                table.setImmediate((Boolean) event.getProperty().getValue());
-            }
-        });
+        immediateCheckbox.addValueChangeListener(
+                event -> table.setImmediate(event.getValue()));
 
         CheckBox headerClickListenerCheckbox = new CheckBox(
                 "Header click listener");
         headerClickListenerCheckbox.setImmediate(true);
         headerClickListenerCheckbox
-                .addValueChangeListener(new ValueChangeListener() {
+                .addValueChangeListener(new HasValue.ValueChangeListener<Boolean>() {
 
                     private HeaderClickListener headerClickListener = new HeaderClickListener() {
 
@@ -57,7 +52,7 @@ public class HeaderFooterClickLeftRightMiddle extends AbstractTestUIWithLog {
                     };
 
                     @Override
-                    public void valueChange(ValueChangeEvent event) {
+                    public void accept(ValueChange<Boolean> event) {
                         if (table.getListeners(HeaderClickEvent.class)
                                 .isEmpty()) {
                             table.addHeaderClickListener(headerClickListener);
@@ -72,7 +67,7 @@ public class HeaderFooterClickLeftRightMiddle extends AbstractTestUIWithLog {
                 "Footer click listener");
         footerClickListenerCheckbox.setImmediate(true);
         footerClickListenerCheckbox
-                .addValueChangeListener(new ValueChangeListener() {
+                .addValueChangeListener(new HasValue.ValueChangeListener<Boolean>() {
 
                     private FooterClickListener footerClickListener = new FooterClickListener() {
 
@@ -87,7 +82,7 @@ public class HeaderFooterClickLeftRightMiddle extends AbstractTestUIWithLog {
                     };
 
                     @Override
-                    public void valueChange(ValueChangeEvent event) {
+                    public void accept(ValueChange<Boolean> event) {
                         if (table.getListeners(FooterClickEvent.class)
                                 .isEmpty()) {
                             table.addFooterClickListener(footerClickListener);
@@ -101,26 +96,15 @@ public class HeaderFooterClickLeftRightMiddle extends AbstractTestUIWithLog {
         CheckBox sortEnabledCheckbox = new CheckBox("Sortable");
         sortEnabledCheckbox.setImmediate(true);
         sortEnabledCheckbox.setValue(table.isSortEnabled());
-        sortEnabledCheckbox.addValueChangeListener(new ValueChangeListener() {
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                table.setSortEnabled((Boolean) event.getProperty().getValue());
-            }
-        });
+        sortEnabledCheckbox.addValueChangeListener(
+                event -> table.setSortEnabled(event.getValue()));
 
         CheckBox columnReorderingCheckbox = new CheckBox(
                 "Column reordering allowed");
         columnReorderingCheckbox.setImmediate(true);
         columnReorderingCheckbox.setValue(table.isColumnReorderingAllowed());
-        columnReorderingCheckbox
-                .addValueChangeListener(new ValueChangeListener() {
-
-                    @Override
-                    public void valueChange(ValueChangeEvent event) {
-                        table.setColumnReorderingAllowed((Boolean) event
-                                .getProperty().getValue());
-                    }
-                });
+        columnReorderingCheckbox.addValueChangeListener(
+                event -> table.setColumnReorderingAllowed(event.getValue()));
 
         addComponent(immediateCheckbox);
         addComponent(headerClickListenerCheckbox);
index 6376ad7df062cdaf23fd81406df525936e470f64..10ffb1c8aab35968f65cc1e2de85f9c43f95991c 100644 (file)
@@ -1,8 +1,6 @@
 package com.vaadin.tests.components.table;
 
 import com.vaadin.data.Item;
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
 import com.vaadin.event.Action;
 import com.vaadin.event.ItemClickEvent;
 import com.vaadin.event.ItemClickEvent.ItemClickListener;
@@ -25,50 +23,34 @@ public class HeaderPositionWhenSorting extends AbstractTestUI implements
     protected void setup(VaadinRequest request) {
         CheckBox cb = new CheckBox("Item click listener");
         cb.setImmediate(true);
-        cb.addValueChangeListener(new ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                if (((Boolean) event.getProperty().getValue())) {
-                    table.addItemClickListener(HeaderPositionWhenSorting.this);
-                } else {
-                    table.removeItemClickListener(HeaderPositionWhenSorting.this);
-                }
-
+        cb.addValueChangeListener(event -> {
+            if (event.getValue()) {
+                table.addItemClickListener(HeaderPositionWhenSorting.this);
+            } else {
+                table.removeItemClickListener(HeaderPositionWhenSorting.this);
             }
         });
         addComponent(cb);
 
         CheckBox cbActionHandler = new CheckBox("Action handler");
         cbActionHandler.setImmediate(true);
-        cbActionHandler.addValueChangeListener(new ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                if (((Boolean) event.getProperty().getValue())) {
-                    table.addActionHandler(HeaderPositionWhenSorting.this);
-                } else {
-                    table.removeActionHandler(HeaderPositionWhenSorting.this);
-                }
-
+        cbActionHandler.addValueChangeListener(event -> {
+            if (event.getValue()) {
+                table.addActionHandler(HeaderPositionWhenSorting.this);
+            } else {
+                table.removeActionHandler(HeaderPositionWhenSorting.this);
             }
         });
         addComponent(cbActionHandler);
 
         CheckBox cbActionHasActions = new CheckBox("Action handler has actions");
         cbActionHasActions.setImmediate(true);
-        cbActionHasActions.addValueChangeListener(new ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                actionHandlerHasActions = ((Boolean) event.getProperty()
-                        .getValue());
+        cbActionHasActions.addValueChangeListener(event -> {
+            actionHandlerHasActions = event.getValue();
 
-                // Workaround to ensure actions are repainted
-                removeComponent(table);
-                addComponent(table);
-
-            }
+            // Workaround to ensure actions are repainted
+            removeComponent(table);
+            addComponent(table);
         });
         addComponent(cbActionHasActions);
 
index b89582bb7e20267f473bec6dc9d4ea70b63bc7f8..abb770ab05a9aaeaa81e38931465117523328caf 100644 (file)
@@ -1,7 +1,5 @@
 package com.vaadin.tests.components.table;
 
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
 import com.vaadin.server.VaadinRequest;
 import com.vaadin.tests.components.AbstractTestUI;
 import com.vaadin.ui.CheckBox;
@@ -20,15 +18,11 @@ public class HeaderUpdateWhenNoRows extends AbstractTestUI {
         table.setImmediate(true);
 
         final CheckBox showHeaders = new CheckBox("Show headers");
-        showHeaders.addValueChangeListener(new ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                if (showHeaders.getValue()) {
-                    table.setColumnHeaderMode(ColumnHeaderMode.EXPLICIT_DEFAULTS_ID);
-                } else {
-                    table.setColumnHeaderMode(ColumnHeaderMode.HIDDEN);
-                }
+        showHeaders.addValueChangeListener(event -> {
+            if (showHeaders.getValue()) {
+                table.setColumnHeaderMode(ColumnHeaderMode.EXPLICIT_DEFAULTS_ID);
+            } else {
+                table.setColumnHeaderMode(ColumnHeaderMode.HIDDEN);
             }
         });
 
index cb69856e957ff9746252e81d08a7cfee20109155..a085408436ee89fe853ae1888416df44b7f7f52c 100644 (file)
@@ -1,17 +1,16 @@
 package com.vaadin.tests.components.table;
 
 import com.vaadin.data.Item;
-import com.vaadin.data.util.MethodProperty;
 import com.vaadin.event.ItemClickEvent;
 import com.vaadin.event.ItemClickEvent.ItemClickListener;
 import com.vaadin.server.ExternalResource;
 import com.vaadin.server.VaadinRequest;
 import com.vaadin.tests.components.AbstractTestUI;
 import com.vaadin.tests.util.Log;
+import com.vaadin.ui.AbstractSelect;
 import com.vaadin.ui.Button;
 import com.vaadin.ui.Button.ClickEvent;
 import com.vaadin.ui.CheckBox;
-import com.vaadin.ui.Component;
 import com.vaadin.ui.HorizontalLayout;
 import com.vaadin.ui.Table;
 import com.vaadin.ui.Tree;
@@ -135,21 +134,31 @@ public class ItemClickEvents extends AbstractTestUI {
 
     }
 
-    private static HorizontalLayout createHorizontalLayout(Component c) {
+    private static HorizontalLayout createHorizontalLayout(AbstractSelect c) {
         HorizontalLayout layout = new HorizontalLayout();
-        CheckBox b = new CheckBox("immediate", new MethodProperty<Boolean>(c,
-                "immediate"));
+        CheckBox b = new CheckBox("immediate");
+        b.setValue(c.isImmediate());
+        b.addValueChangeListener(event -> c.setImmediate(event.getValue()));
         b.setImmediate(true);
         layout.addComponent(b);
-        b = new CheckBox("selectable", new MethodProperty<Boolean>(c,
-                "selectable"));
+        b = new CheckBox("selectable");
+        if (c instanceof Table) {
+            b.setValue(((Table) c).isSelectable());
+            b.addValueChangeListener(event -> ((Table) c).setSelectable(event.getValue()));
+        } else if (c instanceof Tree) {
+            b.setValue(((Tree) c).isSelectable());
+            b.addValueChangeListener(event -> ((Tree) c).setSelectable(event.getValue()));
+        }
         b.setImmediate(true);
         layout.addComponent(b);
-        b = new CheckBox("nullsel", new MethodProperty<Boolean>(c,
-                "nullSelectionAllowed"));
+        b = new CheckBox("nullsel");
+        b.setValue(c.isNullSelectionAllowed());
+        b.addValueChangeListener(event -> c.setNullSelectionAllowed(event.getValue()));
         b.setImmediate(true);
         layout.addComponent(b);
-        b = new CheckBox("multi", new MethodProperty<Boolean>(c, "multiSelect"));
+        b = new CheckBox("multi");
+        b.setValue(c.isMultiSelect());
+        b.addValueChangeListener(event -> c.setMultiSelect(event.getValue()));
         b.setImmediate(true);
         layout.addComponent(b);
         return layout;
index 5a406eac489ac1b4b7196cc4b29503acd4d97afe..cbeaccb589480411d09e1245c867ecb5add24cab 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * Copyright 2000-2014 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
@@ -15,7 +15,6 @@
  */
 package com.vaadin.tests.components.table;
 
-import com.vaadin.data.Property.ValueChangeListener;
 import com.vaadin.server.VaadinRequest;
 import com.vaadin.tests.components.AbstractTestUIWithLog;
 import com.vaadin.ui.CheckBox;
@@ -23,7 +22,7 @@ import com.vaadin.ui.CssLayout;
 import com.vaadin.ui.Table;
 
 /**
- * 
+ *
  * @since
  * @author Vaadin Ltd
  */
@@ -31,7 +30,7 @@ public class SelectAllConstantViewport extends AbstractTestUIWithLog {
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see com.vaadin.tests.components.AbstractTestUI#setup(com.vaadin.server.
      * VaadinRequest)
      */
@@ -46,18 +45,11 @@ public class SelectAllConstantViewport extends AbstractTestUIWithLog {
         table.setSelectable(true);
 
         CheckBox selectAllCheckbox = new CheckBox("Select All");
-        selectAllCheckbox.addValueChangeListener(new ValueChangeListener() {
-            @Override
-            public void valueChange(
-                    com.vaadin.data.Property.ValueChangeEvent event) {
-                Object checked = event.getProperty().getValue();
-                if (checked instanceof Boolean) {
-                    if (((Boolean) checked).booleanValue()) {
-                        table.setValue(table.getItemIds());
-                    } else {
-                        table.setValue(null);
-                    }
-                }
+        selectAllCheckbox.addValueChangeListener(event -> {
+            if (event.getValue()) {
+                table.setValue(table.getItemIds());
+            } else {
+                table.setValue(null);
             }
         });
 
@@ -76,7 +68,7 @@ public class SelectAllConstantViewport extends AbstractTestUIWithLog {
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see com.vaadin.tests.components.AbstractTestUI#getTestDescription()
      */
     @Override
@@ -87,7 +79,7 @@ public class SelectAllConstantViewport extends AbstractTestUIWithLog {
 
     /*
      * (non-Javadoc)
-     * 
+     *
      * @see com.vaadin.tests.components.AbstractTestUI#getTicketNumber()
      */
     @Override
index eb5beec6bda64a93ee00ecd45b9a4a8f1a7b6c76..202fa97c8b15432d9b2576da68c6ae1ede66510d 100644 (file)
@@ -1,8 +1,6 @@
 package com.vaadin.tests.components.table;
 
 import com.vaadin.data.Item;
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
 import com.vaadin.event.Action;
 import com.vaadin.event.ItemClickEvent;
 import com.vaadin.event.ItemClickEvent.ItemClickListener;
@@ -23,50 +21,34 @@ public class TableAndBrowserContextMenu extends TestBase implements
     public void setup() {
         CheckBox cb = new CheckBox("Item click listener");
         cb.setImmediate(true);
-        cb.addListener(new ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                if (((Boolean) event.getProperty().getValue())) {
-                    table.addListener(TableAndBrowserContextMenu.this);
-                } else {
-                    table.removeListener(TableAndBrowserContextMenu.this);
-                }
-
+        cb.addValueChangeListener(event -> {
+            if (event.getValue()) {
+                table.addListener(TableAndBrowserContextMenu.this);
+            } else {
+                table.removeListener(TableAndBrowserContextMenu.this);
             }
         });
         addComponent(cb);
 
         CheckBox cbActionHandler = new CheckBox("Action handler");
         cbActionHandler.setImmediate(true);
-        cbActionHandler.addListener(new ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                if (((Boolean) event.getProperty().getValue())) {
-                    table.addActionHandler(TableAndBrowserContextMenu.this);
-                } else {
-                    table.removeActionHandler(TableAndBrowserContextMenu.this);
-                }
-
+        cbActionHandler.addValueChangeListener(event -> {
+            if (event.getValue()) {
+                table.addActionHandler(TableAndBrowserContextMenu.this);
+            } else {
+                table.removeActionHandler(TableAndBrowserContextMenu.this);
             }
         });
         addComponent(cbActionHandler);
 
         CheckBox cbActionHasActions = new CheckBox("Action handler has actions");
         cbActionHasActions.setImmediate(true);
-        cbActionHasActions.addListener(new ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                actionHandlerHasActions = ((Boolean) event.getProperty()
-                        .getValue());
+        cbActionHasActions.addValueChangeListener(event -> {
+            actionHandlerHasActions = event.getValue();
 
-                // Workaround to ensure actions are repainted
-                removeComponent(table);
-                addComponent(table);
-
-            }
+            // Workaround to ensure actions are repainted
+            removeComponent(table);
+            addComponent(table);
         });
         addComponent(cbActionHasActions);
 
index 1d909d101ed9cd3b11e756282972bb7b344ca505..9415318054f56f028a615d04d4c59fcebe4ad6cd 100644 (file)
@@ -1,7 +1,5 @@
 package com.vaadin.tests.components.table;
 
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
 import com.vaadin.event.Action;
 import com.vaadin.server.VaadinRequest;
 import com.vaadin.tests.components.AbstractTestUI;
@@ -12,7 +10,7 @@ import com.vaadin.ui.Table;
 import com.vaadin.ui.VerticalLayout;
 
 /*
- * Differs from TableContextMenu by number of items, their numbering and 
+ * Differs from TableContextMenu by number of items, their numbering and
  * immediate/selectable/multiselect toggling
  */
 public class TableContextMenuTouch extends AbstractTestUI {
@@ -58,36 +56,25 @@ public class TableContextMenuTouch extends AbstractTestUI {
 
         final CheckBox immediateCheckBox = new CheckBox("Immediate");
         vlay.addComponent(immediateCheckBox);
-        immediateCheckBox.addValueChangeListener(new ValueChangeListener() {
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                table.setImmediate(immediateCheckBox.getValue());
-            }
-        });
+        immediateCheckBox.addValueChangeListener(
+                event -> table.setImmediate(immediateCheckBox.getValue()));
         immediateCheckBox.setValue(true);
         table.setImmediate(immediateCheckBox.getValue());
 
         final CheckBox selectableCheckBox = new CheckBox("Selectable");
         final CheckBox multiselectCheckBox = new CheckBox("Multiselect");
         vlay.addComponent(selectableCheckBox);
-        selectableCheckBox.addValueChangeListener(new ValueChangeListener() {
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                table.setSelectable(selectableCheckBox.getValue());
-                multiselectCheckBox.setEnabled(selectableCheckBox.getValue());
-            }
+        selectableCheckBox.addValueChangeListener(event -> {
+            table.setSelectable(selectableCheckBox.getValue());
+            multiselectCheckBox.setEnabled(selectableCheckBox.getValue());
         });
         selectableCheckBox.setValue(true);
         multiselectCheckBox.setEnabled(selectableCheckBox.getValue());
         table.setSelectable(selectableCheckBox.getValue());
 
         vlay.addComponent(multiselectCheckBox);
-        multiselectCheckBox.addValueChangeListener(new ValueChangeListener() {
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                table.setMultiSelect(multiselectCheckBox.getValue());
-            }
-        });
+        multiselectCheckBox.addValueChangeListener(
+                event -> table.setMultiSelect(multiselectCheckBox.getValue()));
         multiselectCheckBox.setValue(true);
         table.setMultiSelect(multiselectCheckBox.getValue());
 
index 055820210a3e1d1c373a46c4ddcbc08ac4167bde..3b3c78923220a2b5d97df99f9ec84f00454016f6 100644 (file)
@@ -1,7 +1,5 @@
 package com.vaadin.tests.components.table;
 
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
 import com.vaadin.tests.components.AbstractTestCase;
 import com.vaadin.ui.CheckBox;
 import com.vaadin.ui.LegacyWindow;
@@ -11,7 +9,7 @@ import com.vaadin.ui.Table;
  * Setting table height and setting column header mode as hidden leaves the body
  * height of the table as it would be with the headers visible and leaves an
  * empty area below the body.
- * 
+ *
  */
 @SuppressWarnings("serial")
 public class TableHeightWhenHidingHeaders extends AbstractTestCase {
@@ -32,23 +30,19 @@ public class TableHeightWhenHidingHeaders extends AbstractTestCase {
         table.addItem("2").getItemProperty("Name").setValue("Item 2");
 
         CheckBox showHeaders = new CheckBox("Show headers");
-        showHeaders.addListener(new ValueChangeListener() {
+        showHeaders.addValueChangeListener(event -> {
+            if (event.getValue()) {
+                // table body height is now 77px, which together
+                // with header makes 100px
+                table.setColumnHeaderMode(Table.COLUMN_HEADER_MODE_EXPLICIT_DEFAULTS_ID);
+            } else {
+                table.setColumnHeaderMode(Table.COLUMN_HEADER_MODE_HIDDEN);
+                // header disappears, but table body height stays at
+                // 77px
+                // and below the body is an empty area (same height
+                // as header would
+                // have)
 
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                if ((Boolean) event.getProperty().getValue()) {
-                    // table body height is now 77px, which together
-                    // with header makes 100px
-                    table.setColumnHeaderMode(Table.COLUMN_HEADER_MODE_EXPLICIT_DEFAULTS_ID);
-                } else {
-                    table.setColumnHeaderMode(Table.COLUMN_HEADER_MODE_HIDDEN);
-                    // header disappears, but table body height stays at
-                    // 77px
-                    // and below the body is an empty area (same height
-                    // as header would
-                    // have)
-
-                }
             }
         });
         showHeaders.setValue(true);
index 809e639448f4c1ddcaa4570ee0f3a29fb68bef86..9c4802e736ac7ad1e68f93c172de5431e573974f 100644 (file)
@@ -2,8 +2,6 @@ package com.vaadin.tests.components.table;
 
 import com.vaadin.data.Container;
 import com.vaadin.data.Item;
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
 import com.vaadin.data.util.IndexedContainer;
 import com.vaadin.server.VaadinRequest;
 import com.vaadin.tests.components.AbstractTestUI;
@@ -28,37 +26,20 @@ public class TableItemDescriptionGeneratorUI extends AbstractTestUI {
         final Table table = createTable();
         table.setId("table");
         componentDescription = new CheckBox("Tooltip on components");
-        componentDescription.addValueChangeListener(new ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                table.setContainerDataSource(createContainer(componentDescription
-                        .getValue()));
-            }
-        });
+        componentDescription
+                .addValueChangeListener(event -> table.setContainerDataSource(
+                        createContainer(componentDescription.getValue())));
         componentDescription.setImmediate(true);
         componentDescription.setValue(true);
         tableCellItemDescription = new CheckBox("Tooltip on table cells");
         tableCellItemDescription
-                .addValueChangeListener(new ValueChangeListener() {
-
-                    @Override
-                    public void valueChange(ValueChangeEvent event) {
-                        table.refreshRowCache();
-                    }
-                });
+                .addValueChangeListener(event -> table.refreshRowCache());
         tableCellItemDescription.setImmediate(true);
         tableCellItemDescription.setValue(true);
 
         tableRowItemDescription = new CheckBox("Tooltip on table Rows");
         tableRowItemDescription
-                .addValueChangeListener(new ValueChangeListener() {
-
-                    @Override
-                    public void valueChange(ValueChangeEvent event) {
-                        table.refreshRowCache();
-                    }
-                });
+                .addValueChangeListener(event -> table.refreshRowCache());
         tableRowItemDescription.setImmediate(true);
         tableRowItemDescription.setValue(true);
 
index 7e75e8a32d3d28e0cc387f402b2091d1780bc4ac..f9cac0e1f8118cbe52e8df4f6e66ebcc9a60af37 100644 (file)
@@ -1,7 +1,5 @@
 package com.vaadin.tests.components.table;
 
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
 import com.vaadin.tests.components.TestBase;
 import com.vaadin.ui.CheckBox;
 import com.vaadin.ui.Table;
@@ -13,12 +11,8 @@ public class TableScrollOnFocus extends TestBase {
         final CheckBox chkSelectable = new CheckBox("selectable");
 
         chkSelectable.setImmediate(true);
-        chkSelectable.addListener(new ValueChangeListener() {
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                table.setSelectable(chkSelectable.getValue());
-            }
-        });
+        chkSelectable.addValueChangeListener(
+                event -> table.setSelectable(chkSelectable.getValue()));
 
         table.addContainerProperty("row #", String.class, "-");
         table.setColumnWidth("row #", 150);
index 3b5949dd407eab9886b795f200529bb06592a100..a0738de8a4550c126cc4df2a74101f852f8439b4 100644 (file)
@@ -7,7 +7,6 @@ import java.util.Locale;
 
 import com.vaadin.data.Property;
 import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
 import com.vaadin.data.util.sqlcontainer.SQLContainer;
 import com.vaadin.data.util.sqlcontainer.connection.JDBCConnectionPool;
 import com.vaadin.data.util.sqlcontainer.connection.SimpleJDBCConnectionPool;
@@ -65,18 +64,14 @@ public class TableSqlContainer extends AbstractTestUI {
         });
 
         final CheckBox editMode = new CheckBox("Edit mode");
-        editMode.addValueChangeListener(new ValueChangeListener() {
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                table.setEditable(editMode.getValue());
-            }
-        });
+        editMode.addValueChangeListener(
+                event -> table.setEditable(editMode.getValue()));
         addComponent(editMode);
     }
 
     /**
      * (Re)creates the test table
-     * 
+     *
      * @param connectionPool
      */
     private void createTestTable(JDBCConnectionPool connectionPool) {
@@ -102,7 +97,7 @@ public class TableSqlContainer extends AbstractTestUI {
 
     /**
      * Adds test data to the test table
-     * 
+     *
      * @param connectionPool
      * @throws SQLException
      */
index 544fe9bb67576e2f3b73f6a8c8df32225d07303e..7705d52cb1cba17d96eb72ce8bd2bfbc023c5e04 100644 (file)
@@ -5,7 +5,6 @@ import java.util.Arrays;
 import com.vaadin.data.Container;
 import com.vaadin.data.Property;
 import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
 import com.vaadin.data.util.IndexedContainer;
 import com.vaadin.tests.components.TestBase;
 import com.vaadin.tests.util.Log;
@@ -83,17 +82,13 @@ public class TableUndefinedSize extends TestBase {
 
         CheckBox cb = new CheckBox("Column 1");
         cb.setValue(true);
-        cb.addListener(new ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                Boolean value = (Boolean) event.getProperty().getValue();
-                tbl.setColumnCollapsed("Column 1", !value);
-                if (value) {
-                    log.log("Column 1 visible");
-                } else {
-                    log.log("Column 1 hidden");
-                }
+        cb.addValueChangeListener(event -> {
+            Boolean value = event.getValue();
+            tbl.setColumnCollapsed("Column 1", !value);
+            if (value) {
+                log.log("Column 1 visible");
+            } else {
+                log.log("Column 1 hidden");
             }
         });
         cb.setImmediate(true);
@@ -101,18 +96,14 @@ public class TableUndefinedSize extends TestBase {
 
         cb = new CheckBox("Column 2");
         cb.setValue(true);
-        cb.addListener(new ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                Boolean value = (Boolean) event.getProperty().getValue();
-                tbl.setColumnCollapsed("Column 2", !value);
-
-                if (value) {
-                    log.log("Column 2 visible");
-                } else {
-                    log.log("Column 2 hidden");
-                }
+        cb.addValueChangeListener(event -> {
+            Boolean value = event.getValue();
+            tbl.setColumnCollapsed("Column 2", !value);
+
+            if (value) {
+                log.log("Column 2 visible");
+            } else {
+                log.log("Column 2 hidden");
             }
         });
         cb.setImmediate(true);
@@ -120,19 +111,15 @@ public class TableUndefinedSize extends TestBase {
 
         cb = new CheckBox("Column 3");
         cb.setValue(true);
-        cb.addListener(new ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                Boolean value = (Boolean) event.getProperty().getValue();
+        cb.addValueChangeListener(event -> {
+            Boolean value = event.getValue();
 
-                tbl.setColumnCollapsed("Column 3", !value);
+            tbl.setColumnCollapsed("Column 3", !value);
 
-                if (value) {
-                    log.log("Column 3 visible");
-                } else {
-                    log.log("Column 3 hidden");
-                }
+            if (value) {
+                log.log("Column 3 visible");
+            } else {
+                log.log("Column 3 hidden");
             }
         });
         cb.setImmediate(true);
index c571329d14e86d70e6e7ce3f7fc1ba25e0f1bbfd..ad34d5020838a398f9f5bb1cdad4450620141ec4 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * Copyright 2000-2014 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
@@ -19,8 +19,6 @@ import java.lang.reflect.InvocationTargetException;
 
 import com.vaadin.data.Item;
 import com.vaadin.data.Property;
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
 import com.vaadin.data.util.IndexedContainer;
 import com.vaadin.event.ListenerMethod.MethodException;
 import com.vaadin.server.ErrorEvent;
@@ -45,11 +43,11 @@ public class TableWithBrokenGeneratorAndContainer extends TestBase {
     /**
      * Container which throws an exception on every fifth call to
      * {@link #getContainerProperty(Object, Object)}.
-     * 
+     *
      * @author Vaadin Ltd
      * @version @VERSION@
      * @since 7.0
-     * 
+     *
      */
     public class BrokenContainer extends IndexedContainer {
         private int counter = 0;
@@ -96,13 +94,9 @@ public class TableWithBrokenGeneratorAndContainer extends TestBase {
         brokenContainer.setImmediate(true);
         brokenGenerator.setImmediate(true);
         clearTableOnError.setImmediate(true);
-        clearTableOnError.addValueChangeListener(new ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                Boolean value = clearTableOnError.getValue();
-                setErrorHandler(value != null ? value : false);
-            }
+        clearTableOnError.addValueChangeListener(event -> {
+            Boolean value = clearTableOnError.getValue();
+            setErrorHandler(value != null ? value : false);
         });
         final Table table = new Table("Semi-broken table");
         table.setContainerDataSource(createBrokenContainer(10, 4));
index b0622e748ceb8bc7bcff313507f1a4787a6a4ff1..58abce830b5ec562a85c991d14e34cc847e6aafb 100644 (file)
@@ -37,13 +37,9 @@ public class ValueAfterClearingContainer extends TestBase {
         final CheckBox multiselect = new CheckBox("Multiselect");
         multiselect.setImmediate(true);
         multiselect.setId("multiselect");
-        multiselect.addValueChangeListener(new ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                Boolean value = multiselect.getValue();
-                table.setMultiSelect(value == null ? false : value);
-            }
+        multiselect.addValueChangeListener(event -> {
+            Boolean value = multiselect.getValue();
+            table.setMultiSelect(value == null ? false : value);
         });
         addComponent(multiselect);
         Button addItemsButton = new Button("Add table items",
index 8672d4019e0d690d7bc2ecb71d1e1ccc890e611d..a157029e1aad48cb6efe5d181ec923387bd1da4f 100644 (file)
@@ -1,7 +1,5 @@
 package com.vaadin.tests.components.textarea;
 
-import com.vaadin.data.Property;
-import com.vaadin.data.Property.ValueChangeEvent;
 import com.vaadin.tests.components.TestBase;
 import com.vaadin.tests.util.LoremIpsum;
 import com.vaadin.ui.CheckBox;
@@ -30,17 +28,13 @@ public class Wordwrap extends TestBase {
 
         CheckBox onoff = new CheckBox("Wrap state for the right field");
         onoff.setValue(false);
-        onoff.addListener(new Property.ValueChangeListener() {
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                boolean wrap = (Boolean) event.getProperty().getValue();
-                area2.setWordwrap(wrap);
-                if (wrap) {
-                    area2.setCaption("Wrapping");
-                } else {
-                    area2.setCaption("Nonwrapping");
-                }
-
+        onoff.addValueChangeListener(event -> {
+            boolean wrap = event.getValue();
+            area2.setWordwrap(wrap);
+            if (wrap) {
+                area2.setCaption("Wrapping");
+            } else {
+                area2.setCaption("Nonwrapping");
             }
         });
         onoff.setImmediate(true);
index d63d7ddc6654cd7e89e02b3a1e13eb55d8fa61da..c382524b37815f4247ea32326a7f7f24e2244b44 100644 (file)
@@ -1,7 +1,5 @@
 package com.vaadin.tests.components.textfield;
 
-import com.vaadin.data.Property;
-import com.vaadin.data.Property.ValueChangeEvent;
 import com.vaadin.tests.components.TestBase;
 import com.vaadin.ui.AbstractTextField;
 import com.vaadin.ui.Button;
@@ -27,17 +25,14 @@ public class SelectionAndCursorPosition extends TestBase {
         panel.setCaption("Hackers panel");
         CheckBox ml = new CheckBox("Multiline");
         ml.setImmediate(true);
-        ml.addListener(new Property.ValueChangeListener() {
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                if (textField.getUI() == null
-                        || textField.getUI().getSession() == null) {
-                    replaceComponent(textArea, textField);
-                    activeComponent = textField;
-                } else {
-                    replaceComponent(textField, textArea);
-                    activeComponent = textArea;
-                }
+        ml.addValueChangeListener(event -> {
+            if (textField.getUI() == null
+                    || textField.getUI().getSession() == null) {
+                replaceComponent(textArea, textField);
+                activeComponent = textField;
+            } else {
+                replaceComponent(textField, textArea);
+                activeComponent = textArea;
             }
         });
         fl.addComponent(ml);
index da4ea9de0baaa7c8f158e5654e8874d6c5bc8a1a..cd08db9cd9a45f43af2a34c1bb23f9c5e1596119 100644 (file)
@@ -1,7 +1,5 @@
 package com.vaadin.tests.components.textfield;
 
-import com.vaadin.data.Property;
-import com.vaadin.data.Property.ValueChangeEvent;
 import com.vaadin.tests.components.TestBase;
 import com.vaadin.ui.CheckBox;
 import com.vaadin.ui.TextField;
@@ -27,16 +25,12 @@ public class SetTabIndex extends TestBase {
 
         final CheckBox readonly = new CheckBox("Readonly");
         readonly.setImmediate(true);
-        readonly.addListener(new Property.ValueChangeListener() {
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                boolean readonly = Boolean.valueOf(event.getProperty()
-                        .getValue().toString());
-                field1.setReadOnly(readonly);
-                field2.setReadOnly(readonly);
-                field3.setReadOnly(readonly);
-                field0.setReadOnly(readonly);
-            }
+        readonly.addValueChangeListener(event -> {
+            boolean newReadonly = event.getValue();
+            field1.setReadOnly(newReadonly);
+            field2.setReadOnly(newReadonly);
+            field3.setReadOnly(newReadonly);
+            field0.setReadOnly(newReadonly);
         });
         addComponent(readonly);
 
index d52efa05720f7a6607c3fff8f99c646d9bb7998f..9f7a023603497bb3cda6a088544f1aaeb8c04559 100644 (file)
@@ -1,7 +1,5 @@
 package com.vaadin.tests.components.textfield;
 
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
 import com.vaadin.event.ShortcutAction.KeyCode;
 import com.vaadin.tests.components.TestBase;
 import com.vaadin.tests.util.Log;
@@ -28,16 +26,13 @@ public class TextFieldInputPromptAndClickShortcut extends TestBase {
 
         final CheckBox inputPromptSelection = new CheckBox("Input prompt");
         inputPromptSelection.setImmediate(true);
-        inputPromptSelection.addListener(new ValueChangeListener() {
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                if (event.getProperty().getValue() == Boolean.TRUE) {
-                    textField.setInputPrompt("Input prompt");
-                } else {
-                    textField.setInputPrompt(null);
-                }
-                log.log("Set input prompt: " + textField.getInputPrompt());
+        inputPromptSelection.addValueChangeListener(event -> {
+            if (event.getValue()) {
+                textField.setInputPrompt("Input prompt");
+            } else {
+                textField.setInputPrompt(null);
             }
+            log.log("Set input prompt: " + textField.getInputPrompt());
         });
         inputPromptSelection.setImmediate(true);
 
index ab9bcd9a998f82bfe00670b9b4c95d7cf857b5d6..5c2d4d8e39a6780b22773c46134ccbf3f5a05407 100644 (file)
@@ -1,8 +1,6 @@
 package com.vaadin.tests.components.tree;
 
 import com.vaadin.data.Item;
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
 import com.vaadin.data.util.HierarchicalContainer;
 import com.vaadin.event.dd.DragAndDropEvent;
 import com.vaadin.event.dd.DropHandler;
@@ -25,15 +23,11 @@ public class TreeConnectors extends TestBase {
         CheckBox cb = new CheckBox("Connectors");
         cb.setValue(false);
         cb.setImmediate(true);
-        cb.addListener(new ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                if ((Boolean) event.getProperty().getValue()) {
-                    tree.addStyleName(BaseTheme.TREE_CONNECTORS);
-                } else {
-                    tree.removeStyleName(BaseTheme.TREE_CONNECTORS);
-                }
+        cb.addValueChangeListener(event -> {
+            if (event.getValue()) {
+                tree.addStyleName(BaseTheme.TREE_CONNECTORS);
+            } else {
+                tree.removeStyleName(BaseTheme.TREE_CONNECTORS);
             }
         });
         addComponent(cb);
index 6df69c850b25baac1a7a67db038990b3d30d9f90..b200e5cc7c111c338a037baa003d5728586dc644 100644 (file)
@@ -1,8 +1,6 @@
 package com.vaadin.tests.components.tree;
 
 import com.vaadin.data.Item;
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
 import com.vaadin.data.util.HierarchicalContainer;
 import com.vaadin.tests.components.TestBase;
 import com.vaadin.ui.Button;
@@ -45,14 +43,9 @@ public class TreeFiltering extends TestBase {
         final CheckBox filterType = new CheckBox(
                 "Include parent when filtering", true);
         filterType.setImmediate(true);
-        filterType.addListener(new ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                cont.setIncludeParentsWhenFiltering(((CheckBox) event
-                        .getProperty()).getValue());
-                ccTree.markAsDirty();
-            }
+        filterType.addValueChangeListener(event -> {
+            cont.setIncludeParentsWhenFiltering(event.getValue());
+            ccTree.markAsDirty();
         });
         addComponent(filterType);
 
index b20b7c3aab665d0434b339c8730a32a0f8bbbbbc..c8796fd8ce3facaa1b38387e03484e8550c4b2f9 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * Copyright 2000-2014 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
@@ -15,8 +15,6 @@
  */
 package com.vaadin.tests.components.tree;
 
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
 import com.vaadin.server.VaadinRequest;
 import com.vaadin.tests.components.AbstractTestUI;
 import com.vaadin.ui.CheckBox;
@@ -45,12 +43,8 @@ public class TreeHtmlContentAllowed extends AbstractTestUI {
 
         final CheckBox toggle = new CheckBox("HTML content allowed",
                 tree.isHtmlContentAllowed());
-        toggle.addValueChangeListener(new ValueChangeListener() {
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                tree.setHtmlContentAllowed(toggle.getValue().booleanValue());
-            }
-        });
+        toggle.addValueChangeListener(event -> tree
+                .setHtmlContentAllowed(toggle.getValue().booleanValue()));
 
         addComponents(tree, toggle);
     }
index dd98024f1cddf9e6a96b0027973bd9b3989f2bb7..70d83a466bfa430d06d60a441e492e87d323b4d8 100644 (file)
@@ -1,7 +1,5 @@
 package com.vaadin.tests.components.window;
 
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
 import com.vaadin.server.Page.BrowserWindowResizeEvent;
 import com.vaadin.server.Page.BrowserWindowResizeListener;
 import com.vaadin.shared.ui.label.ContentMode;
@@ -66,41 +64,24 @@ public class LazyWindowResize extends AbstractTestCase {
 
         lazyMode = new CheckBox("Lazy resize");
         lazyMode.setImmediate(true);
-        lazyMode.addListener(new ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                setLazy(lazyMode.getValue());
-            }
-        });
+        lazyMode.addValueChangeListener(event -> setLazy(lazyMode.getValue()));
 
         resizeListenerCheckBox = new CheckBox("Resize listener");
         resizeListenerCheckBox.setImmediate(true);
-        resizeListenerCheckBox.addListener(new ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                if (resizeListenerCheckBox.getValue()) {
-                    subWindow.addListener(resizeListener);
-                    mainWindow.addListener(browserWindowResizeListener);
-                } else {
-                    subWindow.removeListener(resizeListener);
-                    mainWindow.removeListener(browserWindowResizeListener);
-                }
-
+        resizeListenerCheckBox.addValueChangeListener(event -> {
+            if (resizeListenerCheckBox.getValue()) {
+                subWindow.addListener(resizeListener);
+                mainWindow.addListener(browserWindowResizeListener);
+            } else {
+                subWindow.removeListener(resizeListener);
+                mainWindow.removeListener(browserWindowResizeListener);
             }
-
         });
         immediateCheckBox = new CheckBox("Windows immediate");
         immediateCheckBox.setImmediate(true);
-        immediateCheckBox.addListener(new ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                mainWindow.setImmediate(immediateCheckBox.getValue());
-                subWindow.setImmediate(immediateCheckBox.getValue());
-            }
-
+        immediateCheckBox.addValueChangeListener(event -> {
+            mainWindow.setImmediate(immediateCheckBox.getValue());
+            subWindow.setImmediate(immediateCheckBox.getValue());
         });
         mainWindow.addComponent(lazyMode);
         mainWindow.addComponent(resizeListenerCheckBox);
index a8102a7d1a68d469d854ac85d062baca95408eec..fef6b9c58bc10459e39c4ab19ac28787faa88905 100644 (file)
@@ -101,23 +101,13 @@ public class WindowMaximizeRestoreTest extends AbstractTestUI {
         });
         final CheckBox resizeable = new CheckBox("Resizeable");
         resizeable.setValue(w.isResizable());
-        resizeable.addValueChangeListener(new ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                w.setResizable(resizeable.getValue());
-            }
-        });
+        resizeable.addValueChangeListener(
+                event -> w.setResizable(resizeable.getValue()));
         ((ComponentContainer) w.getContent()).addComponent(resizeable);
         final CheckBox closeable = new CheckBox("Closeable");
         closeable.setValue(w.isClosable());
-        closeable.addValueChangeListener(new ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                w.setClosable(closeable.getValue());
-            }
-        });
+        closeable.addValueChangeListener(
+                event -> w.setClosable(closeable.getValue()));
         ((ComponentContainer) w.getContent()).addComponent(closeable);
         NativeButton contentFull = new NativeButton("Set Content Size Full",
                 new Button.ClickListener() {
index e66767dac98fff4b2544580b3dde6481ab61842e..a662ee7175e60f1f104828c1150b3d7d12d6ece2 100644 (file)
@@ -1,7 +1,5 @@
 package com.vaadin.tests.components.window;
 
-import com.vaadin.data.Property;
-import com.vaadin.data.Property.ValueChangeEvent;
 import com.vaadin.server.Page;
 import com.vaadin.server.Page.BrowserWindowResizeEvent;
 import com.vaadin.tests.components.TestBase;
@@ -44,28 +42,20 @@ public class WindowResizeListener extends TestBase {
 
         CheckBox subwindow = new CheckBox("show subwindow");
         subwindow.setImmediate(true);
-        subwindow.addListener(new Property.ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                if ((Boolean) event.getProperty().getValue()) {
-                    getMainWindow().addWindow(subwin);
-                } else {
-                    getMainWindow().removeWindow(subwin);
-                }
+        subwindow.addValueChangeListener(event -> {
+            if (event.getValue()) {
+                getMainWindow().addWindow(subwin);
+            } else {
+                getMainWindow().removeWindow(subwin);
             }
         });
         getLayout().addComponent(subwindow);
 
         CheckBox immediate = new CheckBox("immediate");
-        immediate.addListener(new Property.ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                boolean booleanValue = (Boolean) event.getProperty().getValue();
-                getMainWindow().setImmediate(booleanValue);
-                subwin.setImmediate(booleanValue);
-            }
+        immediate.addValueChangeListener(event -> {
+            boolean booleanValue = event.getValue();
+            getMainWindow().setImmediate(booleanValue);
+            subwin.setImmediate(booleanValue);
         });
         immediate.setImmediate(true);
         immediate.setValue(true);
index 8b8ad4cf70a828df222bb684f2b781b3804b53de..02aa099646f9e395ec3e2fdadc40901f2949efe2 100644 (file)
@@ -1,8 +1,6 @@
 package com.vaadin.tests.containers;
 
 import com.vaadin.data.Item;
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
 import com.vaadin.data.util.BeanItemContainer;
 import com.vaadin.server.Sizeable;
 import com.vaadin.tests.components.TestBase;
@@ -87,15 +85,11 @@ public class BeanItemContainerFilteringTest extends TestBase {
             vl.addComponent(filterString);
 
             final CheckBox cb = new CheckBox("Filter on value");
-            cb.addListener(new ValueChangeListener() {
-
-                @Override
-                public void valueChange(ValueChangeEvent event) {
-                    container.removeAllContainerFilters();
-                    if (((CheckBox) event.getProperty()).getValue()) {
-                        container.addContainerFilter("value", filterString
-                                .getValue().toString(), false, false);
-                    }
+            cb.addValueChangeListener(event -> {
+                container.removeAllContainerFilters();
+                if (event.getValue()) {
+                    container.addContainerFilter("value",
+                            filterString.getValue().toString(), false, false);
                 }
             });
             cb.setImmediate(true);
index a1dba3eed8b9d1b47669e3e68fe86321829f6a85..357d0927b35c4020400ae07a72614fc2e95e5d56 100644 (file)
@@ -1,8 +1,6 @@
 package com.vaadin.tests.containers;
 
 import com.vaadin.data.Item;
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
 import com.vaadin.data.util.IndexedContainer;
 import com.vaadin.server.Sizeable;
 import com.vaadin.tests.components.TestBase;
@@ -54,15 +52,11 @@ public class IndexedContainerFilteringTest extends TestBase {
         vl.addComponent(filterString);
 
         final CheckBox cb = new CheckBox("Filter");
-        cb.addListener(new ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                container.removeAllContainerFilters();
-                if (((CheckBox) event.getProperty()).getValue()) {
-                    container.addContainerFilter("column1", filterString
-                            .getValue().toString(), false, false);
-                }
+        cb.addValueChangeListener(event -> {
+            container.removeAllContainerFilters();
+            if (event.getValue()) {
+                container.addContainerFilter("column1", filterString
+                        .getValue().toString(), false, false);
             }
         });
         cb.setImmediate(true);
index b86cb361c0ea2da1d79a76580da37d45ef90a231..b44f8c5a9937a095a8c072f2b5aeca696b3adb9e 100644 (file)
@@ -6,8 +6,6 @@ import java.util.HashMap;
 import java.util.Iterator;
 
 import com.vaadin.data.Container;
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
 import com.vaadin.data.util.BeanItem;
 import com.vaadin.data.util.BeanItemContainer;
 import com.vaadin.data.util.HierarchicalContainer;
@@ -37,24 +35,16 @@ public class TreeDragStart extends TestBase {
         CheckBox checkBox = new CheckBox("Enabled");
         checkBox.setImmediate(true);
         checkBox.setValue(true);
-        checkBox.addListener(new ValueChangeListener() {
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                tree.setEnabled(!tree.isEnabled());
-            }
-        });
+        checkBox.addValueChangeListener(event -> tree.setEnabled(!tree.isEnabled()));
         addComponent(checkBox);
         checkBox = new CheckBox("Drag start");
         checkBox.setImmediate(true);
         checkBox.setValue(true);
-        checkBox.addListener(new ValueChangeListener() {
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                if (((CheckBox) event.getProperty()).getValue()) {
-                    tree.setDragMode(TreeDragMode.NODE);
-                } else {
-                    tree.setDragMode(TreeDragMode.NONE);
-                }
+        checkBox.addValueChangeListener(event -> {
+            if (event.getValue()) {
+                tree.setDragMode(TreeDragMode.NODE);
+            } else {
+                tree.setDragMode(TreeDragMode.NONE);
             }
         });
         addComponent(checkBox);
index 47589ccd26080d1c57b576d6d6afca078e2422ec..44c3cd23b8d2619ddd0fdbde2c2f039227c4a557 100644 (file)
@@ -18,6 +18,7 @@ import com.vaadin.tests.data.bean.Person;
 import com.vaadin.tests.data.bean.Sex;
 import com.vaadin.ui.Button;
 import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.CheckBox;
 import com.vaadin.ui.ComponentContainer;
 import com.vaadin.ui.Notification;
 import com.vaadin.ui.Panel;
@@ -60,21 +61,16 @@ public class BasicPersonForm extends AbstractTestUIWithLog {
     private Configuration configuration = new Configuration();
 
     private class ConfigurationPanel extends Panel {
+        private CheckBox preCommitCheckBox = new CheckBox("Pre Commit Fails", configuration.isPreCommitFails());
+        private CheckBox postCommitCheckBox = new CheckBox("Post Commit Fails", configuration.isPostCommitFails());
 
         public ConfigurationPanel() {
             super("Configuration", new VerticalLayout());
             ((VerticalLayout) getContent()).setMargin(true);
-            BeanItem<Configuration> bi = new BeanItem<BasicPersonForm.Configuration>(
-                    configuration);
-            FieldGroup confFieldGroup = new FieldGroup(bi);
-            confFieldGroup.setItemDataSource(bi);
-            confFieldGroup.setBuffered(false);
-
-            for (Object propertyId : bi.getItemPropertyIds()) {
-                ((ComponentContainer) getContent())
-                        .addComponent(confFieldGroup.buildAndBind(propertyId));
-            }
+            preCommitCheckBox.addValueChangeListener(event -> configuration.setPreCommitFails(event.getValue()));
+            postCommitCheckBox.addValueChangeListener(event -> configuration.setPostCommitFails(event.getValue()));
 
+            ((ComponentContainer) getContent()).addComponents(preCommitCheckBox, postCommitCheckBox);
         }
     }
 
index 77c0723cdd10aea67a8bfe5b21966ae8e9eb073a..8a9449768620f333b73e3b7be9cd4a850aee98b1 100644 (file)
@@ -1,7 +1,5 @@
 package com.vaadin.tests.integration;
 
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
 import com.vaadin.server.Page;
 import com.vaadin.server.Page.BrowserWindowResizeEvent;
 import com.vaadin.tests.components.TestBase;
@@ -21,14 +19,10 @@ public class EmbedSizeTest extends TestBase {
         mainWindow.setImmediate(true);
 
         CheckBox lazyCheckBox = new CheckBox("Lazy resize");
-        lazyCheckBox.addListener(new ValueChangeListener() {
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                CheckBox cb = (CheckBox) event.getProperty();
-                Boolean resizeLazy = cb.getValue();
-                getMainWindow().setResizeLazy(resizeLazy);
-                log.log("Resize lazy: " + resizeLazy);
-            }
+        lazyCheckBox.addValueChangeListener(event -> {
+            boolean resizeLazy = event.getValue();
+            getMainWindow().setResizeLazy(resizeLazy);
+            log.log("Resize lazy: " + resizeLazy);
         });
         lazyCheckBox.setValue(Boolean.FALSE);
         lazyCheckBox.setImmediate(true);
index e506c0ac2975c3d89cf9ca160315795608e525e5..5e9fc8224ac9ca7adf7058e3820f258bc2c8e0b5 100644 (file)
@@ -81,13 +81,8 @@ public class CaptionsInLayouts extends AbstractTestUI {
         CheckBox requiredToggle = new CheckBox();
         requiredToggle.setImmediate(true);
         requiredToggle.setCaption("Required");
-        requiredToggle.addListener(new ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                setRequired((Boolean) event.getProperty().getValue());
-            }
-        });
+        requiredToggle
+                .addValueChangeListener(event -> setRequired(event.getValue()));
         return requiredToggle;
     }
 
@@ -95,13 +90,7 @@ public class CaptionsInLayouts extends AbstractTestUI {
         CheckBox iconToggle = new CheckBox();
         iconToggle.setImmediate(true);
         iconToggle.setCaption("Icons");
-        iconToggle.addListener(new ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                setIcon((Boolean) event.getProperty().getValue());
-            }
-        });
+        iconToggle.addValueChangeListener(event -> setIcon(event.getValue()));
         return iconToggle;
     }
 
@@ -127,13 +116,7 @@ public class CaptionsInLayouts extends AbstractTestUI {
         CheckBox errorToggle = new CheckBox();
         errorToggle.setImmediate(true);
         errorToggle.setCaption("Error");
-        errorToggle.addListener(new ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                setError((Boolean) event.getProperty().getValue());
-            }
-        });
+        errorToggle.addValueChangeListener(event -> setError(event.getValue()));
         return errorToggle;
     }
 
index 77ec82003e6e84e2629fb907101637114d45c324..89e2d9b1fa246712a1d9b254ad497c20aa43bcbb 100644 (file)
@@ -3,13 +3,14 @@ package com.vaadin.tests.layouts;
 import java.util.ArrayList;
 import java.util.List;
 
+import com.vaadin.data.HasRequired;
 import com.vaadin.data.Item;
 import com.vaadin.data.Property.ValueChangeEvent;
 import com.vaadin.data.Property.ValueChangeListener;
-import com.vaadin.legacy.ui.LegacyAbstractField;
 import com.vaadin.server.ThemeResource;
 import com.vaadin.server.UserError;
 import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.AbstractComponent;
 import com.vaadin.ui.Button;
 import com.vaadin.ui.Button.ClickEvent;
 import com.vaadin.ui.Button.ClickListener;
@@ -41,7 +42,7 @@ public class CaptionsInLayoutsWaiAria extends TestBase {
     private HorizontalLayout horizontalLayout;
     private GridLayout gridLayout;
     private FormLayout formLayout;
-    private List<LegacyAbstractField<?>> components = new ArrayList<LegacyAbstractField<?>>();
+    private List<AbstractComponent> components = new ArrayList<>();
     private CssLayout cssLayout;
     private HorizontalLayout layoutParent = new HorizontalLayout();
 
@@ -78,7 +79,7 @@ public class CaptionsInLayoutsWaiAria extends TestBase {
     }
 
     protected void prependCaptions(String prepend) {
-        for (LegacyAbstractField<?> c : components) {
+        for (Component c : components) {
             c.setCaption(prepend + c.getCaption());
         }
 
@@ -88,13 +89,8 @@ public class CaptionsInLayoutsWaiAria extends TestBase {
         CheckBox requiredToggle = new CheckBox();
         requiredToggle.setImmediate(true);
         requiredToggle.setCaption("Required");
-        requiredToggle.addListener(new ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                setRequired((Boolean) event.getProperty().getValue());
-            }
-        });
+        requiredToggle
+                .addValueChangeListener(event -> setRequired(event.getValue()));
         return requiredToggle;
     }
 
@@ -102,13 +98,7 @@ public class CaptionsInLayoutsWaiAria extends TestBase {
         CheckBox iconToggle = new CheckBox();
         iconToggle.setImmediate(true);
         iconToggle.setCaption("Icons");
-        iconToggle.addListener(new ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                setIcon((Boolean) event.getProperty().getValue());
-            }
-        });
+        iconToggle.addValueChangeListener(event -> setIcon(event.getValue()));
         return iconToggle;
     }
 
@@ -116,12 +106,8 @@ public class CaptionsInLayoutsWaiAria extends TestBase {
         CheckBox readOnlyToggle = new CheckBox();
         readOnlyToggle.setImmediate(true);
         readOnlyToggle.setCaption("Read only");
-        readOnlyToggle.addValueChangeListener(new ValueChangeListener() {
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                setReadOnly((Boolean) event.getProperty().getValue());
-            }
-        });
+        readOnlyToggle
+                .addValueChangeListener(event -> setReadOnly(event.getValue()));
 
         return readOnlyToggle;
     }
@@ -131,12 +117,8 @@ public class CaptionsInLayoutsWaiAria extends TestBase {
         enabledToggle.setImmediate(true);
         enabledToggle.setValue(true);
         enabledToggle.setCaption("Enabled");
-        enabledToggle.addValueChangeListener(new ValueChangeListener() {
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                setEnabled((Boolean) event.getProperty().getValue());
-            }
-        });
+        enabledToggle
+                .addValueChangeListener(event -> setEnabled(event.getValue()));
 
         return enabledToggle;
     }
@@ -144,12 +126,7 @@ public class CaptionsInLayoutsWaiAria extends TestBase {
     private Component toggleInvalid() {
         CheckBox invalid = new CheckBox("Invalid");
         invalid.setImmediate(true);
-        invalid.addValueChangeListener(new ValueChangeListener() {
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                setInvalid((Boolean) event.getProperty().getValue());
-            }
-        });
+        invalid.addValueChangeListener(event -> setInvalid(event.getValue()));
 
         return invalid;
     }
@@ -161,20 +138,22 @@ public class CaptionsInLayoutsWaiAria extends TestBase {
                     "Der eingegebene Wert ist nicht zulässig!");
         }
 
-        for (LegacyAbstractField<?> c : components) {
+        for (AbstractComponent c : components) {
             c.setComponentError(userError);
         }
     }
 
     protected void setRequired(boolean value) {
-        for (LegacyAbstractField<?> c : components) {
-            c.setRequired(value);
+        for (AbstractComponent c : components) {
+            if (c instanceof HasRequired) {
+                ((HasRequired) c).setRequired(value);
+            }
         }
 
     }
 
     protected void setIcon(boolean value) {
-        for (LegacyAbstractField<?> c : components) {
+        for (Component c : components) {
             if (!value) {
                 c.setIcon(null);
             } else {
@@ -185,13 +164,13 @@ public class CaptionsInLayoutsWaiAria extends TestBase {
     }
 
     protected void setReadOnly(boolean value) {
-        for (LegacyAbstractField<?> c : components) {
+        for (Component c : components) {
             c.setReadOnly(value);
         }
     }
 
     protected void setEnabled(boolean value) {
-        for (LegacyAbstractField<?> c : components) {
+        for (Component c : components) {
             c.setEnabled(value);
         }
     }
@@ -200,18 +179,12 @@ public class CaptionsInLayoutsWaiAria extends TestBase {
         CheckBox errorToggle = new CheckBox();
         errorToggle.setImmediate(true);
         errorToggle.setCaption("Error");
-        errorToggle.addListener(new ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                setError((Boolean) event.getProperty().getValue());
-            }
-        });
+        errorToggle.addValueChangeListener(event -> setError(event.getValue()));
         return errorToggle;
     }
 
     protected void setError(boolean value) {
-        for (LegacyAbstractField<?> c : components) {
+        for (AbstractComponent c : components) {
             if (value) {
                 c.setComponentError(new UserError("error"));
             } else {
index 2f717d2b64cb2240b58fd62e17f4338c095a57a8..63b5aaba5f330fc9cc88ac2dcb7eb8d9cf2f8e79 100644 (file)
@@ -3,8 +3,6 @@ package com.vaadin.tests.layouts;
 import java.util.HashMap;
 import java.util.Map;
 
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
 import com.vaadin.tests.components.TestBase;
 import com.vaadin.ui.Button;
 import com.vaadin.ui.Button.ClickEvent;
@@ -45,13 +43,8 @@ public class CssLayoutCustomCss extends TestBase implements ClickListener {
     private Component createMarginsToggle() {
         final CheckBox cb = new CheckBox("Margins");
         cb.setImmediate(true);
-        cb.addListener(new ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                ((MarginHandler) layout).setMargin(cb.getValue());
-            }
-        });
+        cb.addValueChangeListener(
+                event -> ((MarginHandler) layout).setMargin(cb.getValue()));
 
         return cb;
     }
index f596fdb77e56751df387603ca951ef7ae3061016..76a3dba08fb9711cf5dd8ae9e4a39a5e3a40520a 100644 (file)
@@ -1,7 +1,5 @@
 package com.vaadin.tests.layouts;
 
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
 import com.vaadin.tests.components.TestBase;
 import com.vaadin.ui.CheckBox;
 import com.vaadin.ui.FormLayout;
@@ -25,15 +23,10 @@ public class FormLayoutWithInvisibleComponent extends TestBase {
     protected void setup() {
         FormLayout formLayout = new FormLayout();
         CheckBox control = new CheckBox("Messages On/Off");
-        control.addListener(new ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                messages.setVisible((Boolean) event.getProperty().getValue());
-                messages.setRequired(true);
-                messages.setCaption("Messages visible");
-            }
-
+        control.addValueChangeListener(event -> {
+            messages.setVisible(event.getValue());
+            messages.setRequired(true);
+            messages.setCaption("Messages visible");
         });
         control.setImmediate(true);
         formLayout.addComponent(control);
index 4e50f0d83b0d547927126cd8d6872808119792ac..dec7c243188d207f726b846aa5f12d34f0636dfe 100644 (file)
@@ -233,7 +233,7 @@ public class LayoutPerformanceTests extends TestBase {
                     return;
                 }
 
-                boolean wrapped = wrapInPanel.booleanValue();
+                boolean wrapped = wrapInPanel.getValue();
                 ComponentContainer container = containerType.buildLayout(
                         ((Number) levels.getValue()).intValue(),
                         ((Number) childAmount.getValue()).intValue(), leafType,
index 528492c33a3af01f024dab2039810a4e5883bb26..c5fa501913c33bb972c23485c73505227602e9fa 100644 (file)
@@ -8,8 +8,6 @@ import java.util.concurrent.TimeUnit;
 import org.apache.commons.lang.SerializationUtils;
 
 import com.vaadin.annotations.Push;
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
 import com.vaadin.server.VaadinRequest;
 import com.vaadin.tests.components.AbstractTestUIWithLog;
 import com.vaadin.ui.AbstractOrderedLayout;
@@ -33,12 +31,8 @@ public class PushRemoveConnectors extends AbstractTestUIWithLog {
     @Override
     protected void setup(VaadinRequest request) {
         final CheckBox pollingEnabled = new CheckBox("Polling enabled");
-        pollingEnabled.addValueChangeListener(new ValueChangeListener() {
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                setPollInterval(pollingEnabled.getValue() ? 1000 : -1);
-            }
-        });
+        pollingEnabled.addValueChangeListener(event -> setPollInterval(
+                pollingEnabled.getValue() ? 1000 : -1));
 
         Button start = new Button("start");
         start.setId(START);
@@ -50,6 +44,7 @@ public class PushRemoveConnectors extends AbstractTestUIWithLog {
                     @Override
                     public void run() {
                         access(new Runnable() {
+                            @Override
                             public void run() {
                                 populate();
                                 log("Serialized session size: "
index e6625451343766b7a74795df8a2b317cf9d5076d..553fa8f24c4c99be1bcee78af2c3023b33181be8 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * Copyright 2000-2014 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
@@ -18,8 +18,6 @@ package com.vaadin.tests.push;
 import java.util.Timer;
 import java.util.TimerTask;
 
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
 import com.vaadin.server.VaadinRequest;
 import com.vaadin.shared.communication.PushMode;
 import com.vaadin.tests.components.AbstractTestUI;
@@ -46,14 +44,11 @@ public class TogglePush extends AbstractTestUI {
         pushSetting.setValue(Boolean.valueOf(getPushConfiguration()
                 .getPushMode().isEnabled()));
         pushSetting.setImmediate(true);
-        pushSetting.addValueChangeListener(new ValueChangeListener() {
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                if (event.getProperty().getValue() == Boolean.TRUE) {
-                    getPushConfiguration().setPushMode(PushMode.AUTOMATIC);
-                } else {
-                    getPushConfiguration().setPushMode(PushMode.DISABLED);
-                }
+        pushSetting.addValueChangeListener(event -> {
+            if (event.getValue()) {
+                getPushConfiguration().setPushMode(PushMode.AUTOMATIC);
+            } else {
+                getPushConfiguration().setPushMode(PushMode.DISABLED);
             }
         });
         addComponent(pushSetting);
index 8ce8c437a4081a16eeb1ded42d3abbd9875121d1..380d83fe28feb8c774bc7f2f44bdb748d3020e7e 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * Copyright 2000-2014 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
@@ -16,8 +16,6 @@
 package com.vaadin.tests.serialization;
 
 import com.vaadin.annotations.Widgetset;
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
 import com.vaadin.server.VaadinRequest;
 import com.vaadin.tests.components.AbstractTestUI;
 import com.vaadin.tests.widgetset.TestingWidgetSet;
@@ -36,14 +34,11 @@ public class NoLayout extends AbstractTestUI {
         addComponent(layoutDetector);
 
         CheckBox uiPolling = new CheckBox("UI polling enabled");
-        uiPolling.addValueChangeListener(new ValueChangeListener() {
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                if (event.getProperty().getValue() == Boolean.TRUE) {
-                    setPollInterval(100);
-                } else {
-                    setPollInterval(-1);
-                }
+        uiPolling.addValueChangeListener(event -> {
+            if (event.getValue()) {
+                setPollInterval(100);
+            } else {
+                setPollInterval(-1);
             }
         });
         addComponent(uiPolling);
index 41d986237c292ca8f76a919fd99eff17b09e916a..862636fa3bceff37fad5c699c57b0938a6e12417 100644 (file)
@@ -1,7 +1,5 @@
 package com.vaadin.tests.themes;
 
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
 import com.vaadin.server.ThemeResource;
 import com.vaadin.server.UserError;
 import com.vaadin.ui.Button;
@@ -32,55 +30,39 @@ public class ButtonsTest extends com.vaadin.server.LegacyApplication {
         setTheme("reindeer");
 
         themeToggle = new CheckBox("Runo theme");
-        themeToggle.addListener(new ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                if (getTheme() == "reindeer") {
-                    setTheme("runo");
-                } else {
-                    setTheme("reindeer");
-                }
+        themeToggle.addValueChangeListener(event -> {
+            if (getTheme() == "reindeer") {
+                setTheme("runo");
+            } else {
+                setTheme("reindeer");
             }
         });
         themeToggle.setStyleName("small");
         themeToggle.setImmediate(true);
 
         styleToggle = new CheckBox("Black style");
-        styleToggle.addListener(new ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                if (!main.getContent().getStyleName().contains("black")) {
-                    main.getContent().setStyleName("black");
-                } else {
-                    main.getContent().setStyleName("");
-                }
+        styleToggle.addValueChangeListener(event -> {
+            if (!main.getContent().getStyleName().contains("black")) {
+                main.getContent().setStyleName("black");
+            } else {
+                main.getContent().setStyleName("");
             }
         });
         styleToggle.setImmediate(true);
         styleToggle.setStyleName("small");
 
         iconToggle = new CheckBox("64x icons");
-        iconToggle.addListener(new ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                largeIcons = !largeIcons;
-                recreateAll();
-            }
+        iconToggle.addValueChangeListener(event -> {
+            largeIcons = !largeIcons;
+            recreateAll();
         });
         iconToggle.setImmediate(true);
         iconToggle.setStyleName("small");
 
         nativeToggle = new CheckBox("Native buttons");
-        nativeToggle.addListener(new ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                nativeButtons = !nativeButtons;
-                recreateAll();
-            }
+        nativeToggle.addValueChangeListener(event -> {
+            nativeButtons = !nativeButtons;
+            recreateAll();
         });
         nativeToggle.setImmediate(true);
         nativeToggle.setStyleName("small");
index e18665f2faf9933937862a272456f90e6a7b9f10..c6f3ba2909c032c63106095dfc00d8af8314211c 100644 (file)
@@ -7,8 +7,8 @@ import java.util.Locale;
 import java.util.TimeZone;
 
 import com.vaadin.annotations.Theme;
+import com.vaadin.data.Binder;
 import com.vaadin.data.Item;
-import com.vaadin.data.Property;
 import com.vaadin.data.Property.ValueChangeEvent;
 import com.vaadin.data.Property.ValueChangeListener;
 import com.vaadin.data.fieldgroup.FieldGroup;
@@ -103,6 +103,7 @@ public class CalendarTest extends GridLayout implements View {
 
     private final FormLayout scheduleEventFieldLayout = new FormLayout();
     private FieldGroup scheduleEventFieldGroup = new FieldGroup();
+    private Binder<CalendarEvent> scheduledEventBinder = new Binder<>();
 
     private Button deleteEventButton;
 
@@ -395,16 +396,8 @@ public class CalendarTest extends GridLayout implements View {
     private void initHideWeekEndButton() {
         hideWeekendsButton = new CheckBox("Hide weekends");
         hideWeekendsButton.setImmediate(true);
-        hideWeekendsButton
-                .addValueChangeListener(new Property.ValueChangeListener() {
-
-                    private static final long serialVersionUID = 1L;
-
-                    @Override
-                    public void valueChange(ValueChangeEvent event) {
-                        setWeekendsHidden(hideWeekendsButton.getValue());
-                    }
-                });
+        hideWeekendsButton.addValueChangeListener(
+                event -> setWeekendsHidden(hideWeekendsButton.getValue()));
     }
 
     private void setWeekendsHidden(boolean weekendsHidden) {
@@ -423,31 +416,15 @@ public class CalendarTest extends GridLayout implements View {
     private void initReadOnlyButton() {
         readOnlyButton = new CheckBox("Read-only mode");
         readOnlyButton.setImmediate(true);
-        readOnlyButton
-                .addValueChangeListener(new Property.ValueChangeListener() {
-
-                    private static final long serialVersionUID = 1L;
-
-                    @Override
-                    public void valueChange(ValueChangeEvent event) {
-                        calendarComponent.setReadOnly(readOnlyButton.getValue());
-                    }
-                });
+        readOnlyButton.addValueChangeListener(event -> calendarComponent
+                .setReadOnly(readOnlyButton.getValue()));
     }
 
     private void initDisabledButton() {
         disabledButton = new CheckBox("Disabled");
         disabledButton.setImmediate(true);
-        disabledButton
-                .addValueChangeListener(new Property.ValueChangeListener() {
-
-                    private static final long serialVersionUID = 1L;
-
-                    @Override
-                    public void valueChange(ValueChangeEvent event) {
-                        calendarComponent.setEnabled(!disabledButton.getValue());
-                    }
-                });
+        disabledButton.addValueChangeListener(event -> calendarComponent
+                .setEnabled(!disabledButton.getValue()));
     }
 
     public void initAddNewEventButton() {
@@ -477,21 +454,12 @@ public class CalendarTest extends GridLayout implements View {
         endDateField = createDateField("End date");
 
         final CheckBox allDayField = createCheckBox("All-day");
-        allDayField.addValueChangeListener(new Property.ValueChangeListener() {
-
-            private static final long serialVersionUID = -7104996493482558021L;
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                Object value = event.getProperty().getValue();
-                if (value instanceof Boolean && Boolean.TRUE.equals(value)) {
-                    setFormDateResolution(Resolution.DAY);
-
-                } else {
-                    setFormDateResolution(Resolution.MINUTE);
-                }
+        allDayField.addValueChangeListener(event -> {
+            if (event.getValue()) {
+                setFormDateResolution(Resolution.DAY);
+            } else {
+                setFormDateResolution(Resolution.MINUTE);
             }
-
         });
 
         captionField = createTextField("Caption");
@@ -528,7 +496,7 @@ public class CalendarTest extends GridLayout implements View {
             scheduleEventFieldGroup.bind(whereField, "where");
         }
         scheduleEventFieldGroup.bind(styleNameField, "styleName");
-        scheduleEventFieldGroup.bind(allDayField, "allDay");
+        scheduledEventBinder.bind(allDayField, CalendarEvent::isAllDay, null);
     }
 
     private CheckBox createCheckBox(String caption) {
@@ -1005,6 +973,7 @@ public class CalendarTest extends GridLayout implements View {
         initFormFields(scheduleEventFieldLayout, event.getClass());
         scheduleEventFieldGroup.setBuffered(true);
         scheduleEventFieldGroup.setItemDataSource(item);
+        scheduledEventBinder.load(event);
     }
 
     private void setFormDateResolution(Resolution resolution) {
@@ -1036,6 +1005,7 @@ public class CalendarTest extends GridLayout implements View {
     private void commitCalendarEvent() throws CommitException {
         scheduleEventFieldGroup.commit();
         BasicEvent event = getFormCalendarEvent();
+        scheduledEventBinder.save(event);
         if (event.getEnd() == null) {
             event.setEnd(event.getStart());
         }
@@ -1048,6 +1018,7 @@ public class CalendarTest extends GridLayout implements View {
 
     private void discardCalendarEvent() {
         scheduleEventFieldGroup.discard();
+        scheduledEventBinder.load(getFormCalendarEvent());
         getUI().removeWindow(scheduleEventPopup);
     }
 
index ea7c42ba2eb211bb490f759d80b59ef0825d4ba8..22626f4d4b9d76adff21ce042d73d868e65c4b82 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * Copyright 2000-2014 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
@@ -689,12 +689,8 @@ public class CommonParts extends VerticalLayout implements View {
                 addComponent(show);
 
                 final CheckBox hidden = new CheckBox("Hidden");
-                hidden.addValueChangeListener(new ValueChangeListener() {
-                    @Override
-                    public void valueChange(ValueChangeEvent event) {
-                        win.setVisible(!hidden.getValue());
-                    }
-                });
+                hidden.addValueChangeListener(
+                        event -> win.setVisible(!hidden.getValue()));
                 addComponent(hidden);
 
                 win.addCloseListener(new CloseListener() {
index 071e6b746a2758c55593bbb24168e20c30b418a5..9938d53238ebdc86aa9c76ca234d175abf0932e5 100644 (file)
@@ -16,8 +16,7 @@
 package com.vaadin.tests.themes.valo;
 
 import com.vaadin.data.Container;
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.data.HasValue;
 import com.vaadin.event.dd.DragAndDropEvent;
 import com.vaadin.event.dd.DropHandler;
 import com.vaadin.event.dd.acceptcriteria.AcceptAll;
@@ -85,35 +84,32 @@ public class Tables extends VerticalLayout implements View {
                 verticalLines, horizontalLines, borderless, headers, compact,
                 small, rowIndex, rowCaption, rowIcon, componentsInCells);
 
-        ValueChangeListener update = new ValueChangeListener() {
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                if (table == null) {
-                    table = new Table();
-                    table.setContainerDataSource(normalContainer);
-                    addComponent(table);
-                }
-                if (hierarchical.getValue() && table instanceof Table) {
-                    removeComponent(table);
-                    table = new TreeTable();
-                    table.setContainerDataSource(hierarchicalContainer);
-                    addComponent(table);
-                } else if (!hierarchical.getValue()
-                        && table instanceof TreeTable) {
-                    removeComponent(table);
-                    table = new Table();
-                    table.setContainerDataSource(normalContainer);
-                    addComponent(table);
-                }
-
-                configure(table, footer.getValue(), sized.getValue(),
-                        expandRatios.getValue(), stripes.getValue(),
-                        verticalLines.getValue(), horizontalLines.getValue(),
-                        borderless.getValue(), headers.getValue(),
-                        compact.getValue(), small.getValue(),
-                        rowIndex.getValue(), rowCaption.getValue(),
-                        rowIcon.getValue(), componentsInCells.getValue());
+        HasValue.ValueChangeListener<Boolean> update = event -> {
+            if (table == null) {
+                table = new Table();
+                table.setContainerDataSource(normalContainer);
+                addComponent(table);
+            }
+            if (hierarchical.getValue() && table instanceof Table) {
+                removeComponent(table);
+                table = new TreeTable();
+                table.setContainerDataSource(hierarchicalContainer);
+                addComponent(table);
+            } else if (!hierarchical.getValue()
+                    && table instanceof TreeTable) {
+                removeComponent(table);
+                table = new Table();
+                table.setContainerDataSource(normalContainer);
+                addComponent(table);
             }
+
+            configure(table, footer.getValue(), sized.getValue(),
+                    expandRatios.getValue(), stripes.getValue(),
+                    verticalLines.getValue(), horizontalLines.getValue(),
+                    borderless.getValue(), headers.getValue(),
+                    compact.getValue(), small.getValue(),
+                    rowIndex.getValue(), rowCaption.getValue(),
+                    rowIcon.getValue(), componentsInCells.getValue());
         };
 
         hierarchical.addValueChangeListener(update);
index 421da5ffe77484aadc6fa1f157438c3f07ea2a60..f808cc1525c4c160d560b98a0e78adab99b881d2 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * Copyright 2000-2014 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
@@ -15,8 +15,7 @@
  */
 package com.vaadin.tests.themes.valo;
 
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.data.HasValue;
 import com.vaadin.navigator.View;
 import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
 import com.vaadin.shared.ui.MarginInfo;
@@ -108,27 +107,24 @@ public class Tabsheets extends VerticalLayout implements View {
         selectedOnly.setImmediate(true);
         wrap.addComponent(selectedOnly);
 
-        ValueChangeListener update = new ValueChangeListener() {
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                String style = framed.getValue() ? "framed " : "";
-                style += centered.getValue() ? " centered-tabs" : "";
-                style += rightAlign.getValue() ? " right-aligned-tabs" : "";
-                style += equal.getValue() ? " equal-width-tabs" : "";
-                style += padded.getValue() ? " padded-tabbar" : "";
-                style += compact.getValue() ? " compact-tabbar" : "";
-                style += iconsOnTop.getValue() ? " icons-on-top" : "";
-                style += selectedOnly.getValue() ? " only-selected-closable"
-                        : "";
-
-                if (tabs != null) {
-                    removeComponent(tabs);
-                }
-                tabs = getTabSheet(caption.getValue(), style.trim(),
-                        closable.getValue(), overflow.getValue(),
-                        icon.getValue(), disable.getValue());
-                addComponent(tabs);
+        HasValue.ValueChangeListener<Boolean> update = event -> {
+            String style = framed.getValue() ? "framed " : "";
+            style += centered.getValue() ? " centered-tabs" : "";
+            style += rightAlign.getValue() ? " right-aligned-tabs" : "";
+            style += equal.getValue() ? " equal-width-tabs" : "";
+            style += padded.getValue() ? " padded-tabbar" : "";
+            style += compact.getValue() ? " compact-tabbar" : "";
+            style += iconsOnTop.getValue() ? " icons-on-top" : "";
+            style += selectedOnly.getValue() ? " only-selected-closable"
+                    : "";
+
+            if (tabs != null) {
+                removeComponent(tabs);
             }
+            tabs = getTabSheet(caption.getValue(), style.trim(),
+                    closable.getValue(), overflow.getValue(),
+                    icon.getValue(), disable.getValue());
+            addComponent(tabs);
         };
         closable.addValueChangeListener(update);
         overflow.addValueChangeListener(update);
index 3dda83060799b8efa61da9935ee246f3c114a0dd..8526cf9a76afe1f9a0ce48811cc2e8110576de63 100644 (file)
@@ -2,6 +2,7 @@ package com.vaadin.tests.tickets;
 
 import java.util.Iterator;
 
+import com.vaadin.data.HasValue;
 import com.vaadin.data.Property;
 import com.vaadin.data.Property.ValueChangeEvent;
 import com.vaadin.data.util.MethodProperty;
@@ -49,8 +50,9 @@ public class Ticket1710 extends com.vaadin.server.LegacyApplication {
         final VerticalLayout orderedLayout = new VerticalLayout();
         LayoutTestingPanel oltp = new LayoutTestingPanel("OrderedLayout",
                 orderedLayout);
-        CheckBox cb = new CheckBox("OrderedLayout",
-                new MethodProperty<Boolean>(oltp, "visible"));
+        CheckBox cb = new CheckBox("OrderedLayout");
+        cb.setValue(oltp.isVisible());
+        cb.addValueChangeListener(event -> oltp.setVisible(event.getValue()));
         cb.setImmediate(true);
         hidingControls.addComponent(cb);
         lo.addComponent(oltp);
@@ -60,21 +62,23 @@ public class Ticket1710 extends com.vaadin.server.LegacyApplication {
         // GridLayout
         GridLayout grid = new GridLayout(1, 1);
         Panel g1tp = new LayoutTestingPanel("Gridlayout with 1 column", grid);
-        cb = new CheckBox("GridLayout (1col)", new MethodProperty<Boolean>(
-                g1tp, "visible"));
+        cb = new CheckBox("GridLayout (1col)");
         cb.setImmediate(true);
         hidingControls.addComponent(cb);
         g1tp.setVisible(false);
+        cb.setValue(g1tp.isVisible());
+        cb.addValueChangeListener(event -> g1tp.setVisible(event.getValue()));
         lo.addComponent(g1tp);
         grid.setSpacing(true);
         addFields(grid);
         GridLayout grid2 = new GridLayout(2, 1);
         Panel g2tp = new LayoutTestingPanel("Gridlayout with 2 columns", grid2);
-        cb = new CheckBox("GridLayout (2cols)", new MethodProperty<Boolean>(
-                g2tp, "visible"));
+        cb = new CheckBox("GridLayout (2cols)");
         cb.setImmediate(true);
         hidingControls.addComponent(cb);
         g2tp.setVisible(false);
+        cb.setValue(g2tp.isVisible());
+        cb.addValueChangeListener(event -> g2tp.setVisible(event.getValue()));
         lo.addComponent(g2tp);
         grid2.setSpacing(true);
         addFields(grid2);
@@ -83,11 +87,12 @@ public class Ticket1710 extends com.vaadin.server.LegacyApplication {
         VerticalLayout el = new VerticalLayout();
         Panel elp = new LayoutTestingPanel(
                 "ExpandLayout width first component expanded", el);
-        cb = new CheckBox("ExpandLayout (vertical)",
-                new MethodProperty<Boolean>(elp, "visible"));
+        cb = new CheckBox("ExpandLayout (vertical)");
         cb.setImmediate(true);
         hidingControls.addComponent(cb);
         elp.setVisible(false);
+        cb.setValue(elp.isVisible());
+        cb.addValueChangeListener(event -> elp.setVisible(event.getValue()));
         el.setHeight("700px");
         addFields(el);
         Component firstComponent = el.getComponentIterator().next();
@@ -97,11 +102,12 @@ public class Ticket1710 extends com.vaadin.server.LegacyApplication {
         HorizontalLayout elh = new HorizontalLayout();
         Panel elhp = new LayoutTestingPanel(
                 "ExpandLayout width first component expanded; horizontal", elh);
-        cb = new CheckBox("ExpandLayout (horizontal)",
-                new MethodProperty<Boolean>(elhp, "visible"));
+        cb = new CheckBox("ExpandLayout (horizontal)");
         cb.setImmediate(true);
         hidingControls.addComponent(cb);
         elhp.setVisible(false);
+        cb.setValue(elhp.isVisible());
+        cb.addValueChangeListener(event -> elhp.setVisible(event.getValue()));
         elh.setWidth("2000px");
         elh.setHeight("100px");
         addFields(elh);
@@ -113,11 +119,12 @@ public class Ticket1710 extends com.vaadin.server.LegacyApplication {
         // CustomLayout
         VerticalLayout cl = new VerticalLayout();
         Panel clp = new LayoutTestingPanel("CustomLayout", cl);
-        cb = new CheckBox("CustomLayout", new MethodProperty<Boolean>(clp,
-                "visible"));
+        cb = new CheckBox("CustomLayout");
         cb.setImmediate(true);
         hidingControls.addComponent(cb);
         clp.setVisible(false);
+        cb.setValue(clp.isVisible());
+        cb.addValueChangeListener(event -> clp.setVisible(event.getValue()));
         lo.addComponent(clp);
         cl.addComponent(new Label("<<< Add customlayout testcase here >>>"));
 
@@ -125,11 +132,12 @@ public class Ticket1710 extends com.vaadin.server.LegacyApplication {
         VerticalLayout formPanelLayout = new VerticalLayout();
         formPanelLayout.setMargin(true);
         Panel formPanel = new Panel("Form", formPanelLayout);
-        cb = new CheckBox("Form", new MethodProperty<Boolean>(formPanel,
-                "visible"));
+        cb = new CheckBox("Form");
         cb.setImmediate(true);
         hidingControls.addComponent(cb);
         formPanel.setVisible(false);
+        cb.setValue(formPanel.isVisible());
+        cb.addValueChangeListener(event -> formPanel.setVisible(event.getValue()));
         formPanelLayout.addComponent(getFormPanelExample());
         lo.addComponent(formPanel);
 
@@ -145,7 +153,7 @@ public class Ticket1710 extends com.vaadin.server.LegacyApplication {
         f.setCaption("Test form");
         CheckBox fb2 = new CheckBox("Test button", true);
         fb2.setComponentError(new SystemError("Test error"));
-        f.addField("fb2", fb2);
+        f.getLayout().addComponent(fb2);
         TextField ft1 = new TextField("With caption");
         ft1.setComponentError(new SystemError("Error"));
         f.addField("ft1", ft1);
@@ -270,15 +278,13 @@ public class Ticket1710 extends com.vaadin.server.LegacyApplication {
             controls.addComponent(new Label("width"));
             controls.addComponent(new TextField(new MethodProperty<Float>(
                     testedLayout, "width")));
-            CheckBox widthPercentsCheckBox = new CheckBox("%",
-                    new MethodProperty<Boolean>(this, "widthPercents"));
+            CheckBox widthPercentsCheckBox = new CheckBox("%");
             widthPercentsCheckBox.setImmediate(true);
             controls.addComponent(widthPercentsCheckBox);
             controls.addComponent(new Label("height"));
             controls.addComponent(new TextField(new MethodProperty<Float>(
                     testedLayout, "height")));
-            CheckBox heightPercentsCheckBox = new CheckBox("%",
-                    new MethodProperty<Boolean>(this, "heightPercents"));
+            CheckBox heightPercentsCheckBox = new CheckBox("%");
             heightPercentsCheckBox.setImmediate(true);
             controls.addComponent(heightPercentsCheckBox);
             controls.addComponent(marginLeft);
@@ -289,18 +295,13 @@ public class Ticket1710 extends com.vaadin.server.LegacyApplication {
                 controls.addComponent(spacing);
             }
 
-            Property.ValueChangeListener marginSpacingListener = new Property.ValueChangeListener() {
-                @Override
-                public void valueChange(ValueChangeEvent event) {
-                    updateMarginsAndSpacing();
-                }
-            };
+            HasValue.ValueChangeListener<Boolean> marginSpacingListener = event -> updateMarginsAndSpacing();
 
-            marginBottom.addListener(marginSpacingListener);
-            marginTop.addListener(marginSpacingListener);
-            marginLeft.addListener(marginSpacingListener);
-            marginRight.addListener(marginSpacingListener);
-            spacing.addListener(marginSpacingListener);
+            marginBottom.addValueChangeListener(marginSpacingListener);
+            marginTop.addValueChangeListener(marginSpacingListener);
+            marginLeft.addValueChangeListener(marginSpacingListener);
+            marginRight.addValueChangeListener(marginSpacingListener);
+            spacing.addValueChangeListener(marginSpacingListener);
             updateMarginsAndSpacing();
 
             addAlignmentControls();
index 5c6f45de87c053a29118c152c8f5dc24f5534d34..3d64f9d4265c33a3b86f097900b0d078e17c2ac8 100644 (file)
@@ -1,7 +1,5 @@
 package com.vaadin.tests.tickets;
 
-import com.vaadin.data.Property;
-import com.vaadin.data.Property.ValueChangeEvent;
 import com.vaadin.event.Action;
 import com.vaadin.event.Action.Handler;
 import com.vaadin.server.LegacyApplication;
@@ -39,41 +37,35 @@ public class Ticket1857 extends LegacyApplication implements Handler {
                 false);
         footer.addComponent(actionHandlerEnabler);
         actionHandlerEnabler.setImmediate(true);
-        actionHandlerEnabler.addListener(new Property.ValueChangeListener() {
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                if (actionHandlerEnabler.getValue().booleanValue()) {
-                    t.addActionHandler(Ticket1857.this);
-                } else {
-                    t.removeActionHandler(Ticket1857.this);
-                }
+        actionHandlerEnabler.addValueChangeListener(event -> {
+            if (actionHandlerEnabler.getValue().booleanValue()) {
+                t.addActionHandler(Ticket1857.this);
+            } else {
+                t.removeActionHandler(Ticket1857.this);
             }
         });
 
         final CheckBox cellStylesEnabler = new CheckBox("Cell styles", false);
         footer.addComponent(cellStylesEnabler);
         cellStylesEnabler.setImmediate(true);
-        cellStylesEnabler.addListener(new Property.ValueChangeListener() {
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                if (cellStylesEnabler.getValue().booleanValue()) {
-                    t.setCellStyleGenerator(new Table.CellStyleGenerator() {
-                        @Override
-                        public String getStyle(Table source, Object itemId,
-                                Object propertyId) {
-                            Object cell = t.getContainerProperty(itemId,
-                                    propertyId).getValue();
-                            if (!(cell instanceof Integer)) {
-                                return null;
-                            }
-                            int age = ((Integer) cell).intValue();
-                            return age > 65 ? "old" : (age < 18 ? "young"
-                                    : null);
+        cellStylesEnabler.addValueChangeListener(event -> {
+            if (cellStylesEnabler.getValue().booleanValue()) {
+                t.setCellStyleGenerator(new Table.CellStyleGenerator() {
+                    @Override
+                    public String getStyle(Table source, Object itemId,
+                            Object propertyId) {
+                        Object cell = t.getContainerProperty(itemId,
+                                propertyId).getValue();
+                        if (!(cell instanceof Integer)) {
+                            return null;
                         }
-                    });
-                } else {
-                    t.setCellStyleGenerator(null);
-                }
+                        int age = ((Integer) cell).intValue();
+                        return age > 65 ? "old" : (age < 18 ? "young"
+                                : null);
+                    }
+                });
+            } else {
+                t.setCellStyleGenerator(null);
             }
         });
         cellStylesEnabler.setValue(Boolean.TRUE);
index 789e8c3a450c8aad1a516eac48debbef075d1fa0..7ebd9c421acfb98cd964304204f272ab1bc9a6d2 100644 (file)
@@ -1,7 +1,5 @@
 package com.vaadin.tests.tickets;
 
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
 import com.vaadin.data.util.IndexedContainer;
 import com.vaadin.server.LegacyApplication;
 import com.vaadin.server.Sizeable;
@@ -116,18 +114,12 @@ public class Ticket1983 extends LegacyApplication {
             leftSide.setFirstComponent(ol);
 
             CheckBox checkBox = new CheckBox("Two col");
-            checkBox.addListener(new ValueChangeListener() {
-
-                @Override
-                public void valueChange(ValueChangeEvent event) {
-                    if ((Boolean) event.getProperty().getValue()) {
-                        table.setVisibleColumns(new Object[] { propId, propId2 });
-                    } else {
-                        table.setVisibleColumns(new Object[] { propId });
-                    }
-
+            checkBox.addValueChangeListener(event -> {
+                if (event.getValue()) {
+                    table.setVisibleColumns(new Object[] { propId, propId2 });
+                } else {
+                    table.setVisibleColumns(new Object[] { propId });
                 }
-
             });
             ol.addComponent(checkBox);
 
index d1baceb17c75a3cd189ee13efaf62af7bb46046f..2c02dd62646a23b8e8a4dfd6b96a3efdde25d7fe 100644 (file)
@@ -6,6 +6,7 @@ import com.vaadin.legacy.data.validator.LegacyCompositeValidator;
 import com.vaadin.legacy.data.validator.LegacyCompositeValidator.CombinationMode;
 import com.vaadin.legacy.data.validator.LegacyIntegerValidator;
 import com.vaadin.server.LegacyApplication;
+import com.vaadin.tests.util.CheckBoxWithPropertyDataSource;
 import com.vaadin.ui.Button;
 import com.vaadin.ui.CheckBox;
 import com.vaadin.ui.LegacyWindow;
@@ -65,7 +66,7 @@ public class Ticket20 extends LegacyApplication {
                 "readOnly", "readThrough", "invalidCommitted",
                 "validationVisible" };
         for (int i = 0; i < visibleProps.length; i++) {
-            CheckBox b = new CheckBox(visibleProps[i],
+            CheckBox b = new CheckBoxWithPropertyDataSource(visibleProps[i],
                     new MethodProperty<Boolean>(tx, visibleProps[i]));
             b.setImmediate(true);
             mainWin.addComponent(b);
index cf442e2218a0d2d893a5ab64fc7ae1c328b31f9e..96fb88596d8d8c139b1b54c11602f16516563b37 100644 (file)
@@ -1,7 +1,5 @@
 package com.vaadin.tests.tickets;
 
-import com.vaadin.data.Property;
-import com.vaadin.data.Property.ValueChangeEvent;
 import com.vaadin.server.LegacyApplication;
 import com.vaadin.ui.CheckBox;
 import com.vaadin.ui.Label;
@@ -21,14 +19,11 @@ public class Ticket2001 extends LegacyApplication {
         w.addComponent(l);
 
         final CheckBox b = new CheckBox("fixed width: 30px", false);
-        b.addListener(new Property.ValueChangeListener() {
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                if (b.getValue()) {
-                    l.setWidth("30px");
-                } else {
-                    l.setWidth(null);
-                }
+        b.addValueChangeListener(event -> {
+            if (b.getValue()) {
+                l.setWidth("30px");
+            } else {
+                l.setWidth(null);
             }
         });
         b.setImmediate(true);
index 12866da5703c6401eb542641feb34627de366d8b..5c4cc72d605be06fd96721dbed2d9f2f432a0a49 100644 (file)
@@ -35,13 +35,8 @@ public class Ticket2038 extends LegacyApplication {
                 false);
         w.addComponent(b);
         b.setImmediate(true);
-        b.addListener(new Property.ValueChangeListener() {
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                tf.setRequiredError(b.getValue() ? "Field must not be empty"
-                        : null);
-            }
-        });
+        b.addValueChangeListener(event -> tf.setRequiredError(
+                b.getValue() ? "Field must not be empty" : null));
     }
 
 }
index da9f7fecc808ad9857a8afe705194ff90a8b9635..e52ab33ffd4cb962415bdf4846fc7283f25ae47d 100644 (file)
@@ -1,8 +1,5 @@
 package com.vaadin.tests.tickets;
 
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.data.Property.ValueChangeListener;
-import com.vaadin.data.util.MethodProperty;
 import com.vaadin.event.ItemClickEvent;
 import com.vaadin.event.ItemClickEvent.ItemClickListener;
 import com.vaadin.server.ExternalResource;
@@ -33,33 +30,35 @@ public class Ticket2104 extends LegacyApplication {
 
         HorizontalLayout ol = new HorizontalLayout();
         main.addComponent(ol);
-        CheckBox cb = new CheckBox("immediate", new MethodProperty<Boolean>(
-                tree, "immediate"));
+        CheckBox cb = new CheckBox("immediate");
+        cb.setValue(tree.isImmediate());
+        cb.addValueChangeListener(event -> tree.setImmediate(event.getValue()));
         cb.setImmediate(true);
         ol.addComponent(cb);
-        cb = new CheckBox("selectable", new MethodProperty<Boolean>(tree,
-                "selectable"));
+        cb = new CheckBox("selectable");
+        cb.setValue(tree.isSelectable());
+        cb.addValueChangeListener(
+                event -> tree.setSelectable(event.getValue()));
         cb.setImmediate(true);
         ol.addComponent(cb);
-        cb = new CheckBox("nullsel", new MethodProperty<Boolean>(tree,
-                "nullSelectionAllowed"));
+        cb = new CheckBox("nullsel");
+        cb.setValue(tree.isNullSelectionAllowed());
+        cb.addValueChangeListener(
+                event -> tree.setNullSelectionAllowed(event.getValue()));
         cb.setImmediate(true);
         ol.addComponent(cb);
-        cb = new CheckBox("multi", new MethodProperty<Boolean>(tree,
-                "multiSelect"));
+        cb = new CheckBox("multi");
+        cb.setValue(tree.isMultiSelect());
+        cb.addValueChangeListener(
+                event -> tree.setMultiSelect(event.getValue()));
         cb.setImmediate(true);
         ol.addComponent(cb);
         cb = new CheckBox("icon");
-        cb.addListener(new ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                if (tree.getItemIconPropertyId() == null) {
-                    tree.setItemIconPropertyId("icon");
-                } else {
-                    tree.setItemIconPropertyId(null);
-                }
-
+        cb.addValueChangeListener(event -> {
+            if (tree.getItemIconPropertyId() == null) {
+                tree.setItemIconPropertyId("icon");
+            } else {
+                tree.setItemIconPropertyId(null);
             }
         });
         cb.setImmediate(true);
@@ -94,20 +93,27 @@ public class Ticket2104 extends LegacyApplication {
 
         ol = new HorizontalLayout();
         main.addComponent(ol);
-        cb = new CheckBox("immediate", new MethodProperty<Boolean>(table,
-                "immediate"));
+        cb = new CheckBox("immediate");
+        cb.setValue(table.isImmediate());
+        cb.addValueChangeListener(event -> table.setImmediate(event.getValue()));
         cb.setImmediate(true);
         ol.addComponent(cb);
-        cb = new CheckBox("selectable", new MethodProperty<Boolean>(table,
-                "selectable"));
+        cb = new CheckBox("selectable");
+        cb.setValue(table.isSelectable());
+        cb.addValueChangeListener(
+                event -> table.setSelectable(event.getValue()));
         cb.setImmediate(true);
         ol.addComponent(cb);
-        cb = new CheckBox("nullsel", new MethodProperty<Boolean>(table,
-                "nullSelectionAllowed"));
+        cb = new CheckBox("nullsel");
+        cb.setValue(table.isNullSelectionAllowed());
+        cb.addValueChangeListener(
+                event -> table.setNullSelectionAllowed(event.getValue()));
         cb.setImmediate(true);
         ol.addComponent(cb);
-        cb = new CheckBox("multi", new MethodProperty<Boolean>(table,
-                "multiSelect"));
+        cb = new CheckBox("multi");
+        cb.setValue(table.isMultiSelect());
+        cb.addValueChangeListener(
+                event -> table.setMultiSelect(event.getValue()));
         cb.setImmediate(true);
         ol.addComponent(cb);
         main.addComponent(table);
index ae5e032a9f51e41f2eb62d6aaa287627c9287caf..a7da4b3425b6e81786960c9f6416d3f8746091f4 100644 (file)
@@ -48,13 +48,8 @@ public class Ticket2107 extends LegacyApplication {
                 false);
         w.addComponent(b);
         b.setImmediate(true);
-        b.addListener(new Property.ValueChangeListener() {
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                tf.setRequiredError(b.getValue() ? "Field must not be empty"
-                        : null);
-            }
-        });
+        b.addValueChangeListener(event -> tf.setRequiredError(
+                b.getValue() ? "Field must not be empty" : null));
     }
 
 }
index ba94bd394d634327da085b203b19a93894e424d2..77a08248f42055ac9fb5b4568208850addffb1fc 100644 (file)
@@ -1,6 +1,5 @@
 package com.vaadin.tests.tickets;
 
-import com.vaadin.data.util.MethodProperty;
 import com.vaadin.server.LegacyApplication;
 import com.vaadin.ui.CheckBox;
 import com.vaadin.ui.Component;
@@ -55,8 +54,9 @@ public class Ticket2125 extends LegacyApplication {
                 }
 
             });
-            CheckBox b = new CheckBox("editmode", new MethodProperty<Boolean>(
-                    table, "editable"));
+            CheckBox b = new CheckBox("editmode");
+            b.setValue(table.isEditable());
+            b.addValueChangeListener(event -> table.setEditable(event.getValue()));
             b.setImmediate(true);
             addComponent(b);
         }
index d765bd3a015e8bc51fe872fd6ab5ca8c6fb65fcc..29537270f014818945bf82df199783f465732a6a 100644 (file)
@@ -1,7 +1,5 @@
 package com.vaadin.tests.tickets;
 
-import com.vaadin.data.util.ObjectProperty;
-import com.vaadin.legacy.ui.LegacyAbstractField;
 import com.vaadin.server.LegacyApplication;
 import com.vaadin.ui.AbstractComponent;
 import com.vaadin.ui.AbstractOrderedLayout;
@@ -42,7 +40,6 @@ public class Ticket2151 extends LegacyApplication {
 
         checkButton(Button.class);
         checkCheckBox(CheckBox.class);
-        checkDataBinding(CheckBox.class);
 
     }
 
@@ -83,36 +80,4 @@ public class Ticket2151 extends LegacyApplication {
 
     }
 
-    private void checkDataBinding(Class<? extends LegacyAbstractField> class1) {
-        boolean ok = false;
-        LegacyAbstractField b;
-        try {
-            b = class1.newInstance();
-            b.setCaption("Button of type " + class1.getSimpleName());
-            try {
-                b.setBuffered(false);
-                ObjectProperty<String> prop = new ObjectProperty<String>(
-                        "ABC 123");
-                /*
-                 * This should throw an exception or somehow tell that the
-                 * property was invalid (wrong type). See #2223.
-                 */
-                b.setPropertyDataSource(prop);
-            } catch (Exception e) {
-                e.printStackTrace();
-            }
-        } catch (Exception e1) {
-            e1.printStackTrace();
-            return;
-        }
-
-        if (ok) {
-            status.setValue(status.getValue() + " "
-                    + class1.getClass().getSimpleName() + "/DB: OK");
-        } else {
-            status.setValue(status.getValue() + " "
-                    + class1.getClass().getSimpleName() + "/DB: FAILED");
-        }
-
-    }
 }
index 833f794fdb0293264023c1f29d87bc69c6f3af0d..6efde3764871f090e86ffa1ab739c30e664397ae 100644 (file)
@@ -6,6 +6,7 @@ import com.vaadin.legacy.data.Validator;
 import com.vaadin.legacy.data.validator.LegacyIntegerValidator;
 import com.vaadin.server.LegacyApplication;
 import com.vaadin.server.ThemeResource;
+import com.vaadin.tests.util.CheckBoxWithPropertyDataSource;
 import com.vaadin.ui.AbstractComponent;
 import com.vaadin.ui.Alignment;
 import com.vaadin.ui.Button;
@@ -85,7 +86,7 @@ public class Ticket736 extends LegacyApplication {
                 "readOnly", "readThrough", "writeThrough", "invalidCommitted",
                 "validationVisible", "immediate" };
         for (int i = 0; i < visibleProps.length; i++) {
-            CheckBox b = new CheckBox(visibleProps[i],
+            CheckBox b = new CheckBoxWithPropertyDataSource(visibleProps[i],
                     new MethodProperty<Boolean>(f, visibleProps[i]));
             b.setImmediate(true);
             formPropertiesLayout.addComponent(b);
index 2cb4f815caadff11cd90bf64253838ac384e77a3..2cd53cbcc8ea1e2b7f631315e33efa660fca62a8 100644 (file)
@@ -3,6 +3,7 @@ package com.vaadin.tests.tickets;
 import com.vaadin.data.util.MethodProperty;
 import com.vaadin.legacy.data.validator.LegacyIntegerValidator;
 import com.vaadin.server.LegacyApplication;
+import com.vaadin.tests.util.CheckBoxWithPropertyDataSource;
 import com.vaadin.ui.Button;
 import com.vaadin.ui.CheckBox;
 import com.vaadin.ui.LegacyWindow;
@@ -25,7 +26,7 @@ public class Ticket846 extends LegacyApplication {
                 "readOnly", "readThrough", "invalidCommitted",
                 "validationVisible" };
         for (int i = 0; i < visibleProps.length; i++) {
-            CheckBox b = new CheckBox(visibleProps[i],
+            CheckBox b = new CheckBoxWithPropertyDataSource(visibleProps[i],
                     new MethodProperty<Boolean>(tx, visibleProps[i]));
             b.setImmediate(true);
             mainWin.addComponent(b);
diff --git a/uitest/src/main/java/com/vaadin/tests/util/CheckBoxWithPropertyDataSource.java b/uitest/src/main/java/com/vaadin/tests/util/CheckBoxWithPropertyDataSource.java
new file mode 100644 (file)
index 0000000..ca3c2a6
--- /dev/null
@@ -0,0 +1,34 @@
+package com.vaadin.tests.util;
+
+import com.vaadin.data.Property;
+import com.vaadin.data.Property.ValueChangeNotifier;
+import com.vaadin.legacy.data.Validator.InvalidValueException;
+import com.vaadin.ui.CheckBox;
+
+public class CheckBoxWithPropertyDataSource extends CheckBox {
+
+    public CheckBoxWithPropertyDataSource(String caption) {
+        super(caption);
+    }
+
+    public CheckBoxWithPropertyDataSource(String caption,
+            Property<Boolean> property) {
+        super(caption);
+
+        setValue(property.getValue());
+        addValueChangeListener(event -> property.setValue(event.getValue()));
+
+        if (property instanceof ValueChangeNotifier) {
+            ((ValueChangeNotifier) property)
+                    .addValueChangeListener(event -> setValue(
+                            (Boolean) event.getProperty().getValue()));
+        }
+    }
+
+    public void validate() {
+        if (isRequired() && !getValue()) {
+            throw new InvalidValueException("Required CheckBox should be checked");
+        }
+    }
+
+}
index e6dbd99777515d5e46688c35d760fada28c818ce..dfaab414e6defc1b53f9ceb23aa51838c410f57f 100644 (file)
@@ -28,12 +28,8 @@ public class ValidationOfRequiredEmptyFields extends AbstractTestUI {
     protected void setup(VaadinRequest request) {
         requiredInput = new CheckBox("Field required");
         requiredInput.setImmediate(true);
-        requiredInput.addValueChangeListener(new ValueChangeListener() {
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                tf.setRequired(requiredInput.getValue());
-            }
-        });
+        requiredInput.addValueChangeListener(
+                event -> tf.setRequired(requiredInput.getValue()));
 
         requiredErrorInput = new TextField("Required error message");
         requiredErrorInput.setImmediate(true);
@@ -46,31 +42,22 @@ public class ValidationOfRequiredEmptyFields extends AbstractTestUI {
 
         integerValidatorInput = new CheckBox("Integer validator");
         integerValidatorInput.setImmediate(true);
-        integerValidatorInput.addValueChangeListener(new ValueChangeListener() {
-
-            @Override
-            public void valueChange(ValueChangeEvent event) {
-                if (integerValidatorInput.getValue()) {
-                    tf.addValidator(integerValidator);
-                } else {
-                    tf.removeValidator(integerValidator);
-                }
+        integerValidatorInput.addValueChangeListener(event -> {
+            if (integerValidatorInput.getValue()) {
+                tf.addValidator(integerValidator);
+            } else {
+                tf.removeValidator(integerValidator);
             }
         });
         stringLengthValidatorInput = new CheckBox("String length validator");
         stringLengthValidatorInput.setImmediate(true);
-        stringLengthValidatorInput
-                .addValueChangeListener(new ValueChangeListener() {
-
-                    @Override
-                    public void valueChange(ValueChangeEvent event) {
-                        if (stringLengthValidatorInput.getValue()) {
-                            tf.addValidator(stringLengthValidator);
-                        } else {
-                            tf.removeValidator(stringLengthValidator);
-                        }
-                    }
-                });
+        stringLengthValidatorInput.addValueChangeListener(event -> {
+            if (stringLengthValidatorInput.getValue()) {
+                tf.addValidator(stringLengthValidator);
+            } else {
+                tf.removeValidator(stringLengthValidator);
+            }
+        });
 
         tf = new TextField();
         tf.setImmediate(true);
diff --git a/uitest/src/test/java/com/vaadin/tests/components/checkbox/CheckBoxNullValueTest.java b/uitest/src/test/java/com/vaadin/tests/components/checkbox/CheckBoxNullValueTest.java
deleted file mode 100644 (file)
index 12ed650..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-package com.vaadin.tests.components.checkbox;
-
-import java.util.List;
-
-import org.junit.Assert;
-import org.junit.Test;
-import org.openqa.selenium.WebElement;
-
-import com.vaadin.testbench.By;
-import com.vaadin.testbench.elements.ButtonElement;
-import com.vaadin.testbench.elements.CheckBoxElement;
-import com.vaadin.tests.tb3.MultiBrowserTest;
-
-public class CheckBoxNullValueTest extends MultiBrowserTest {
-    @Test
-    public void testValidation() throws Exception {
-        openTestURL();
-        CheckBoxElement checkbox = $(CheckBoxElement.class).first();
-        CheckBoxElement requiredCheckbox = $(CheckBoxElement.class).caption(
-                "A required checkbox").first();
-
-        assertValid(checkbox, true);
-        assertValid(requiredCheckbox, true);
-        ButtonElement validate = $(ButtonElement.class).caption("Validate")
-                .first();
-        validate.click();
-
-        assertValid(checkbox, true);
-        assertValid(requiredCheckbox, false);
-
-        click(checkbox);
-        click(requiredCheckbox);
-        validate.click();
-
-        assertValid(checkbox, true);
-        assertValid(requiredCheckbox, true);
-
-        click(checkbox);
-        click(requiredCheckbox);
-        validate.click();
-        assertValid(checkbox, true);
-        assertValid(requiredCheckbox, false);
-
-    }
-
-    private void assertValid(CheckBoxElement checkbox, boolean valid) {
-        boolean hasIndicator = false;
-        List<WebElement> e = checkbox.findElements(By
-                .className("v-errorindicator"));
-        if (e.size() != 0) {
-            hasIndicator = e.get(0).isDisplayed();
-        }
-
-        Assert.assertEquals("Checkbox state should be "
-                + (valid ? "valid" : "invalid"), valid, !hasIndicator);
-
-    }
-
-}
index c430821534d0c83b754fe5cb8f314bea35448373..6e2312e34cf362dd266209a4f38edf2b78b8360a 100644 (file)
@@ -1,12 +1,12 @@
 /*
  * Copyright 2000-2014 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
@@ -22,6 +22,7 @@ import org.openqa.selenium.By;
 import com.vaadin.testbench.elements.CheckBoxElement;
 import com.vaadin.testbench.elements.GridElement;
 import com.vaadin.testbench.parallel.TestCategory;
+import com.vaadin.tests.legacyelements.LegacyCheckBoxElement;
 import com.vaadin.tests.tb3.SingleBrowserTest;
 
 @TestCategory("grid")
@@ -40,7 +41,7 @@ public class GridCheckBoxDisplayTest extends SingleBrowserTest {
         // First edit false item and see that the CheckBox is unchecked
         grid.getCell(1, 0).doubleClick();
 
-        CheckBoxElement checkbox = $(CheckBoxElement.class).first();
+        CheckBoxElement checkbox = $(LegacyCheckBoxElement.class).first();
         Assert.assertEquals("CheckBox was checked", "unchecked",
                 checkbox.getValue());
 
@@ -49,7 +50,7 @@ public class GridCheckBoxDisplayTest extends SingleBrowserTest {
         // Edit true item and see that the CheckBox is checked
         grid.getCell(0, 0).doubleClick();
 
-        checkbox = $(CheckBoxElement.class).first();
+        checkbox = $(LegacyCheckBoxElement.class).first();
         Assert.assertEquals("CheckBox was not checked.", "checked",
                 checkbox.getValue());
 
@@ -58,7 +59,7 @@ public class GridCheckBoxDisplayTest extends SingleBrowserTest {
         // Edit false item and confirm that the CheckBox is unchecked again
         grid.getCell(1, 0).doubleClick();
 
-        checkbox = $(CheckBoxElement.class).first();
+        checkbox = $(LegacyCheckBoxElement.class).first();
         Assert.assertEquals("CheckBox was checked", "unchecked",
                 checkbox.getValue());
     }
diff --git a/uitest/src/test/java/com/vaadin/tests/legacyelements/LegacyCheckBoxElement.java b/uitest/src/test/java/com/vaadin/tests/legacyelements/LegacyCheckBoxElement.java
new file mode 100644 (file)
index 0000000..3fe30a2
--- /dev/null
@@ -0,0 +1,9 @@
+package com.vaadin.tests.legacyelements;
+
+import com.vaadin.testbench.elements.CheckBoxElement;
+import com.vaadin.testbench.elementsbase.ServerClass;
+
+@ServerClass("com.vaadin.legacy.ui.LegacyCheckBox")
+public class LegacyCheckBoxElement extends CheckBoxElement {
+
+}