package ru.project.ui.creation; import com.googlecode.lanterna.gui2.ActionListBox; import com.googlecode.lanterna.gui2.WindowBasedTextGUI; import java.util.function.Consumer; import ru.project.ui.base.BaseModalWindow; public class FillMethodSelectionWindow extends BaseModalWindow { private final Consumer onFillMethodSelected; public FillMethodSelectionWindow( WindowBasedTextGUI gui, Consumer onFillMethodSelected) { super("Выбор способа заполнения", gui); this.onFillMethodSelected = onFillMethodSelected; ActionListBox menu = new ActionListBox(); menu.addItem("Пользовательские данные", () -> selectFillMethod(FillMethod.CUSTOM)); menu.addItem("Случайные данные", () -> selectFillMethod(FillMethod.RANDOM)); menu.addItem("Данные из файла", () -> selectFillMethod(FillMethod.FILE)); menu.addItem("Выйти", this::close); setComponent(menu); } private void selectFillMethod(FillMethod fillMethod) { onFillMethodSelected.accept(fillMethod); close(); } }