File tree Expand file tree Collapse file tree 3 files changed +46
-1
lines changed
spring-shell-core/src/main/java/org/springframework/shell/component/view/control
modules/ROOT/pages/tui/intro
src/test/java/org/springframework/shell/docs Expand file tree Collapse file tree 3 files changed +46
-1
lines changed Original file line number Diff line number Diff line change 2424 */
2525public interface ViewService {
2626
27+ /**
28+ * Gets a current modal view.
29+ *
30+ * @return current modal view
31+ */
32+ @ Nullable
2733 View getModal ();
2834
29- void setModal (View view );
35+ /**
36+ * Sets a new modal view. Setting modal to {@code null} clears existing modal.
37+ *
38+ * @param view a view to use as modal
39+ */
40+ void setModal (@ Nullable View view );
3041
42+ /**
43+ * Sets a view to be focused. Setting focus to {@code null} clears focused view.
44+ *
45+ * @param view a view to be focused
46+ */
3147 void setFocus (@ Nullable View view );
3248}
Original file line number Diff line number Diff line change @@ -41,3 +41,16 @@ events and request _interrupt_.
4141----
4242include::{snippets}/TerminalUiSnippets.java[tag=exitingfromloop]
4343----
44+
45+ == Modal View
46+
47+ `TerminalUI` supports having one active modal view. Modal view is placed
48+ on top of all other views and takes all input events.
49+
50+ [source, java, indent=0]
51+ ----
52+ include::{snippets}/TerminalUiSnippets.java[tag=uimodal]
53+ ----
54+
55+ NOTE: As views should not directly know anything about `TerminalUi` and
56+ interface `ViewService` exposes modal related functions.
Original file line number Diff line number Diff line change 2222import org .springframework .shell .component .view .TerminalUI ;
2323import org .springframework .shell .component .view .TerminalUIBuilder ;
2424import org .springframework .shell .component .view .control .BoxView ;
25+ import org .springframework .shell .component .view .control .DialogView ;
2526import org .springframework .shell .component .view .event .EventLoop ;
2627import org .springframework .shell .component .view .event .KeyEvent .Key ;
2728import org .springframework .shell .geom .HorizontalAlign ;
@@ -111,4 +112,19 @@ void sample() {
111112 // end::uirun[]
112113 }
113114
115+ class SampleUiModal {
116+
117+ // tag::uimodal[]
118+ TerminalUI ui ;
119+
120+ void sample () {
121+ DialogView dialog = new DialogView ();
122+ // set modal
123+ ui .setModal (dialog );
124+ // clear modal
125+ ui .setModal (null );
126+ }
127+ // end::uimodal[]
128+ }
129+
114130}
You can’t perform that action at this time.
0 commit comments