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

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

There is a newer version: 5.2.4
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.vaadin7.components;

import com.holonplatform.core.property.Property;
import com.holonplatform.core.property.PropertyRenderer;
import com.holonplatform.vaadin7.internal.components.InputFieldWrapper;
import com.vaadin.ui.Component;
import com.vaadin.ui.Field;

/**
 * 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. * @return true if the field as required, false otherwise */ public boolean isRequired(); /** * Sets the field as required. *

* Required fields should show a required indicator symbol in UI and the default non-empty validator is * setted up. *

* @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 Field} instance. * @param Value type * @param field The field instance (not null) * @return A new {@link Input} component which wraps the given field */ static Input from(Field 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 Field}. * @param Property type */ public interface InputFieldPropertyRenderer extends InputPropertyRenderer { /** * Render given property as consistent value type {@link Field} to handle the property value. * @param property Property to render * @return property {@link Field} */ Field 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 - 2024 Weber Informatics LLC | Privacy Policy