com.vaadin.flow.component.checkbox.GeneratedVaadinCheckboxGroup Maven / Gradle / Ivy
/*
* Copyright 2000-2018 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.flow.component.checkbox;
import javax.annotation.Generated;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import com.vaadin.flow.component.AbstractSinglePropertyField;
import com.vaadin.flow.component.ComponentEvent;
import com.vaadin.flow.component.ComponentEventListener;
import com.vaadin.flow.component.HasStyle;
import com.vaadin.flow.component.HasTheme;
import com.vaadin.flow.component.NotSupported;
import com.vaadin.flow.component.Synchronize;
import com.vaadin.flow.component.Tag;
import com.vaadin.flow.component.dependency.JsModule;
import com.vaadin.flow.component.dependency.NpmPackage;
import com.vaadin.flow.function.SerializableBiFunction;
import com.vaadin.flow.function.SerializableFunction;
import com.vaadin.flow.shared.Registration;
/**
*
* Description copied from corresponding location in WebComponent:
*
*
* {@code } is a Polymer element for grouping
* vaadin-checkboxes.
*
*
* <vaadin-checkbox-group label="Preferred language of
* contact:"> <vaadin-checkbox
* value="en">English</vaadin-checkbox> <vaadin-checkbox
* value="fr">Français</vaadin-checkbox> <vaadin-checkbox
* value="de">Deutsch</vaadin-checkbox>
* </vaadin-checkbox-group>
*
* Styling
*
* The following shadow DOM parts are available for styling:
*
*
*
*
* Part name
* Description
*
*
*
* {@code label}
* The label element
*
*
* {@code group-field}
* The element that wraps checkboxes
*
*
* {@code error-message}
* The error message element
*
*
*
*
* The following state attributes are available for styling:
*
*
*
*
* Attribute
* Description
* Part name
*
*
*
* {@code disabled}
* Set when the checkbox group and its children are disabled.
* :host
*
*
* {@code has-label}
* Set when the element has a label
* :host
*
*
* {@code has-value}
* Set when the element has a value
* :host
*
*
* {@code required}
* Set when the element is required
* :host
*
*
* {@code invalid}
* Set when the element is invalid
* :host
*
*
*
*
* See
* ThemableMixin
* – how to apply styles for shadow parts
*
*/
@Generated({ "Generator: com.vaadin.generator.ComponentGenerator#1.1-SNAPSHOT",
"WebComponent: Vaadin.CheckboxGroupElement#2.2.2",
"Flow#1.1-SNAPSHOT" })
@Tag("vaadin-checkbox-group")
@NpmPackage(value = "@vaadin/vaadin-checkbox", version = "2.3.0")
@JsModule("@vaadin/vaadin-checkbox/src/vaadin-checkbox-group.js")
public abstract class GeneratedVaadinCheckboxGroup, T>
extends AbstractSinglePropertyField
implements HasStyle, HasTheme {
/**
* Adds theme variants to the component.
*
* @param variants
* theme variants to add
*/
public void addThemeVariants(CheckboxGroupVariant... variants) {
getThemeNames().addAll(
Stream.of(variants).map(CheckboxGroupVariant::getVariantName)
.collect(Collectors.toList()));
}
/**
* Removes theme variants from the component.
*
* @param variants
* theme variants to remove
*/
public void removeThemeVariants(CheckboxGroupVariant... variants) {
getThemeNames().removeAll(
Stream.of(variants).map(CheckboxGroupVariant::getVariantName)
.collect(Collectors.toList()));
}
/**
*
* Description copied from corresponding location in WebComponent:
*
*
* The current disabled state of the checkbox group. True if group and all
* internal checkboxes are disabled.
*
* This property is not synchronized automatically from the client side, so
* the returned value may not be the same as in client side.
*
*
* @return the {@code disabled} property from the webcomponent
*/
protected boolean isDisabledBoolean() {
return getElement().getProperty("disabled", false);
}
/**
*
* Description copied from corresponding location in WebComponent:
*
*
* The current disabled state of the checkbox group. True if group and all
* internal checkboxes are disabled.
*
*
* @param disabled
* the boolean value to set
*/
protected void setDisabled(boolean disabled) {
getElement().setProperty("disabled", disabled);
}
/**
*
* Description copied from corresponding location in WebComponent:
*
*
* String used for the label element.
*
* This property is not synchronized automatically from the client side, so
* the returned value may not be the same as in client side.
*
*
* @return the {@code label} property from the webcomponent
*/
protected String getLabelString() {
return getElement().getProperty("label");
}
/**
*
* Description copied from corresponding location in WebComponent:
*
*
* String used for the label element.
*
*
* @param label
* the String value to set
*/
protected void setLabel(String label) {
getElement().setProperty("label", label == null ? "" : label);
}
/**
*
* Description copied from corresponding location in WebComponent:
*
*
* Error to show when the input value is invalid.
*
* This property is not synchronized automatically from the client side, so
* the returned value may not be the same as in client side.
*
*
* @return the {@code errorMessage} property from the webcomponent
*/
protected String getErrorMessageString() {
return getElement().getProperty("errorMessage");
}
/**
*
* Description copied from corresponding location in WebComponent:
*
*
* Error to show when the input value is invalid.
*
*
* @param errorMessage
* the String value to set
*/
protected void setErrorMessage(String errorMessage) {
getElement().setProperty("errorMessage",
errorMessage == null ? "" : errorMessage);
}
/**
*
* Description copied from corresponding location in WebComponent:
*
*
* Specifies that the user must fill in a value.
*
* This property is not synchronized automatically from the client side, so
* the returned value may not be the same as in client side.
*
*
* @return the {@code required} property from the webcomponent
*/
protected boolean isRequiredBoolean() {
return getElement().getProperty("required", false);
}
/**
*
* Description copied from corresponding location in WebComponent:
*
*
* Specifies that the user must fill in a value.
*
*
* @param required
* the boolean value to set
*/
protected void setRequired(boolean required) {
getElement().setProperty("required", required);
}
/**
*
* Description copied from corresponding location in WebComponent:
*
*
* This property is set to true when the control value is invalid.
*
* This property is synchronized automatically from client side when a
* 'invalid-changed' event happens.
*
*
* @return the {@code invalid} property from the webcomponent
*/
@Synchronize(property = "invalid", value = "invalid-changed")
protected boolean isInvalidBoolean() {
return getElement().getProperty("invalid", false);
}
/**
*
* Description copied from corresponding location in WebComponent:
*
*
* This property is set to true when the control value is invalid.
*
*
* @param invalid
* the boolean value to set
*/
protected void setInvalid(boolean invalid) {
getElement().setProperty("invalid", invalid);
}
/**
*
* Description copied from corresponding location in WebComponent:
*
*
* Returns true if {@code value} is valid. {@code } uses this to
* check the validity or all its elements.
*
*
* This function is not supported by Flow because it returns a
* boolean
. Functions with return types different than void are
* not supported at this moment.
*/
@NotSupported
protected void validate() {
}
public static class InvalidChangeEvent>
extends ComponentEvent {
private final boolean invalid;
public InvalidChangeEvent(R source, boolean fromClient) {
super(source, fromClient);
this.invalid = source.isInvalidBoolean();
}
public boolean isInvalid() {
return invalid;
}
}
/**
* Adds a listener for {@code invalid-changed} events fired by the
* webcomponent.
*
* @param listener
* the listener
* @return a {@link Registration} for removing the event listener
*/
protected Registration addInvalidChangeListener(
ComponentEventListener> listener) {
return getElement()
.addPropertyChangeListener("invalid",
event -> listener.onComponentEvent(
new InvalidChangeEvent((R) this,
event.isUserOriginated())));
}
/**
* Constructs a new GeneratedVaadinCheckboxGroup component with the given
* arguments.
*
* @param initialValue
* the initial value to set to the value
* @param defaultValue
* the default value to use if the value isn't defined
* @param elementPropertyType
* the type of the element property
* @param presentationToModel
* a function that converts a string value to a model value
* @param modelToPresentation
* a function that converts a model value to a string value
* @param
* the property type
*/
public
GeneratedVaadinCheckboxGroup(T initialValue, T defaultValue,
Class
elementPropertyType,
SerializableFunction
presentationToModel,
SerializableFunction modelToPresentation) {
super("value", defaultValue, elementPropertyType, presentationToModel,
modelToPresentation);
if (initialValue != null) {
setModelValue(initialValue, false);
setPresentationValue(initialValue);
}
}
/**
* Constructs a new GeneratedVaadinCheckboxGroup component with the given
* arguments.
*
* @param initialValue
* the initial value to set to the value
* @param defaultValue
* the default value to use if the value isn't defined
* @param acceptNullValues
* whether null
is accepted as a model value
*/
public GeneratedVaadinCheckboxGroup(T initialValue, T defaultValue,
boolean acceptNullValues) {
super("value", defaultValue, acceptNullValues);
if (initialValue != null) {
setModelValue(initialValue, false);
setPresentationValue(initialValue);
}
}
/**
* Constructs a new GeneratedVaadinCheckboxGroup component with the given
* arguments.
*
* @param initialValue
* the initial value to set to the value
* @param defaultValue
* the default value to use if the value isn't defined
* @param elementPropertyType
* the type of the element property
* @param presentationToModel
* a function that accepts this component and a property value
* and returns a model value
* @param modelToPresentation
* a function that accepts this component and a model value and
* returns a property value
* @param
* the property type
*/
public
GeneratedVaadinCheckboxGroup(T initialValue, T defaultValue,
Class
elementPropertyType,
SerializableBiFunction presentationToModel,
SerializableBiFunction modelToPresentation) {
super("value", defaultValue, elementPropertyType, presentationToModel,
modelToPresentation);
if (initialValue != null) {
setModelValue(initialValue, false);
setPresentationValue(initialValue);
}
}
/**
* Default constructor.
*/
public GeneratedVaadinCheckboxGroup() {
this(null, null, null, (SerializableFunction) null,
(SerializableFunction) null);
}
}