org.bklab.crud.menu.FluentCrudMenuButton Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fluent-vaadin-flow Show documentation
Show all versions of fluent-vaadin-flow Show documentation
Broderick Labs for fluent vaadin flow. Inherits common Vaadin components.
package org.bklab.crud.menu;
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.contextmenu.ContextMenu;
import com.vaadin.flow.component.grid.Grid;
import org.bklab.crud.FluentCrudView;
import java.util.Objects;
import java.util.function.BiPredicate;
import java.util.function.Predicate;
public class FluentCrudMenuButton> {
private final Button button;
private final ContextMenu contextMenu;
private final IFluentMenuBuilder menuEntityBiConsumer;
private final FluentCrudView fluentCrudView;
private T entity;
public FluentCrudMenuButton(FluentCrudView fluentCrudView,
T entity, Button button, ContextMenu contextMenu,
IFluentMenuBuilder menuEntityBiConsumer) {
this.fluentCrudView = fluentCrudView;
this.entity = entity;
this.button = button;
this.contextMenu = contextMenu;
this.menuEntityBiConsumer = menuEntityBiConsumer;
}
public void reload() {
contextMenu.removeAll();
if (menuEntityBiConsumer != null) {
menuEntityBiConsumer.safeBuild(fluentCrudView, contextMenu, entity);
}
}
public void reload(T entity) {
this.reload(entity, t -> Objects.equals(t, entity));
}
public void reload(T entity, Predicate sameFunction) {
if (!sameFunction.test(entity)) return;
this.entity = entity;
contextMenu.removeAll();
if (menuEntityBiConsumer != null) {
menuEntityBiConsumer.safeBuild(fluentCrudView, contextMenu, entity);
}
}
public boolean isThisEntity(T entity, BiPredicate sameFunction) {
return sameFunction == null
? Objects.equals(entity, this.entity)
: sameFunction.test(entity, this.entity);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy