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

org.bklab.flow.factory.ButtonFactory Maven / Gradle / Ivy

There is a newer version: 22.0.1
Show newest version
/*
 * Copyright (c) 2008 - 2020. - Broderick Labs.
 * Author: Broderick Johansson
 * E-mail: [email protected]
 * Modify date:2020-06-17 20:42:39
 * _____________________________
 * Project name: fluent-vaadin-flow
 * Class name:org.bklab.flow.factory.ButtonFactory
 * Copyright (c) 2008 - 2020. - Broderick Labs.
 */

package org.bklab.flow.factory;

import com.vaadin.flow.component.ClickEvent;
import com.vaadin.flow.component.Component;
import com.vaadin.flow.component.ComponentEventListener;
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.icon.VaadinIcon;
import org.bklab.flow.FlowFactory;
import org.bklab.flow.base.GeneratedVaadinButtonFactory;
import org.bklab.flow.base.HasEnabledFactory;
import org.bklab.flow.base.HasSizeFactory;

public class ButtonFactory extends FlowFactory implements
        GeneratedVaadinButtonFactory,
        HasSizeFactory,
        HasEnabledFactory {

    public ButtonFactory(Button component) {
        super(component);
    }

    public ButtonFactory(String text) {
        this(new Button(text));
    }

    public ButtonFactory(String text, Component icon, ComponentEventListener> clickListener) {
        this(new Button(text, icon, clickListener));
    }

    public ButtonFactory(String text, ComponentEventListener> clickListener) {
        this(new Button(text, clickListener));
    }

    public ButtonFactory(String text, Component icon) {
        this(new Button(text, icon));
    }

    public ButtonFactory() {
        this(new Button());
    }

    public ButtonFactory text(String text) {
        get().setText(text);
        return this;
    }

    public ButtonFactory icon(Component icon) {
        get().setIcon(icon);
        return this;
    }

    public ButtonFactory icon(VaadinIcon icon) {
        get().setIcon(icon.create());
        return this;
    }

    public ButtonFactory clickInClient() {
        get().clickInClient();
        return this;
    }

    public ButtonFactory iconAfterText(boolean iconAfterText) {
        get().setIconAfterText(iconAfterText);
        return this;
    }

    public ButtonFactory click() {
        get().click();
        return this;
    }

    public ButtonFactory disableOnClick(boolean disableOnClick) {
        get().setDisableOnClick(disableOnClick);
        return this;
    }

    public ButtonFactory autofocus(boolean autofocus) {
        get().setAutofocus(autofocus);
        return this;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy