com.holonplatform.vaadin7.components.Components Maven / Gradle / Ivy
/*
* Copyright 2016-2017 Axioma srl.
*
* 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 java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;
import com.holonplatform.core.property.Property;
import com.holonplatform.core.property.PropertyBox;
import com.holonplatform.core.property.PropertySet;
import com.holonplatform.vaadin7.components.ComposableComponent.Composer;
import com.holonplatform.vaadin7.components.Dialog.DialogBuilder;
import com.holonplatform.vaadin7.components.Dialog.QuestionDialogBuilder;
import com.holonplatform.vaadin7.components.PropertyInputForm.PropertyInputFormBuilder;
import com.holonplatform.vaadin7.components.PropertyInputGroup.PropertyInputGroupBuilder;
import com.holonplatform.vaadin7.components.PropertyViewForm.PropertyViewFormBuilder;
import com.holonplatform.vaadin7.components.PropertyViewGroup.PropertyViewGroupBuilder;
import com.holonplatform.vaadin7.components.builders.BooleanInputBuilder;
import com.holonplatform.vaadin7.components.builders.ButtonBuilder;
import com.holonplatform.vaadin7.components.builders.ButtonConfigurator;
import com.holonplatform.vaadin7.components.builders.ClickableLayoutConfigurator;
import com.holonplatform.vaadin7.components.builders.ComponentConfigurator;
import com.holonplatform.vaadin7.components.builders.CssLayoutBuilder;
import com.holonplatform.vaadin7.components.builders.DateInputBuilder;
import com.holonplatform.vaadin7.components.builders.FormLayoutBuilder;
import com.holonplatform.vaadin7.components.builders.GridLayoutBuilder;
import com.holonplatform.vaadin7.components.builders.HorizontalLayoutBuilder;
import com.holonplatform.vaadin7.components.builders.InputConfigurator;
import com.holonplatform.vaadin7.components.builders.LabelBuilder;
import com.holonplatform.vaadin7.components.builders.LayoutConfigurator;
import com.holonplatform.vaadin7.components.builders.MultiPropertySelectInputBuilder;
import com.holonplatform.vaadin7.components.builders.MultiSelectInputBuilder;
import com.holonplatform.vaadin7.components.builders.NumberInputBuilder;
import com.holonplatform.vaadin7.components.builders.OrderedLayoutConfigurator;
import com.holonplatform.vaadin7.components.builders.PanelBuilder;
import com.holonplatform.vaadin7.components.builders.SecretInputBuilder;
import com.holonplatform.vaadin7.components.builders.SinglePropertySelectInputBuilder;
import com.holonplatform.vaadin7.components.builders.SingleSelectInputBuilder;
import com.holonplatform.vaadin7.components.builders.StringInputBuilder;
import com.holonplatform.vaadin7.components.builders.VerticalLayoutBuilder;
import com.holonplatform.vaadin7.components.builders.ViewComponentBuilder;
import com.holonplatform.vaadin7.components.builders.BaseSelectInputBuilder.RenderingMode;
import com.holonplatform.vaadin7.components.builders.ButtonConfigurator.BaseButtonConfigurator;
import com.holonplatform.vaadin7.components.builders.ClickableLayoutConfigurator.BaseClickableLayoutConfigurator;
import com.holonplatform.vaadin7.components.builders.ComponentConfigurator.BaseComponentConfigurator;
import com.holonplatform.vaadin7.components.builders.InputConfigurator.BaseFieldConfigurator;
import com.holonplatform.vaadin7.components.builders.ItemListingBuilder.GridItemListingBuilder;
import com.holonplatform.vaadin7.components.builders.ItemListingBuilder.TableItemListingBuilder;
import com.holonplatform.vaadin7.components.builders.LayoutConfigurator.BaseLayoutConfigurator;
import com.holonplatform.vaadin7.components.builders.OrderedLayoutConfigurator.BaseOrderedLayoutConfigurator;
import com.holonplatform.vaadin7.components.builders.PropertyListingBuilder.GridPropertyListingBuilder;
import com.holonplatform.vaadin7.components.builders.PropertyListingBuilder.TablePropertyListingBuilder;
import com.holonplatform.vaadin7.components.builders.TemporalInputBuilder.TemporalWithTimeFieldBuilder;
import com.holonplatform.vaadin7.components.builders.TemporalInputBuilder.TemporalWithoutTimeFieldBuilder;
import com.holonplatform.vaadin7.internal.components.BooleanField;
import com.holonplatform.vaadin7.internal.components.DateField;
import com.holonplatform.vaadin7.internal.components.DefaultPropertyViewGroup;
import com.holonplatform.vaadin7.internal.components.Filler;
import com.holonplatform.vaadin7.internal.components.InlineDateField;
import com.holonplatform.vaadin7.internal.components.LocalDateField;
import com.holonplatform.vaadin7.internal.components.LocalDateTimeField;
import com.holonplatform.vaadin7.internal.components.NumberField;
import com.holonplatform.vaadin7.internal.components.SecretField;
import com.holonplatform.vaadin7.internal.components.StringArea;
import com.holonplatform.vaadin7.internal.components.StringField;
import com.holonplatform.vaadin7.internal.components.builders.DefaultButtonBuilder;
import com.holonplatform.vaadin7.internal.components.builders.DefaultButtonConfigurator;
import com.holonplatform.vaadin7.internal.components.builders.DefaultClickableLayoutConfigurator;
import com.holonplatform.vaadin7.internal.components.builders.DefaultComponentConfigurator;
import com.holonplatform.vaadin7.internal.components.builders.DefaultCssLayoutBuilder;
import com.holonplatform.vaadin7.internal.components.builders.DefaultFieldConfigurator;
import com.holonplatform.vaadin7.internal.components.builders.DefaultFormLayoutBuilder;
import com.holonplatform.vaadin7.internal.components.builders.DefaultGridLayoutBuilder;
import com.holonplatform.vaadin7.internal.components.builders.DefaultHorizontalLayoutBuilder;
import com.holonplatform.vaadin7.internal.components.builders.DefaultLabelBuilder;
import com.holonplatform.vaadin7.internal.components.builders.DefaultLayoutConfigurator;
import com.holonplatform.vaadin7.internal.components.builders.DefaultOrderedLayoutConfigurator;
import com.holonplatform.vaadin7.internal.components.builders.DefaultPanelBuilder;
import com.holonplatform.vaadin7.internal.components.builders.DefaultVerticalLayoutBuilder;
import com.vaadin.shared.ui.datefield.Resolution;
import com.vaadin.ui.AbsoluteLayout;
import com.vaadin.ui.AbstractComponent;
import com.vaadin.ui.AbstractField;
import com.vaadin.ui.Button;
import com.vaadin.ui.Component;
import com.vaadin.ui.CssLayout;
import com.vaadin.ui.FormLayout;
import com.vaadin.ui.Grid;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.Panel;
import com.vaadin.ui.Table;
import com.vaadin.ui.VerticalLayout;
/**
* Main provider of UI components builders and configurators.
*
* Provides static methods to obtain builder for common UI components type, allowing fluent and implementation-agnostic
* components creation and configuration.
*
*
* @since 5.0.0
*/
public interface Components {
// Configurators
/**
* Get a {@link ComponentConfigurator} to configure given component.
* @param component Component to configure (not null)
* @return BaseComponentConfigurator
*/
static BaseComponentConfigurator configure(AbstractComponent component) {
return new DefaultComponentConfigurator(component);
}
/**
* Get a {@link ButtonConfigurator} to configure given button.
* @param button Button to configure (not null)
* @return BaseButtonConfigurator
*/
static BaseButtonConfigurator configure(Button button) {
return new DefaultButtonConfigurator(button);
}
/**
* Get a {@link InputConfigurator} to configure given field.
* @param Field type
* @param field Field to configure (not null)
* @return BaseFieldConfigurator
*/
static BaseFieldConfigurator configure(AbstractField field) {
return new DefaultFieldConfigurator<>(field);
}
/**
* Get a {@link OrderedLayoutConfigurator} to configure given layout.
* @param layout Layout to configure
* @return Layout configurator
*/
static BaseOrderedLayoutConfigurator configure(VerticalLayout layout) {
return new DefaultOrderedLayoutConfigurator<>(layout);
}
/**
* Get a {@link OrderedLayoutConfigurator} to configure given layout.
* @param layout Layout to configure
* @return Layout configurator
*/
static BaseOrderedLayoutConfigurator configure(HorizontalLayout layout) {
return new DefaultOrderedLayoutConfigurator<>(layout);
}
/**
* Get a {@link OrderedLayoutConfigurator} to configure given layout.
* @param layout Layout to configure
* @return Layout configurator
*/
static BaseOrderedLayoutConfigurator configure(FormLayout layout) {
return new DefaultOrderedLayoutConfigurator<>(layout);
}
/**
* Get a {@link LayoutConfigurator} to configure given layout.
* @param layout Layout to configure
* @return Layout configurator
*/
static BaseLayoutConfigurator configure(GridLayout layout) {
return new DefaultLayoutConfigurator<>(layout);
}
/**
* Get a {@link ClickableLayoutConfigurator} to configure given layout.
* @param layout Layout to configure
* @return Layout configurator
*/
static BaseClickableLayoutConfigurator configure(CssLayout layout) {
return new DefaultClickableLayoutConfigurator<>(layout);
}
/**
* Get a {@link ClickableLayoutConfigurator} to configure given layout.
* @param layout Layout to configure
* @return Layout configurator
*/
static BaseClickableLayoutConfigurator configure(AbsoluteLayout layout) {
return new DefaultClickableLayoutConfigurator<>(layout);
}
// Builders
/**
* Build a filler component, i.e. a {@link Label} with undefined size and the HTML entity
as
* content, which can be used with full expand ratio as a space filler in layouts.
* @return Filler
*/
static Component filler() {
return new Filler();
}
/**
* Gets a builder to create {@link Label}s.
*
* The Label is of undefined size by default.
*
* @return Label builder
*/
static LabelBuilder label() {
return new DefaultLabelBuilder();
}
/**
* Gets a builder to create {@link Button}s.
* @return Button builder
*/
static ButtonBuilder button() {
return button(false);
}
/**
* Gets a builder to create {@link Button}s
* @param nativeMode true
to create a "native" button, i.e. implemented using the native button of web
* browsers, using the HTML <button>
element.
* @return Button builder
*/
static ButtonBuilder button(boolean nativeMode) {
return new DefaultButtonBuilder(nativeMode);
}
/**
* Gets a builder to create {@link CssLayout}s.
* @return CssLayout builder
*/
static CssLayoutBuilder cssLayout() {
return new DefaultCssLayoutBuilder();
}
/**
* Gets a builder to create {@link FormLayout}s.
* @return FormLayout builder
*/
static FormLayoutBuilder formLayout() {
return new DefaultFormLayoutBuilder();
}
/**
* Gets a builder to create {@link FormLayout}s.
* @return FormLayout builder
*/
static GridLayoutBuilder gridLayout() {
return gridLayout(1, 1);
}
/**
* Gets a builder to create {@link GridLayout}s.
* @param columns Initial number of columns
* @param rows Initial number of rows
* @return GridLayout builder
*/
static GridLayoutBuilder gridLayout(int columns, int rows) {
return new DefaultGridLayoutBuilder(columns, rows);
}
/**
* Gets a builder to create {@link HorizontalLayout}s.
* @return HorizontalLayout builder
*/
static HorizontalLayoutBuilder hl() {
return new DefaultHorizontalLayoutBuilder();
}
/**
* Gets a builder to create {@link VerticalLayout}s.
* @return VerticalLayout builder
*/
static VerticalLayoutBuilder vl() {
return new DefaultVerticalLayoutBuilder();
}
/**
* Gets a builder to create {@link Panel}s.
* @return Panel builder
*/
static PanelBuilder panel() {
return new DefaultPanelBuilder();
}
/**
* Gets a builder to create and open a {@link Dialog} window. The dialog will present by default a single
* ok button.
* @return DialogBuilder
*/
static DialogBuilder dialog() {
return Dialog.builder();
}
/**
* Gets a builder to create and open a question {@link Dialog} window. The dialog will present by default a
* yes and a no button. Use
* {@link QuestionDialogBuilder#callback(com.holonplatform.vaadin7.components.Dialog.QuestionCallback)} to handle
* the user selected answer.
* @return QuestionDialogBuilder
*/
static QuestionDialogBuilder questionDialog() {
return Dialog.question();
}
// Inputs
/**
* {@link Input}, {@link PropertyInputGroup} and {@link PropertyInputForm} builders provider.
*/
static interface input {
/**
* Gets a builder to create {@link String} type {@link Input}s.
* @return Input builder
*/
static StringInputBuilder string() {
return string(false);
}
/**
* Gets a builder to create {@link String} type {@link Input}s.
* @param area true
to create an input component rendered as a text area,
* false
for a standard text input
* @return Input builder
*/
static StringInputBuilder string(boolean area) {
return area ? new StringArea.Builder() : new StringField.Builder();
}
/**
* Gets a builder to create {@link String} type {@link Input}s which not display user input on screen, used to
* enter secret text information like passwords.
* @return Input builder
*/
static SecretInputBuilder secretString() {
return new SecretField.Builder();
}
/**
* Gets a builder to create {@link Number} type {@link Input}s.
* @param Number type
* @param numberClass Concrete number class
* @return Input builder
*/
static NumberInputBuilder number(Class numberClass) {
return new NumberField.Builder<>(numberClass);
}
/**
* Gets a builder to create {@link Boolean} type {@link Input}s.
* @return Input builder
*/
static BooleanInputBuilder boolean_() {
return new BooleanField.Builder();
}
/**
* Gets a builder to create {@link Date} type {@link Input}s.
* @param resolution field Resolution
* @param inline true
to render the input component using an inline calendar
* @return Input builder
*/
static DateInputBuilder date(Resolution resolution, boolean inline) {
return inline ? new InlineDateField.Builder(resolution) : new DateField.Builder(resolution);
}
/**
* Gets a builder to create {@link Date} type {@link Input}s.
* @param resolution field Resolution
* @return Input builder
*/
static DateInputBuilder date(Resolution resolution) {
return date(resolution, false);
}
/**
* Gets a builder to create {@link Date} type {@link Input}s.
* @param inline true
to render the input component using an inline calendar
* @return Input builder
*/
static DateInputBuilder date(boolean inline) {
return date(Resolution.DAY, inline);
}
/**
* Gets a builder to create {@link Date} type {@link Input}s.
* @return Input builder
*/
static DateInputBuilder date() {
return date(Resolution.DAY, false);
}
/**
* Gets a builder to create {@link LocalDate} type {@link Input}s.
* @param inline true
to render the input component using an inline calendar
* @return Input builder
*/
static TemporalWithoutTimeFieldBuilder localDate(boolean inline) {
return new LocalDateField.Builder(inline);
}
/**
* Gets a builder to create {@link LocalDate} type {@link Input}s.
* @return Input builder
*/
static TemporalWithoutTimeFieldBuilder localDate() {
return localDate(false);
}
/**
* Gets a builder to create {@link LocalDateTime} type {@link Input}s.
* @param inline true
to render the input component using an inline calendar
* @return Input builder
*/
static TemporalWithTimeFieldBuilder localDateTime(boolean inline) {
return new LocalDateTimeField.Builder(inline);
}
/**
* Gets a builder to create {@link LocalDateTime} type {@link Input}s.
* @return Input builder
*/
static TemporalWithTimeFieldBuilder localDateTime() {
return localDateTime(false);
}
/**
* Gets a builder to create a single selection {@link Input}.
* @param Selection value type
* @param type Selection value type
* @param renderingMode Rendering mode
* @return Input builder
*/
static SingleSelectInputBuilder singleSelect(Class extends T> type, RenderingMode renderingMode) {
return SingleSelect.builder(type, renderingMode);
}
/**
* Gets a builder to create a single selection {@link Input} using default {@link RenderingMode#SELECT}.
* @param Selection value type
* @param type Selection value type
* @return Input builder
*/
static SingleSelectInputBuilder singleSelect(Class extends T> type) {
return SingleSelect.builder(type);
}
/**
* Gets a builder to create a {@link SingleSelect} with a {@link PropertyBox} items data source with
* {@link Property} as item properties.
* @param Selection value type
* @param selectProperty Property to select (not null)
* @param renderingMode Rendering mode
* @return {@link SingleSelect} builder
*/
static SinglePropertySelectInputBuilder singleSelect(Property selectProperty,
RenderingMode renderingMode) {
return SingleSelect.property(selectProperty, renderingMode);
}
/**
* Gets a builder to create a {@link SingleSelect} with a {@link PropertyBox} items data source with
* {@link Property} as item properties. Default {@link RenderingMode#SELECT} is assumed.
* @param Selection value type
* @param selectProperty Property to select (not null)
* @return {@link SingleSelect} builder
*/
static SinglePropertySelectInputBuilder singleSelect(Property selectProperty) {
return SingleSelect.property(selectProperty, RenderingMode.SELECT);
}
/**
* Gets a builder to create a multiple selection {@link Input}.
* @param Selection value type
* @param type Selection value type
* @param renderingMode Rendering mode
* @return Input builder
*/
static MultiSelectInputBuilder multiSelect(Class extends T> type, RenderingMode renderingMode) {
return MultiSelect.builder(type, renderingMode);
}
/**
* Gets a builder to create a multiple selection {@link Input} using default {@link RenderingMode#OPTIONS}.
* @param Selection value type
* @param type Selection value type
* @return Input builder
*/
static MultiSelectInputBuilder multiSelect(Class extends T> type) {
return MultiSelect.builder(type);
}
/**
* Gets a builder to create a {@link MultiSelect} with a {@link PropertyBox} items data source with
* {@link Property} as item properties.
* @param Selection value type
* @param selectProperty Property to select (not null)
* @param renderingMode Rendering mode
* @return {@link MultiSelect} builder
*/
static MultiPropertySelectInputBuilder multiSelect(Property selectProperty,
RenderingMode renderingMode) {
return MultiSelect.property(selectProperty, renderingMode);
}
/**
* Gets a builder to create a {@link MultiSelect} with a {@link PropertyBox} items data source with
* {@link Property} as item properties. Default {@link RenderingMode#SELECT} is assumed.
* @param Selection value type
* @param selectProperty Property to select (not null)
* @return {@link MultiSelect} builder
*/
static MultiPropertySelectInputBuilder multiSelect(Property selectProperty) {
return MultiSelect.property(selectProperty, RenderingMode.OPTIONS);
}
/**
* Gets a builder to create a single selection {@link Input} with given {@link Enum} class as data source, using
* all enum constants as selection items.
* @param Enum value type
* @param type Enum value type
* @param renderingMode Rendering mode
* @return Input builder
*/
static > SingleSelectInputBuilder enumSingle(Class type, RenderingMode renderingMode) {
return singleSelect(type, renderingMode).items(type.getEnumConstants());
}
/**
* Gets a builder to create a single selection {@link Input} with given {@link Enum} class as data source, using
* all enum constants as selection items and default {@link RenderingMode#SELECT} rendering mode.
* @param Enum value type
* @param type Enum value type
* @return Input builder
*/
static > SingleSelectInputBuilder enumSingle(Class type) {
return singleSelect(type).items(type.getEnumConstants());
}
/**
* Gets a builder to create a multiple selection {@link Input} with given {@link Enum} class as data source,
* using all enum constants as selection items.
* @param Enum value type
* @param type Enum value type
* @param renderingMode Rendering mode
* @return Input builder
*/
static > MultiSelectInputBuilder enumMulti(Class type, RenderingMode renderingMode) {
return multiSelect(type, renderingMode).items(type.getEnumConstants());
}
/**
* Gets a builder to create a multiple selection {@link Input} with given {@link Enum} class as data source,
* using all enum constants as selection items and default {@link RenderingMode#OPTIONS} rendering mode.
* @param Enum value type
* @param type Enum value type
* @return Input builder
*/
static > MultiSelectInputBuilder enumMulti(Class type) {
return multiSelect(type).items(type.getEnumConstants());
}
/**
* Gets a builder to create a {@link PropertyInputGroup}.
* @return {@link PropertyInputGroup} builder
*/
static PropertyInputGroupBuilder propertyGroup() {
return PropertyInputGroup.builder();
}
/**
* Gets a builder to create a {@link PropertyInputForm}.
* @param Content type
* @param content Form content, where fields will be composed by the form {@link Composer} (not null)
* @return {@link PropertyInputForm} builder
*/
static PropertyInputFormBuilder form(C content) {
return PropertyInputForm.builder(content);
}
/**
* Gets a builder to create a {@link PropertyInputForm} using a {@link FormLayout} as layout component and a
* default {@link PropertyInputForm#componentContainerComposer()} to compose the fields on layout.
* @return {@link PropertyInputForm} builder
*/
static PropertyInputFormBuilder form() {
return PropertyInputForm.builder(formLayout().fullWidth().spacing().build())
.composer(ComposableComponent.componentContainerComposer());
}
/**
* Gets a builder to create a {@link PropertyInputForm} using a {@link VerticalLayout} as layout component and a
* default {@link PropertyInputForm#componentContainerComposer()} to compose the fields on layout.
* @return {@link PropertyInputForm} builder
*/
static PropertyInputFormBuilder formVertical() {
return PropertyInputForm.builder(vl().fullWidth().build())
.composer(ComposableComponent.componentContainerComposer());
}
/**
* Gets a builder to create a {@link PropertyInputForm} using a {@link HorizontalLayout} as layout component and
* a default {@link PropertyInputForm#componentContainerComposer()} to compose the fields on layout.
* @return {@link PropertyInputForm} builder
*/
static PropertyInputFormBuilder formHorizontal() {
return PropertyInputForm.builder(hl().build())
.composer(ComposableComponent.componentContainerComposer(false));
}
/**
* Gets a builder to create a {@link PropertyInputForm} using a {@link VerticalLayout} as layout component and a
* default {@link PropertyInputForm#componentContainerComposer()} to compose the fields on layout.
* @return {@link PropertyInputForm} builder
*/
static PropertyInputFormBuilder formGrid() {
return PropertyInputForm.builder(gridLayout().fullWidth().build())
.composer(ComposableComponent.componentContainerComposer());
}
}
// View components
/**
* {@link ViewComponent} and {@link PropertyViewGroup} builders provider.
*/
static interface view {
/**
* Gets a builder to create a {@link ViewComponent} instance.
* @param Value type
* @param valueType the value type handled by the {@link ViewComponent}
* @return {@link ViewComponent} builder
*/
static ViewComponentBuilder component(Class extends T> valueType) {
return ViewComponent.builder(valueType);
}
/**
* Get a builder to create and setup a {@link PropertyViewGroup}.
* @return {@link PropertyViewGroup} builder
*/
static PropertyViewGroupBuilder propertyGroup() {
return new DefaultPropertyViewGroup.DefaultBuilder();
}
/**
* Gets a builder to create a {@link PropertyViewForm}.
* @param Content type
* @param content Form content, where view components will be composed by the form {@link Composer} (not null)
* @return {@link PropertyViewForm} builder
*/
static PropertyViewFormBuilder form(C content) {
return PropertyViewForm.builder(content);
}
/**
* Gets a builder to create a {@link PropertyViewForm} using a {@link FormLayout} as layout component and a
* default {@link PropertyViewForm#componentContainerComposer()} to compose the view components on layout.
* @return {@link PropertyViewForm} builder
*/
static PropertyViewFormBuilder form() {
return PropertyViewForm.builder(formLayout().fullWidth().build())
.composer(ComposableComponent.componentContainerComposer());
}
/**
* Gets a builder to create a {@link PropertyViewForm} using a {@link VerticalLayout} as layout component and a
* default {@link PropertyViewForm#componentContainerComposer()} to compose the view components on layout.
* @return {@link PropertyViewForm} builder
*/
static PropertyViewFormBuilder formVertical() {
return PropertyViewForm.builder(vl().fullWidth().build())
.composer(ComposableComponent.componentContainerComposer());
}
/**
* Gets a builder to create a {@link PropertyViewForm} using a {@link HorizontalLayout} as layout component and
* a default {@link PropertyViewForm#componentContainerComposer()} to compose the view components on layout.
* @return {@link PropertyViewForm} builder
*/
static PropertyViewFormBuilder formHorizontal() {
return PropertyViewForm.builder(hl().build())
.composer(ComposableComponent.componentContainerComposer(false));
}
/**
* Gets a builder to create a {@link PropertyViewForm} using a {@link VerticalLayout} as layout component and a
* default {@link PropertyViewForm#componentContainerComposer()} to compose the view components on layout.
* @return {@link PropertyViewForm} builder
*/
static PropertyViewFormBuilder formGrid() {
return PropertyViewForm.builder(gridLayout().fullWidth().build())
.composer(ComposableComponent.componentContainerComposer());
}
}
// Item listings
/**
* {@link ItemListing} builders provider.
*/
static interface listing {
/**
* Builder to create an {@link ItemListing} instance using a {@link Grid} as backing component.
* @param Item data type
* @param itemType Item bean type
* @return Grid {@link ItemListing} builder
*/
static GridItemListingBuilder items(Class itemType) {
return BeanListing.builder(itemType);
}
/**
* Builder to create an {@link PropertyListing} instance using a {@link Grid} as backing component.
* @param Actual property type
* @param properties The property set to use for the listing
* @return Grid {@link PropertyListing} builder
*/
@SafeVarargs
static
> GridPropertyListingBuilder properties(P... properties) {
return properties(PropertySet.of(properties));
}
/**
* Builder to create an {@link PropertyListing} instance using a {@link Grid} as backing component.
* @param
Actual property type
* @param properties The property set to use for the listing
* @return Grid {@link PropertyListing} builder
*/
static
> GridPropertyListingBuilder properties(Iterable
properties) {
return PropertyListing.builder(properties);
}
/**
* Builder to create an {@link ItemListing} instance using a {@link Table} as backing component.
* @param Item data type
* @param itemType Item bean type
* @return Table {@link ItemListing} builder
*/
static TableItemListingBuilder itemsUsingTable(Class itemType) {
return BeanListing.tableBuilder(itemType);
}
/**
* Builder to create an {@link PropertyListing} instance using a {@link Table} as backing component.
* @param Actual property type
* @param properties The property set to use for the listing
* @return Table {@link PropertyListing} builder
*/
@SafeVarargs
static
> TablePropertyListingBuilder propertiesUsingTable(P... properties) {
return propertiesUsingTable(PropertySet.of(properties));
}
/**
* Builder to create an {@link PropertyListing} instance using a {@link Table} as backing component.
* @param
Actual property type
* @param properties The property set to use for the listing
* @return Table {@link PropertyListing} builder
*/
static
> TablePropertyListingBuilder propertiesUsingTable(Iterable
properties) {
return PropertyListing.tableBuilder(properties);
}
}
}