feat(ui): add main menu and navigation skeleton
This commit is contained in:
+20
@@ -41,6 +41,13 @@
|
||||
<artifactId>junit-jupiter-params</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.googlecode.lanterna</groupId>
|
||||
<artifactId>lanterna</artifactId>
|
||||
<version>3.1.5</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
@@ -91,5 +98,18 @@
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<version>3.6.3</version>
|
||||
|
||||
<configuration>
|
||||
<mainClass>ru.project.App</mainClass>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
</build>
|
||||
</project>
|
||||
|
||||
@@ -1,10 +1,31 @@
|
||||
package ru.project;
|
||||
|
||||
/**
|
||||
* Hello world!
|
||||
*/
|
||||
public class App {
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Hello World!");
|
||||
import com.googlecode.lanterna.gui2.MultiWindowTextGUI;
|
||||
import com.googlecode.lanterna.screen.Screen;
|
||||
import com.googlecode.lanterna.screen.TerminalScreen;
|
||||
import com.googlecode.lanterna.terminal.DefaultTerminalFactory;
|
||||
import ru.project.ui.MainMenu;
|
||||
import ru.project.ui.Navigator;
|
||||
|
||||
public final class App {
|
||||
|
||||
private App() {}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
DefaultTerminalFactory factory = new DefaultTerminalFactory();
|
||||
|
||||
Screen screen = new TerminalScreen(factory.createTerminal());
|
||||
|
||||
screen.startScreen();
|
||||
|
||||
try {
|
||||
MultiWindowTextGUI gui = new MultiWindowTextGUI(screen);
|
||||
|
||||
Navigator navigator = new Navigator(gui);
|
||||
|
||||
gui.addWindowAndWait(new MainMenu(navigator));
|
||||
} finally {
|
||||
screen.stopScreen();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
package ru.project.ui;
|
||||
|
||||
public class CollectionView extends EmptyMenu {
|
||||
|
||||
public CollectionView() {
|
||||
super("Текущая коллекция");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package ru.project.ui;
|
||||
|
||||
public class CountOccurrencesMenu extends EmptyMenu {
|
||||
|
||||
public CountOccurrencesMenu() {
|
||||
super("Подсчёт количества вхождений");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package ru.project.ui;
|
||||
|
||||
public class CreateCollectionMenu extends EmptyMenu {
|
||||
|
||||
public CreateCollectionMenu() {
|
||||
super("Создание новой коллекции");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package ru.project.ui;
|
||||
|
||||
import com.googlecode.lanterna.gui2.BasicWindow;
|
||||
import com.googlecode.lanterna.gui2.Button;
|
||||
import com.googlecode.lanterna.gui2.Direction;
|
||||
import com.googlecode.lanterna.gui2.Label;
|
||||
import com.googlecode.lanterna.gui2.LinearLayout;
|
||||
import com.googlecode.lanterna.gui2.Panel;
|
||||
|
||||
public abstract class EmptyMenu extends BasicWindow {
|
||||
|
||||
protected EmptyMenu(String title) {
|
||||
super(title);
|
||||
|
||||
Panel panel = new Panel(new LinearLayout(Direction.VERTICAL));
|
||||
|
||||
panel.addComponent(new Label("Раздел находится в разработке"));
|
||||
|
||||
panel.addComponent(new Button("Назад", this::close));
|
||||
|
||||
setComponent(panel);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package ru.project.ui;
|
||||
|
||||
import com.googlecode.lanterna.gui2.BasicWindow;
|
||||
import com.googlecode.lanterna.gui2.Button;
|
||||
import com.googlecode.lanterna.gui2.Direction;
|
||||
import com.googlecode.lanterna.gui2.LinearLayout;
|
||||
import com.googlecode.lanterna.gui2.Panel;
|
||||
|
||||
public class MainMenu extends BasicWindow {
|
||||
|
||||
public MainMenu(Navigator navigator) {
|
||||
super("ГЛАВНОЕ МЕНЮ");
|
||||
|
||||
Panel panel = new Panel(new LinearLayout(Direction.VERTICAL));
|
||||
|
||||
panel.addComponent(new Button("Показать текущую коллекцию", navigator::showCollectionView));
|
||||
|
||||
panel.addComponent(new Button("Создать новую коллекцию", navigator::showCreateCollection));
|
||||
|
||||
panel.addComponent(
|
||||
new Button("Сохранить текущую коллекцию в файл", navigator::showSaveCollection));
|
||||
|
||||
panel.addComponent(new Button("Сортировать текущую коллекцию", navigator::showSortCollection));
|
||||
|
||||
panel.addComponent(new Button("Найти элемент", navigator::showSearchElement));
|
||||
|
||||
panel.addComponent(
|
||||
new Button("Подсчитать количество вхождений", navigator::showCountOccurrences));
|
||||
|
||||
panel.addComponent(new Button("Завершить выполнение программы", this::close));
|
||||
|
||||
setComponent(panel);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package ru.project.ui;
|
||||
|
||||
import com.googlecode.lanterna.gui2.BasicWindow;
|
||||
import com.googlecode.lanterna.gui2.WindowBasedTextGUI;
|
||||
|
||||
public class Navigator {
|
||||
|
||||
private final WindowBasedTextGUI gui;
|
||||
|
||||
public Navigator(WindowBasedTextGUI gui) {
|
||||
this.gui = gui;
|
||||
}
|
||||
|
||||
public void show(BasicWindow window) {
|
||||
gui.addWindowAndWait(window);
|
||||
}
|
||||
|
||||
public void showCollectionView() {
|
||||
show(new CollectionView());
|
||||
}
|
||||
|
||||
public void showCreateCollection() {
|
||||
show(new CreateCollectionMenu());
|
||||
}
|
||||
|
||||
public void showSaveCollection() {
|
||||
show(new SaveCollectionMenu());
|
||||
}
|
||||
|
||||
public void showSortCollection() {
|
||||
show(new SortCollectionMenu());
|
||||
}
|
||||
|
||||
public void showSearchElement() {
|
||||
show(new SearchElementMenu());
|
||||
}
|
||||
|
||||
public void showCountOccurrences() {
|
||||
show(new CountOccurrencesMenu());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package ru.project.ui;
|
||||
|
||||
public class SaveCollectionMenu extends EmptyMenu {
|
||||
|
||||
public SaveCollectionMenu() {
|
||||
super("Сохранение текущей коллекции");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package ru.project.ui;
|
||||
|
||||
public class SearchElementMenu extends EmptyMenu {
|
||||
|
||||
public SearchElementMenu() {
|
||||
super("Поиск элемента");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package ru.project.ui;
|
||||
|
||||
public class SortCollectionMenu extends EmptyMenu {
|
||||
|
||||
public SortCollectionMenu() {
|
||||
super("Сортировка текущей коллекции");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user