feat(ui): add collection sorting menu and sort method selection
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user