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

org.dominokit.domino.ui.datatable.plugins.EmptyStatePlugin Maven / Gradle / Ivy

There is a newer version: 1.0.139
Show newest version
package org.dominokit.domino.ui.datatable.plugins;

import org.dominokit.domino.ui.datatable.DataTable;
import org.dominokit.domino.ui.datatable.events.TableDataUpdatedEvent;
import org.dominokit.domino.ui.icons.BaseIcon;
import org.dominokit.domino.ui.layout.EmptyState;
import org.dominokit.domino.ui.style.Color;
import org.dominokit.domino.ui.style.Styles;

public class EmptyStatePlugin implements DataTablePlugin {

    private EmptyState emptyState;

    public EmptyStatePlugin(BaseIcon emptyStateIcon, String title) {
        emptyState = EmptyState.create(emptyStateIcon)
                .setTitle(title)
                .setIconColor(Color.GREY)
                .setTitleColor(Color.GREY)
                .styler(style -> style.remove(Styles.vertical_center));
    }

    @Override
    public void onAfterAddTable(DataTable dataTable) {
        dataTable.addTableEventListner(TableDataUpdatedEvent.DATA_UPDATED, event -> {
            TableDataUpdatedEvent tableDataUpdatedEvent = (TableDataUpdatedEvent) event;
            if (tableDataUpdatedEvent.getTotalCount() == 0) {
                emptyState.show();
            } else {
                emptyState.hide();
            }
        });
        dataTable.element().appendChild(emptyState.element());
    }

    public EmptyState getEmptyState() {
        return emptyState;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy