All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.holonplatform.vaadin.components.Input Maven / Gradle / Ivy

There is a newer version: 5.4.0
Show newest version
/*
 * Copyright 2000-2017 Holon TDCN.
 * 
 * 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.holonplatform.vaadin.components;

import com.holonplatform.core.property.Property;
import com.holonplatform.core.property.PropertyRenderer;
import com.holonplatform.vaadin.internal.components.InputFieldWrapper;
import com.vaadin.data.HasValue;
import com.vaadin.ui.Component;

/**
 * Input component representation, i.e. a UI component that has a user-editable value.
 * 

* Extends {@link ValueHolder} since handles a value, supporting {@link ValueChangeListener}s registration. *

*

* The actual UI {@link Component} which represents the input component can be obtained through {@link #getComponent()}. *

* * @param Value type * * @since 5.0.0 */ public interface Input extends ValueHolder, ValueComponent { /** * Sets the read-only mode of this input component. The user can't change the value when in read-only mode. * @param readOnly the read-only mode of this input component */ void setReadOnly(boolean readOnly); /** * Returns whether this input component is in read-only mode or not. * @return false if the user can modify the value, true if not */ boolean isReadOnly(); /** * Gets whether the field is required, i.e. a required indicator symbol is visible. * @return true if the field as required, false otherwise */ public boolean isRequired(); /** * Sets whether the required indicator symbol is visible. * @param required true to set the field as required, false otherwise */ void setRequired(boolean required); /** * Sets the focus for this input component, if supported by concrete component implementation. */ void focus(); /** * Create a {@link Input} component type from given {@link HasValue} component. * @param Value type * @param {@link HasValue} component type * @param field The field instance (not null) * @return A new {@link Input} component which wraps the given field */ static & Component, T> Input from(F field) { return new InputFieldWrapper<>(field); } /** * A convenience interface with a fixed {@link Input} rendering type to use a {@link Input} {@link PropertyRenderer} * as a functional interface. * @param Property type */ @FunctionalInterface public interface InputPropertyRenderer extends PropertyRenderer, T> { /* * (non-Javadoc) * @see com.holonplatform.core.property.PropertyRenderer#getRenderType() */ @SuppressWarnings("unchecked") @Override default Class> getRenderType() { return (Class>) (Class) Input.class; } } /** * A convenience interface to render a {@link Property} as a {@link Input} using a {@link HasValue} component. * @param Property type */ public interface InputFieldPropertyRenderer & Component> extends InputPropertyRenderer { /** * Render given property as consistent value type {@link HasValue} component to handle the property * value. * @param property Property to render * @return property {@link HasValue} component */ F renderField(Property property); /* * (non-Javadoc) * @see com.holonplatform.core.property.PropertyRenderer#render(com.holonplatform.core.property.Property) */ @Override default Input render(Property property) { return Input.from(renderField(property)); } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy