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

org.bklab.flow.layout.tab.FluentTab Maven / Gradle / Ivy

There is a newer version: 22.0.1
Show newest version
package org.bklab.flow.layout.tab;

import com.vaadin.flow.component.Component;
import com.vaadin.flow.component.tabs.Tab;

import java.util.function.Supplier;

public class FluentTab extends Tab {
    protected final String id;
    protected Supplier componentSupplier;
    protected Component component;
    protected boolean cacheMode = true;

    public FluentTab(String id) {
        this.id = id;
    }

    public FluentTab(String id, Supplier componentSupplier) {
        this(id, id, componentSupplier);
    }

    public FluentTab(String id, String caption, Supplier componentSupplier) {
        super(caption);
        this.id = id;
        this.componentSupplier = componentSupplier;
    }

    public FluentTab(String id, String caption) {
        super(caption);
        this.id = id;
    }

    public FluentTab(String id, Component component, Supplier componentSupplier) {
        super(component);
        this.id = id;
        this.componentSupplier = componentSupplier;
    }

    public FluentTab(String id, Supplier componentSupplier, Component... component) {
        super(component);
        this.id = id;
        this.componentSupplier = componentSupplier;
    }

    public Component getComponent() {
        if (component == null || !cacheMode) component = componentSupplier.get();
        return component;
    }

    public Supplier getComponentSupplier() {
        return componentSupplier;
    }

    public FluentTab enableCache() {
        this.cacheMode = true;
        return this;
    }

    public FluentTab disableCache() {
        this.cacheMode = false;
        return this;
    }

    public String getTabId() {
        return id;
    }

    public boolean isCacheMode() {
        return cacheMode;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy