Package com.tonic.vellum
Class App.Builder
- java.lang.Object
-
- com.tonic.vellum.App.Builder
-
- Enclosing class:
- App
public static final class App.Builder extends java.lang.ObjectFluent builder for an App.
-
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Appbuild()Builds the configured app.App.BuilderfocusOrder(Section... targets)Sets the sections that participate in focus navigation, in order.App.BuilderinitialFocus(Section target)Sets the section that holds focus when the app starts.App.Buildernavigation(Navigation navigation)Sets the navigation strategy that moves focus between targets.App.BuilderonError(java.util.function.Consumer<java.lang.Throwable> handler)Sets a handler for exceptions thrown by a task, key handler, or section render, invoked on the UI thread.App.BuilderonQuit(java.util.function.Predicate<KeyEvent> predicate)Quits when a key matches the predicate.App.BuilderonQuitKey(char ch)Quits on a specific printable character.App.BuilderonQuitKey(Key key)Quits on a specific logical key.App.Builderroot(Section root)Sets the root section of the UI.
-
-
-
Method Detail
-
root
public App.Builder root(Section root)
Sets the root section of the UI.- Parameters:
root- the root section- Returns:
- this Builder for chaining
-
focusOrder
public App.Builder focusOrder(Section... targets)
Sets the sections that participate in focus navigation, in order.- Parameters:
targets- the focusable sections in navigation order- Returns:
- this Builder for chaining
-
navigation
public App.Builder navigation(Navigation navigation)
Sets the navigation strategy that moves focus between targets.- Parameters:
navigation- the navigation strategy- Returns:
- this Builder for chaining
-
initialFocus
public App.Builder initialFocus(Section target)
Sets the section that holds focus when the app starts.- Parameters:
target- the initially focused section- Returns:
- this Builder for chaining
-
onQuit
public App.Builder onQuit(java.util.function.Predicate<KeyEvent> predicate)
Quits when a key matches the predicate.- Parameters:
predicate- tested against each key event- Returns:
- this Builder for chaining
-
onQuitKey
public App.Builder onQuitKey(Key key)
Quits on a specific logical key.- Parameters:
key- the logical key that triggers quit- Returns:
- this Builder for chaining
-
onQuitKey
public App.Builder onQuitKey(char ch)
Quits on a specific printable character.- Parameters:
ch- the character that triggers quit- Returns:
- this Builder for chaining
-
onError
public App.Builder onError(java.util.function.Consumer<java.lang.Throwable> handler)
Sets a handler for exceptions thrown by a task, key handler, or section render, invoked on the UI thread. Without one, the loop keeps running and the first error is printed after the terminal is restored.- Parameters:
handler- the error handler- Returns:
- this Builder for chaining
-
build
public App build()
Builds the configured app.- Returns:
- the new app
- Throws:
java.lang.IllegalStateException- if no root section is set
-
-