io.bretty.console.view.ActionView Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of console-view Show documentation
Show all versions of console-view Show documentation
A Java framework to instantly build the View layer of your command line app. No more worries about anything like
printing menus or validating user inputs. Just focus on your app logic.
package io.bretty.console.view;
/**
* The view that is used for a custom leaf functionality implementation.
* It provides useful features like managed UI wrapper, e.g. {@code prompt()}
* to prompt an input from the user with automatic validation.
* Workflow of the default implementation:
* 1) print title;
* 2) execute custom action;
* 3) pause
* 4) go back to parent view
*/
public abstract class ActionView extends AbstractView {
public ActionView(String runningTitle, String nameInParentMenu) {
super(runningTitle, nameInParentMenu);
}
public ActionView(String runningTitle, String nameInParentMenu, ViewConfig viewConfig) {
super(runningTitle, nameInParentMenu, viewConfig);
}
/**
* to create your custom {@code ActionView} subclass, implement this method
* to execute your custom logic between printing the title and go back to
* the parent view
*/
public abstract void executeCustomAction();
@Override
public void display() {
this.println();
this.println(this.runningTitle);
this.executeCustomAction();
this.pause();
this.goBack();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy