From 9661839707a76de888a4ede6da4ab9a12d3c023a Mon Sep 17 00:00:00 2001
From: Artur Signell
Date: Wed, 17 Aug 2016 09:24:32 +0300
Subject: [PATCH] Remove Form and FormFieldFactory
Form was deprecated in Vaadin 7 when FieldGroup was introduced.
In Vaadin 8, FieldGroup is deprecated in favor of Binder. Having three
different "forms" would be very confusing.
Change-Id: I17775c922940edc5df7dd5bdc80bfe9652588270
---
.../main/java/com/vaadin/client/ui/VForm.java | 139 --
.../vaadin/client/ui/form/FormConnector.java | 236 ---
.../vaadin/data/fieldgroup/FieldGroup.java | 247 ++-
.../com/vaadin/legacy/ui/LegacyDateField.java | 59 -
.../vaadin/server/ComponentSizeValidator.java | 80 +-
.../com/vaadin/ui/DefaultFieldFactory.java | 41 +-
server/src/main/java/com/vaadin/ui/Form.java | 1425 -----------------
.../java/com/vaadin/ui/FormFieldFactory.java | 57 -
.../tests/server/SerializationTest.java | 21 +-
.../tests/server/component/form/FormTest.java | 68 -
.../com/vaadin/shared/ui/form/FormState.java | 27 -
.../button/ButtonWithShortcutNotRendered.java | 172 --
.../AbstractNestedFormExample.java | 76 -
.../components/customfield/AddressField.java | 97 --
.../customfield/AddressFormExample.java | 50 -
.../customfield/BooleanFieldExample.java | 89 -
.../components/customfield/EmbeddedForm.java | 67 -
.../customfield/EmbeddedFormExample.java | 17 -
.../customfield/NestedFormExample.java | 15 -
.../customfield/NestedPersonForm.java | 99 --
.../components/datefield/CommitInvalid.java | 143 --
.../datefield/DateFieldInSubWindow.java | 150 --
.../ShowSelectedDateAfterInvalid.java | 58 -
.../form/FormCaptionClickFocusing.java | 29 -
.../form/FormClearDatasourceRepaint.java | 73 -
.../form/FormCommitWithInvalidValues.java | 73 -
.../components/form/FormDescription.java | 42 -
.../components/form/FormErrorVisible.java | 66 -
.../components/form/FormFieldCaptions.java | 86 -
.../form/FormFieldCaptionsStyles.java | 48 -
.../form/FormNotGettingSmaller.java | 52 -
.../components/form/FormPrimaryStyleName.java | 47 -
.../components/form/FormRenderingFlicker.java | 66 -
.../tests/components/form/FormTest.java | 269 ----
.../tests/components/form/FormTooltips.java | 58 -
.../form/FormWithEnterShortCut.java | 47 -
.../form/FormWithPaddingsAndBorders.java | 46 -
.../FormWithPropertyFormatterConnected.java | 91 --
.../form/FormWithRelativelySizedLayout.java | 52 -
...definedWideFormWithRelativeWideFooter.java | 36 -
.../gridlayout/GridLayoutInForm.java | 84 -
.../KeyboardNavigationDatasourceChange.java | 137 --
.../OutOfSyncIssueWithKeyboardShortcut.java | 194 ---
.../UndefinedHeightSubWindowAndContent.java | 60 -
.../sqlcontainer/CheckboxUpdateProblem.java | 114 --
.../tests/fieldgroup/FormManyToMany.java | 28 -
.../tests/fieldgroup/FormOneToMany.java | 43 -
.../vaadin/tests/fieldgroup/FormOneToOne.java | 38 -
.../vaadin/tests/fields/FormManyToMany.java | 28 -
.../vaadin/tests/fields/FormOneToMany.java | 43 -
.../com/vaadin/tests/fields/FormOneToOne.java | 38 -
.../tests/layouts/GridLayoutCaptions.java | 230 ---
.../vaadin/tests/layouts/HtmlInCaption.java | 10 +-
.../tests/layouts/TestAbsoluteLayout.java | 326 ----
.../com/vaadin/tests/tickets/Ticket1710.java | 414 -----
.../com/vaadin/tests/tickets/Ticket1878.java | 391 -----
.../com/vaadin/tests/tickets/Ticket2204.java | 181 ---
.../com/vaadin/tests/tickets/Ticket2244.java | 130 --
.../com/vaadin/tests/tickets/Ticket2364.java | 37 -
.../com/vaadin/tests/tickets/Ticket2407.java | 21 -
.../com/vaadin/tests/tickets/Ticket677.java | 226 ---
.../com/vaadin/tests/tickets/Ticket736.java | 190 ---
.../validation/EmptyFieldErrorIndicators.java | 147 --
.../validation/RequiredErrorMessage.java | 52 -
.../RequiredIndicatorForReadOnly.java | 33 -
.../tests/validation/TestValidators.java | 179 ---
.../components/form/FormTooltipsTest.java | 60 -
...ndefinedHeightSubWindowAndContentTest.java | 35 -
68 files changed, 171 insertions(+), 7912 deletions(-)
delete mode 100644 client/src/main/java/com/vaadin/client/ui/VForm.java
delete mode 100644 client/src/main/java/com/vaadin/client/ui/form/FormConnector.java
delete mode 100644 server/src/main/java/com/vaadin/ui/Form.java
delete mode 100644 server/src/main/java/com/vaadin/ui/FormFieldFactory.java
delete mode 100644 server/src/test/java/com/vaadin/tests/server/component/form/FormTest.java
delete mode 100644 shared/src/main/java/com/vaadin/shared/ui/form/FormState.java
delete mode 100644 uitest/src/main/java/com/vaadin/tests/components/button/ButtonWithShortcutNotRendered.java
delete mode 100644 uitest/src/main/java/com/vaadin/tests/components/customfield/AbstractNestedFormExample.java
delete mode 100644 uitest/src/main/java/com/vaadin/tests/components/customfield/AddressField.java
delete mode 100644 uitest/src/main/java/com/vaadin/tests/components/customfield/AddressFormExample.java
delete mode 100644 uitest/src/main/java/com/vaadin/tests/components/customfield/BooleanFieldExample.java
delete mode 100644 uitest/src/main/java/com/vaadin/tests/components/customfield/EmbeddedForm.java
delete mode 100644 uitest/src/main/java/com/vaadin/tests/components/customfield/EmbeddedFormExample.java
delete mode 100644 uitest/src/main/java/com/vaadin/tests/components/customfield/NestedFormExample.java
delete mode 100644 uitest/src/main/java/com/vaadin/tests/components/customfield/NestedPersonForm.java
delete mode 100644 uitest/src/main/java/com/vaadin/tests/components/datefield/CommitInvalid.java
delete mode 100644 uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldInSubWindow.java
delete mode 100644 uitest/src/main/java/com/vaadin/tests/components/datefield/ShowSelectedDateAfterInvalid.java
delete mode 100644 uitest/src/main/java/com/vaadin/tests/components/form/FormCaptionClickFocusing.java
delete mode 100644 uitest/src/main/java/com/vaadin/tests/components/form/FormClearDatasourceRepaint.java
delete mode 100644 uitest/src/main/java/com/vaadin/tests/components/form/FormCommitWithInvalidValues.java
delete mode 100644 uitest/src/main/java/com/vaadin/tests/components/form/FormDescription.java
delete mode 100644 uitest/src/main/java/com/vaadin/tests/components/form/FormErrorVisible.java
delete mode 100644 uitest/src/main/java/com/vaadin/tests/components/form/FormFieldCaptions.java
delete mode 100644 uitest/src/main/java/com/vaadin/tests/components/form/FormFieldCaptionsStyles.java
delete mode 100644 uitest/src/main/java/com/vaadin/tests/components/form/FormNotGettingSmaller.java
delete mode 100644 uitest/src/main/java/com/vaadin/tests/components/form/FormPrimaryStyleName.java
delete mode 100644 uitest/src/main/java/com/vaadin/tests/components/form/FormRenderingFlicker.java
delete mode 100644 uitest/src/main/java/com/vaadin/tests/components/form/FormTest.java
delete mode 100644 uitest/src/main/java/com/vaadin/tests/components/form/FormTooltips.java
delete mode 100644 uitest/src/main/java/com/vaadin/tests/components/form/FormWithEnterShortCut.java
delete mode 100644 uitest/src/main/java/com/vaadin/tests/components/form/FormWithPaddingsAndBorders.java
delete mode 100644 uitest/src/main/java/com/vaadin/tests/components/form/FormWithPropertyFormatterConnected.java
delete mode 100644 uitest/src/main/java/com/vaadin/tests/components/form/FormWithRelativelySizedLayout.java
delete mode 100644 uitest/src/main/java/com/vaadin/tests/components/form/UndefinedWideFormWithRelativeWideFooter.java
delete mode 100644 uitest/src/main/java/com/vaadin/tests/components/gridlayout/GridLayoutInForm.java
delete mode 100644 uitest/src/main/java/com/vaadin/tests/components/table/KeyboardNavigationDatasourceChange.java
delete mode 100644 uitest/src/main/java/com/vaadin/tests/components/textfield/OutOfSyncIssueWithKeyboardShortcut.java
delete mode 100644 uitest/src/main/java/com/vaadin/tests/components/window/UndefinedHeightSubWindowAndContent.java
delete mode 100644 uitest/src/main/java/com/vaadin/tests/containers/sqlcontainer/CheckboxUpdateProblem.java
delete mode 100644 uitest/src/main/java/com/vaadin/tests/fieldgroup/FormManyToMany.java
delete mode 100644 uitest/src/main/java/com/vaadin/tests/fieldgroup/FormOneToMany.java
delete mode 100644 uitest/src/main/java/com/vaadin/tests/fieldgroup/FormOneToOne.java
delete mode 100644 uitest/src/main/java/com/vaadin/tests/fields/FormManyToMany.java
delete mode 100644 uitest/src/main/java/com/vaadin/tests/fields/FormOneToMany.java
delete mode 100644 uitest/src/main/java/com/vaadin/tests/fields/FormOneToOne.java
delete mode 100644 uitest/src/main/java/com/vaadin/tests/layouts/GridLayoutCaptions.java
delete mode 100644 uitest/src/main/java/com/vaadin/tests/layouts/TestAbsoluteLayout.java
delete mode 100644 uitest/src/main/java/com/vaadin/tests/tickets/Ticket1710.java
delete mode 100644 uitest/src/main/java/com/vaadin/tests/tickets/Ticket1878.java
delete mode 100644 uitest/src/main/java/com/vaadin/tests/tickets/Ticket2204.java
delete mode 100644 uitest/src/main/java/com/vaadin/tests/tickets/Ticket2244.java
delete mode 100644 uitest/src/main/java/com/vaadin/tests/tickets/Ticket2364.java
delete mode 100644 uitest/src/main/java/com/vaadin/tests/tickets/Ticket2407.java
delete mode 100644 uitest/src/main/java/com/vaadin/tests/tickets/Ticket677.java
delete mode 100644 uitest/src/main/java/com/vaadin/tests/tickets/Ticket736.java
delete mode 100644 uitest/src/main/java/com/vaadin/tests/validation/EmptyFieldErrorIndicators.java
delete mode 100644 uitest/src/main/java/com/vaadin/tests/validation/RequiredErrorMessage.java
delete mode 100644 uitest/src/main/java/com/vaadin/tests/validation/RequiredIndicatorForReadOnly.java
delete mode 100644 uitest/src/main/java/com/vaadin/tests/validation/TestValidators.java
delete mode 100644 uitest/src/test/java/com/vaadin/tests/components/form/FormTooltipsTest.java
delete mode 100644 uitest/src/test/java/com/vaadin/tests/components/window/UndefinedHeightSubWindowAndContentTest.java
diff --git a/client/src/main/java/com/vaadin/client/ui/VForm.java b/client/src/main/java/com/vaadin/client/ui/VForm.java
deleted file mode 100644
index ca38ea070b..0000000000
--- a/client/src/main/java/com/vaadin/client/ui/VForm.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * 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.ui;
-
-import com.google.gwt.dom.client.Element;
-import com.google.gwt.event.dom.client.KeyDownEvent;
-import com.google.gwt.event.dom.client.KeyDownHandler;
-import com.google.gwt.event.shared.HandlerRegistration;
-import com.google.gwt.user.client.DOM;
-import com.google.gwt.user.client.Event;
-import com.google.gwt.user.client.ui.ComplexPanel;
-import com.google.gwt.user.client.ui.Widget;
-import com.vaadin.client.ApplicationConnection;
-import com.vaadin.client.VErrorMessage;
-
-public class VForm extends ComplexPanel implements KeyDownHandler {
-
- public static final String CLASSNAME = "v-form";
-
- /** For internal use only. May be removed or replaced in the future. */
- public String id;
-
- /** For internal use only. May be removed or replaced in the future. */
- public Widget lo;
-
- /** For internal use only. May be removed or replaced in the future. */
- public Element legend = DOM.createLegend();
-
- /** For internal use only. May be removed or replaced in the future. */
- public Element caption = DOM.createSpan();
-
- /** For internal use only. May be removed or replaced in the future. */
- public Element desc = DOM.createDiv();
-
- /** For internal use only. May be removed or replaced in the future. */
- public Icon icon;
-
- /** For internal use only. May be removed or replaced in the future. */
- public VErrorMessage errorMessage = new VErrorMessage();
-
- /** For internal use only. May be removed or replaced in the future. */
- public Element fieldContainer = DOM.createDiv();
-
- /** For internal use only. May be removed or replaced in the future. */
- public Element footerContainer = DOM.createDiv();
-
- /** For internal use only. May be removed or replaced in the future. */
- public Element fieldSet = DOM.createFieldSet();
-
- /** For internal use only. May be removed or replaced in the future. */
- public Widget footer;
-
- /** For internal use only. May be removed or replaced in the future. */
- public ApplicationConnection client;
-
- /** For internal use only. May be removed or replaced in the future. */
- public ShortcutActionHandler shortcutHandler;
-
- /** For internal use only. May be removed or replaced in the future. */
- public HandlerRegistration keyDownRegistration;
-
- public VForm() {
- setElement(DOM.createDiv());
- getElement().appendChild(fieldSet);
- setStyleName(CLASSNAME);
- fieldSet.appendChild(legend);
- legend.appendChild(caption);
-
- fieldSet.appendChild(desc); // Adding description for initial padding
- // measurements, removed later if no
- // description is set
-
- fieldSet.appendChild(fieldContainer);
- errorMessage.setVisible(false);
-
- fieldSet.appendChild(errorMessage.getElement());
- fieldSet.appendChild(footerContainer);
-
- errorMessage.setOwner(this);
- }
-
- @Override
- public void setStyleName(String style) {
- super.setStyleName(style);
- updateStyleNames();
- }
-
- @Override
- public void setStylePrimaryName(String style) {
- super.setStylePrimaryName(style);
- updateStyleNames();
- }
-
- protected void updateStyleNames() {
- fieldContainer.setClassName(getStylePrimaryName() + "-content");
- errorMessage.setStyleName(getStylePrimaryName() + "-errormessage");
- desc.setClassName(getStylePrimaryName() + "-description");
- footerContainer.setClassName(getStylePrimaryName() + "-footer");
- }
-
- @Override
- public void onKeyDown(KeyDownEvent event) {
- shortcutHandler.handleKeyboardEvent(Event.as(event.getNativeEvent()));
- }
-
- public void setFooterWidget(Widget footerWidget) {
- if (footer != null) {
- remove(footer);
- }
- if (footerWidget != null) {
- super.add(footerWidget, footerContainer);
- }
- footer = footerWidget;
- }
-
- public void setLayoutWidget(Widget newLayoutWidget) {
- if (lo != null) {
- remove(lo);
- }
- if (newLayoutWidget != null) {
- super.add(newLayoutWidget, fieldContainer);
- }
- lo = newLayoutWidget;
- }
-}
diff --git a/client/src/main/java/com/vaadin/client/ui/form/FormConnector.java b/client/src/main/java/com/vaadin/client/ui/form/FormConnector.java
deleted file mode 100644
index 857c2bd40e..0000000000
--- a/client/src/main/java/com/vaadin/client/ui/form/FormConnector.java
+++ /dev/null
@@ -1,236 +0,0 @@
-/*
- * 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.ui.form;
-
-import com.google.gwt.dom.client.Element;
-import com.google.gwt.dom.client.Style.Unit;
-import com.google.gwt.event.dom.client.KeyDownEvent;
-import com.google.gwt.user.client.ui.Widget;
-import com.vaadin.client.ApplicationConnection;
-import com.vaadin.client.ComponentConnector;
-import com.vaadin.client.ConnectorHierarchyChangeEvent;
-import com.vaadin.client.LayoutManager;
-import com.vaadin.client.Paintable;
-import com.vaadin.client.TooltipInfo;
-import com.vaadin.client.UIDL;
-import com.vaadin.client.VCaption;
-import com.vaadin.client.ui.AbstractComponentContainerConnector;
-import com.vaadin.client.ui.ShortcutActionHandler;
-import com.vaadin.client.ui.VForm;
-import com.vaadin.client.ui.layout.ElementResizeEvent;
-import com.vaadin.client.ui.layout.ElementResizeListener;
-import com.vaadin.client.ui.layout.MayScrollChildren;
-import com.vaadin.shared.ui.ComponentStateUtil;
-import com.vaadin.shared.ui.Connect;
-import com.vaadin.shared.ui.form.FormState;
-import com.vaadin.ui.Form;
-
-@Connect(Form.class)
-public class FormConnector extends AbstractComponentContainerConnector
- implements Paintable, MayScrollChildren {
-
- private final ElementResizeListener footerResizeListener = new ElementResizeListener() {
- @Override
- public void onElementResize(ElementResizeEvent e) {
- VForm form = getWidget();
-
- LayoutManager lm = getLayoutManager();
- int footerHeight = 0;
- if (form.footer != null) {
- footerHeight += lm.getOuterHeight(form.footer.getElement());
- }
-
- if (form.errorMessage.isVisible()) {
- footerHeight += lm.getOuterHeight(form.errorMessage
- .getElement());
- footerHeight -= lm.getMarginTop(form.errorMessage.getElement());
- form.errorMessage.getElement().getStyle()
- .setMarginTop(-footerHeight, Unit.PX);
- form.footerContainer.getStyle().clearMarginTop();
- } else {
- form.footerContainer.getStyle().setMarginTop(-footerHeight,
- Unit.PX);
- }
-
- form.fieldContainer.getStyle().setPaddingBottom(footerHeight,
- Unit.PX);
- }
- };
-
- @Override
- protected void init() {
- getLayoutManager().addElementResizeListener(
- getWidget().errorMessage.getElement(), footerResizeListener);
- }
-
- @Override
- public void onUnregister() {
- VForm form = getWidget();
- getLayoutManager().removeElementResizeListener(
- form.errorMessage.getElement(), footerResizeListener);
- if (form.footer != null) {
- getLayoutManager().removeElementResizeListener(
- form.footer.getElement(), footerResizeListener);
- }
- }
-
- @Override
- public boolean delegateCaptionHandling() {
- return false;
- }
-
- @Override
- public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
- getWidget().client = client;
- getWidget().id = uidl.getId();
-
- if (!isRealUpdate(uidl)) {
- return;
- }
-
- boolean legendEmpty = true;
- if (getState().caption != null) {
- VCaption.setCaptionText(getWidget().caption, getState());
- legendEmpty = false;
- } else {
- getWidget().caption.setInnerText("");
- }
- if (getWidget().icon != null) {
- getWidget().legend.removeChild(getWidget().icon.getElement());
- }
- if (getIconUri() != null) {
- getWidget().icon = client.getIcon(getIconUri());
- getWidget().legend.insertFirst(getWidget().icon.getElement());
-
- legendEmpty = false;
- }
- if (legendEmpty) {
- getWidget().addStyleDependentName("nocaption");
- } else {
- getWidget().removeStyleDependentName("nocaption");
- }
-
- if (null != getState().errorMessage) {
- getWidget().errorMessage.updateMessage(getState().errorMessage);
- getWidget().errorMessage.setVisible(true);
- } else {
- getWidget().errorMessage.setVisible(false);
- }
-
- if (ComponentStateUtil.hasDescription(getState())) {
- getWidget().desc.setInnerHTML(getState().description);
- if (getWidget().desc.getParentElement() == null) {
- getWidget().fieldSet.insertAfter(getWidget().desc,
- getWidget().legend);
- }
- } else {
- getWidget().desc.setInnerHTML("");
- if (getWidget().desc.getParentElement() != null) {
- getWidget().fieldSet.removeChild(getWidget().desc);
- }
- }
-
- // also recalculates size of the footer if undefined size form - see
- // #3710
- client.runDescendentsLayout(getWidget());
-
- // We may have actions attached
- if (uidl.getChildCount() >= 1) {
- UIDL childUidl = uidl.getChildByTagName("actions");
- if (childUidl != null) {
- if (getWidget().shortcutHandler == null) {
- getWidget().shortcutHandler = new ShortcutActionHandler(
- getConnectorId(), client);
- getWidget().keyDownRegistration = getWidget()
- .addDomHandler(getWidget(), KeyDownEvent.getType());
- }
- getWidget().shortcutHandler.updateActionMap(childUidl);
- }
- } else if (getWidget().shortcutHandler != null) {
- getWidget().keyDownRegistration.removeHandler();
- getWidget().shortcutHandler = null;
- getWidget().keyDownRegistration = null;
- }
- }
-
- @Override
- public void updateCaption(ComponentConnector component) {
- // NOP form don't render caption for neither field layout nor footer
- // layout
- }
-
- @Override
- public VForm getWidget() {
- return (VForm) super.getWidget();
- }
-
- @Override
- public boolean isReadOnly() {
- return super.isReadOnly() || getState().propertyReadOnly;
- }
-
- @Override
- public FormState getState() {
- return (FormState) super.getState();
- }
-
- private ComponentConnector getFooter() {
- return (ComponentConnector) getState().footer;
- }
-
- private ComponentConnector getLayout() {
- return (ComponentConnector) getState().layout;
- }
-
- @Override
- public void onConnectorHierarchyChange(
- ConnectorHierarchyChangeEvent connectorHierarchyChangeEvent) {
- Widget newFooterWidget = null;
- ComponentConnector footer = getFooter();
-
- if (footer != null) {
- newFooterWidget = footer.getWidget();
- Widget currentFooter = getWidget().footer;
- if (currentFooter != null) {
- // Remove old listener
- getLayoutManager().removeElementResizeListener(
- currentFooter.getElement(), footerResizeListener);
- }
- getLayoutManager().addElementResizeListener(
- newFooterWidget.getElement(), footerResizeListener);
- }
- getWidget().setFooterWidget(newFooterWidget);
-
- Widget newLayoutWidget = null;
- ComponentConnector newLayout = getLayout();
- if (newLayout != null) {
- newLayoutWidget = newLayout.getWidget();
- }
- getWidget().setLayoutWidget(newLayoutWidget);
- }
-
- @Override
- public TooltipInfo getTooltipInfo(Element element) {
- // Form shows its description and error message
- // as a part of the actual layout
- return null;
- }
-
- @Override
- public boolean hasTooltip() {
- return false;
- }
-}
diff --git a/server/src/main/java/com/vaadin/data/fieldgroup/FieldGroup.java b/server/src/main/java/com/vaadin/data/fieldgroup/FieldGroup.java
index acf35f154e..c880ef4335 100644
--- a/server/src/main/java/com/vaadin/data/fieldgroup/FieldGroup.java
+++ b/server/src/main/java/com/vaadin/data/fieldgroup/FieldGroup.java
@@ -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
@@ -28,21 +28,18 @@ import java.util.Map;
import com.vaadin.data.Item;
import com.vaadin.data.Property;
import com.vaadin.data.util.TransactionalPropertyWrapper;
-import com.vaadin.legacy.ui.LegacyField;
import com.vaadin.legacy.data.Validator.InvalidValueException;
import com.vaadin.legacy.ui.LegacyAbstractField;
+import com.vaadin.legacy.ui.LegacyField;
import com.vaadin.ui.DefaultFieldFactory;
-import com.vaadin.ui.Form;
import com.vaadin.util.ReflectTools;
/**
* FieldGroup provides an easy way of binding fields to data and handling
* commits of these fields.
*
- * The functionality of FieldGroup is similar to {@link Form} but
- * {@link FieldGroup} does not handle layouts in any way. The typical use case
- * is to create a layout outside the FieldGroup and then use FieldGroup to bind
- * the fields to a data source.
+ * The typical use case is to create a layout outside the FieldGroup and then
+ * use FieldGroup to bind the fields to a data source.
*
*
* {@link FieldGroup} is not a UI component so it cannot be added to a layout.
@@ -50,7 +47,7 @@ import com.vaadin.util.ReflectTools;
* using a FieldGroupFieldFactory but you still have to add them to the correct
* position in your layout.
*
- *
+ *
* @author Vaadin Ltd
* @since 7.0
*/
@@ -75,15 +72,14 @@ public class FieldGroup implements Serializable {
/**
* Constructs a field binder. Use {@link #setItemDataSource(Item)} to set a
* data source for the field binder.
- *
+ *
*/
public FieldGroup() {
-
}
/**
* Constructs a field binder that uses the given data source.
- *
+ *
* @param itemDataSource
* The data source to bind the fields to
*/
@@ -94,7 +90,7 @@ public class FieldGroup implements Serializable {
/**
* Updates the item that is used by this FieldBinder. Rebinds all fields to
* the properties in the new item.
- *
+ *
* @param itemDataSource
* The new item to use
*/
@@ -110,10 +106,10 @@ public class FieldGroup implements Serializable {
* Gets the item used by this FieldBinder. Note that you must call
* {@link #commit()} for the item to be updated unless buffered mode has
* been switched off.
- *
+ *
* @see #setBuffered(boolean)
* @see #commit()
- *
+ *
* @return The item used by this FieldBinder
*/
public Item getItemDataSource() {
@@ -123,12 +119,12 @@ public class FieldGroup implements Serializable {
/**
* Checks the buffered mode for the bound fields.
*
- *
+ *
* @see #setBuffered(boolean) for more details on buffered mode
- *
+ *
* @see LegacyField#isBuffered()
* @return true if buffered mode is on, false otherwise
- *
+ *
*/
public boolean isBuffered() {
return buffered;
@@ -144,7 +140,7 @@ public class FieldGroup implements Serializable {
*
* The default is to use buffered mode.
*
- *
+ *
* @see LegacyField#setBuffered(boolean)
* @param buffered
* true to turn on buffered mode, false otherwise
@@ -166,7 +162,7 @@ public class FieldGroup implements Serializable {
* Note that this will not accurately represent the enabled status of all
* fields if you change the enabled status of the fields through some other
* method than {@link #setEnabled(boolean)}.
- *
+ *
* @return true if the fields are enabled, false otherwise
*/
public boolean isEnabled() {
@@ -175,7 +171,7 @@ public class FieldGroup implements Serializable {
/**
* Updates the enabled state of all bound fields.
- *
+ *
* @param fieldsEnabled
* true to enable all bound fields, false to disable them
*/
@@ -193,7 +189,7 @@ public class FieldGroup implements Serializable {
* Note that this will not accurately represent the read only status of all
* fields if you change the read only status of the fields through some
* other method than {@link #setReadOnly(boolean)}.
- *
+ *
* @return true if the fields are set to read only, false otherwise
*/
public boolean isReadOnly() {
@@ -204,7 +200,7 @@ public class FieldGroup implements Serializable {
* Sets the read only state to the given value for all fields with writable
* data source. Fields with read only data source will always be set to read
* only.
- *
+ *
* @param fieldsReadOnly
* true to set the fields with writable data source to read only,
* false to set them to read write
@@ -226,7 +222,7 @@ public class FieldGroup implements Serializable {
*
* The fields are not returned in any specific order.
*
- *
+ *
* @return A collection with all bound Fields
*/
public Collection> getFields() {
@@ -240,7 +236,7 @@ public class FieldGroup implements Serializable {
*
* This method also adds validators when applicable.
*
- *
+ *
* @param field
* The field to bind
* @param propertyId
@@ -249,7 +245,8 @@ public class FieldGroup implements Serializable {
* If the field is null or the property id is already bound to
* another field by this field binder
*/
- public void bind(LegacyField> field, Object propertyId) throws BindException {
+ public void bind(LegacyField> field, Object propertyId)
+ throws BindException {
throwIfFieldIsNull(field, propertyId);
throwIfPropertyIdAlreadyBound(field, propertyId);
@@ -275,7 +272,8 @@ public class FieldGroup implements Serializable {
return;
}
- field.setPropertyDataSource(wrapInTransactionalProperty(getItemProperty(propertyId)));
+ field.setPropertyDataSource(
+ wrapInTransactionalProperty(getItemProperty(propertyId)));
configureField(field);
}
@@ -289,14 +287,14 @@ public class FieldGroup implements Serializable {
private void throwIfFieldIsNull(LegacyField> field, Object propertyId) {
if (field == null) {
- throw new BindException(
- String.format(
- "Cannot bind property id '%s' to a null field.",
- propertyId));
+ throw new BindException(String.format(
+ "Cannot bind property id '%s' to a null field.",
+ propertyId));
}
}
- private void throwIfPropertyIdAlreadyBound(LegacyField> field, Object propertyId) {
+ private void throwIfPropertyIdAlreadyBound(LegacyField> field,
+ Object propertyId) {
if (propertyIdToField.containsKey(propertyId)
&& propertyIdToField.get(propertyId) != field) {
throw new BindException("Property id " + propertyId
@@ -306,7 +304,7 @@ public class FieldGroup implements Serializable {
/**
* Gets the property with the given property id from the item.
- *
+ *
* @param propertyId
* The id if the property to find
* @return The property with the given id from the item
@@ -335,7 +333,7 @@ public class FieldGroup implements Serializable {
* Note that the field is not detached from its property data source if it
* is no longer connected to the same property id it was bound to using this
* FieldBinder.
- *
+ *
* @param field
* The field to detach
* @throws BindException
@@ -374,7 +372,7 @@ public class FieldGroup implements Serializable {
* By default this updates the buffered, read only and enabled state of the
* field. Also adds validators when applicable. Fields with read only data
* source are always configured as read only.
- *
+ *
* @param field
* The field to update
*/
@@ -392,24 +390,20 @@ public class FieldGroup implements Serializable {
/**
* Gets the type of the property with the given property id.
- *
+ *
* @param propertyId
* The propertyId. Must be find
* @return The type of the property
*/
protected Class> getPropertyType(Object propertyId) throws BindException {
if (getItemDataSource() == null) {
- throw new BindException(
- "Property type for '"
- + propertyId
- + "' could not be determined. No item data source has been set.");
+ throw new BindException("Property type for '" + propertyId
+ + "' could not be determined. No item data source has been set.");
}
Property> p = getItemDataSource().getItemProperty(propertyId);
if (p == null) {
- throw new BindException(
- "Property type for '"
- + propertyId
- + "' could not be determined. No property with that id was found.");
+ throw new BindException("Property type for '" + propertyId
+ + "' could not be determined. No property with that id was found.");
}
return p.getType();
@@ -425,7 +419,7 @@ public class FieldGroup implements Serializable {
*
* No guarantee is given for the order of the property ids
*
- *
+ *
* @return A collection of bound property ids
*/
public Collection
*
* This binds the firstName TextField to a "firstName" property in the item,
* lastName TextField to a "last" property and builds an age TextField using
* the field factory and then binds it to the "age" property.
*
- *
+ *
* @param objectWithMemberFields
* The object that contains (Java) member fields to build and
* bind
@@ -892,14 +886,14 @@ public class FieldGroup implements Serializable {
* member fields that have not been initialized.
*
* This method processes all (Java) member fields whose type extends
- * {@link LegacyField} and that can be mapped to a property id. Property ids are
- * searched in the following order: @{@link PropertyId} annotations, exact
- * field name matches and the case-insensitive matching that ignores
+ * {@link LegacyField} and that can be mapped to a property id. Property ids
+ * are searched in the following order: @{@link PropertyId} annotations,
+ * exact field name matches and the case-insensitive matching that ignores
* underscores. Fields that are not initialized (null) are built using the
* field factory is buildFields is true. All non-null fields for which a
* property id can be determined are bound to the property id.
*
- *
+ *
* @param objectWithMemberFields
* The object that contains (Java) member fields to build and
* bind
@@ -910,7 +904,8 @@ public class FieldGroup implements Serializable {
boolean buildFields) throws BindException {
Class> objectClass = objectWithMemberFields.getClass();
- for (java.lang.reflect.Field memberField : getFieldsInDeclareOrder(objectClass)) {
+ for (java.lang.reflect.Field memberField : getFieldsInDeclareOrder(
+ objectClass)) {
if (!LegacyField.class.isAssignableFrom(memberField.getType())) {
// Process next field
@@ -1012,7 +1007,7 @@ public class FieldGroup implements Serializable {
* buildAndBindMemberFields} can easily be customized by overriding this
* method. No other changes are needed.
*
- *
+ *
* @param memberField
* The field an object id is searched for
* @return
@@ -1020,10 +1015,8 @@ public class FieldGroup implements Serializable {
protected Object findPropertyId(java.lang.reflect.Field memberField) {
String fieldName = memberField.getName();
if (getItemDataSource() == null) {
- throw new SearchException(
- "Property id type for field '"
- + fieldName
- + "' could not be determined. No item data source has been set.");
+ throw new SearchException("Property id type for field '" + fieldName
+ + "' could not be determined. No item data source has been set.");
}
Item dataSource = getItemDataSource();
if (dataSource.getItemProperty(fieldName) != null) {
@@ -1049,11 +1042,11 @@ public class FieldGroup implements Serializable {
/**
* Exception thrown by a FieldGroup when the commit operation fails.
- *
+ *
* Provides information about validation errors through
* {@link #getInvalidFields()} if the cause of the failure is that all bound
* fields did not pass validation
- *
+ *
*/
public static class CommitException extends Exception {
@@ -1099,7 +1092,7 @@ public class FieldGroup implements Serializable {
/**
* Returns the field group where the exception occurred
- *
+ *
* @since 7.4
* @return the field group
*/
@@ -1136,7 +1129,7 @@ public class FieldGroup implements Serializable {
/**
* Builds a field and binds it to the given property id using the field
* binder.
- *
+ *
* @param propertyId
* The property id to bind to. Must be present in the field
* finder.
@@ -1153,7 +1146,7 @@ public class FieldGroup implements Serializable {
/**
* Builds a field using the given caption and binds it to the given property
* id using the field binder.
- *
+ *
* @param caption
* The caption for the field
* @param propertyId
@@ -1161,7 +1154,8 @@ public class FieldGroup implements Serializable {
* finder.
* @throws BindException
* If there is a problem while building or binding
- * @return The created and bound field. Can be any type of {@link LegacyField}.
+ * @return The created and bound field. Can be any type of
+ * {@link LegacyField}.
*/
public LegacyField> buildAndBind(String caption, Object propertyId)
throws BindException {
@@ -1171,7 +1165,7 @@ public class FieldGroup implements Serializable {
/**
* Builds a field using the given caption and binds it to the given property
* id using the field binder. Ensures the new field is of the given type.
- *
+ *
* @param caption
* The caption for the field
* @param propertyId
@@ -1179,11 +1173,12 @@ public class FieldGroup implements Serializable {
* finder.
* @throws BindException
* If the field could not be created
- * @return The created and bound field. Can be any type of {@link LegacyField}.
+ * @return The created and bound field. Can be any type of
+ * {@link LegacyField}.
*/
- public T buildAndBind(String caption, Object propertyId,
- Class fieldType) throws BindException {
+ public T buildAndBind(String caption,
+ Object propertyId, Class fieldType) throws BindException {
Class> type = getPropertyType(propertyId);
T field = build(caption, type, fieldType);
@@ -1196,10 +1191,10 @@ public class FieldGroup implements Serializable {
* Creates a field based on the given data type.
*
* The data type is the type that we want to edit using the field. The field
- * type is the type of field we want to create, can be {@link LegacyField} if any
- * LegacyField is good.
+ * type is the type of field we want to create, can be {@link LegacyField}
+ * if any LegacyField is good.
*
- *
+ *
* @param caption
* The caption for the new field
* @param dataType
@@ -1214,9 +1209,9 @@ public class FieldGroup implements Serializable {
Class fieldType) throws BindException {
T field = getFieldFactory().createField(dataType, fieldType);
if (field == null) {
- throw new BindException("Unable to build a field of type "
- + fieldType.getName() + " for editing "
- + dataType.getName());
+ throw new BindException(
+ "Unable to build a field of type " + fieldType.getName()
+ + " for editing " + dataType.getName());
}
field.setCaption(caption);
@@ -1224,11 +1219,11 @@ public class FieldGroup implements Serializable {
}
/**
- * Returns an array containing LegacyField objects reflecting all the fields of
- * the class or interface represented by this Class object. The elements in
- * the array returned are sorted in declare order from sub class to super
+ * Returns an array containing LegacyField objects reflecting all the fields
+ * of the class or interface represented by this Class object. The elements
+ * in the array returned are sorted in declare order from sub class to super
* class.
- *
+ *
* @param searchClass
* @return
*/
@@ -1248,7 +1243,7 @@ public class FieldGroup implements Serializable {
/**
* Clears the value of all fields.
- *
+ *
* @since 7.4
*/
public void clear() {
diff --git a/server/src/main/java/com/vaadin/legacy/ui/LegacyDateField.java b/server/src/main/java/com/vaadin/legacy/ui/LegacyDateField.java
index 4bb114bbd5..2a91cd7b7b 100644
--- a/server/src/main/java/com/vaadin/legacy/ui/LegacyDateField.java
+++ b/server/src/main/java/com/vaadin/legacy/ui/LegacyDateField.java
@@ -18,7 +18,6 @@ package com.vaadin.legacy.ui;
import java.text.SimpleDateFormat;
import java.util.Calendar;
-import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.Locale;
@@ -44,7 +43,6 @@ import com.vaadin.shared.ui.datefield.DateFieldConstants;
import com.vaadin.shared.ui.datefield.Resolution;
import com.vaadin.shared.ui.datefield.TextualDateFieldState;
import com.vaadin.ui.Component;
-import com.vaadin.ui.Form;
import com.vaadin.ui.LegacyComponent;
import com.vaadin.ui.declarative.DesignAttributeHandler;
import com.vaadin.ui.declarative.DesignContext;
@@ -603,16 +601,6 @@ public class LegacyDateField extends LegacyAbstractField implements
fireValueChange(false);
}
- /*
- * Because of our custom implementation of isValid(), that
- * also checks the parsingSucceeded flag, we must also
- * notify the form (if this is used in one) that the
- * validity of this field has changed.
- *
- * Normally fields validity doesn't change without value
- * change and form depends on this implementation detail.
- */
- notifyFormOfValidityChange();
markAsDirty();
}
} else if (newDate != oldDate
@@ -699,21 +687,6 @@ public class LegacyDateField extends LegacyAbstractField implements
* and flags about invalid input.
*/
setInternalValue(null);
-
- /*
- * Due to DateField's special implementation of isValid(),
- * datefields validity may change although the logical value does
- * not change. This is an issue for Form which expects that validity
- * of Fields cannot change unless actual value changes.
- *
- * So we check if this field is inside a form and the form has
- * registered this as a field. In this case we repaint the form.
- * Without this hacky solution the form might not be able to clean
- * validation errors etc. We could avoid this by firing an extra
- * value change event, but feels like at least as bad solution as
- * this.
- */
- notifyFormOfValidityChange();
markAsDirty();
return;
}
@@ -721,38 +694,6 @@ public class LegacyDateField extends LegacyAbstractField implements
super.setValue(newValue, repaintIsNotNeeded);
}
- /**
- * Detects if this field is used in a Form (logically) and if so, notifies
- * it (by repainting it) that the validity of this field might have changed.
- */
- private void notifyFormOfValidityChange() {
- Component parenOfDateField = getParent();
- boolean formFound = false;
- while (parenOfDateField != null || formFound) {
- if (parenOfDateField instanceof Form) {
- Form f = (Form) parenOfDateField;
- Collection> visibleItemProperties = f.getItemPropertyIds();
- for (Object fieldId : visibleItemProperties) {
- LegacyField> field = f.getField(fieldId);
- if (equals(field)) {
- /*
- * this datefield is logically in a form. Do the same
- * thing as form does in its value change listener that
- * it registers to all fields.
- */
- f.markAsDirty();
- formFound = true;
- break;
- }
- }
- }
- if (formFound) {
- break;
- }
- parenOfDateField = parenOfDateField.getParent();
- }
- }
-
@Override
protected void setInternalValue(Date newValue) {
// Also set the internal dateString
diff --git a/server/src/main/java/com/vaadin/server/ComponentSizeValidator.java b/server/src/main/java/com/vaadin/server/ComponentSizeValidator.java
index b8b06c780f..a03059c61c 100644
--- a/server/src/main/java/com/vaadin/server/ComponentSizeValidator.java
+++ b/server/src/main/java/com/vaadin/server/ComponentSizeValidator.java
@@ -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,10 +34,8 @@ import com.vaadin.ui.AbstractSplitPanel;
import com.vaadin.ui.Component;
import com.vaadin.ui.ComponentContainer;
import com.vaadin.ui.CustomComponent;
-import com.vaadin.ui.Form;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.GridLayout.Area;
-import com.vaadin.ui.Layout;
import com.vaadin.ui.Panel;
import com.vaadin.ui.TabSheet;
import com.vaadin.ui.UI;
@@ -52,7 +50,7 @@ public class ComponentSizeValidator implements Serializable {
/**
* Recursively checks given component and its subtree for invalid layout
* setups. Prints errors to std err stream.
- *
+ *
* @param component
* component to check
* @return set of first level errors found
@@ -91,16 +89,6 @@ public class ComponentSizeValidator implements Serializable {
errors = validateComponentRelativeSizes(it.next(), errors,
parent);
}
- } else if (component instanceof Form) {
- Form form = (Form) component;
- if (form.getLayout() != null) {
- errors = validateComponentRelativeSizes(form.getLayout(),
- errors, parent);
- }
- if (form.getFooter() != null) {
- errors = validateComponentRelativeSizes(form.getFooter(),
- errors, parent);
- }
}
return errors;
@@ -127,7 +115,8 @@ public class ComponentSizeValidator implements Serializable {
err.append("Layout problem detected: ");
err.append(msg);
err.append("\n");
- err.append("Relative sizes were replaced by undefined sizes, components may not render as expected.\n");
+ err.append(
+ "Relative sizes were replaced by undefined sizes, components may not render as expected.\n");
errorStream.println(err);
}
@@ -181,7 +170,8 @@ public class ComponentSizeValidator implements Serializable {
private final Vector subErrors = new Vector();
- public InvalidLayout(Component component, boolean height, boolean width) {
+ public InvalidLayout(Component component, boolean height,
+ boolean width) {
this.component = component;
invalidHeight = height;
invalidWidth = width;
@@ -289,7 +279,8 @@ public class ComponentSizeValidator implements Serializable {
}
- private static Stack getHeightAttributes(Component component) {
+ private static Stack getHeightAttributes(
+ Component component) {
Stack attributes = new Stack();
attributes
.add(new ComponentInfo(component, getHeightString(component)));
@@ -303,7 +294,8 @@ public class ComponentSizeValidator implements Serializable {
return attributes;
}
- private static Stack getWidthAttributes(Component component) {
+ private static Stack getWidthAttributes(
+ Component component) {
Stack attributes = new Stack();
attributes.add(new ComponentInfo(component, getWidthString(component)));
Component parent = component.getParent();
@@ -320,7 +312,8 @@ public class ComponentSizeValidator implements Serializable {
String width = "width: ";
if (hasRelativeWidth(component)) {
width += "RELATIVE, " + component.getWidth() + " %";
- } else if (component instanceof Window && component.getParent() == null) {
+ } else if (component instanceof Window
+ && component.getParent() == null) {
width += "MAIN WINDOW";
} else if (component.getWidth() >= 0) {
width += "ABSOLUTE, " + component.getWidth() + " "
@@ -336,7 +329,8 @@ public class ComponentSizeValidator implements Serializable {
String height = "height: ";
if (hasRelativeHeight(component)) {
height += "RELATIVE, " + component.getHeight() + " %";
- } else if (component instanceof Window && component.getParent() == null) {
+ } else if (component instanceof Window
+ && component.getParent() == null) {
height += "MAIN WINDOW";
} else if (component.getHeight() > 0) {
height += "ABSOLUTE, " + component.getHeight() + " "
@@ -427,8 +421,8 @@ public class ComponentSizeValidator implements Serializable {
if (parent instanceof VerticalLayout) {
horizontal = false;
}
- if (horizontal
- && hasNonRelativeHeightComponent((AbstractOrderedLayout) parent)) {
+ if (horizontal && hasNonRelativeHeightComponent(
+ (AbstractOrderedLayout) parent)) {
return true;
} else {
return false;
@@ -484,11 +478,12 @@ public class ComponentSizeValidator implements Serializable {
}
private static boolean hasRelativeHeight(Component component) {
- return (component.getHeightUnits() == Unit.PERCENTAGE && component
- .getHeight() > 0);
+ return (component.getHeightUnits() == Unit.PERCENTAGE
+ && component.getHeight() > 0);
}
- private static boolean hasNonRelativeWidthComponent(AbstractOrderedLayout ol) {
+ private static boolean hasNonRelativeWidthComponent(
+ AbstractOrderedLayout ol) {
Iterator it = ol.getComponentIterator();
while (it.hasNext()) {
if (!hasRelativeWidth(it.next())) {
@@ -536,7 +531,8 @@ public class ComponentSizeValidator implements Serializable {
boolean columnHasWidth = false;
for (int col = componentArea.getColumn1(); !columnHasWidth
&& col <= componentArea.getColumn2(); col++) {
- for (int row = 0; !columnHasWidth && row < gl.getRows(); row++) {
+ for (int row = 0; !columnHasWidth
+ && row < gl.getRows(); row++) {
Component c = gl.getComponent(col, row);
if (c != null) {
columnHasWidth = !hasRelativeWidth(c);
@@ -549,12 +545,6 @@ public class ComponentSizeValidator implements Serializable {
// Other components define column width
return true;
}
- } else if (parent instanceof Form) {
- /*
- * If some other part of the form is not relative it determines
- * the component width
- */
- return hasNonRelativeWidthComponent((Form) parent);
} else if (parent instanceof AbstractSplitPanel
|| parent instanceof TabSheet
|| parent instanceof CustomComponent) {
@@ -591,20 +581,6 @@ public class ComponentSizeValidator implements Serializable {
}
- private static boolean hasNonRelativeWidthComponent(Form form) {
- Layout layout = form.getLayout();
- Layout footer = form.getFooter();
-
- if (layout != null && !hasRelativeWidth(layout)) {
- return true;
- }
- if (footer != null && !hasRelativeWidth(footer)) {
- return true;
- }
-
- return false;
- }
-
private static Map creationLocations = new HashMap();
private static Map widthLocations = new HashMap();
private static Map heightLocations = new HashMap();
@@ -638,7 +614,8 @@ public class ComponentSizeValidator implements Serializable {
setLocation(heightLocations, object);
}
- private static void setLocation(Map map, Object object) {
+ private static void setLocation(Map map,
+ Object object) {
StackTraceElement[] traceLines = Thread.currentThread().getStackTrace();
for (StackTraceElement traceElement : traceLines) {
Class> cls;
@@ -650,7 +627,8 @@ public class ComponentSizeValidator implements Serializable {
}
cls = Class.forName(className);
- if (cls == ComponentSizeValidator.class || cls == Thread.class) {
+ if (cls == ComponentSizeValidator.class
+ || cls == Thread.class) {
continue;
}
@@ -675,7 +653,7 @@ public class ComponentSizeValidator implements Serializable {
/**
* Validates the layout and returns a collection of errors
- *
+ *
* @since 7.1
* @param ui
* The UI to validate
diff --git a/server/src/main/java/com/vaadin/ui/DefaultFieldFactory.java b/server/src/main/java/com/vaadin/ui/DefaultFieldFactory.java
index fc096e6bb7..9078c6095e 100644
--- a/server/src/main/java/com/vaadin/ui/DefaultFieldFactory.java
+++ b/server/src/main/java/com/vaadin/ui/DefaultFieldFactory.java
@@ -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,10 +15,10 @@
*/
package com.vaadin.ui;
+import java.text.Normalizer.Form;
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.LegacyDateField;
@@ -27,23 +27,22 @@ import com.vaadin.legacy.ui.LegacyTextField;
import com.vaadin.shared.util.SharedUtil;
/**
- * This class contains a basic implementation for both {@link FormFieldFactory}
- * and {@link TableFieldFactory}. The class is singleton, use {@link #get()}
- * method to get reference to the instance.
- *
+ * This class contains a basic implementation for {@link TableFieldFactory}. The
+ * class is singleton, use {@link #get()} method to get reference to the
+ * instance.
+ *
*
* There are also some static helper methods available for custom built field
* factories.
- *
+ *
*/
-public class DefaultFieldFactory
- implements FormFieldFactory, TableFieldFactory {
+public class DefaultFieldFactory implements TableFieldFactory {
private static final DefaultFieldFactory instance = new DefaultFieldFactory();
/**
* Singleton method to get an instance of DefaultFieldFactory.
- *
+ *
* @return an instance of DefaultFieldFactory
*/
public static DefaultFieldFactory get() {
@@ -53,15 +52,6 @@ public class DefaultFieldFactory
protected DefaultFieldFactory() {
}
- @Override
- public LegacyField> createField(Item item, Object propertyId,
- Component uiContext) {
- Class> type = item.getItemProperty(propertyId).getType();
- LegacyField> field = createFieldByPropertyType(type);
- field.setCaption(createCaptionByPropertyId(propertyId));
- return field;
- }
-
@Override
public LegacyField createField(Container container, Object itemId,
Object propertyId, Component uiContext) {
@@ -76,7 +66,7 @@ public class DefaultFieldFactory
/**
* If name follows method naming conventions, convert the name to spaced
* upper case text. For example, convert "firstName" to "First Name"
- *
+ *
* @param propertyId
* @return the formatted caption string
*/
@@ -95,7 +85,7 @@ public class DefaultFieldFactory
* Item: {@link Form}.
* default field type: {@link LegacyTextField}.
*
- *
+ *
* @param type
* the type of the property
* @return the most suitable generic {@link LegacyField} for given type
@@ -106,11 +96,6 @@ public class DefaultFieldFactory
return null;
}
- // Item field
- if (Item.class.isAssignableFrom(type)) {
- return new Form();
- }
-
// Date field
if (Date.class.isAssignableFrom(type)) {
final LegacyDateField df = new LegacyDateField();
diff --git a/server/src/main/java/com/vaadin/ui/Form.java b/server/src/main/java/com/vaadin/ui/Form.java
deleted file mode 100644
index ff747f429f..0000000000
--- a/server/src/main/java/com/vaadin/ui/Form.java
+++ /dev/null
@@ -1,1425 +0,0 @@
-/*
- * 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.ui;
-
-import java.io.Serializable;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.Map;
-
-import com.vaadin.data.Buffered;
-import com.vaadin.data.Item;
-import com.vaadin.data.Property;
-import com.vaadin.data.fieldgroup.FieldGroup;
-import com.vaadin.data.util.BeanItem;
-import com.vaadin.event.Action;
-import com.vaadin.event.Action.Handler;
-import com.vaadin.event.Action.ShortcutNotifier;
-import com.vaadin.event.ActionManager;
-import com.vaadin.legacy.data.Validatable;
-import com.vaadin.legacy.data.Validator;
-import com.vaadin.legacy.data.Validator.InvalidValueException;
-import com.vaadin.legacy.ui.LegacyAbstractField;
-import com.vaadin.legacy.ui.LegacyField;
-import com.vaadin.server.AbstractErrorMessage;
-import com.vaadin.server.CompositeErrorMessage;
-import com.vaadin.server.ErrorMessage;
-import com.vaadin.server.PaintException;
-import com.vaadin.server.PaintTarget;
-import com.vaadin.server.UserError;
-import com.vaadin.shared.ui.form.FormState;
-
-/**
- * Form component provides easy way of creating and managing sets fields.
- *
- *
- * Form is a container for fields implementing {@link LegacyField}
- * interface. It provides support for any layouts and provides buffering
- * interface for easy connection of commit and discard buttons. All the form
- * fields can be customized by adding validators, setting captions and icons,
- * setting immediateness, etc. Also direct mechanism for replacing existing
- * fields with selections is given.
- *
- *
- *
- * Form provides customizable editor for classes implementing
- * {@link com.vaadin.data.Item} interface. Also the form itself implements this
- * interface for easier connectivity to other items. To use the form as editor
- * for an item, just connect the item to form with
- * {@link Form#setItemDataSource(Item)}. If only a part of the item needs to be
- * edited, {@link Form#setItemDataSource(Item,Collection)} can be used instead.
- * After the item has been connected to the form, the automatically created
- * fields can be customized and new fields can be added. If you need to connect
- * a class that does not implement {@link com.vaadin.data.Item} interface, most
- * properties of any class following bean pattern, can be accessed trough
- * {@link com.vaadin.data.util.BeanItem}.
- *
- *
- * @author Vaadin Ltd.
- * @since 3.0
- * @deprecated As of 7.0, use {@link FieldGroup} instead of {@link Form} for
- * more flexibility.
- */
-@Deprecated
-public class Form extends LegacyAbstractField implements Item.Editor,
- Buffered, Item, Validatable, Action.Notifier, HasComponents,
- LegacyComponent {
-
- private Object propertyValue;
-
- /**
- * Item connected to this form as datasource.
- */
- private Item itemDatasource;
-
- /**
- * Ordered list of property ids in this editor.
- */
- private final LinkedList propertyIds = new LinkedList<>();
-
- /**
- * Current buffered source exception.
- */
- private Buffered.SourceException currentBufferedSourceException = null;
-
- /**
- * Is the form in buffered mode.
- */
- private boolean buffered = false;
-
- /**
- * Mapping from propertyName to corresponding field.
- */
- private final HashMap> fields = new HashMap<>();
-
- /**
- * Form may act as an Item, its own properties are stored here.
- */
- private final HashMap> ownProperties = new HashMap<>();
-
- /**
- * Field factory for this form.
- */
- private FormFieldFactory fieldFactory;
-
- /**
- * Visible item properties.
- */
- private Collection> visibleItemProperties;
-
- /**
- * Form needs to repaint itself if child fields value changes due possible
- * change in form validity.
- *
- * TODO introduce ValidityChangeEvent (#6239) and start using it instead.
- * See e.g. DateField#notifyFormOfValidityChange().
- */
- private final ValueChangeListener fieldValueChangeListener = new ValueChangeListener() {
- @Override
- public void valueChange(
- com.vaadin.data.Property.ValueChangeEvent event) {
- markAsDirty();
- }
- };
-
- /**
- * If this is true, commit implicitly calls setValidationVisible(true).
- */
- private boolean validationVisibleOnCommit = true;
-
- // special handling for gridlayout; remember initial cursor pos
- private int gridlayoutCursorX = -1;
- private int gridlayoutCursorY = -1;
-
- /**
- * Keeps track of the Actions added to this component, and manages the
- * painting and handling as well. Note that the extended LegacyAbstractField
- * is a {@link ShortcutNotifier} and has a actionManager that delegates
- * actions to the containing window. This one does not delegate.
- */
- private ActionManager ownActionManager = new ActionManager(this);
-
- /**
- * Constructs a new form with default layout.
- *
- *
- * By default the form uses {@link FormLayout}.
- *
- */
- public Form() {
- this(null);
- setValidationVisible(false);
- }
-
- /**
- * Constructs a new form with given {@link Layout}.
- *
- * @param formLayout
- * the layout of the form.
- */
- public Form(Layout formLayout) {
- this(formLayout, DefaultFieldFactory.get());
- }
-
- /**
- * Constructs a new form with given {@link Layout} and
- * {@link FormFieldFactory}.
- *
- * @param formLayout
- * the layout of the form.
- * @param fieldFactory
- * the FieldFactory of the form.
- */
- public Form(Layout formLayout, FormFieldFactory fieldFactory) {
- super();
- setLayout(formLayout);
- setFooter(new HorizontalLayout());
- setFormFieldFactory(fieldFactory);
- setValidationVisible(false);
- setWidth(100, UNITS_PERCENTAGE);
- }
-
- @Override
- protected FormState getState() {
- return (FormState) super.getState();
- }
-
- @Override
- protected FormState getState(boolean markAsDirty) {
- return (FormState) super.getState(markAsDirty);
- }
-
- /* Documented in interface */
- @Override
- public void paintContent(PaintTarget target) throws PaintException {
- if (ownActionManager != null) {
- ownActionManager.paintActions(null, target);
- }
- }
-
- @Override
- public void changeVariables(Object source, Map variables) {
- // Actions
- if (ownActionManager != null) {
- ownActionManager.handleActions(variables, this);
- }
- }
-
- /**
- * The error message of a Form is the error of the first field with a
- * non-empty error.
- *
- * Empty error messages of the contained fields are skipped, because an
- * empty error indicator would be confusing to the user, especially if there
- * are errors that have something to display. This is also the reason why
- * the calculation of the error message is separate from validation, because
- * validation fails also on empty errors.
- */
- @Override
- public ErrorMessage getErrorMessage() {
-
- // Reimplement the checking of validation error by using
- // getErrorMessage() recursively instead of validate().
- ErrorMessage validationError = null;
- if (isValidationVisible()) {
- for (final Iterator i = propertyIds.iterator(); i
- .hasNext();) {
- Object f = fields.get(i.next());
- if (f instanceof AbstractComponent) {
- AbstractComponent field = (AbstractComponent) f;
-
- validationError = field.getErrorMessage();
- if (validationError != null) {
- // Show caption as error for fields with empty errors
- if ("".equals(validationError.toString())) {
- validationError = new UserError(field.getCaption());
- }
- break;
- } else if (f instanceof LegacyField && !((LegacyField>) f)
- .isValid()) {
- // Something is wrong with the field, but no proper
- // error is given. Generate one.
- validationError = new UserError(field.getCaption());
- break;
- }
- }
- }
- }
-
- // Return if there are no errors at all
- if (getComponentError() == null && validationError == null
- && currentBufferedSourceException == null) {
- return null;
- }
-
- // Throw combination of the error types
- return new CompositeErrorMessage(
- new ErrorMessage[] {
- getComponentError(),
- validationError,
- AbstractErrorMessage
- .getErrorMessageForException(
- currentBufferedSourceException) });
- }
-
- /**
- * Controls the making validation visible implicitly on commit.
- *
- * Having commit() call setValidationVisible(true) implicitly is the default
- * behaviour. You can disable the implicit setting by setting this property
- * as false.
- *
- * It is useful, because you usually want to start with the form free of
- * errors and only display them after the user clicks Ok. You can disable
- * the implicit setting by setting this property as false.
- *
- * @param makeVisible
- * If true (default), validation is made visible when commit() is
- * called. If false, the visibility is left as it is.
- */
- public void setValidationVisibleOnCommit(boolean makeVisible) {
- validationVisibleOnCommit = makeVisible;
- }
-
- /**
- * Is validation made automatically visible on commit?
- *
- * See setValidationVisibleOnCommit().
- *
- * @return true if validation is made automatically visible on commit.
- */
- public boolean isValidationVisibleOnCommit() {
- return validationVisibleOnCommit;
- }
-
- /*
- * Commit changes to the data source Don't add a JavaDoc comment here, we
- * use the default one from the interface.
- */
- @Override
- public void commit() throws Buffered.SourceException,
- InvalidValueException {
-
- LinkedList problems = null;
-
- // Only commit on valid state if so requested
- if (!isInvalidCommitted() && !isValid()) {
- /*
- * The values are not ok and we are told not to commit invalid
- * values
- */
- if (validationVisibleOnCommit) {
- setValidationVisible(true);
- }
-
- // Find the first invalid value and throw the exception
- validate();
- }
-
- // Try to commit all
- for (final Iterator i = propertyIds.iterator(); i.hasNext();) {
- try {
- final LegacyField> f = (fields.get(i.next()));
- // Commit only non-readonly fields.
- if (!f.isReadOnly()) {
- f.commit();
- }
- } catch (final Buffered.SourceException e) {
- if (problems == null) {
- problems = new LinkedList<>();
- }
- problems.add(e);
- }
- }
-
- // No problems occurred
- if (problems == null) {
- if (currentBufferedSourceException != null) {
- currentBufferedSourceException = null;
- markAsDirty();
- }
- return;
- }
-
- // Commit problems
- final Throwable[] causes = new Throwable[problems.size()];
- int index = 0;
- for (final Iterator i = problems.iterator(); i
- .hasNext();) {
- causes[index++] = i.next();
- }
- final Buffered.SourceException e = new Buffered.SourceException(this,
- causes);
- currentBufferedSourceException = e;
- markAsDirty();
- throw e;
- }
-
- /*
- * Discards local changes and refresh values from the data source Don't add
- * a JavaDoc comment here, we use the default one from the interface.
- */
- @Override
- public void discard() throws Buffered.SourceException {
-
- LinkedList problems = null;
-
- // Try to discard all changes
- for (final Iterator i = propertyIds.iterator(); i.hasNext();) {
- try {
- (fields.get(i.next())).discard();
- } catch (final Buffered.SourceException e) {
- if (problems == null) {
- problems = new LinkedList<>();
- }
- problems.add(e);
- }
- }
-
- // No problems occurred
- if (problems == null) {
- if (currentBufferedSourceException != null) {
- currentBufferedSourceException = null;
- markAsDirty();
- }
- return;
- }
-
- // Discards problems occurred
- final Throwable[] causes = new Throwable[problems.size()];
- int index = 0;
- for (final Iterator i = problems.iterator(); i
- .hasNext();) {
- causes[index++] = i.next();
- }
- final Buffered.SourceException e = new Buffered.SourceException(this,
- causes);
- currentBufferedSourceException = e;
- markAsDirty();
- throw e;
- }
-
- /*
- * Is the object modified but not committed? Don't add a JavaDoc comment
- * here, we use the default one from the interface.
- */
- @Override
- public boolean isModified() {
- for (final Iterator i = propertyIds.iterator(); i.hasNext();) {
- final LegacyField> f = fields.get(i.next());
- if (f != null && f.isModified()) {
- return true;
- }
-
- }
- return false;
- }
-
- /*
- * Sets the editor's buffered mode to the specified status. Don't add a
- * JavaDoc comment here, we use the default one from the interface.
- */
- @Override
- public void setBuffered(boolean buffered) {
- if (buffered != this.buffered) {
- this.buffered = buffered;
- for (final Iterator i = propertyIds.iterator(); i
- .hasNext();) {
- (fields.get(i.next())).setBuffered(buffered);
- }
- }
- }
-
- /**
- * Adds a new property to form and create corresponding field.
- *
- * @see com.vaadin.data.Item#addItemProperty(Object, Property)
- */
- @Override
- public boolean addItemProperty(Object id, Property property) {
-
- // Checks inputs
- if (id == null || property == null) {
- throw new NullPointerException("Id and property must be non-null");
- }
-
- // Checks that the property id is not reserved
- if (propertyIds.contains(id)) {
- return false;
- }
-
- propertyIds.add(id);
- ownProperties.put(id, property);
-
- // Gets suitable field
- final LegacyField> field = fieldFactory.createField(this, id, this);
- if (field == null) {
- return false;
- }
-
- // Configures the field
- bindPropertyToField(id, property, field);
-
- // Register and attach the created field
- addField(id, field);
-
- return true;
- }
-
- /**
- * Registers the field with the form and adds the field to the form layout.
- *
- *
- * The property id must not be already used in the form.
- *
- *
- *
- * This field is added to the layout using the
- * {@link #attachField(Object, LegacyField)} method.
- *
- *
- * @param propertyId
- * the Property id the the field.
- * @param field
- * the field which should be added to the form.
- */
- public void addField(Object propertyId, LegacyField> field) {
- registerField(propertyId, field);
- attachField(propertyId, field);
- markAsDirty();
- }
-
- /**
- * Register the field with the form. All registered fields are validated
- * when the form is validated and also committed when the form is committed.
- *
- *
- * The property id must not be already used in the form.
- *
- *
- *
- * @param propertyId
- * the Property id of the field.
- * @param field
- * the LegacyField that should be registered
- */
- private void registerField(Object propertyId, LegacyField> field) {
- if (propertyId == null || field == null) {
- return;
- }
-
- fields.put(propertyId, field);
- field.addListener(fieldValueChangeListener);
- if (!propertyIds.contains(propertyId)) {
- // adding a field directly
- propertyIds.addLast(propertyId);
- }
-
- // Update the buffered mode and immediate to match the
- // form.
- // Should this also include invalidCommitted (#3993)?
- field.setBuffered(buffered);
- if (isImmediate() && field instanceof AbstractComponent) {
- ((AbstractComponent) field).setImmediate(true);
- }
- }
-
- /**
- * Adds the field to the form layout.
- *
- * The field is added to the form layout in the default position (the
- * position used by {@link Layout#addComponent(Component)}. If the
- * underlying layout is a {@link CustomLayout} the field is added to the
- * CustomLayout location given by the string representation of the property
- * id using {@link CustomLayout#addComponent(Component, String)}.
- *
- *
- *
- * Override this method to control how the fields are added to the layout.
- *
- * The property data source of the field specified with property id is
- * returned. If there is a (with specified property id) having no data
- * source, the field is returned instead of the data source.
- *
- *
- * @see com.vaadin.data.Item#getItemProperty(Object)
- */
- @Override
- public Property getItemProperty(Object id) {
- final LegacyField> field = fields.get(id);
- if (field == null) {
- // field does not exist or it is not (yet) created for this property
- return ownProperties.get(id);
- }
- final Property> property = field.getPropertyDataSource();
-
- if (property != null) {
- return property;
- } else {
- return field;
- }
- }
-
- /**
- * Gets the field identified by the propertyid.
- *
- * @param propertyId
- * the id of the property.
- */
- public LegacyField getField(Object propertyId) {
- return fields.get(propertyId);
- }
-
- /* Documented in interface */
- @Override
- public Collection> getItemPropertyIds() {
- return Collections.unmodifiableCollection(propertyIds);
- }
-
- /**
- * Removes the property and corresponding field from the form.
- *
- * @see com.vaadin.data.Item#removeItemProperty(Object)
- */
- @Override
- public boolean removeItemProperty(Object id) {
- ownProperties.remove(id);
-
- final LegacyField> field = fields.get(id);
-
- if (field != null) {
- propertyIds.remove(id);
- fields.remove(id);
- detachField(field);
- field.removeListener(fieldValueChangeListener);
- return true;
- }
-
- return false;
- }
-
- /**
- * Called when a form field is detached from a Form. Typically when a new
- * Item is assigned to Form via {@link #setItemDataSource(Item)}.
- *
- * Override this method to control how the fields are removed from the
- * layout.
- *
- *
- * @param field
- * the field to be detached from the forms layout.
- */
- protected void detachField(final LegacyField field) {
- Component p = field.getParent();
- if (p instanceof ComponentContainer) {
- ((ComponentContainer) p).removeComponent(field);
- }
- }
-
- /**
- * Removes all properties and fields from the form.
- *
- * @return the Success of the operation. Removal of all fields succeeded if
- * (and only if) the return value is true.
- */
- public boolean removeAllProperties() {
- final Object[] properties = propertyIds.toArray();
- boolean success = true;
-
- for (int i = 0; i < properties.length; i++) {
- if (!removeItemProperty(properties[i])) {
- success = false;
- }
- }
-
- return success;
- }
-
- /* Documented in the interface */
- @Override
- public Item getItemDataSource() {
- return itemDatasource;
- }
-
- /**
- * Sets the item datasource for the form.
- *
- *
- * Setting item datasource clears any fields, the form might contain and
- * adds all the properties as fields to the form.
- *
- *
- * @see com.vaadin.data.Item.Viewer#setItemDataSource(Item)
- */
- @Override
- public void setItemDataSource(Item newDataSource) {
- setItemDataSource(newDataSource,
- newDataSource != null ? newDataSource.getItemPropertyIds()
- : null);
- }
-
- /**
- * Set the item datasource for the form, but limit the form contents to
- * specified properties of the item.
- *
- *
- * Setting item datasource clears any fields, the form might contain and
- * adds the specified the properties as fields to the form, in the specified
- * order.
- *
- *
- * @see com.vaadin.data.Item.Viewer#setItemDataSource(Item)
- */
- public void setItemDataSource(Item newDataSource,
- Collection> propertyIds) {
-
- if (getLayout() instanceof GridLayout) {
- GridLayout gl = (GridLayout) getLayout();
- if (gridlayoutCursorX == -1) {
- // first setItemDataSource, remember initial cursor
- gridlayoutCursorX = gl.getCursorX();
- gridlayoutCursorY = gl.getCursorY();
- } else {
- // restore initial cursor
- gl.setCursorX(gridlayoutCursorX);
- gl.setCursorY(gridlayoutCursorY);
- }
- }
-
- // Removes all fields first from the form
- removeAllProperties();
-
- // Sets the datasource
- itemDatasource = newDataSource;
-
- // If the new datasource is null, just set null datasource
- if (itemDatasource == null) {
- markAsDirty();
- return;
- }
-
- // Adds all the properties to this form
- for (final Iterator> i = propertyIds.iterator(); i.hasNext();) {
- final Object id = i.next();
- final Property> property = itemDatasource.getItemProperty(id);
- if (id != null && property != null) {
- final LegacyField> f = fieldFactory.createField(
- itemDatasource, id,
- this);
- if (f != null) {
- bindPropertyToField(id, property, f);
- addField(id, f);
- }
- }
- }
- }
-
- /**
- * Binds an item property to a field. The default behavior is to bind
- * property straight to LegacyField. If Property.Viewer type property (e.g.
- * PropertyFormatter) is already set for field, the property is bound to
- * that Property.Viewer.
- *
- * @param propertyId
- * @param property
- * @param field
- * @since 6.7.3
- */
- protected void bindPropertyToField(final Object propertyId,
- final Property property, final LegacyField field) {
- // check if field has a property that is Viewer set. In that case we
- // expect developer has e.g. PropertyFormatter that he wishes to use and
- // assign the property to the Viewer instead.
- boolean hasFilterProperty = field.getPropertyDataSource() != null
- && (field.getPropertyDataSource() instanceof Property.Viewer);
- if (hasFilterProperty) {
- ((Property.Viewer) field.getPropertyDataSource())
- .setPropertyDataSource(property);
- } else {
- field.setPropertyDataSource(property);
- }
- }
-
- /**
- * Gets the layout of the form.
- *
- *
- * By default form uses OrderedLayout with form
- * -style.
- *
- *
- * @return the Layout of the form.
- */
- public Layout getLayout() {
- return (Layout) getState(false).layout;
- }
-
- /**
- * Sets the layout of the form.
- *
- *
- * If set to null then Form uses a FormLayout by default.
- *
- *
- * @param layout
- * the layout of the form.
- */
- public void setLayout(Layout layout) {
-
- // Use orderedlayout by default
- if (layout == null) {
- layout = new FormLayout();
- }
-
- // reset cursor memory
- gridlayoutCursorX = -1;
- gridlayoutCursorY = -1;
-
- // Move fields from previous layout
- if (getLayout() != null) {
- final Object[] properties = propertyIds.toArray();
- for (int i = 0; i < properties.length; i++) {
- LegacyField> f = getField(properties[i]);
- detachField(f);
- if (layout instanceof CustomLayout) {
- ((CustomLayout) layout).addComponent(f,
- properties[i].toString());
- } else {
- layout.addComponent(f);
- }
- }
-
- getLayout().setParent(null);
- }
-
- // Replace the previous layout
- layout.setParent(this);
- getState().layout = layout;
- }
-
- /**
- * Sets the form field to be selectable from static list of changes.
- *
- *
- * The list values and descriptions are given as array. The value-array must
- * contain the current value of the field and the lengths of the arrays must
- * match. Null values are not supported.
- *
- *
- * Note: since Vaadin 7.0, returns an {@link AbstractSelect} instead of a
- * {@link Select}.
- *
- * @param propertyId
- * the id of the property.
- * @param values
- * @param descriptions
- * @return the select property generated
- */
- public AbstractSelect replaceWithSelect(Object propertyId, Object[] values,
- Object[] descriptions) {
-
- // Checks the parameters
- if (propertyId == null || values == null || descriptions == null) {
- throw new NullPointerException("All parameters must be non-null");
- }
- if (values.length != descriptions.length) {
- throw new IllegalArgumentException(
- "Value and description list are of different size");
- }
-
- // Gets the old field
- final LegacyField> oldField = fields.get(propertyId);
- if (oldField == null) {
- throw new IllegalArgumentException(
- "Field with given propertyid '"
- + propertyId.toString() + "' can not be found.");
- }
- final Object value = oldField.getPropertyDataSource() == null ? oldField
- .getValue() : oldField.getPropertyDataSource().getValue();
-
- // Checks that the value exists and check if the select should
- // be forced in multiselect mode
- boolean found = false;
- boolean isMultiselect = false;
- for (int i = 0; i < values.length && !found; i++) {
- if (values[i] == value
- || (value != null && value.equals(values[i]))) {
- found = true;
- }
- }
- if (value != null && !found) {
- if (value instanceof Collection) {
- for (final Iterator> it = ((Collection>) value)
- .iterator(); it
- .hasNext();) {
- final Object val = it.next();
- found = false;
- for (int i = 0; i < values.length && !found; i++) {
- if (values[i] == val
- || (val != null && val.equals(values[i]))) {
- found = true;
- }
- }
- if (!found) {
- throw new IllegalArgumentException(
- "Currently selected value '" + val
- + "' of property '"
- + propertyId.toString()
- + "' was not found");
- }
- }
- isMultiselect = true;
- } else {
- throw new IllegalArgumentException("Current value '" + value
- + "' of property '" + propertyId.toString()
- + "' was not found");
- }
- }
-
- // Creates the new field matching to old field parameters
- final AbstractSelect newField = isMultiselect ? new ListSelect()
- : new Select();
- newField.setCaption(oldField.getCaption());
- newField.setReadOnly(oldField.isReadOnly());
- newField.setBuffered(oldField.isBuffered());
-
- // Creates the options list
- newField.addContainerProperty("desc", String.class, "");
- newField.setItemCaptionPropertyId("desc");
- for (int i = 0; i < values.length; i++) {
- Object id = values[i];
- final Item item;
- if (id == null) {
- id = newField.addItem();
- item = newField.getItem(id);
- newField.setNullSelectionItemId(id);
- } else {
- item = newField.addItem(id);
- }
-
- if (item != null) {
- item.getItemProperty("desc").setValue(
- descriptions[i].toString());
- }
- }
-
- // Sets the property data source
- final Property> property = oldField.getPropertyDataSource();
- oldField.setPropertyDataSource(null);
- newField.setPropertyDataSource(property);
-
- // Replaces the old field with new one
- getLayout().replaceComponent(oldField, newField);
- fields.put(propertyId, newField);
- newField.addListener(fieldValueChangeListener);
- oldField.removeListener(fieldValueChangeListener);
-
- return newField;
- }
-
- /**
- * Checks the validity of the Form and all of its fields.
- *
- * @see com.vaadin.legacy.data.Validatable#validate()
- */
- @Override
- public void validate() throws InvalidValueException {
- super.validate();
- for (final Iterator i = propertyIds.iterator(); i.hasNext();) {
- (fields.get(i.next())).validate();
- }
- }
-
- /**
- * Checks the validabtable object accept invalid values.
- *
- * @see com.vaadin.legacy.data.Validatable#isInvalidAllowed()
- */
- @Override
- public boolean isInvalidAllowed() {
- return true;
- }
-
- /**
- * Should the validabtable object accept invalid values.
- *
- * @see com.vaadin.legacy.data.Validatable#setInvalidAllowed(boolean)
- */
- @Override
- public void setInvalidAllowed(boolean invalidValueAllowed)
- throws UnsupportedOperationException {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Sets the component's to read-only mode to the specified state.
- *
- * @see com.vaadin.ui.Component#setReadOnly(boolean)
- */
- @Override
- public void setReadOnly(boolean readOnly) {
- super.setReadOnly(readOnly);
- for (final Iterator> i = propertyIds.iterator(); i.hasNext();) {
- (fields.get(i.next())).setReadOnly(readOnly);
- }
- }
-
- /**
- * Sets the field factory used by this Form to genarate Fields for
- * properties.
- *
- * {@link FormFieldFactory} is used to create fields for form properties.
- * {@link DefaultFieldFactory} is used by default.
- *
- * @param fieldFactory
- * the new factory used to create the fields.
- * @see LegacyField
- * @see FormFieldFactory
- */
- public void setFormFieldFactory(FormFieldFactory fieldFactory) {
- this.fieldFactory = fieldFactory;
- }
-
- /**
- * Get the field factory of the form.
- *
- * @return the FormFieldFactory Factory used to create the fields.
- */
- public FormFieldFactory getFormFieldFactory() {
- return fieldFactory;
- }
-
- /**
- * Gets the field type.
- *
- * @see com.vaadin.legacy.ui.LegacyAbstractField#getType()
- */
- @Override
- public Class> getType() {
- if (getPropertyDataSource() != null) {
- return getPropertyDataSource().getType();
- }
- return Object.class;
- }
-
- /**
- * Sets the internal value.
- *
- * This is relevant when the Form is used as LegacyField.
- *
- * @see com.vaadin.legacy.ui.LegacyAbstractField#setInternalValue(java.lang.Object)
- */
- @Override
- protected void setInternalValue(Object newValue) {
- // Stores the old value
- final Object oldValue = propertyValue;
-
- // Sets the current Value
- super.setInternalValue(newValue);
- propertyValue = newValue;
-
- // Ignores form updating if data object has not changed.
- if (oldValue != newValue) {
- setFormDataSource(newValue, getVisibleItemProperties());
- }
- }
-
- /**
- * Gets the first focusable field in form. If there are enabled,
- * non-read-only fields, the first one of them is returned. Otherwise, the
- * field for the first property (or null if none) is returned.
- *
- * @return the LegacyField.
- */
- private LegacyField> getFirstFocusableField() {
- Collection> itemPropertyIds = getItemPropertyIds();
- if (itemPropertyIds != null && itemPropertyIds.size() > 0) {
- for (Object id : itemPropertyIds) {
- if (id != null) {
- LegacyField> field = getField(id);
- if (field.isConnectorEnabled() && !field.isReadOnly()) {
- return field;
- }
- }
- }
- // fallback: first field if none of the fields is enabled and
- // writable
- Object id = itemPropertyIds.iterator().next();
- if (id != null) {
- return getField(id);
- }
- }
- return null;
- }
-
- /**
- * Updates the internal form datasource.
- *
- * Method setFormDataSource.
- *
- * @param data
- * @param properties
- */
- protected void setFormDataSource(Object data, Collection> properties) {
-
- // If data is an item use it.
- Item item = null;
- if (data instanceof Item) {
- item = (Item) data;
- } else if (data != null) {
- item = new BeanItem<>(data);
- }
-
- // Sets the datasource to form
- if (item != null && properties != null) {
- // Shows only given properties
- this.setItemDataSource(item, properties);
- } else {
- // Shows all properties
- this.setItemDataSource(item);
- }
- }
-
- /**
- * Returns the visibleProperties.
- *
- * @return the Collection of visible Item properites.
- */
- public Collection> getVisibleItemProperties() {
- return visibleItemProperties;
- }
-
- /**
- * Sets the visibleProperties.
- *
- * @param visibleProperties
- * the visibleProperties to set.
- */
- public void setVisibleItemProperties(Collection> visibleProperties) {
- visibleItemProperties = visibleProperties;
- Object value = getValue();
- if (value == null) {
- value = itemDatasource;
- }
- setFormDataSource(value, getVisibleItemProperties());
- }
-
- /**
- * Sets the visibleProperties.
- *
- * @param visibleProperties
- * the visibleProperties to set.
- */
- public void setVisibleItemProperties(Object... visibleProperties) {
- LinkedList v = new LinkedList<>();
- for (int i = 0; i < visibleProperties.length; i++) {
- v.add(visibleProperties[i]);
- }
- setVisibleItemProperties(v);
- }
-
- /**
- * Focuses the first field in the form.
- *
- * @see com.vaadin.ui.Component.Focusable#focus()
- */
- @Override
- public void focus() {
- final LegacyField> f = getFirstFocusableField();
- if (f != null) {
- f.focus();
- }
- }
-
- /**
- * Sets the Tabulator index of this Focusable component.
- *
- * @see com.vaadin.ui.Component.Focusable#setTabIndex(int)
- */
- @Override
- public void setTabIndex(int tabIndex) {
- super.setTabIndex(tabIndex);
- for (final Iterator> i = getItemPropertyIds().iterator(); i
- .hasNext();) {
- (getField(i.next())).setTabIndex(tabIndex);
- }
- }
-
- /**
- * Setting the form to be immediate also sets all the fields of the form to
- * the same state.
- */
- @Override
- public void setImmediate(boolean immediate) {
- super.setImmediate(immediate);
- for (Iterator> i = fields.values().iterator(); i
- .hasNext();) {
- LegacyField> f = i.next();
- if (f instanceof AbstractComponent) {
- ((AbstractComponent) f).setImmediate(immediate);
- }
- }
- }
-
- /**
- * {@inheritDoc}
- *
- * A Form is empty if all of its fields are empty.
- *
- */
- @Override
- public boolean isEmpty() {
-
- for (Iterator> i = fields.values().iterator(); i
- .hasNext();) {
- LegacyField> f = i.next();
- if (f instanceof LegacyAbstractField) {
- if (!((LegacyAbstractField>) f).isEmpty()) {
- return false;
- }
- }
- }
-
- return true;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.vaadin.ui.AbstractField#clear()
- */
- @Override
- public void clear() {
- for (Iterator> i = fields.values().iterator(); i
- .hasNext();) {
- LegacyField> f = i.next();
- if (f instanceof LegacyAbstractField) {
- ((LegacyAbstractField>) f).clear();
- }
- }
- }
-
- /**
- * Adding validators directly to form is not supported.
- *
- * Add the validators to form fields instead.
- */
- @Override
- public void addValidator(Validator validator) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Returns a layout that is rendered below normal form contents. This area
- * can be used for example to include buttons related to form contents.
- *
- * @return layout rendered below normal form contents or null if no footer
- * is used
- */
- public Layout getFooter() {
- return (Layout) getState(false).footer;
- }
-
- /**
- * Sets the layout that is rendered below normal form contents. No footer is
- * rendered if this is set to null, .
- *
- * @param footer
- * the new footer layout
- */
- public void setFooter(Layout footer) {
- if (getFooter() != null) {
- getFooter().setParent(null);
- }
- getState().footer = footer;
- if (footer != null) {
- footer.setParent(this);
- }
- }
-
- @Override
- public void setEnabled(boolean enabled) {
- super.setEnabled(enabled);
- if (getParent() != null && !getParent().isEnabled()) {
- // some ancestor still disabled, don't update children
- return;
- } else {
- getLayout().markAsDirtyRecursive();
- }
- }
-
- /*
- * ACTIONS
- */
-
- /**
- * Gets the {@link ActionManager} responsible for handling {@link Action}s
- * added to this Form.
- * Note that Form has another ActionManager inherited from
- * {@link LegacyAbstractField}. The ownActionManager handles Actions
- * attached to this Form specifically, while the ActionManager in
- * LegacyAbstractField delegates to the containing Window (i.e global
- * Actions).
- *
- * @return
- */
- protected ActionManager getOwnActionManager() {
- if (ownActionManager == null) {
- ownActionManager = new ActionManager(this);
- }
- return ownActionManager;
- }
-
- @Override
- public void addActionHandler(Handler actionHandler) {
- getOwnActionManager().addActionHandler(actionHandler);
- }
-
- @Override
- public void removeActionHandler(Handler actionHandler) {
- if (ownActionManager != null) {
- ownActionManager.removeActionHandler(actionHandler);
- }
- }
-
- /**
- * Removes all action handlers
- */
- public void removeAllActionHandlers() {
- if (ownActionManager != null) {
- ownActionManager.removeAllActionHandlers();
- }
- }
-
- @Override
- public void addAction(
- T action) {
- getOwnActionManager().addAction(action);
- }
-
- @Override
- public void removeAction(
- T action) {
- if (ownActionManager != null) {
- ownActionManager.removeAction(action);
- }
- }
-
- @Override
- public Iterator iterator() {
- return new ComponentIterator();
- }
-
- /**
- * Modifiable and Serializable Iterator for the components, used by
- * {@link Form#getComponentIterator()}.
- */
- private class ComponentIterator implements Iterator,
- Serializable {
-
- int i = 0;
-
- @Override
- public boolean hasNext() {
- if (i < getComponentCount()) {
- return true;
- }
- return false;
- }
-
- @Override
- public Component next() {
- if (!hasNext()) {
- return null;
- }
- i++;
- if (i == 1) {
- if (getLayout() != null) {
- return getLayout();
- }
- if (getFooter() != null) {
- return getFooter();
- }
- } else if (i == 2) {
- if (getFooter() != null) {
- return getFooter();
- }
- }
- return null;
- }
-
- @Override
- public void remove() {
- if (i == 1) {
- if (getLayout() != null) {
- setLayout(null);
- i = 0;
- } else {
- setFooter(null);
- }
- } else if (i == 2) {
- setFooter(null);
- }
- }
- }
-
- /**
- * @deprecated As of 7.0, use {@link #iterator()} instead.
- */
- @Deprecated
- public Iterator getComponentIterator() {
- return iterator();
- }
-
- public int getComponentCount() {
- int count = 0;
- if (getLayout() != null) {
- count++;
- }
- if (getFooter() != null) {
- count++;
- }
-
- return count;
- }
-
-}
diff --git a/server/src/main/java/com/vaadin/ui/FormFieldFactory.java b/server/src/main/java/com/vaadin/ui/FormFieldFactory.java
deleted file mode 100644
index 5483b7a904..0000000000
--- a/server/src/main/java/com/vaadin/ui/FormFieldFactory.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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.ui;
-
-import java.io.Serializable;
-
-import com.vaadin.data.Item;
-import com.vaadin.data.fieldgroup.FieldGroup;
-import com.vaadin.legacy.ui.LegacyField;
-
-/**
- * Factory interface for creating new Field-instances based on {@link Item},
- * property id and uiContext (the component responsible for displaying fields).
- * Currently this interface is used by {@link Form}, but might later be used by
- * some other components for {@link Field} generation.
- *
- *
- *
- * @author Vaadin Ltd.
- * @since 6.0
- * @see TableFieldFactory
- * @deprecated As of 7.0, use {@link FieldGroup} instead of {@link Form} for
- * more flexibility.
- */
-@Deprecated
-public interface FormFieldFactory extends Serializable {
- /**
- * Creates a field based on the item, property id and the component (most
- * commonly {@link Form}) where the Field will be presented.
- *
- * @param item
- * the item where the property belongs to.
- * @param propertyId
- * the Id of the property.
- * @param uiContext
- * the component where the field is presented, most commonly this
- * is {@link Form}. uiContext will not necessary be the parent
- * component of the field, but the one that is responsible for
- * creating it.
- * @return the field suitable for editing the specified data.
- */
- LegacyField> createField(Item item, Object propertyId,
- Component uiContext);
-}
diff --git a/server/src/test/java/com/vaadin/tests/server/SerializationTest.java b/server/src/test/java/com/vaadin/tests/server/SerializationTest.java
index 995781f9bc..6a7c0f1755 100644
--- a/server/src/test/java/com/vaadin/tests/server/SerializationTest.java
+++ b/server/src/test/java/com/vaadin/tests/server/SerializationTest.java
@@ -17,31 +17,18 @@ import com.vaadin.data.util.IndexedContainer;
import com.vaadin.data.util.MethodProperty;
import com.vaadin.legacy.data.validator.LegacyRegexpValidator;
import com.vaadin.server.VaadinSession;
-import com.vaadin.ui.Form;
public class SerializationTest {
@Test
public void testValidators() throws Exception {
- LegacyRegexpValidator validator = new LegacyRegexpValidator(".*", "Error");
+ LegacyRegexpValidator validator = new LegacyRegexpValidator(".*",
+ "Error");
validator.validate("aaa");
LegacyRegexpValidator validator2 = serializeAndDeserialize(validator);
validator2.validate("aaa");
}
- @Test
- public void testForm() throws Exception {
- Form f = new Form();
- String propertyId = "My property";
- f.addItemProperty(propertyId, new MethodProperty(new Data(),
- "dummyGetterAndSetter"));
- f.replaceWithSelect(propertyId, new Object[] { "a", "b", null },
- new String[] { "Item a", "ITem b", "Null item" });
-
- serializeAndDeserialize(f);
-
- }
-
@Test
public void testIndedexContainerItemIds() throws Exception {
IndexedContainer ic = new IndexedContainer();
@@ -95,8 +82,8 @@ public class SerializationTest {
ObjectOutputStream out = new ObjectOutputStream(bs);
out.writeObject(s);
byte[] data = bs.toByteArray();
- ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(
- data));
+ ObjectInputStream in = new ObjectInputStream(
+ new ByteArrayInputStream(data));
@SuppressWarnings("unchecked")
S s2 = (S) in.readObject();
diff --git a/server/src/test/java/com/vaadin/tests/server/component/form/FormTest.java b/server/src/test/java/com/vaadin/tests/server/component/form/FormTest.java
deleted file mode 100644
index e68679262f..0000000000
--- a/server/src/test/java/com/vaadin/tests/server/component/form/FormTest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * 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.tests.server.component.form;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import com.vaadin.legacy.ui.LegacyTextField;
-import com.vaadin.ui.Form;
-
-/**
- * Test for {@link Form}.
- *
- * @author Vaadin Ltd
- */
-public class FormTest {
-
- @Test
- public void testFocus() {
- Form form = new Form();
- final boolean firstFieldIsFocused[] = new boolean[1];
- LegacyTextField field1 = new LegacyTextField() {
- @Override
- public boolean isConnectorEnabled() {
- return false;
- }
-
- @Override
- public void focus() {
- firstFieldIsFocused[0] = true;
- }
- };
-
- final boolean secondFieldIsFocused[] = new boolean[1];
- LegacyTextField field2 = new LegacyTextField() {
- @Override
- public boolean isConnectorEnabled() {
- return true;
- }
-
- @Override
- public void focus() {
- secondFieldIsFocused[0] = true;
- }
- };
- form.addField("a", field1);
- form.addField("b", field2);
- form.focus();
-
- Assert.assertTrue("Field with enabled connector is not focused",
- secondFieldIsFocused[0]);
- Assert.assertFalse("Field with disabled connector is focused",
- firstFieldIsFocused[0]);
- }
-}
diff --git a/shared/src/main/java/com/vaadin/shared/ui/form/FormState.java b/shared/src/main/java/com/vaadin/shared/ui/form/FormState.java
deleted file mode 100644
index 99ed11f8df..0000000000
--- a/shared/src/main/java/com/vaadin/shared/ui/form/FormState.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * 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.shared.ui.form;
-
-import com.vaadin.shared.AbstractFieldState;
-import com.vaadin.shared.Connector;
-
-public class FormState extends AbstractFieldState {
- {
- primaryStyleName = "v-form";
- }
- public Connector layout;
- public Connector footer;
-}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/button/ButtonWithShortcutNotRendered.java b/uitest/src/main/java/com/vaadin/tests/components/button/ButtonWithShortcutNotRendered.java
deleted file mode 100644
index 6da8ef8fe5..0000000000
--- a/uitest/src/main/java/com/vaadin/tests/components/button/ButtonWithShortcutNotRendered.java
+++ /dev/null
@@ -1,172 +0,0 @@
-package com.vaadin.tests.components.button;
-
-import com.vaadin.annotations.PreserveOnRefresh;
-import com.vaadin.data.Item;
-import com.vaadin.data.Property;
-import com.vaadin.data.util.HierarchicalContainer;
-import com.vaadin.event.ShortcutAction.KeyCode;
-import com.vaadin.legacy.ui.LegacyField;
-import com.vaadin.legacy.ui.LegacyTextField;
-import com.vaadin.server.VaadinRequest;
-import com.vaadin.shared.ui.MarginInfo;
-import com.vaadin.tests.components.AbstractTestUI;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.DefaultFieldFactory;
-import com.vaadin.ui.Form;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.VerticalSplitPanel;
-
-@PreserveOnRefresh
-@SuppressWarnings("deprecation")
-public class ButtonWithShortcutNotRendered extends AbstractTestUI {
-
- @Override
- protected String getTestDescription() {
- return "Button with shortcut broken if the shortcut is rendered before the button";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 9825;
- }
-
- Button defaultButton;
- Button otherButton;
-
- @SuppressWarnings("unchecked")
- @Override
- protected void setup(VaadinRequest request) {
- getLayout().setWidth(100, Unit.PERCENTAGE);
- getLayout().setHeight(null);
- getLayout().setMargin(new MarginInfo(true, false, false, false));
-
- HierarchicalContainer container = new HierarchicalContainer();
- container.addContainerProperty("t1", String.class, "");
- container.addContainerProperty("t2", String.class, "");
-
- Item item = container.addItem("r1");
- item.getItemProperty("t1").setValue("Row1 t1");
- item.getItemProperty("t2").setValue("Row1 t2");
-
- item = container.addItem("r2");
- item.getItemProperty("t1").setValue("Row2 t1");
- item.getItemProperty("t2").setValue("Row2 t2");
-
- MyForm form = new MyForm();
- MyTable table = new MyTable(form, container);
-
- VerticalSplitPanel splitPanel = new VerticalSplitPanel();
- splitPanel.setWidth(100, Unit.PERCENTAGE);
- splitPanel.setHeight(400, Unit.PIXELS);
- splitPanel.setFirstComponent(table);
- splitPanel.setSecondComponent(form);
- splitPanel.setSplitPosition(50, Unit.PERCENTAGE);
-
- addComponent(splitPanel);
- }
-
- public class MyTable extends Table {
- final MyForm form;
-
- public MyTable(MyForm pform, HierarchicalContainer container) {
- form = pform;
- setContainerDataSource(container);
- setSelectable(true);
- setImmediate(true);
- setWidth(100, Unit.PERCENTAGE);
- setHeight(null);
-
- addValueChangeListener(new Property.ValueChangeListener() {
-
- @Override
- public void valueChange(
- com.vaadin.data.Property.ValueChangeEvent event) {
- final Item item = getItem(getValue());
- form.setItemDataSource(item);
- }
-
- });
- }
- }
-
- public class MyForm extends Form implements ClickListener {
- final GridLayout layout;
-
- @SuppressWarnings("unchecked")
- public MyForm() {
- setWidth(100, Unit.PERCENTAGE);
- setHeight(null);
- setImmediate(true);
-
- setFormFieldFactory(new DefaultFieldFactory() {
-
- @Override
- public LegacyTextField createField(Item item, Object propertyId,
- Component uiContext) {
- LegacyTextField t = new LegacyTextField();
- t.setWidth(100, Unit.PERCENTAGE);
- t.setHeight(null);
- t.setCaption((String) propertyId);
- t.setImmediate(false);
- return t;
- }
- });
-
- layout = new GridLayout(2, 1);
- layout.setWidth(100, Unit.PERCENTAGE);
- layout.setHeight(null);
- layout.setColumnExpandRatio(0, 0.5f);
- layout.setColumnExpandRatio(1, 0.5f);
- layout.setMargin(true);
- layout.setSpacing(true);
- setLayout(layout);
-
- HorizontalLayout footer = new HorizontalLayout();
- footer.setSpacing(true);
- footer.setMargin(false);
- footer.setVisible(false);
- setFooter(footer);
-
- defaultButton = new Button("Default Button", this);
- defaultButton.setClickShortcut(KeyCode.ENTER);
- footer.addComponent(defaultButton);
-
- otherButton = new Button("Other button", this);
- footer.addComponent(otherButton);
- }
-
- @Override
- public void setItemDataSource(Item newDataSource) {
- if (newDataSource != null) {
- super.setItemDataSource(newDataSource);
- layout.setVisible(true);
- getFooter().setVisible(true);
- } else {
- super.setItemDataSource(null);
- layout.setVisible(false);
- getFooter().setVisible(false);
- }
- }
-
- @Override
- @SuppressWarnings("rawtypes")
- protected void attachField(Object propertyId, LegacyField field) {
- if (propertyId.equals("t1")) {
- layout.addComponent(field, 0, 0);
- } else if (propertyId.equals("t2")) {
- layout.addComponent(field, 1, 0);
- }
- }
-
- @Override
- public void buttonClick(ClickEvent event) {
- // NOP
- }
-
- }
-}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/customfield/AbstractNestedFormExample.java b/uitest/src/main/java/com/vaadin/tests/components/customfield/AbstractNestedFormExample.java
deleted file mode 100644
index 07c740a96d..0000000000
--- a/uitest/src/main/java/com/vaadin/tests/components/customfield/AbstractNestedFormExample.java
+++ /dev/null
@@ -1,76 +0,0 @@
-package com.vaadin.tests.components.customfield;
-
-import com.vaadin.data.Item;
-import com.vaadin.data.Property;
-import com.vaadin.data.Property.ValueChangeEvent;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.tests.util.Person;
-import com.vaadin.ui.Table;
-
-/**
- * Demonstrate the use of a form as a custom field within another form.
- */
-public abstract class AbstractNestedFormExample extends TestBase {
- private NestedPersonForm personForm;
- private boolean embeddedAddress;
-
- public void setup(boolean embeddedAddress) {
- this.embeddedAddress = embeddedAddress;
-
- addComponent(getPersonTable());
- }
-
- /**
- * Creates a table with two person objects
- */
- public Table getPersonTable() {
- Table table = new Table();
- table.setPageLength(5);
- table.setSelectable(true);
- table.setImmediate(true);
- table.setNullSelectionAllowed(true);
- table.addContainerProperty("Name", String.class, null);
- table.addListener(getTableValueChangeListener());
- Person person = new Person("Teppo", "Testaaja",
- "teppo.testaaja@example.com", "", "Ruukinkatu 2–4", 20540,
- "Turku");
- Person person2 = new Person("Taina", "Testaaja",
- "taina.testaaja@example.com", "", "Ruukinkatu 2–4", 20540,
- "Turku");
- Item item = table.addItem(person);
- item.getItemProperty("Name").setValue(
- person.getFirstName() + " " + person.getLastName());
- item = table.addItem(person2);
- item.getItemProperty("Name").setValue(
- person2.getFirstName() + " " + person2.getLastName());
- return table;
- }
-
- /**
- * Creates value change listener for the table
- */
- private Property.ValueChangeListener getTableValueChangeListener() {
- return new Property.ValueChangeListener() {
-
- @Override
- public void valueChange(ValueChangeEvent event) {
- if (personForm != null) {
- removeComponent(personForm);
- }
- if (event.getProperty().getValue() != null) {
- personForm = new NestedPersonForm((Person) event
- .getProperty().getValue(), embeddedAddress);
- personForm.setWidth("350px");
- addComponent(personForm);
- }
- }
-
- };
- }
-
- @Override
- protected Integer getTicketNumber() {
- return null;
- }
-
-}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/customfield/AddressField.java b/uitest/src/main/java/com/vaadin/tests/components/customfield/AddressField.java
deleted file mode 100644
index 9d68ad3800..0000000000
--- a/uitest/src/main/java/com/vaadin/tests/components/customfield/AddressField.java
+++ /dev/null
@@ -1,97 +0,0 @@
-package com.vaadin.tests.components.customfield;
-
-import java.util.Arrays;
-import java.util.List;
-
-import com.vaadin.data.Buffered;
-import com.vaadin.data.util.BeanItem;
-import com.vaadin.legacy.data.Validator.InvalidValueException;
-import com.vaadin.tests.util.Address;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.CustomField;
-import com.vaadin.ui.Form;
-
-/**
- * Nested form for the Address object of the Person object
- */
-public class AddressField extends CustomField {
- private Form addressForm;
- private final Form parentForm;
-
- public AddressField() {
- this(null);
- }
-
- public AddressField(Form parentForm) {
- this.parentForm = parentForm;
- }
-
- @Override
- protected Component initContent() {
- if (parentForm != null) {
- addressForm = new EmbeddedForm(parentForm);
- } else {
- addressForm = new Form();
- }
- addressForm.setCaption("Address");
- addressForm.setBuffered(true);
-
- // make sure field changes are sent early
- addressForm.setImmediate(true);
- addressForm.setFooter(null);
- return addressForm;
- }
-
- @Override
- protected Form getContent() {
- return (Form) super.getContent();
- }
-
- @Override
- public void setInternalValue(Address address) throws ReadOnlyException {
- // create the address if not given
- if (null == address) {
- address = new Address();
- }
-
- super.setInternalValue(address);
-
- // set item data source and visible properties in a single operation to
- // avoid creating fields multiple times
- List visibleProperties = Arrays.asList("streetAddress",
- "postalCode", "city");
- getContent().setItemDataSource(new BeanItem(address),
- visibleProperties);
- }
-
- /**
- * commit changes of the address form
- */
- @Override
- public void commit() throws Buffered.SourceException, InvalidValueException {
- addressForm.commit();
- super.commit();
- }
-
- /**
- * discard changes of the address form
- */
- @Override
- public void discard() throws Buffered.SourceException {
- // Do not discard the top-level value
- // super.discard();
- addressForm.discard();
- }
-
- @Override
- public boolean isReadOnly() {
- // In this application, the address is modified implicitly by
- // addressForm.commit(), not by setting the Address object for a Person.
- return false;
- }
-
- @Override
- public Class getType() {
- return Address.class;
- }
-}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/customfield/AddressFormExample.java b/uitest/src/main/java/com/vaadin/tests/components/customfield/AddressFormExample.java
deleted file mode 100644
index e5ac67b32e..0000000000
--- a/uitest/src/main/java/com/vaadin/tests/components/customfield/AddressFormExample.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package com.vaadin.tests.components.customfield;
-
-import java.util.Locale;
-
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.tests.util.Address;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Notification;
-
-/**
- * Demonstrate a custom field which is a form, and contains another custom field
- * for the selection of a city.
- */
-public class AddressFormExample extends TestBase {
-
- @Override
- protected void setup() {
- getMainWindow().setLocale(Locale.ENGLISH);
- Address address = new Address("Ruukinkatu 2-4", 20540, "Turku");
- final AddressField field = new AddressField();
- field.setValue(address);
- field.setRequired(true);
-
- addComponent(field);
-
- Button commitButton = new Button("Save", new Button.ClickListener() {
- @Override
- public void buttonClick(ClickEvent event) {
- field.commit();
- Address address = field.getValue();
- Notification.show("Address saved: "
- + address.getStreetAddress() + ", "
- + address.getPostalCode() + ", " + address.getCity());
- }
- });
- addComponent(commitButton);
- }
-
- @Override
- protected String getDescription() {
- return "Custom field for editing an Address";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return null;
- }
-
-}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/customfield/BooleanFieldExample.java b/uitest/src/main/java/com/vaadin/tests/components/customfield/BooleanFieldExample.java
deleted file mode 100644
index 29fffbbf16..0000000000
--- a/uitest/src/main/java/com/vaadin/tests/components/customfield/BooleanFieldExample.java
+++ /dev/null
@@ -1,89 +0,0 @@
-package com.vaadin.tests.components.customfield;
-
-import com.vaadin.data.Item;
-import com.vaadin.data.util.BeanItem;
-import com.vaadin.legacy.ui.LegacyField;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.DefaultFieldFactory;
-import com.vaadin.ui.Form;
-import com.vaadin.ui.Notification;
-import com.vaadin.ui.VerticalLayout;
-
-public class BooleanFieldExample extends TestBase {
-
- /**
- * Data model class with two boolean fields.
- */
- public static class TwoBooleans {
- private boolean normal;
- private boolean custom;
-
- public void setNormal(boolean normal) {
- this.normal = normal;
- }
-
- public boolean isNormal() {
- return normal;
- }
-
- public void setCustom(boolean custom) {
- this.custom = custom;
- }
-
- public boolean isCustom() {
- return custom;
- }
- }
-
- @Override
- protected void setup() {
- final VerticalLayout layout = new VerticalLayout();
- layout.setMargin(true);
-
- final Form form = new Form();
- form.setFooter(null);
- form.setFormFieldFactory(new DefaultFieldFactory() {
- @Override
- public LegacyField createField(Item item, Object propertyId,
- Component uiContext) {
- if ("custom".equals(propertyId)) {
- return new BooleanField();
- }
- return super.createField(item, propertyId, uiContext);
- }
- });
- final TwoBooleans data = new TwoBooleans();
- form.setItemDataSource(new BeanItem(data));
-
- layout.addComponent(form);
-
- Button submit = new Button("Submit", new ClickListener() {
- @Override
- public void buttonClick(ClickEvent event) {
- form.commit();
- Notification.show("The custom boolean field value is "
- + data.isCustom() + ".\n"
- + "The checkbox (default boolean field) value is "
- + data.isNormal() + ".");
- }
- });
- layout.addComponent(submit);
-
- addComponent(layout);
- }
-
- @Override
- protected String getDescription() {
- return "A customized field (a two-state button) for editing a boolean value.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return null;
- }
-
-}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/customfield/EmbeddedForm.java b/uitest/src/main/java/com/vaadin/tests/components/customfield/EmbeddedForm.java
deleted file mode 100644
index 764949b7a3..0000000000
--- a/uitest/src/main/java/com/vaadin/tests/components/customfield/EmbeddedForm.java
+++ /dev/null
@@ -1,67 +0,0 @@
-package com.vaadin.tests.components.customfield;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import com.vaadin.legacy.ui.LegacyField;
-import com.vaadin.ui.CustomLayout;
-import com.vaadin.ui.Form;
-import com.vaadin.ui.Layout;
-
-/**
- * Form that displays its fields in the layout of another form.
- *
- * The fields are still logically part of this form even though they are in the
- * layout of the parent form. The embedded form itself is automatically hidden.
- *
- * TODO Known issue: any field factory creating an {@link EmbeddedForm}
- * (directly or indirectly) should re-use the field once it has been created to
- * avoid the creation of duplicate fields when e.g. setting the visible item
- * properties.
- */
-public class EmbeddedForm extends Form {
- private Form parentForm;
- private Map fields = new HashMap();
-
- /**
- * Create a form that places its fields in another {@link Form}.
- *
- * @param parentForm
- * form to which to embed the fields, not null
- */
- public EmbeddedForm(Form parentForm) {
- this.parentForm = parentForm;
- setVisible(false);
- }
-
- @Override
- protected void attachField(Object propertyId, LegacyField field) {
- if (propertyId == null || field == null) {
- return;
- }
-
- Layout layout = parentForm.getLayout();
-
- LegacyField oldField = fields.get(propertyId);
- if (oldField != null) {
- layout.removeComponent(oldField);
- }
-
- fields.put(propertyId, field);
-
- if (layout instanceof CustomLayout) {
- ((CustomLayout) layout).addComponent(field, propertyId.toString());
- } else {
- layout.addComponent(field);
- }
- }
-
- @Override
- public boolean removeItemProperty(Object id) {
- // remove the field from the parent layout if already added there
- parentForm.getLayout().removeComponent(fields.get(id));
- fields.remove(id);
-
- return super.removeItemProperty(id);
- }
-}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/customfield/EmbeddedFormExample.java b/uitest/src/main/java/com/vaadin/tests/components/customfield/EmbeddedFormExample.java
deleted file mode 100644
index aeb1984937..0000000000
--- a/uitest/src/main/java/com/vaadin/tests/components/customfield/EmbeddedFormExample.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package com.vaadin.tests.components.customfield;
-
-public class EmbeddedFormExample extends AbstractNestedFormExample {
-
- @Override
- protected void setup() {
- super.setup(true);
- }
-
- @Override
- protected String getDescription() {
- return "An address form embedded in a person form.\n"
- + "The address fields are placed in the layout of the parent (person) form.\n"
- + "Note that in many cases the same result can be achieved with a property that maps subfields to the top level.";
- }
-
-}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/customfield/NestedFormExample.java b/uitest/src/main/java/com/vaadin/tests/components/customfield/NestedFormExample.java
deleted file mode 100644
index 91fb43f4e2..0000000000
--- a/uitest/src/main/java/com/vaadin/tests/components/customfield/NestedFormExample.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package com.vaadin.tests.components.customfield;
-
-public class NestedFormExample extends AbstractNestedFormExample {
-
- @Override
- protected void setup() {
- super.setup(false);
- }
-
- @Override
- protected String getDescription() {
- return "An address form nested in a person form.";
- }
-
-}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/customfield/NestedPersonForm.java b/uitest/src/main/java/com/vaadin/tests/components/customfield/NestedPersonForm.java
deleted file mode 100644
index 5ecd75d34e..0000000000
--- a/uitest/src/main/java/com/vaadin/tests/components/customfield/NestedPersonForm.java
+++ /dev/null
@@ -1,99 +0,0 @@
-package com.vaadin.tests.components.customfield;
-
-import java.util.Arrays;
-
-import com.vaadin.data.Item;
-import com.vaadin.data.util.BeanItem;
-import com.vaadin.legacy.ui.LegacyField;
-import com.vaadin.shared.ui.MarginInfo;
-import com.vaadin.tests.util.Person;
-import com.vaadin.ui.Alignment;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.DefaultFieldFactory;
-import com.vaadin.ui.Form;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.Layout.MarginHandler;
-
-/**
- * Example of nested forms
- */
-public class NestedPersonForm extends Form {
- private BeanItem beanItem;
- private final boolean embeddedAddress;
-
- /**
- * Creates a person form which contains nested form for the persons address
- */
- public NestedPersonForm(Person person, boolean embeddedAddress) {
- this.embeddedAddress = embeddedAddress;
-
- beanItem = new BeanItem(person);
- setCaption("Update person details");
- setBuffered(true);
- setFormFieldFactory(new PersonFieldFactory());
- // set the data source and the visible fields
- // Note that if the nested form is the first or last field in the parent
- // form, styles from the parent (padding, ...) may leak to its contents.
- setItemDataSource(beanItem, Arrays.asList("firstName", "lastName",
- "address", "email", "phoneNumber"));
- getFooter().addComponent(getButtonsLayout());
- ((MarginHandler) getFooter()).setMargin(new MarginInfo(false, false,
- true, true));
- }
-
- /**
- * Get apply and discard button in the layout
- */
- private Component getButtonsLayout() {
- HorizontalLayout buttons = new HorizontalLayout();
- buttons.setSpacing(true);
- Button discardChanges = new Button("Discard changes",
- new Button.ClickListener() {
- @Override
- public void buttonClick(ClickEvent event) {
- NestedPersonForm.this.discard();
- }
- });
- buttons.addComponent(discardChanges);
- buttons.setComponentAlignment(discardChanges, Alignment.MIDDLE_LEFT);
-
- Button apply = new Button("Apply", new Button.ClickListener() {
- @Override
- public void buttonClick(ClickEvent event) {
- try {
- NestedPersonForm.this.commit();
- } catch (Exception e) {
- // Ignored, we'll let the Form handle the errors
- }
- }
- });
- buttons.addComponent(apply);
- return buttons;
- }
-
- /**
- * LegacyField factory for person form
- */
- private class PersonFieldFactory extends DefaultFieldFactory {
- // reuse the address field - required by EmbeddedForm
- private AddressField addressField;
-
- @Override
- public LegacyField createField(Item item, Object propertyId,
- Component uiContext) {
- LegacyField f = super.createField(item, propertyId, uiContext);
- if ("address".equals(propertyId)) {
- // create a custom field for the Address object
- if (addressField == null) {
- Form form = (embeddedAddress && uiContext instanceof Form) ? (Form) uiContext
- : null;
- addressField = new AddressField(form);
- }
- f = addressField;
- }
- return f;
- }
- }
-}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/datefield/CommitInvalid.java b/uitest/src/main/java/com/vaadin/tests/components/datefield/CommitInvalid.java
deleted file mode 100644
index dd5da9c526..0000000000
--- a/uitest/src/main/java/com/vaadin/tests/components/datefield/CommitInvalid.java
+++ /dev/null
@@ -1,143 +0,0 @@
-package com.vaadin.tests.components.datefield;
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Locale;
-
-import com.vaadin.data.util.ObjectProperty;
-import com.vaadin.legacy.data.Validator.InvalidValueException;
-import com.vaadin.legacy.ui.LegacyDateField;
-import com.vaadin.legacy.ui.LegacyTextField;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.tests.util.Log;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Form;
-
-public class CommitInvalid extends TestBase {
-
- @Override
- protected String getDescription() {
- return "DateField with parsing error is committed regardless "
- + "of the invalidity. Parsing error should be handled"
- + " as a builtin validator, similar to isRequired()"
- + " in LegacyAbstractField.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 5927;
- }
-
- ObjectProperty dateProperty;
- private LegacyDateField dateField;
- private ObjectProperty integerProperty;
- private LegacyTextField integerField;
- private Log log;
-
- @Override
- protected void setup() {
- /*
- * Create and configure form.
- */
- final Form form = new Form();
- form.setBuffered(true); // set write buffering on
- form.setImmediate(true); // make form (and especially its fields
- // immediate)
-
- /*
- * Create and configure Date LegacyField, the actual component to be
- * tested.
- */
- dateProperty = new ObjectProperty(
- new Date(2009 - 1900, 4 - 1, 1));
-
- dateField = new LegacyDateField("Year", dateProperty);
- dateField.setLocale(new Locale("fi", "FI"));
- dateField.setResolution(LegacyDateField.RESOLUTION_DAY);
- dateField.setId("_DF");
- form.addField("date", dateField);
-
- /*
- * Create a TextField with integer property (and integer validator,
- * preventing invalid typed values to be pushded to property) as a
- * reference component.
- */
- integerProperty = new ObjectProperty(42);
- integerField = new LegacyTextField("Another LegacyField",
- integerProperty);
- integerField.setId("_IF");
- form.addField("text", integerField);
-
- /*
- * Action buttons.
- */
- Button validate = new Button("Validate");
- validate.setId("_validate");
- validate.addListener(new Button.ClickListener() {
- @Override
- public void buttonClick(ClickEvent event) {
- try {
- form.validate();
- log.log("Form is valid");
- } catch (InvalidValueException e) {
- log.log("Validation failed:" + e.getLocalizedMessage());
- } finally {
- printState();
- }
- }
- });
- form.getFooter().addComponent(validate);
-
- Button commit = new Button("Commit");
- commit.setId("_commit");
- commit.addListener(new Button.ClickListener() {
- @Override
- public void buttonClick(ClickEvent event) {
- try {
- form.commit();
- log.log("Commit succeeded");
- } catch (InvalidValueException e) {
- log.log("Commit failed : " + e.getLocalizedMessage());
- } finally {
- printState();
- }
- }
- });
-
- form.getFooter().addComponent(commit);
- Button printState = new Button("printState");
- printState.addListener(new Button.ClickListener() {
- @Override
- public void buttonClick(ClickEvent event) {
- printState();
- }
-
- });
- form.getFooter().addComponent(printState);
-
- log = new Log(7);
- log.log("Test app started");
- printState();
-
- addComponent(form);
- addComponent(log);
-
- }
-
- SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
-
- private String f(Date date) {
- if (date == null) {
- return "null";
- }
- return dateFormat.format(date);
- }
-
- private void printState() {
- log.log("Date. LegacyField: " + f(dateField.getValue()) + " Property: "
- + f(dateProperty.getValue()));
- log.log("Integer: LegacyField: " + integerField.getValue()
- + " Property: " + integerProperty.getValue());
- }
-}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldInSubWindow.java b/uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldInSubWindow.java
deleted file mode 100644
index f993b4558b..0000000000
--- a/uitest/src/main/java/com/vaadin/tests/components/datefield/DateFieldInSubWindow.java
+++ /dev/null
@@ -1,150 +0,0 @@
-package com.vaadin.tests.components.datefield;
-
-import java.util.Date;
-
-import com.vaadin.data.Item;
-import com.vaadin.data.util.BeanItem;
-import com.vaadin.legacy.ui.LegacyField;
-import com.vaadin.shared.ui.datefield.Resolution;
-import com.vaadin.tests.components.AbstractTestCase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.DateField;
-import com.vaadin.ui.DefaultFieldFactory;
-import com.vaadin.ui.Form;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.LegacyWindow;
-import com.vaadin.ui.VerticalLayout;
-import com.vaadin.ui.Window;
-
-public class DateFieldInSubWindow extends AbstractTestCase {
-
- @SuppressWarnings("serial")
- public class TestCaseWindow extends Window {
-
- public class MyBean {
- private Date myDate;
- private String myString;
-
- public Date getMyDate() {
- return myDate;
- }
-
- public void setMyDate(Date myDate) {
- this.myDate = myDate;
- }
-
- public String getMyString() {
- return myString;
- }
-
- public void setMyString(String myString) {
- this.myString = myString;
- }
-
- }
-
- private MyBean myBean;
-
- public TestCaseWindow() {
- super("Test Case Window");
- setModal(true);
- setWidth("400px");
- myBean = new MyBean();
-
- initWindow();
- }
-
- protected class CustomerFieldFactory extends DefaultFieldFactory {
-
- public static final String COMMON_FIELD_WIDTH = "12em";
-
- @Override
- public LegacyField> createField(Item item, Object propertyId,
- Component uiContext) {
- LegacyField> f = super.createField(item, propertyId,
- uiContext);
-
- if ("myDate".equals(propertyId)) {
- ((DateField) f).setResolution(Resolution.MINUTE);
- ((DateField) f).setCaption("This is my date");
-
- }
-
- return f;
- }
- }
-
- protected void initWindow() {
- VerticalLayout layout = new VerticalLayout();
- layout.setMargin(true);
- layout.setSpacing(true);
- setContent(layout);
-
- /**
- * This causes the window to add the .v-readonly style!
- */
- setClosable(false);
-
- CustomerFieldFactory fieldFactory = new CustomerFieldFactory();
- final Form generalForm = new Form();
- {
- generalForm.setFooter(null);
- generalForm.setCaption("My form");
- generalForm.setBuffered(false);
- generalForm.setFormFieldFactory(fieldFactory);
-
- BeanItem myBeanItem = new BeanItem(myBean);
- generalForm.setItemDataSource(myBeanItem);
-
- generalForm.setVisibleItemProperties(
- new String[] { "myDate", "myString" });
- generalForm.setValidationVisible(true);
- layout.addComponent(generalForm);
- }
-
- HorizontalLayout buttons = new HorizontalLayout();
- {
- buttons.setSpacing(true);
-
- Button b = new Button("Close", new Button.ClickListener() {
-
- @Override
- public void buttonClick(ClickEvent event) {
- TestCaseWindow.this.close();
- }
- });
- buttons.addComponent(b);
- layout.addComponent(buttons);
-
- }
- }
- }
-
- @Override
- public void init() {
- LegacyWindow mainWindow = new LegacyWindow();
- setMainWindow(mainWindow);
- Button open = new Button("Open window", new Button.ClickListener() {
- @Override
- public void buttonClick(ClickEvent event) {
- getMainWindow().addWindow(new TestCaseWindow());
- }
- });
-
- mainWindow.addComponent(open);
- }
-
- @Override
- protected String getDescription() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 4582;
- }
-
-}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/datefield/ShowSelectedDateAfterInvalid.java b/uitest/src/main/java/com/vaadin/tests/components/datefield/ShowSelectedDateAfterInvalid.java
deleted file mode 100644
index 3fad7767f5..0000000000
--- a/uitest/src/main/java/com/vaadin/tests/components/datefield/ShowSelectedDateAfterInvalid.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package com.vaadin.tests.components.datefield;
-
-import com.vaadin.legacy.ui.LegacyPopupDateField;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Form;
-import com.vaadin.ui.Label;
-
-/**
- * First entering an invalid date, forcing a server roundtrip and then selecting
- * a valid date from the popup in a non-immediate {@link LegacyPopupDateField} caused
- * the invalid date string to continue to show.
- */
-public class ShowSelectedDateAfterInvalid extends TestBase {
-
- @Override
- protected void setup() {
- final Label result = new Label();
-
- final Form form = new Form();
-
- LegacyPopupDateField datefield = new LegacyPopupDateField();
- datefield.setResolution(LegacyPopupDateField.RESOLUTION_DAY);
- datefield.setDateFormat("dd/MM/yyyy");
-
- form.addField("datefield", datefield);
-
- Button button = new Button("Validate");
-
- button.addListener(new Button.ClickListener() {
- @Override
- public void buttonClick(Button.ClickEvent event) {
- form.setValidationVisible(true);
- if (form.isValid()) {
- result.setValue("Valid!");
- } else {
- result.setValue("Invalid");
- }
- }
-
- });
-
- addComponent(form);
- addComponent(button);
- addComponent(result);
- }
-
- @Override
- protected String getDescription() {
- return "DateField doesn't show selected value after invalid and then selecting a value";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 5369;
- }
-
-}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/form/FormCaptionClickFocusing.java b/uitest/src/main/java/com/vaadin/tests/components/form/FormCaptionClickFocusing.java
deleted file mode 100644
index ec44f42ba0..0000000000
--- a/uitest/src/main/java/com/vaadin/tests/components/form/FormCaptionClickFocusing.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package com.vaadin.tests.components.form;
-
-import com.vaadin.legacy.ui.LegacyTextField;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.FormLayout;
-
-public class FormCaptionClickFocusing extends TestBase {
-
- @Override
- protected void setup() {
- FormLayout layout = new FormLayout();
-
- LegacyTextField field = new LegacyTextField("Field 1");
- layout.addComponent(field);
-
- addComponent(layout);
- }
-
- @Override
- protected String getDescription() {
- return "Formlayout should focus the field if the layout is clicked and the field is focusable.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 4567;
- }
-
-}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/form/FormClearDatasourceRepaint.java b/uitest/src/main/java/com/vaadin/tests/components/form/FormClearDatasourceRepaint.java
deleted file mode 100644
index df403ceb78..0000000000
--- a/uitest/src/main/java/com/vaadin/tests/components/form/FormClearDatasourceRepaint.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package com.vaadin.tests.components.form;
-
-import com.vaadin.data.util.BeanItem;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Form;
-
-public class FormClearDatasourceRepaint extends TestBase {
-
- public static class MyBean {
-
- private String value;
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
- }
-
- public static class MySecondBean extends MyBean {
-
- private String value2;
-
- public String getValue2() {
- return value2;
- }
-
- public void setValue2(String value) {
- value2 = value;
- }
- }
-
- @Override
- protected void setup() {
-
- final Form form = new Form();
- form.setFooter(null);
- form.setItemDataSource(new BeanItem(new MySecondBean()));
- addComponent(form);
-
- addComponent(new Button("Clear datasource", new Button.ClickListener() {
- @Override
- public void buttonClick(ClickEvent event) {
- form.setItemDataSource(null);
- }
- }));
-
- addComponent(new Button("Change data source",
- new Button.ClickListener() {
- @Override
- public void buttonClick(ClickEvent event) {
- form.setItemDataSource(new BeanItem(
- new MyBean()));
- }
- }));
-
- }
-
- @Override
- protected String getDescription() {
- return "The form should adjust its size when clearing and setting data sources";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 7626;
- }
-
-}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/form/FormCommitWithInvalidValues.java b/uitest/src/main/java/com/vaadin/tests/components/form/FormCommitWithInvalidValues.java
deleted file mode 100644
index 7b09c7c484..0000000000
--- a/uitest/src/main/java/com/vaadin/tests/components/form/FormCommitWithInvalidValues.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package com.vaadin.tests.components.form;
-
-import com.vaadin.legacy.data.validator.LegacyStringLengthValidator;
-import com.vaadin.legacy.ui.LegacyTextField;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Button.ClickListener;
-import com.vaadin.ui.Form;
-import com.vaadin.ui.Notification;
-
-public class FormCommitWithInvalidValues extends TestBase {
-
- private Form form;
-
- @Override
- protected String getDescription() {
- return "Commiting a form with invalid values should throw an exception";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 2466;
- }
-
- @Override
- protected void setup() {
- form = new Form();
- form.setFooter(null);
- LegacyTextField tf = new LegacyTextField(
- "A field, must contain 1-2 chars");
- tf.addValidator(
- new LegacyStringLengthValidator("Invalid length", 1, 2, false));
- tf.setRequired(true);
-
- form.addField("a", tf);
-
- Button b = new Button("Commit", new ClickListener() {
-
- @Override
- public void buttonClick(ClickEvent event) {
- try {
- form.commit();
- if (form.isValid()) {
- getMainWindow().showNotification(
- "OK! Form validated and no error was thrown",
- Notification.TYPE_HUMANIZED_MESSAGE);
- } else {
- getMainWindow().showNotification(
- "Form is invalid but no exception was thrown",
- Notification.TYPE_ERROR_MESSAGE);
- }
- } catch (Exception e) {
- if (form.isValid()) {
- getMainWindow().showNotification(
- "Form is valid but an exception was thrown",
- Notification.TYPE_ERROR_MESSAGE);
- } else {
- getMainWindow().showNotification(
- "OK! Error was thrown for an invalid input",
- Notification.TYPE_HUMANIZED_MESSAGE);
-
- }
- }
- }
-
- });
-
- addComponent(form);
- addComponent(b);
- }
-
-}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/form/FormDescription.java b/uitest/src/main/java/com/vaadin/tests/components/form/FormDescription.java
deleted file mode 100644
index 00c5ed9d65..0000000000
--- a/uitest/src/main/java/com/vaadin/tests/components/form/FormDescription.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package com.vaadin.tests.components.form;
-
-import com.vaadin.legacy.ui.LegacyTextField;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Form;
-
-public class FormDescription extends TestBase {
-
- @Override
- protected void setup() {
- final Form form = new Form();
- form.setDescription("Some description");
- form.addField("AAAA", new LegacyTextField());
- addComponent(form);
-
- addComponent(new Button("Toggle description",
- new Button.ClickListener() {
- @Override
- public void buttonClick(ClickEvent event) {
- if (form.getDescription() == null) {
- form.setDescription("Form description");
- } else {
- form.setDescription(null);
- }
- }
- }));
-
- }
-
- @Override
- protected String getDescription() {
- return "Description element should be removed from DOM when not used";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 3725;
- }
-
-}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/form/FormErrorVisible.java b/uitest/src/main/java/com/vaadin/tests/components/form/FormErrorVisible.java
deleted file mode 100644
index f9a8c35300..0000000000
--- a/uitest/src/main/java/com/vaadin/tests/components/form/FormErrorVisible.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright 2012 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.tests.components.form;
-
-import com.vaadin.legacy.ui.LegacyTextField;
-import com.vaadin.server.UserError;
-import com.vaadin.server.VaadinRequest;
-import com.vaadin.tests.components.AbstractTestUI;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Form;
-import com.vaadin.ui.Label;
-
-public class FormErrorVisible extends AbstractTestUI {
-
- @Override
- protected void setup(VaadinRequest request) {
- addComponent(buildForm("With footer and error", true, true));
- addComponent(buildForm("With footer", false, true));
- addComponent(buildForm("With error", true, false));
- addComponent(buildForm("With nothing", false, false));
- addComponent(new Label("The end to see where the last form ends"));
- }
-
- private Form buildForm(String caption, boolean withError, boolean withFooter) {
- Form form = new Form();
- form.setCaption(caption);
- form.addField("value", new LegacyTextField("MyField"));
-
- if (withError) {
- form.setComponentError(new UserError("Has error"));
- }
-
- if (withFooter) {
- form.getFooter().addComponent(new Button("Footer button"));
- } else {
- form.setFooter(null);
- }
-
- return form;
- }
-
- @Override
- protected String getTestDescription() {
- return "Footer and error should be taken into account when rendering Form";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return Integer.valueOf(10460);
- }
-
-}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/form/FormFieldCaptions.java b/uitest/src/main/java/com/vaadin/tests/components/form/FormFieldCaptions.java
deleted file mode 100644
index 25487fba7c..0000000000
--- a/uitest/src/main/java/com/vaadin/tests/components/form/FormFieldCaptions.java
+++ /dev/null
@@ -1,86 +0,0 @@
-package com.vaadin.tests.components.form;
-
-import com.vaadin.data.Item;
-import com.vaadin.data.util.BeanItem;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Form;
-import com.vaadin.ui.HorizontalLayout;
-
-public class FormFieldCaptions extends TestBase {
-
- @Override
- protected void setup() {
- // Method 1
- Form form1 = new Form();
- Item item1 = createItem();
- for (Object propertyId : item1.getItemPropertyIds()) {
- form1.addItemProperty(propertyId, item1.getItemProperty(propertyId));
- }
-
- // Method 2
-
- Form form2 = new Form();
- Item item2 = createItem();
- form2.setItemDataSource(item2);
-
- // Layout
- HorizontalLayout hl = new HorizontalLayout();
- hl.addComponent(form1);
- hl.addComponent(form2);
-
- addComponent(hl);
- }
-
- private Item createItem() {
- return new BeanItem(new Person("John", "Doe", 38));
- }
-
- public class Person {
- private String firstName;
- private String lastName;
-
- public Person(String firstName, String lastName, int age) {
- super();
- this.firstName = firstName;
- this.lastName = lastName;
- this.age = age;
- }
-
- public String getFirstName() {
- return firstName;
- }
-
- public void setFirstName(String firstName) {
- this.firstName = firstName;
- }
-
- public String getLastName() {
- return lastName;
- }
-
- public void setLastName(String lastName) {
- this.lastName = lastName;
- }
-
- public int getAge() {
- return age;
- }
-
- public void setAge(int age) {
- this.age = age;
- }
-
- private int age;
- }
-
- @Override
- protected String getDescription() {
- return "The two forms generated using different methods should have the same captions for all fields";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 3554;
- }
-
-}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/form/FormFieldCaptionsStyles.java b/uitest/src/main/java/com/vaadin/tests/components/form/FormFieldCaptionsStyles.java
deleted file mode 100644
index 4018ac3115..0000000000
--- a/uitest/src/main/java/com/vaadin/tests/components/form/FormFieldCaptionsStyles.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package com.vaadin.tests.components.form;
-
-import com.vaadin.legacy.ui.LegacyTextField;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.FormLayout;
-
-public class FormFieldCaptionsStyles extends TestBase {
-
- @Override
- protected void setup() {
-
- setTheme("tests-tickets");
-
- FormLayout layout = new FormLayout();
-
- LegacyTextField field1 = new LegacyTextField("Red style");
- field1.setStyleName("ticket4997-red");
- layout.addComponent(field1);
-
- LegacyTextField field2 = new LegacyTextField("Blue style");
- field2.setStyleName("ticket4997-blue");
- layout.addComponent(field2);
-
- LegacyTextField field3 = new LegacyTextField("Red-Blue style");
- field3.addStyleName("ticket4997-red");
- field3.addStyleName("ticket4997-blue");
- layout.addComponent(field3);
-
- LegacyTextField field4 = new LegacyTextField("Disabled");
- field4.setEnabled(false);
- field4.addStyleName("foobar"); // no visible change, but points out
- // a regression #5377
- layout.addComponent(field4);
-
- addComponent(layout);
- }
-
- @Override
- protected String getDescription() {
- return "The field captions should have the same style names as the field";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 4997;
- }
-
-}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/form/FormNotGettingSmaller.java b/uitest/src/main/java/com/vaadin/tests/components/form/FormNotGettingSmaller.java
deleted file mode 100644
index a47ab944a2..0000000000
--- a/uitest/src/main/java/com/vaadin/tests/components/form/FormNotGettingSmaller.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package com.vaadin.tests.components.form;
-
-import com.vaadin.data.Item;
-import com.vaadin.data.util.ObjectProperty;
-import com.vaadin.data.util.PropertysetItem;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Form;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.Label;
-
-public class FormNotGettingSmaller extends TestBase {
-
- @Override
- protected void setup() {
- Item item = new PropertysetItem();
- item.addItemProperty("name", new ObjectProperty(
- "Charles Anthony"));
- item.addItemProperty("city", new ObjectProperty("London"));
- item.addItemProperty("isTallPerson", new ObjectProperty(
- Boolean.FALSE));
-
- Label spacer = new Label();
- HorizontalLayout buttons = new HorizontalLayout();
- buttons.setSpacing(true);
- buttons.setWidth("100%");
- buttons.addComponent(spacer);
- buttons.addComponent(new Button("OK"));
- buttons.addComponent(new Button("Cancel"));
- buttons.setExpandRatio(spacer, 1f);
-
- Form form = new Form();
- form.setDescription("Ooh. Just a demonstration of things, really. Some long lorem ipsum dolor sit amet.Some very long lorem ipsum dolor sit amet.Some very long lorem ipsum dolor sit amet.Some very long lorem ipsum dolor sit amet.");
-
- form.setItemDataSource(item);
- form.setFooter(buttons);
-
- getLayout().addComponent(form);
- }
-
- @Override
- protected String getDescription() {
- return "When resizing window buttons should stay on "
- + "right edge of the screent. Form should also get narrower.";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 3365;
- }
-
-}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/form/FormPrimaryStyleName.java b/uitest/src/main/java/com/vaadin/tests/components/form/FormPrimaryStyleName.java
deleted file mode 100644
index d20412b5c6..0000000000
--- a/uitest/src/main/java/com/vaadin/tests/components/form/FormPrimaryStyleName.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package com.vaadin.tests.components.form;
-
-import com.vaadin.legacy.ui.LegacyTextField;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.Button.ClickEvent;
-import com.vaadin.ui.Form;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.Label;
-
-public class FormPrimaryStyleName extends TestBase {
-
- @Override
- protected void setup() {
- final Form form = new Form();
- form.addField("aaa", new LegacyTextField());
- form.setDescription("This is a form description");
- form.setCaption("This is a form caption");
- form.setPrimaryStyleName("my-form");
-
- HorizontalLayout formFooter = new HorizontalLayout();
- formFooter.addComponent(new Label("Form footer"));
- form.setFooter(formFooter);
-
- addComponent(form);
-
- addComponent(new Button("Set primary stylename",
- new Button.ClickListener() {
- @Override
- public void buttonClick(ClickEvent event) {
- form.setPrimaryStyleName("my-second-form");
- }
- }));
-
- }
-
- @Override
- protected String getDescription() {
- return "Form should handle primary stylenames both initially and dynamically";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 9904;
- }
-
-}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/form/FormRenderingFlicker.java b/uitest/src/main/java/com/vaadin/tests/components/form/FormRenderingFlicker.java
deleted file mode 100644
index 41e1a91781..0000000000
--- a/uitest/src/main/java/com/vaadin/tests/components/form/FormRenderingFlicker.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package com.vaadin.tests.components.form;
-
-import com.vaadin.data.Item;
-import com.vaadin.event.ItemClickEvent;
-import com.vaadin.event.ItemClickEvent.ItemClickListener;
-import com.vaadin.tests.components.TestBase;
-import com.vaadin.ui.Form;
-import com.vaadin.ui.Panel;
-import com.vaadin.ui.Table;
-import com.vaadin.ui.VerticalLayout;
-
-public class FormRenderingFlicker extends TestBase {
-
- private VerticalLayout tableLayout;
- private Table table;
- private Panel tablePanel;
- private Form form;
-
- @Override
- protected String getDescription() {
- return "Clicking on an item in the table will replace the panel (surrounding the table) with a form. This should not cause the table rows to move downwards or cause any other visible flicker";
- }
-
- @Override
- protected Integer getTicketNumber() {
- return 2816;
- }
-
- @Override
- protected void setup() {
- createTableLayout();
- form = new Form();
-
- tablePanel = new Panel();
- tablePanel.setContent(tableLayout);
-
- addComponent(tablePanel);
- }
-
- private void createTableLayout() {
- tableLayout = new VerticalLayout();
- table = new Table();
- table.addContainerProperty("name", String.class, "");
- table.addContainerProperty("age", String.class, "");
- for (int i = 0; i < 100; i++) {
- table.addItem(new Object[] { "Name " + i, String.valueOf(i) },
- new Object());
- }
- table.setImmediate(true);
- table.addListener(new ItemClickListener() {
-
- @Override
- public void itemClick(ItemClickEvent event) {
- clicked(event.getItem());
- }
-
- });
-
- tableLayout.addComponent(table);
- }
-
- protected void clicked(Item item) {
- getLayout().replaceComponent(tablePanel, form);
- }
-
-}
diff --git a/uitest/src/main/java/com/vaadin/tests/components/form/FormTest.java b/uitest/src/main/java/com/vaadin/tests/components/form/FormTest.java
deleted file mode 100644
index f6cb84289f..0000000000
--- a/uitest/src/main/java/com/vaadin/tests/components/form/FormTest.java
+++ /dev/null
@@ -1,269 +0,0 @@
-package com.vaadin.tests.components.form;
-
-import java.util.LinkedHashMap;
-
-import com.vaadin.data.Item;
-import com.vaadin.data.util.BeanItem;
-import com.vaadin.legacy.ui.LegacyField;
-import com.vaadin.legacy.ui.LegacyTextField;
-import com.vaadin.shared.ui.AlignmentInfo;
-import com.vaadin.tests.components.abstractfield.LegacyAbstractFieldTest;
-import com.vaadin.tests.components.select.AbstractSelectTestCase;
-import com.vaadin.tests.util.Person;
-import com.vaadin.tests.util.Product;
-import com.vaadin.ui.Alignment;
-import com.vaadin.ui.Button;
-import com.vaadin.ui.ComboBox;
-import com.vaadin.ui.Component;
-import com.vaadin.ui.CssLayout;
-import com.vaadin.ui.DefaultFieldFactory;
-import com.vaadin.ui.Form;
-import com.vaadin.ui.FormFieldFactory;
-import com.vaadin.ui.FormLayout;
-import com.vaadin.ui.GridLayout;
-import com.vaadin.ui.HorizontalLayout;
-import com.vaadin.ui.Layout;
-import com.vaadin.ui.Layout.AlignmentHandler;
-import com.vaadin.ui.VerticalLayout;
-
-public class FormTest extends LegacyAbstractFieldTest