
com.mantledillusion.vaadin.cotton.component.builders.VerticalLayoutBuilder Maven / Gradle / Ivy
package com.mantledillusion.vaadin.cotton.component.builders;
import com.mantledillusion.vaadin.cotton.component.ComponentBuilder;
import com.mantledillusion.vaadin.cotton.component.mixin.*;
import com.vaadin.flow.component.Component;
import com.vaadin.flow.component.orderedlayout.FlexComponent;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
/**
* {@link ComponentBuilder} for {@link VerticalLayout}s.
*/
public class VerticalLayoutBuilder extends AbstractComponentBuilder implements
HasElementBuilder,
HasSizeBuilder,
HasStyleBuilder,
HasEnabledBuilder,
HasComponentsBuilder,
ThemableLayoutBuilder,
FlexComponentBuilder,
ClickableBuilder {
private VerticalLayoutBuilder() {}
/**
* Factory method for a new instance.
*
* @return A new instance, never null.
*/
public static VerticalLayoutBuilder create() {
return new VerticalLayoutBuilder();
}
@Override
protected VerticalLayout instantiate() {
return new VerticalLayout();
}
/**
* Builder method, configures the {@link Component}'s horizontal child {@link Component} alignment.
*
* @see VerticalLayout#setHorizontalComponentAlignment(FlexComponent.Alignment, Component...)
* @param alignment
* the individual alignment for the children components. Setting
* null
will reset the alignment to its default
* @param componentsToAlign
* The components to which the individual alignment should be set
* @return this
*/
public VerticalLayoutBuilder setHorizontalComponentAlignment(FlexComponent.Alignment alignment,
Component... componentsToAlign) {
return configure(verticalLayout -> verticalLayout.setHorizontalComponentAlignment(alignment, componentsToAlign));
}
/**
* Builder method, configures the {@link Component}'s default horizontal child {@link Component} alignment.
*
* @see VerticalLayout#setDefaultHorizontalComponentAlignment(FlexComponent.Alignment)
* @param alignment
* the alignment to apply to the components. Setting
* null
will reset the alignment to its default
* @return this
*/
public VerticalLayoutBuilder setDefaultHorizontalComponentAlignment(FlexComponent.Alignment alignment) {
return configure(verticalLayout -> verticalLayout.setDefaultHorizontalComponentAlignment(alignment));
}
/**
* Builder method, configures the {@link Component}'s child {@link Component}s.
*
* @see VerticalLayout#add(Component...)
* @see VerticalLayout#setHorizontalComponentAlignment(FlexComponent.Alignment, Component...)
* @param alignment The alignment to align the given components with; might not be null.
* @param components The {@link Component}s to add; might be null, might not contain nulls.
* @return this
*/
public VerticalLayoutBuilder add(FlexComponent.Alignment alignment, Component... components) {
return configure(verticalLayout -> {
verticalLayout.add(components);
verticalLayout.setHorizontalComponentAlignment(alignment, components);
});
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy