feat(ui): add collection sorting menu and sort method selection

This commit is contained in:
2026-08-29 22:58:09 +04:00
parent 8f55486449
commit 1de5a59e93
4 changed files with 143 additions and 2 deletions
@@ -0,0 +1,33 @@
package ru.project.ui.window;
import com.googlecode.lanterna.gui2.ActionListBox;
import com.googlecode.lanterna.gui2.WindowBasedTextGUI;
import java.util.function.Consumer;
import ru.project.model.SortMethod;
import ru.project.ui.base.BaseModalWindow;
public class SortMethodSelectionWindow extends BaseModalWindow {
private final Consumer<SortMethod> onSortMethodSelected;
public SortMethodSelectionWindow(
WindowBasedTextGUI gui, Consumer<SortMethod> onSortMethodSelected) {
super("Выбрать способ сортировки", gui);
this.onSortMethodSelected = onSortMethodSelected;
ActionListBox menu = new ActionListBox();
menu.addItem("Обычная сортировка", () -> selectSortMethod(SortMethod.NORMAL));
menu.addItem("Сортировка по чётности", () -> selectSortMethod(SortMethod.PARITY));
setComponent(menu);
}
private void selectSortMethod(SortMethod sortMethod) {
onSortMethodSelected.accept(sortMethod);
close();
}
}