diff options
34 files changed, 311 insertions, 168 deletions
diff --git a/client/src/main/java/com/vaadin/client/connectors/AbstractMultiSelectConnector.java b/client/src/main/java/com/vaadin/client/connectors/AbstractMultiSelectConnector.java index 86dbe672e0..0dbe3cb331 100644 --- a/client/src/main/java/com/vaadin/client/connectors/AbstractMultiSelectConnector.java +++ b/client/src/main/java/com/vaadin/client/connectors/AbstractMultiSelectConnector.java @@ -25,11 +25,13 @@ import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.IsWidget; import com.google.gwt.user.client.ui.Widget; import com.vaadin.client.data.DataSource; +import com.vaadin.client.ui.HasRequiredIndicator; import com.vaadin.shared.Range; import com.vaadin.shared.Registration; import com.vaadin.shared.data.selection.MultiSelectServerRpc; import com.vaadin.shared.data.selection.SelectionModel; import com.vaadin.shared.ui.ListingJsonConstants; +import com.vaadin.shared.ui.RequiredIndicatorState; import elemental.json.JsonObject; @@ -44,7 +46,8 @@ import elemental.json.JsonObject; * @since 8.0 */ public abstract class AbstractMultiSelectConnector - extends AbstractListingConnector<SelectionModel.Multi<?>> { + extends AbstractListingConnector<SelectionModel.Multi<?>> + implements HasRequiredIndicator { /** * Abstraction layer to help populate different multiselect widgets based on @@ -148,14 +151,18 @@ public abstract class AbstractMultiSelectConnector protected void init() { super.init(); - MultiSelectServerRpc rpcProxy = getRpcProxy( - MultiSelectServerRpc.class); + MultiSelectServerRpc rpcProxy = getRpcProxy(MultiSelectServerRpc.class); getMultiSelectWidget().addSelectionChangeListener( (addedItems, removedItems) -> rpcProxy .updateSelection(addedItems, removedItems)); } @Override + public RequiredIndicatorState getState() { + return (RequiredIndicatorState) super.getState(); + } + + @Override public void setDataSource(DataSource<JsonObject> dataSource) { dataSource.addDataChangeHandler(this::onDataChange); super.setDataSource(dataSource); @@ -179,4 +186,9 @@ public abstract class AbstractMultiSelectConnector } getMultiSelectWidget().setItems(items); } + + @Override + public boolean isRequiredIndicatorVisible() { + return getState().required && !isReadOnly(); + } } diff --git a/client/src/main/java/com/vaadin/client/connectors/AbstractSingleSelectConnector.java b/client/src/main/java/com/vaadin/client/connectors/AbstractSingleSelectConnector.java new file mode 100644 index 0000000000..5554b8421c --- /dev/null +++ b/client/src/main/java/com/vaadin/client/connectors/AbstractSingleSelectConnector.java @@ -0,0 +1,44 @@ +/* + * Copyright 2000-2016 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.client.connectors; + +import com.google.gwt.event.dom.client.HasAllFocusHandlers; +import com.google.gwt.user.client.ui.Widget; +import com.vaadin.client.ui.HasRequiredIndicator; +import com.vaadin.shared.data.selection.SelectionModel; +import com.vaadin.shared.ui.AbstractSingleSelectState; + +/** + * An abstract class for single selection connectors. + * + * @author Vaadin Ltd + * @since 8.0.0 + */ +public abstract class AbstractSingleSelectConnector<WIDGET extends Widget & HasAllFocusHandlers> + extends + AbstractFocusableListingConnector<WIDGET, SelectionModel.Single<?>> + implements HasRequiredIndicator { + + @Override + public AbstractSingleSelectState getState() { + return (AbstractSingleSelectState) super.getState(); + } + + @Override + public boolean isRequiredIndicatorVisible() { + return getState().required && !isReadOnly(); + } +} diff --git a/client/src/main/java/com/vaadin/client/ui/AbstractComponentConnector.java b/client/src/main/java/com/vaadin/client/ui/AbstractComponentConnector.java index a6d73be0c8..5fff238fd4 100644 --- a/client/src/main/java/com/vaadin/client/ui/AbstractComponentConnector.java +++ b/client/src/main/java/com/vaadin/client/ui/AbstractComponentConnector.java @@ -668,6 +668,13 @@ public abstract class AbstractComponentConnector extends AbstractConnector */ getWidget().setStylePrimaryName(state.primaryStyleName); } + + // set required style name if components supports that + if (this instanceof HasRequiredIndicator) { + getWidget().setStyleName(StyleConstants.REQUIRED, + ((HasRequiredIndicator) this).isRequiredIndicatorVisible()); + } + Profiler.leave("AbstractComponentConnector.updateWidgetStyleNames"); } diff --git a/client/src/main/java/com/vaadin/client/ui/AbstractFieldConnector.java b/client/src/main/java/com/vaadin/client/ui/AbstractFieldConnector.java index 18834b2f8b..015b805ee1 100644 --- a/client/src/main/java/com/vaadin/client/ui/AbstractFieldConnector.java +++ b/client/src/main/java/com/vaadin/client/ui/AbstractFieldConnector.java @@ -30,14 +30,6 @@ public abstract class AbstractFieldConnector extends AbstractComponentConnector return getState().modified; } - /** - * Checks whether the required indicator should be shown for the field. - * - * Required indicators are hidden if the field or its data source is - * read-only. - * - * @return true if required indicator should be shown - */ @Override public boolean isRequiredIndicatorVisible() { return getState().required && !isReadOnly(); @@ -58,8 +50,5 @@ public abstract class AbstractFieldConnector extends AbstractComponentConnector // add / remove error style name to Fields setWidgetStyleNameWithPrefix(getWidget().getStylePrimaryName(), StyleConstants.REQUIRED_EXT, isRequiredIndicatorVisible()); - - getWidget().setStyleName(StyleConstants.REQUIRED, - isRequiredIndicatorVisible()); } } diff --git a/client/src/main/java/com/vaadin/client/ui/combobox/ComboBoxConnector.java b/client/src/main/java/com/vaadin/client/ui/combobox/ComboBoxConnector.java index 96fa5ea3cd..97f382453f 100644 --- a/client/src/main/java/com/vaadin/client/ui/combobox/ComboBoxConnector.java +++ b/client/src/main/java/com/vaadin/client/ui/combobox/ComboBoxConnector.java @@ -22,6 +22,7 @@ import com.vaadin.client.connectors.AbstractListingConnector; import com.vaadin.client.connectors.data.HasDataSource; import com.vaadin.client.data.DataSource; import com.vaadin.client.ui.HasErrorIndicator; +import com.vaadin.client.ui.HasRequiredIndicator; import com.vaadin.client.ui.SimpleManagedLayout; import com.vaadin.client.ui.VComboBox; import com.vaadin.client.ui.VComboBox.DataReceivedHandler; @@ -42,7 +43,8 @@ import elemental.json.JsonObject; @Connect(ComboBox.class) public class ComboBoxConnector extends AbstractListingConnector<SelectionModel.Single<?>> - implements HasDataSource, SimpleManagedLayout, HasErrorIndicator { + implements HasRequiredIndicator, HasDataSource, SimpleManagedLayout, + HasErrorIndicator { private ComboBoxServerRpc rpc = getRpcProxy(ComboBoxServerRpc.class); private SelectionServerRpc selectionRpc = getRpcProxy( @@ -181,8 +183,8 @@ public class ComboBoxConnector page = 0; } } - int adjustment = (getWidget().nullSelectionAllowed - && "".equals(getWidget().lastFilter)) ? 1 : 0; + int adjustment = getWidget().nullSelectionAllowed + && "".equals(getWidget().lastFilter) ? 1 : 0; int startIndex = Math.max(0, page * getWidget().pageLength - adjustment); int pageLength = getWidget().pageLength > 0 ? getWidget().pageLength @@ -331,4 +333,8 @@ public class ComboBoxConnector dataChangeHandlerRegistration.remove(); } + @Override + public boolean isRequiredIndicatorVisible() { + return getState().required && !isReadOnly(); + } } diff --git a/client/src/main/java/com/vaadin/client/ui/nativeselect/NativeSelectConnector.java b/client/src/main/java/com/vaadin/client/ui/nativeselect/NativeSelectConnector.java index 20c625a40d..18764f8b86 100644 --- a/client/src/main/java/com/vaadin/client/ui/nativeselect/NativeSelectConnector.java +++ b/client/src/main/java/com/vaadin/client/ui/nativeselect/NativeSelectConnector.java @@ -18,12 +18,11 @@ package com.vaadin.client.ui.nativeselect; import com.google.gwt.event.shared.HandlerRegistration; import com.vaadin.client.annotations.OnStateChange; -import com.vaadin.client.connectors.AbstractFocusableListingConnector; +import com.vaadin.client.connectors.AbstractSingleSelectConnector; import com.vaadin.client.data.DataSource; import com.vaadin.client.ui.VNativeSelect; import com.vaadin.shared.Range; import com.vaadin.shared.Registration; -import com.vaadin.shared.data.selection.SelectionModel; import com.vaadin.shared.data.selection.SelectionServerRpc; import com.vaadin.shared.ui.Connect; import com.vaadin.shared.ui.nativeselect.NativeSelectState; @@ -41,8 +40,8 @@ import elemental.json.JsonObject; * @since 8.0 */ @Connect(com.vaadin.ui.NativeSelect.class) -public class NativeSelectConnector extends - AbstractFocusableListingConnector<VNativeSelect, SelectionModel.Single<?>> { +public class NativeSelectConnector + extends AbstractSingleSelectConnector<VNativeSelect> { private HandlerRegistration selectionChangeRegistration; private Registration dataChangeRegistration; diff --git a/client/src/main/java/com/vaadin/client/ui/optiongroup/CheckBoxGroupConnector.java b/client/src/main/java/com/vaadin/client/ui/optiongroup/CheckBoxGroupConnector.java index 5955037e65..940287d583 100644 --- a/client/src/main/java/com/vaadin/client/ui/optiongroup/CheckBoxGroupConnector.java +++ b/client/src/main/java/com/vaadin/client/ui/optiongroup/CheckBoxGroupConnector.java @@ -24,6 +24,7 @@ import java.util.List; import com.vaadin.client.communication.StateChangeEvent; import com.vaadin.client.connectors.AbstractFocusableListingConnector; import com.vaadin.client.data.DataSource; +import com.vaadin.client.ui.HasRequiredIndicator; import com.vaadin.client.ui.VCheckBoxGroup; import com.vaadin.shared.data.selection.MultiSelectServerRpc; import com.vaadin.shared.data.selection.SelectionModel; @@ -35,8 +36,11 @@ import elemental.json.JsonObject; @Connect(CheckBoxGroup.class) // We don't care about the framework-provided selection model at this point +// TODO refactor to extend AbstractMultiSelectConnector, maybe when +// SelectionModel is removed from client side framwork8-issues#421 public class CheckBoxGroupConnector extends - AbstractFocusableListingConnector<VCheckBoxGroup, SelectionModel<?>> { + AbstractFocusableListingConnector<VCheckBoxGroup, SelectionModel<?>> + implements HasRequiredIndicator { @Override protected void init() { @@ -84,4 +88,9 @@ public class CheckBoxGroupConnector extends return (CheckBoxGroupState) super.getState(); } + // TODO remove once this extends AbstractMultiSelectConnector + @Override + public boolean isRequiredIndicatorVisible() { + return getState().required && !isReadOnly(); + } } diff --git a/client/src/main/java/com/vaadin/client/ui/optiongroup/RadioButtonGroupConnector.java b/client/src/main/java/com/vaadin/client/ui/optiongroup/RadioButtonGroupConnector.java index 4f3cad3c4c..13e39677d3 100644 --- a/client/src/main/java/com/vaadin/client/ui/optiongroup/RadioButtonGroupConnector.java +++ b/client/src/main/java/com/vaadin/client/ui/optiongroup/RadioButtonGroupConnector.java @@ -21,12 +21,11 @@ import java.util.List; import com.vaadin.client.annotations.OnStateChange; import com.vaadin.client.communication.StateChangeEvent; -import com.vaadin.client.connectors.AbstractFocusableListingConnector; +import com.vaadin.client.connectors.AbstractSingleSelectConnector; import com.vaadin.client.data.DataSource; import com.vaadin.client.ui.VRadioButtonGroup; import com.vaadin.shared.Range; import com.vaadin.shared.Registration; -import com.vaadin.shared.data.selection.SelectionModel; import com.vaadin.shared.data.selection.SelectionServerRpc; import com.vaadin.shared.ui.Connect; import com.vaadin.shared.ui.optiongroup.RadioButtonGroupState; @@ -35,8 +34,8 @@ import com.vaadin.ui.RadioButtonGroup; import elemental.json.JsonObject; @Connect(RadioButtonGroup.class) -public class RadioButtonGroupConnector extends - AbstractFocusableListingConnector<VRadioButtonGroup, SelectionModel.Single<?>> { +public class RadioButtonGroupConnector + extends AbstractSingleSelectConnector<VRadioButtonGroup> { private Registration selectionChangeRegistration; private Registration dataChangeRegistration; diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractField.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractField.java index eb6255e37a..f8188faa4d 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractField.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/AbstractField.java @@ -1433,42 +1433,11 @@ public abstract class AbstractField<T> extends AbstractLegacyComponent removePropertyListeners(); } - /** - * Is this field required. Required fields must filled by the user. - * - * If the field is required, it is visually indicated in the user interface. - * Furthermore, setting field to be required implicitly adds "non-empty" - * validator and thus isValid() == false or any isEmpty() fields. In those - * cases validation errors are not painted as it is obvious that the user - * must fill in the required fields. - * - * On the other hand, for the non-required fields isValid() == true if the - * field isEmpty() regardless of any attached validators. - * - * - * @return <code>true</code> if the field is required, otherwise - * <code>false</code>. - */ @Override public boolean isRequired() { return getState(false).required; } - /** - * Sets the field required. Required fields must filled by the user. - * - * If the field is required, it is visually indicated in the user interface. - * Furthermore, setting field to be required implicitly adds "non-empty" - * validator and thus isValid() == false or any isEmpty() fields. In those - * cases validation errors are not painted as it is obvious that the user - * must fill in the required fields. - * - * On the other hand, for the non-required fields isValid() == true if the - * field isEmpty() regardless of any attached validators. - * - * @param required - * Is the field required. - */ @Override public void setRequired(boolean required) { getState().required = required; diff --git a/compatibility-server/src/main/java/com/vaadin/v7/ui/Field.java b/compatibility-server/src/main/java/com/vaadin/v7/ui/Field.java index d98153da29..1594bc28b5 100644 --- a/compatibility-server/src/main/java/com/vaadin/v7/ui/Field.java +++ b/compatibility-server/src/main/java/com/vaadin/v7/ui/Field.java @@ -16,8 +16,6 @@ package com.vaadin.v7.ui; -import com.vaadin.data.HasRequired; -import com.vaadin.data.HasValue.ValueChangeEvent; import com.vaadin.ui.Component; import com.vaadin.ui.Component.Focusable; import com.vaadin.v7.data.BufferedValidatable; @@ -48,7 +46,7 @@ import com.vaadin.v7.data.Property; @Deprecated public interface Field<T> extends Component, BufferedValidatable, Property<T>, Property.ValueChangeNotifier, Property.ValueChangeListener, - Property.Editor, Focusable, HasRequired { + Property.Editor, Focusable { /** * Is this field required. * @@ -58,7 +56,6 @@ public interface Field<T> extends Component, BufferedValidatable, Property<T>, * <code>false</code>. * @since 3.1 */ - @Override public boolean isRequired(); /** @@ -68,7 +65,6 @@ public interface Field<T> extends Component, BufferedValidatable, Property<T>, * Is the field required. * @since 3.1 */ - @Override public void setRequired(boolean required); /** diff --git a/server/src/main/java/com/vaadin/data/HasRequired.java b/server/src/main/java/com/vaadin/data/HasRequired.java deleted file mode 100644 index cca6fcd699..0000000000 --- a/server/src/main/java/com/vaadin/data/HasRequired.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2000-2016 Vaadin Ltd. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ -package com.vaadin.data; - -import com.vaadin.ui.Component; - -/** - * Interface implemented by field which can be marked as required. A required - * status is handled by the parent layout. - * - * @since 8.0 - * @author Vaadin Ltd - */ -public interface HasRequired extends Component { - - /** - * Sets whether the field is required or not. - * - * If the field is required, it is visually indicated in the user interface. - * - * @param required - * <code>true</code> to make the field required, - * <code>false</code> otherwise - */ - public void setRequired(boolean required); - - /** - * Checks whether the field is required. - * - * @return <code>true</code> if the field is required, <code>false</code> - * otherwise - */ - public boolean isRequired(); - -} diff --git a/server/src/main/java/com/vaadin/data/HasValue.java b/server/src/main/java/com/vaadin/data/HasValue.java index aa130344b2..e02297b7f4 100644 --- a/server/src/main/java/com/vaadin/data/HasValue.java +++ b/server/src/main/java/com/vaadin/data/HasValue.java @@ -94,7 +94,7 @@ public interface HasValue<V> extends Serializable { * This a shorthand method for {@link HasValue#getValue()} for the event * source {@link #getSource()}. Thus the value is always the most recent * one, even if has been changed after the firing of this event. - * + * * @see HasValue#getValue() * * @return the new value @@ -217,4 +217,22 @@ public interface HasValue<V> extends Serializable { public default boolean isEmpty() { return Objects.equals(getValue(), getEmptyValue()); } + + /** + * Sets the required indicator visible or not. + * <p> + * If set visible, it is visually indicated in the user interface. + * + * @param requiredIndicatorVisible + * <code>true</code> to make the required indicator visible, + * <code>false</code> if not + */ + public void setRequiredIndicatorVisible(boolean requiredIndicatorVisible); + + /** + * Checks whether the required indicator is visible. + * + * @return <code>true</code> if visible, <code>false</code> if not + */ + public boolean isRequiredIndicatorVisible(); } diff --git a/server/src/main/java/com/vaadin/data/validator/NotEmptyValidator.java b/server/src/main/java/com/vaadin/data/validator/NotEmptyValidator.java index 99532c34d1..b033538949 100644 --- a/server/src/main/java/com/vaadin/data/validator/NotEmptyValidator.java +++ b/server/src/main/java/com/vaadin/data/validator/NotEmptyValidator.java @@ -17,7 +17,7 @@ package com.vaadin.data.validator; import java.util.Objects; -import com.vaadin.data.HasRequired; +import com.vaadin.data.HasValue; import com.vaadin.data.Result; import com.vaadin.data.Validator; import com.vaadin.data.util.converter.ValueContext; @@ -34,21 +34,22 @@ import com.vaadin.data.util.converter.ValueContext; * <p> * If the field is required, it is visually indicated in the user interface. * Furthermore, required fields requires "non-empty" validator. So in addition - * to call {@link HasRequired#setRequired(boolean)} method one should add an - * instance of this validator explicitly so the code looks like this: + * to call {@link HasRequired#setRequiredIndicatorVisible(boolean)} method one + * should add an instance of this validator explicitly so the code looks like + * this: * * <pre> * <code> * Binder<Bean,String, String> binder = new Binder<>(); * TextField name = new TextField(); - * name.setRequired(true); + * name.setRequiredIndicatorVisible(true); * binder.forField(name).withValidator( * new NonEmptyValidator("Name cannot be empty")) * .bind(Bean::getName, Bean::setName); * </code> * </pre> * - * @see HasRequired + * @see HasValue#setRequiredIndicatorVisible(boolean) * @author Vaadin Ltd * @since 8.0 * diff --git a/server/src/main/java/com/vaadin/ui/AbstractComponent.java b/server/src/main/java/com/vaadin/ui/AbstractComponent.java index 6cbf745851..8711b601e6 100644 --- a/server/src/main/java/com/vaadin/ui/AbstractComponent.java +++ b/server/src/main/java/com/vaadin/ui/AbstractComponent.java @@ -60,6 +60,7 @@ import com.vaadin.shared.EventId; import com.vaadin.shared.MouseEventDetails; import com.vaadin.shared.Registration; import com.vaadin.shared.ui.ComponentStateUtil; +import com.vaadin.shared.ui.RequiredIndicatorState; import com.vaadin.shared.util.SharedUtil; import com.vaadin.ui.declarative.DesignAttributeHandler; import com.vaadin.ui.declarative.DesignContext; @@ -1045,7 +1046,7 @@ public abstract class AbstractComponent extends AbstractClientConnector } /** - * Returns true if the component is responsive + * Returns true if the component is responsive. * * @since 7.5.0 * @return true if the component is responsive @@ -1370,6 +1371,58 @@ public abstract class AbstractComponent extends AbstractClientConnector listener); } + /** + * Sets the visibility of the required indicator. <strong>NOTE: Does not + * apply for all components!</strong>. + * <p> + * If the component supports the required indicator (state extends + * {@link RequiredIndicatorState}), then expose this method and + * {@link #isRequiredIndicatorVisible()} as {@code public} in the component + * and call this method. + * <p> + * This method will throw a {@link IllegalStateException} if the component + * state (returned by {@link #getState()}) does not inherit + * {@link RequiredIndicatorState}. + * + * @param visible + * <code>true</code> to make the required indicator visible, + * <code>false</code> if not + */ + protected void setRequiredIndicatorVisible(boolean visible) { + if (getState(false) instanceof RequiredIndicatorState) { + ((RequiredIndicatorState) getState()).required = visible; + } else { + throw new IllegalStateException( + "This component does not support the required indicator, since state is of type " + + getStateType().getSimpleName() + + " and does not inherit " + + RequiredIndicatorState.class.getSimpleName()); + } + } + + /** + * Checks whether the required indicator is visible or not. <strong>NOTE: + * Does not apply for all components!</strong>. + * <p> + * This method will throw a {@link IllegalStateException} if the component + * state (returned by {@link #getState()}) does not inherit + * {@link RequiredIndicatorState}. + * + * @return <code>true</code> if visible, <code>false</code> if not + * @see #setRequiredIndicatorVisible(boolean) + */ + protected boolean isRequiredIndicatorVisible() { + if (getState(false) instanceof RequiredIndicatorState) { + return ((RequiredIndicatorState) getState(false)).required; + } else { + throw new IllegalStateException( + "This component does not support the required indicator, since state is of type " + + getStateType().getSimpleName() + + " and does not inherit " + + RequiredIndicatorState.class.getSimpleName()); + } + } + private static final Logger getLogger() { return Logger.getLogger(AbstractComponent.class.getName()); } diff --git a/server/src/main/java/com/vaadin/ui/AbstractField.java b/server/src/main/java/com/vaadin/ui/AbstractField.java index 4add30183e..065825b5ad 100644 --- a/server/src/main/java/com/vaadin/ui/AbstractField.java +++ b/server/src/main/java/com/vaadin/ui/AbstractField.java @@ -23,7 +23,6 @@ import java.util.Objects; import org.jsoup.nodes.Attributes; import org.jsoup.nodes.Element; -import com.vaadin.data.HasRequired; import com.vaadin.data.HasValue; import com.vaadin.shared.AbstractFieldState; import com.vaadin.shared.Registration; @@ -49,7 +48,7 @@ import com.vaadin.util.ReflectTools; * the input value type */ public abstract class AbstractField<T> extends AbstractComponent - implements HasValue<T>, HasRequired, Focusable { + implements HasValue<T>, Focusable { @Deprecated private static final Method VALUE_CHANGE_METHOD = ReflectTools.findMethod( @@ -214,12 +213,12 @@ public abstract class AbstractField<T> extends AbstractComponent } @Override - public void setRequired(boolean required) { - getState().required = required; + public void setRequiredIndicatorVisible(boolean visible) { + super.setRequiredIndicatorVisible(visible); } @Override - public boolean isRequired() { - return getState(false).required; + public boolean isRequiredIndicatorVisible() { + return super.isRequiredIndicatorVisible(); } } diff --git a/server/src/main/java/com/vaadin/ui/AbstractMultiSelect.java b/server/src/main/java/com/vaadin/ui/AbstractMultiSelect.java index 5ab6951f8d..99c1682536 100644 --- a/server/src/main/java/com/vaadin/ui/AbstractMultiSelect.java +++ b/server/src/main/java/com/vaadin/ui/AbstractMultiSelect.java @@ -37,6 +37,7 @@ import com.vaadin.shared.data.selection.MultiSelectServerRpc; import com.vaadin.shared.data.selection.SelectionModel; import com.vaadin.shared.data.selection.SelectionModel.Multi; import com.vaadin.shared.ui.ListingJsonConstants; +import com.vaadin.shared.ui.RequiredIndicatorState; import com.vaadin.util.ReflectTools; import elemental.json.JsonObject; @@ -472,4 +473,24 @@ public abstract class AbstractMultiSelect<T> this.itemEnabledProvider = itemEnabledProvider; } + @Override + public void setRequiredIndicatorVisible(boolean visible) { + super.setRequiredIndicatorVisible(visible); + } + + @Override + public boolean isRequiredIndicatorVisible() { + return super.isRequiredIndicatorVisible(); + } + + @Override + protected RequiredIndicatorState getState() { + return (RequiredIndicatorState) super.getState(); + } + + @Override + protected RequiredIndicatorState getState(boolean markAsDirty) { + return (RequiredIndicatorState) super.getState(markAsDirty); + }; + } diff --git a/server/src/main/java/com/vaadin/ui/AbstractSingleSelect.java b/server/src/main/java/com/vaadin/ui/AbstractSingleSelect.java index c4405f06b1..272acf3b09 100644 --- a/server/src/main/java/com/vaadin/ui/AbstractSingleSelect.java +++ b/server/src/main/java/com/vaadin/ui/AbstractSingleSelect.java @@ -306,7 +306,7 @@ public abstract class AbstractSingleSelect<T> extends * The call is delegated to {@link #getSelectedItem()} * * @return the current selection, may be {@code null} - * + * * @see #getSelectedItem() * @see Single#getSelectedItem */ @@ -321,7 +321,7 @@ public abstract class AbstractSingleSelect<T> extends * value is {@code null} then it deselects currently selected item. * <p> * The call is delegated to {@link #setSelectedItem(Object)}. - * + * * @see #setSelectedItem(Object) * @see Single#setSelectedItem(Object) * @@ -349,4 +349,14 @@ public abstract class AbstractSingleSelect<T> extends protected AbstractSingleSelectState getState(boolean markAsDirty) { return (AbstractSingleSelectState) super.getState(markAsDirty); } + + @Override + public void setRequiredIndicatorVisible(boolean visible) { + super.setRequiredIndicatorVisible(visible); + } + + @Override + public boolean isRequiredIndicatorVisible() { + return super.isRequiredIndicatorVisible(); + } } diff --git a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java index ba00773fec..f474e51e99 100644 --- a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java +++ b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPopup.java @@ -710,6 +710,16 @@ public class ColorPickerPopup extends Window implements HasValue<Color> { } }; + @Override + public void setRequiredIndicatorVisible(boolean visible) { + super.setRequiredIndicatorVisible(visible); + } + + @Override + public boolean isRequiredIndicatorVisible() { + return super.isRequiredIndicatorVisible(); + } + private static Logger getLogger() { return Logger.getLogger(ColorPickerPopup.class.getName()); } diff --git a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPreview.java b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPreview.java index 67724d134b..27e5690e3c 100644 --- a/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPreview.java +++ b/server/src/main/java/com/vaadin/ui/components/colorpicker/ColorPickerPreview.java @@ -185,4 +185,14 @@ public class ColorPickerPreview extends CssLayout implements HasValue<Color> { protected String getCss(Component c) { return "background: " + color.getCSS(); } + + @Override + public void setRequiredIndicatorVisible(boolean visible) { + super.setRequiredIndicatorVisible(visible); + } + + @Override + public boolean isRequiredIndicatorVisible() { + return super.isRequiredIndicatorVisible(); + } } diff --git a/server/src/test/java/com/vaadin/tests/server/component/abstractfield/AbstractFieldDeclarativeTest.java b/server/src/test/java/com/vaadin/tests/server/component/abstractfield/AbstractFieldDeclarativeTest.java index df7b64b671..e22905c9f3 100644 --- a/server/src/test/java/com/vaadin/tests/server/component/abstractfield/AbstractFieldDeclarativeTest.java +++ b/server/src/test/java/com/vaadin/tests/server/component/abstractfield/AbstractFieldDeclarativeTest.java @@ -28,7 +28,7 @@ import com.vaadin.ui.AbstractField; * declarative test for a real component should extend it and implement abstract * methods to be able to test the common properties. Components specific * properties should be tested additionally in the subclasses implementations. - * + * * @author Vaadin Ltd * */ @@ -39,10 +39,11 @@ public abstract class AbstractFieldDeclarativeTest<T extends AbstractField<V>, V public void requiredDeserialization() throws InstantiationException, IllegalAccessException { boolean isRequired = true; - String design = String.format("<%s required/>", getComponentTag()); + String design = String.format("<%s required-indicator-visible/>", + getComponentTag()); T component = getComponentClass().newInstance(); - component.setRequired(isRequired); + component.setRequiredIndicatorVisible(isRequired); testRead(design, component); testWrite(design, component); } diff --git a/shared/src/main/java/com/vaadin/shared/AbstractFieldState.java b/shared/src/main/java/com/vaadin/shared/AbstractFieldState.java index 5040e91d48..e24880c3af 100644 --- a/shared/src/main/java/com/vaadin/shared/AbstractFieldState.java +++ b/shared/src/main/java/com/vaadin/shared/AbstractFieldState.java @@ -15,7 +15,7 @@ */ package com.vaadin.shared; -import com.vaadin.shared.ui.TabIndexState; +import com.vaadin.shared.ui.RequiredIndicatorState; /** * Shared state for {@link com.vaadin.ui.AbstractField}. @@ -24,8 +24,7 @@ import com.vaadin.shared.ui.TabIndexState; * @since 7.0.0 * */ -public class AbstractFieldState extends TabIndexState { +public class AbstractFieldState extends RequiredIndicatorState { public boolean hideErrors = false; - public boolean required = false; public boolean modified = false; } diff --git a/shared/src/main/java/com/vaadin/shared/ui/AbstractSingleSelectState.java b/shared/src/main/java/com/vaadin/shared/ui/AbstractSingleSelectState.java index 98aad0bf37..da4510bfdb 100644 --- a/shared/src/main/java/com/vaadin/shared/ui/AbstractSingleSelectState.java +++ b/shared/src/main/java/com/vaadin/shared/ui/AbstractSingleSelectState.java @@ -1,12 +1,12 @@ /* * Copyright 2000-2016 Vaadin Ltd. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the @@ -22,7 +22,7 @@ package com.vaadin.shared.ui; * * @since 8.0 */ -public class AbstractSingleSelectState extends TabIndexState { +public class AbstractSingleSelectState extends RequiredIndicatorState { /** * The key of the currently selected item or {@code null} if no item is diff --git a/shared/src/main/java/com/vaadin/shared/ui/RequiredIndicatorState.java b/shared/src/main/java/com/vaadin/shared/ui/RequiredIndicatorState.java new file mode 100644 index 0000000000..b26a8ceb2b --- /dev/null +++ b/shared/src/main/java/com/vaadin/shared/ui/RequiredIndicatorState.java @@ -0,0 +1,32 @@ +/* + * Copyright 2000-2016 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.shared.ui; + +/** + * State for components that can show the required indicator. + * + * @author Vaadin Ltd + * @since 8.0.0 + * + */ +public class RequiredIndicatorState extends TabIndexState { + + /** + * Is the required indicator visible or not. + */ + public boolean required; + +} diff --git a/shared/src/main/java/com/vaadin/shared/ui/TabIndexState.java b/shared/src/main/java/com/vaadin/shared/ui/TabIndexState.java index f0c709d373..485448e758 100644 --- a/shared/src/main/java/com/vaadin/shared/ui/TabIndexState.java +++ b/shared/src/main/java/com/vaadin/shared/ui/TabIndexState.java @@ -19,7 +19,7 @@ import com.vaadin.shared.AbstractComponentState; import com.vaadin.shared.annotations.NoLayout; /** - * Interface implemented by state classes that support tab indexes. + * State for components that support tab indexes. * * @author Vaadin Ltd * @since 7.0.0 diff --git a/shared/src/main/java/com/vaadin/shared/ui/listselect/ListSelectState.java b/shared/src/main/java/com/vaadin/shared/ui/listselect/ListSelectState.java index 8999f3c739..8992dc6647 100644 --- a/shared/src/main/java/com/vaadin/shared/ui/listselect/ListSelectState.java +++ b/shared/src/main/java/com/vaadin/shared/ui/listselect/ListSelectState.java @@ -16,7 +16,7 @@ package com.vaadin.shared.ui.listselect; import com.vaadin.shared.annotations.DelegateToWidget; -import com.vaadin.shared.ui.TabIndexState; +import com.vaadin.shared.ui.RequiredIndicatorState; /** * Shared state for ListSelect component. @@ -24,7 +24,7 @@ import com.vaadin.shared.ui.TabIndexState; * @author Vaadin Ltd * */ -public class ListSelectState extends TabIndexState { +public class ListSelectState extends RequiredIndicatorState { { primaryStyleName = "v-select"; } diff --git a/shared/src/main/java/com/vaadin/shared/ui/optiongroup/CheckBoxGroupState.java b/shared/src/main/java/com/vaadin/shared/ui/optiongroup/CheckBoxGroupState.java index 2decfdd49c..82695a913c 100644 --- a/shared/src/main/java/com/vaadin/shared/ui/optiongroup/CheckBoxGroupState.java +++ b/shared/src/main/java/com/vaadin/shared/ui/optiongroup/CheckBoxGroupState.java @@ -16,7 +16,7 @@ package com.vaadin.shared.ui.optiongroup; import com.vaadin.shared.annotations.DelegateToWidget; -import com.vaadin.shared.AbstractFieldState; +import com.vaadin.shared.ui.RequiredIndicatorState; /** * Shared state for the CheckBoxGroup component. @@ -24,7 +24,7 @@ import com.vaadin.shared.AbstractFieldState; * @author Vaadin Ltd. * @since 8.0 */ -public class CheckBoxGroupState extends AbstractFieldState { +public class CheckBoxGroupState extends RequiredIndicatorState { { primaryStyleName = "v-select-optiongroup"; diff --git a/shared/src/main/java/com/vaadin/shared/ui/twincolselect/TwinColSelectState.java b/shared/src/main/java/com/vaadin/shared/ui/twincolselect/TwinColSelectState.java index a6b09c0e91..fe1f1fab23 100644 --- a/shared/src/main/java/com/vaadin/shared/ui/twincolselect/TwinColSelectState.java +++ b/shared/src/main/java/com/vaadin/shared/ui/twincolselect/TwinColSelectState.java @@ -16,14 +16,14 @@ package com.vaadin.shared.ui.twincolselect; import com.vaadin.shared.annotations.DelegateToWidget; -import com.vaadin.shared.ui.TabIndexState; +import com.vaadin.shared.ui.RequiredIndicatorState; /** * Shared state for the TwinColSelect component. * * @since 7.0 */ -public class TwinColSelectState extends TabIndexState { +public class TwinColSelectState extends RequiredIndicatorState { { primaryStyleName = "v-select-twincol"; } diff --git a/uitest/src/main/java/com/vaadin/tests/components/AbstractComponentTestCase.java b/uitest/src/main/java/com/vaadin/tests/components/AbstractComponentTestCase.java index 8dce9c73e2..f34c663029 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/AbstractComponentTestCase.java +++ b/uitest/src/main/java/com/vaadin/tests/components/AbstractComponentTestCase.java @@ -5,7 +5,7 @@ import java.util.Date; import java.util.List; import java.util.Locale; -import com.vaadin.data.HasRequired; +import com.vaadin.data.HasValue; import com.vaadin.server.Resource; import com.vaadin.server.ThemeResource; import com.vaadin.server.UserError; @@ -109,8 +109,10 @@ public abstract class AbstractComponentTestCase<T extends AbstractComponent> // TODO Move to AbstractFieldTestCase protected Command<T, Boolean> requiredCommand = (c, enabled, data) -> { - if (c instanceof HasRequired) { - ((HasRequired) c).setRequired(enabled); + if (c instanceof HasValue) { + ((HasValue) c).setRequiredIndicatorVisible(enabled); + } else if (c instanceof Field) { + ((Field) c).setRequired(enabled); } else { throw new IllegalArgumentException(c.getClass().getName() + " is not a field and cannot be set to required"); diff --git a/uitest/src/main/java/com/vaadin/tests/components/ComponentTestCase.java b/uitest/src/main/java/com/vaadin/tests/components/ComponentTestCase.java index 1010a42e7d..591bf599cb 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/ComponentTestCase.java +++ b/uitest/src/main/java/com/vaadin/tests/components/ComponentTestCase.java @@ -4,7 +4,7 @@ import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; -import com.vaadin.data.HasRequired; +import com.vaadin.data.HasValue; import com.vaadin.server.VaadinRequest; import com.vaadin.ui.AbstractComponent; import com.vaadin.ui.Alignment; @@ -13,6 +13,7 @@ import com.vaadin.ui.CheckBox; import com.vaadin.ui.Component; import com.vaadin.ui.HorizontalLayout; import com.vaadin.v7.data.Item; +import com.vaadin.v7.ui.Field; import com.vaadin.v7.ui.NativeSelect; public abstract class ComponentTestCase<T extends AbstractComponent> @@ -71,7 +72,8 @@ public abstract class ComponentTestCase<T extends AbstractComponent> actions.add(createReadonlyAction(false)); actions.add(createErrorIndicatorAction(false)); - if (HasRequired.class.isAssignableFrom(getTestClass())) { + if (HasValue.class.isAssignableFrom(getTestClass()) + || Field.class.isAssignableFrom(getTestClass())) { actions.add(createRequiredAction(false)); } diff --git a/uitest/src/main/java/com/vaadin/tests/components/datefield/DatePopupStyleName.java b/uitest/src/main/java/com/vaadin/tests/components/datefield/DatePopupStyleName.java index d08194681e..794db5e096 100644 --- a/uitest/src/main/java/com/vaadin/tests/components/datefield/DatePopupStyleName.java +++ b/uitest/src/main/java/com/vaadin/tests/components/datefield/DatePopupStyleName.java @@ -15,7 +15,7 @@ public class DatePopupStyleName extends TestBase { final AbstractDateField df = new TestDateField(); df.setValue(LocalDate.of(1970, 1, 15)); df.setWidth("200px"); - df.setRequired(true); + df.setRequiredIndicatorVisible(true); df.setComponentError(new UserError("abc")); df.addStyleName("popup-style"); addComponent(df); diff --git a/uitest/src/main/java/com/vaadin/tests/layouts/CaptionsInLayoutsWaiAria.java b/uitest/src/main/java/com/vaadin/tests/layouts/CaptionsInLayoutsWaiAria.java index b995fe9093..5c8788f53e 100644 --- a/uitest/src/main/java/com/vaadin/tests/layouts/CaptionsInLayoutsWaiAria.java +++ b/uitest/src/main/java/com/vaadin/tests/layouts/CaptionsInLayoutsWaiAria.java @@ -3,7 +3,7 @@ package com.vaadin.tests.layouts; import java.util.ArrayList; import java.util.List; -import com.vaadin.data.HasRequired; +import com.vaadin.data.HasValue; import com.vaadin.server.ThemeResource; import com.vaadin.server.UserError; import com.vaadin.tests.components.TestBase; @@ -24,6 +24,7 @@ import com.vaadin.ui.VerticalLayout; import com.vaadin.v7.data.Item; import com.vaadin.v7.data.Property.ValueChangeEvent; import com.vaadin.v7.data.Property.ValueChangeListener; +import com.vaadin.v7.ui.Field; import com.vaadin.v7.ui.NativeSelect; import com.vaadin.v7.ui.OptionGroup; import com.vaadin.v7.ui.PasswordField; @@ -140,8 +141,10 @@ public class CaptionsInLayoutsWaiAria extends TestBase { protected void setRequired(boolean value) { for (AbstractComponent c : components) { - if (c instanceof HasRequired) { - ((HasRequired) c).setRequired(value); + if (c instanceof HasValue) { + ((HasValue) c).setRequiredIndicatorVisible(value); + } else if (c instanceof Field) { + ((Field) c).setRequired(value); } } diff --git a/uitest/src/main/java/com/vaadin/tests/layouts/FormLayoutWithInvisibleComponent.java b/uitest/src/main/java/com/vaadin/tests/layouts/FormLayoutWithInvisibleComponent.java index f06db44b5c..6c7b112910 100644 --- a/uitest/src/main/java/com/vaadin/tests/layouts/FormLayoutWithInvisibleComponent.java +++ b/uitest/src/main/java/com/vaadin/tests/layouts/FormLayoutWithInvisibleComponent.java @@ -25,7 +25,7 @@ public class FormLayoutWithInvisibleComponent extends TestBase { CheckBox control = new CheckBox("Messages On/Off"); control.addValueChangeListener(event -> { messages.setVisible(event.getValue()); - messages.setRequired(true); + messages.setRequiredIndicatorVisible(true); messages.setCaption("Messages visible"); }); formLayout.addComponent(control); diff --git a/uitest/src/main/java/com/vaadin/tests/layouts/OrderedLayoutBasics.java b/uitest/src/main/java/com/vaadin/tests/layouts/OrderedLayoutBasics.java index 4d1f0213c4..112965d06a 100644 --- a/uitest/src/main/java/com/vaadin/tests/layouts/OrderedLayoutBasics.java +++ b/uitest/src/main/java/com/vaadin/tests/layouts/OrderedLayoutBasics.java @@ -343,7 +343,7 @@ public class OrderedLayoutBasics extends TestBase { tf = new TextArea("100% high TextField"); tf.setCaption(null); - tf.setRequired(true); + tf.setRequiredIndicatorVisible(true); tf.setValue("100% high Field"); tf.setHeight("100%"); tf.setWidth("100px"); @@ -352,7 +352,7 @@ public class OrderedLayoutBasics extends TestBase { tf = new TextArea("100% high TextField"); tf.setCaption("100% high TextField"); - tf.setRequired(true); + tf.setRequiredIndicatorVisible(true); tf.setValue("100% high Field"); tf.setHeight("100%"); tf.setWidth("100px"); @@ -602,7 +602,7 @@ public class OrderedLayoutBasics extends TestBase { tf.setValue("60% x 100% TextField"); tf.setWidth("100%"); tf.setHeight("100%"); - tf.setRequired(true); + tf.setRequiredIndicatorVisible(true); // tf.setComponentError(new UserError("It's broken!")); // tf.setHeight("100%"); @@ -617,7 +617,7 @@ public class OrderedLayoutBasics extends TestBase { tf.setValue("60% x 60% TextField"); tf.setWidth("100%"); tf.setHeight("60%"); - tf.setRequired(true); + tf.setRequiredIndicatorVisible(true); ol.addComponent(tf); ol.setExpandRatio(tf, 1f); ol.setComponentAlignment(tf, Alignment.MIDDLE_LEFT); @@ -696,7 +696,7 @@ public class OrderedLayoutBasics extends TestBase { tf.setValue("200x200 TextField"); tf.setWidth("200px"); tf.setHeight("200px"); - tf.setRequired(true); + tf.setRequiredIndicatorVisible(true); // tf.setComponentError(new UserError("It's broken!")); // tf.setHeight("100%"); @@ -723,9 +723,9 @@ public class OrderedLayoutBasics extends TestBase { tf = new TextArea("200x200px Field"); tf.setCaption("This one has a caption"); tf.setWidth("200px"); - tf.setHeight(((i + 1) * 50) + "px"); + tf.setHeight((i + 1) * 50 + "px"); tf.setValue(tf.getWidth() + "x" + tf.getHeight() + " TextField"); - tf.setRequired(true); + tf.setRequiredIndicatorVisible(true); // tf.setComponentError(new UserError("It's broken!")); // tf.setHeight("100%"); @@ -814,7 +814,7 @@ public class OrderedLayoutBasics extends TestBase { tf = new TextField( "A very long caption which is probably much longer than the field and includes indicators"); - tf.setRequired(true); + tf.setRequiredIndicatorVisible(true); tf.setComponentError(new UserError("abc123")); ol.addComponent(tf); @@ -852,7 +852,7 @@ public class OrderedLayoutBasics extends TestBase { tf = new TextField( "A long caption which is probably much longer than the field"); tf.setValue("Undefined width"); - tf.setRequired(true); + tf.setRequiredIndicatorVisible(true); tf.setComponentError(new UserError("123")); ol.addComponent(tf); ol.setComponentAlignment(tf, Alignment.BOTTOM_RIGHT); @@ -861,7 +861,7 @@ public class OrderedLayoutBasics extends TestBase { "A very long caption which is probably much longer than the field and includes indicators"); tf.setValue("Undefined width"); tf.setIcon(new ThemeResource("icons/16/document-add.png")); - tf.setRequired(true); + tf.setRequiredIndicatorVisible(true); tf.setComponentError(new UserError("abc123")); ol.addComponent(tf); ol.setComponentAlignment(tf, Alignment.BOTTOM_RIGHT); @@ -905,7 +905,7 @@ public class OrderedLayoutBasics extends TestBase { "A long caption which is probably much longer than the field"); tf.setValue("100% wide field, ratio 2"); tf.setSizeFull(); - tf.setRequired(true); + tf.setRequiredIndicatorVisible(true); tf.setComponentError(new UserError("123")); ol.addComponent(tf); ol.setComponentAlignment(tf, Alignment.BOTTOM_RIGHT); @@ -916,7 +916,7 @@ public class OrderedLayoutBasics extends TestBase { tf.setValue("100% wide field, ratio 3"); tf.setSizeFull(); tf.setIcon(new ThemeResource("icons/16/document-add.png")); - tf.setRequired(true); + tf.setRequiredIndicatorVisible(true); tf.setComponentError(new UserError("abc123")); ol.addComponent(tf); ol.setComponentAlignment(tf, Alignment.BOTTOM_RIGHT); @@ -959,7 +959,7 @@ public class OrderedLayoutBasics extends TestBase { "A long caption which is probably much longer than the field"); tf.setWidth("250px"); tf.setValue("250px wide field"); - tf.setRequired(true); + tf.setRequiredIndicatorVisible(true); tf.setComponentError(new UserError("123")); ol.addComponent(tf); ol.setComponentAlignment(tf, Alignment.BOTTOM_RIGHT); @@ -969,7 +969,7 @@ public class OrderedLayoutBasics extends TestBase { tf.setValue("200px wide field"); tf.setWidth("200px"); tf.setIcon(new ThemeResource("icons/16/document-add.png")); - tf.setRequired(true); + tf.setRequiredIndicatorVisible(true); tf.setComponentError(new UserError("abc123")); ol.addComponent(tf); ol.setComponentAlignment(tf, Alignment.BOTTOM_RIGHT); @@ -1209,7 +1209,7 @@ public class OrderedLayoutBasics extends TestBase { ta.setValue("60% x 100% TextField"); ta.setWidth("60%"); ta.setHeight("100%"); - ta.setRequired(true); + ta.setRequiredIndicatorVisible(true); ta.setRows(2); ol.addComponent(ta); diff --git a/uitest/src/main/java/com/vaadin/tests/util/CheckBoxWithPropertyDataSource.java b/uitest/src/main/java/com/vaadin/tests/util/CheckBoxWithPropertyDataSource.java index bd9df1e8f8..db29239bf3 100644 --- a/uitest/src/main/java/com/vaadin/tests/util/CheckBoxWithPropertyDataSource.java +++ b/uitest/src/main/java/com/vaadin/tests/util/CheckBoxWithPropertyDataSource.java @@ -26,7 +26,7 @@ public class CheckBoxWithPropertyDataSource extends CheckBox { } public void validate() { - if (isRequired() && !getValue()) { + if (isRequiredIndicatorVisible() && !getValue()) { throw new InvalidValueException( "Required CheckBox should be checked"); } |