From d77bcac59c74672337072e78b402075e27d492c4 Mon Sep 17 00:00:00 2001 From: Janne Valkealahti Date: Fri, 20 Oct 2023 08:07:17 +0100 Subject: [PATCH] Update docs --- .../modules/ROOT/pages/tui/views/box.adoc | 14 +++ .../modules/ROOT/pages/tui/views/button.adoc | 49 ++++++++ .../modules/ROOT/pages/tui/views/dialog.adoc | 26 +++++ .../modules/ROOT/pages/tui/views/grid.adoc | 16 +-- .../modules/ROOT/pages/tui/views/list.adoc | 106 ++++++++++++------ .../modules/ROOT/pages/tui/views/menu.adoc | 51 +++++++++ .../modules/ROOT/pages/tui/views/menubar.adoc | 29 +++++ .../shell/docs/ButtonViewSnippets.java | 35 ++++++ 8 files changed, 282 insertions(+), 44 deletions(-) create mode 100644 spring-shell-docs/src/test/java/org/springframework/shell/docs/ButtonViewSnippets.java diff --git a/spring-shell-docs/modules/ROOT/pages/tui/views/box.adoc b/spring-shell-docs/modules/ROOT/pages/tui/views/box.adoc index 60ac4dcb..a00611d4 100644 --- a/spring-shell-docs/modules/ROOT/pages/tui/views/box.adoc +++ b/spring-shell-docs/modules/ROOT/pages/tui/views/box.adoc @@ -8,7 +8,21 @@ _BoxView_ is a base implementation providing functionality to draw into a bounded _Rectancle_. Only direct use of it is its `drawFunction` which allows to do simple things without implementing a full custom `View`. + [source, java, indent=0] ---- include::{snippets}/BoxViewSnippets.java[tag=sample] ---- + +== Customisation +_BoxView_ as mostly being a base class contains some useful features +like if it should draw a border and what what are its paddings. +Border can have a title and its color and focused color can be +defined. It's also possible to explicitely set background color +which will override one from styling. + +== Default Bindings +Does not have any default bindings. + +== Events +Does not have any events. diff --git a/spring-shell-docs/modules/ROOT/pages/tui/views/button.adoc b/spring-shell-docs/modules/ROOT/pages/tui/views/button.adoc index 6021b283..73db8f64 100644 --- a/spring-shell-docs/modules/ROOT/pages/tui/views/button.adoc +++ b/spring-shell-docs/modules/ROOT/pages/tui/views/button.adoc @@ -6,3 +6,52 @@ ifndef::snippets[:snippets: ../../../../../src/test/java/org/springframework/she _ButtonView_ is a base implementation providing functionality to draw a button. Inherits xref:tui/views/box.adoc[]. + +[source, text] +---- +┌──────┐ +│ text │ +└──────┘ +---- + +You can set a text for a button and action to do when button is selected. + +[source, java, indent=0] +---- +include::{snippets}/ButtonViewSnippets.java[tag=sample] +---- + +== Default Bindings + +Default _key bindigs_ are: + +.Key +|=== +|Command |Description + +|Enter +|Selects a button + +|=== + +Default _mouse bindigs_ are: + +.Mouse +|=== +|Command |Description + +|Released \| Button1 +|Selects a button + +|=== + +== Events +[[tui-views-list-events]] +.ListView Events +|=== +|Event |Description + +|ButtonViewSelectEvent +|Button is selected. + +|=== diff --git a/spring-shell-docs/modules/ROOT/pages/tui/views/dialog.adoc b/spring-shell-docs/modules/ROOT/pages/tui/views/dialog.adoc index 32bd7f8a..241b9692 100644 --- a/spring-shell-docs/modules/ROOT/pages/tui/views/dialog.adoc +++ b/spring-shell-docs/modules/ROOT/pages/tui/views/dialog.adoc @@ -6,3 +6,29 @@ ifndef::snippets[:snippets: ../../../../../src/test/java/org/springframework/she _DialogView_ is a base implementation providing functionality to draw a dialog. Inherits xref:tui/views/box.adoc[]. + +[source, text] +---- +┌──────────────────┐ +│ │ +│
│ +│ │ +├──────────────────┤ +│ │ +└──────────────────┘ +---- + +== Default Bindings +Does not have any default bindings. + +== Events +Events are sent depending on a used list type. + +.DialogView Events +|=== +|Event |Description + +|DialogViewCloseEvent +|Dialog requested to get closed. + +|=== diff --git a/spring-shell-docs/modules/ROOT/pages/tui/views/grid.adoc b/spring-shell-docs/modules/ROOT/pages/tui/views/grid.adoc index 26a3d303..89b3a693 100644 --- a/spring-shell-docs/modules/ROOT/pages/tui/views/grid.adoc +++ b/spring-shell-docs/modules/ROOT/pages/tui/views/grid.adoc @@ -13,15 +13,15 @@ include::{snippets}/GridViewSnippets.java[tag=snippet1] Will result layout of: -[source, text, indent=0] +[source, text] ---- -┌---┬---┐ -| | | -| | | -├---┼---┤ -| | | -| | | -└---┴---┘ +┌───┬───┐ +│ │ │ +│ │ │ +├───┼───┤ +│ │ │ +│ │ │ +└───┴───┘ ---- == Default Bindings diff --git a/spring-shell-docs/modules/ROOT/pages/tui/views/list.adoc b/spring-shell-docs/modules/ROOT/pages/tui/views/list.adoc index fc391a14..0d531a5a 100644 --- a/spring-shell-docs/modules/ROOT/pages/tui/views/list.adoc +++ b/spring-shell-docs/modules/ROOT/pages/tui/views/list.adoc @@ -28,42 +28,6 @@ Supports `NOCHECK``, `CHECK`` and `RADIO`` include::{snippets}/ListViewSnippets.java[tag=snippet2] ---- -== Default Bindings - -Default _view commands_ are: - -[[tui-views-list-viewcommands]] -.ViewCommands -|=== -|Command |Description - -|LINE_UP -|Selection moves up. Bound to _CursorUp_ and _WheelUp_. - -|LINE_DOWN -|Selection moves down. Bound to _CursorDown_ and _WheelDown_. - -|=== - -_Enter_ is choosing an active item. _Space_ is changing selection state. - -== Events - -Events are sent depending on a used list type. - -[[tui-views-list-events]] -.ListView Events -|=== -|Event |Description - -|ListViewOpenSelectedItemEvent -|Active item is requested to get opened. - -|ListViewSelectedItemChangedEvent -|Active item is changed. - -|=== - == Customisation How individual cells are shown depends on a _CellFactory_. Default implementation @@ -82,3 +46,73 @@ And set it as a factory: ---- include::{snippets}/ListViewSnippets.java[tag=uselistcell] ---- + +== Default Bindings +Default _view commands_ are: + +[[tui-views-list-viewcommands]] +.ViewCommands +|=== +|Command |Description + +|LINE_UP +|Selection moves up. + +|LINE_DOWN +|Selection moves down. + +|=== + +Default _key bindigs_ are: + +.Key +|=== +|Command |Description + +|CursorUp +|Bound ViewCommand LINE_UP + +|CursorDown +|Bound ViewCommand LINE_DOWN + +|Enter +|Choose active item. + +|Space +|Change active item selection state. + +|=== + +Default _mouse bindigs_ are: + +.Mouse +|=== +|Command |Description + +|Wheel \| WheelUp +|Bound ViewCommand LINE_UP + +|Wheel \| WheelDown +|Bound ViewCommand LINE_DOWN + +|Released \| Button1 +|Choose item + +|=== + +== Events + +Events are sent depending on a used list type. + +[[tui-views-list-events]] +.ListView Events +|=== +|Event |Description + +|ListViewOpenSelectedItemEvent +|Active item is requested to get opened. + +|ListViewSelectedItemChangedEvent +|Active item is changed. + +|=== diff --git a/spring-shell-docs/modules/ROOT/pages/tui/views/menu.adoc b/spring-shell-docs/modules/ROOT/pages/tui/views/menu.adoc index b877e3f6..cbab5534 100644 --- a/spring-shell-docs/modules/ROOT/pages/tui/views/menu.adoc +++ b/spring-shell-docs/modules/ROOT/pages/tui/views/menu.adoc @@ -6,3 +6,54 @@ ifndef::snippets[:snippets: ../../../../../src/test/java/org/springframework/she _MenuView_ is a base implementation providing functionality to draw a menu. Inherits xref:tui/views/box.adoc[]. + +== Default Bindings +Default _key bindigs_ are: + +.Key +|=== +|Command |Description + +|CursorUp +|Move selection up + +|CursorDown +|Move selection down + +|Enter +|Choose active item. + +|=== + +Default _mouse bindigs_ are: + +.Mouse +|=== +|Command |Description + +|Wheel \| WheelUp +|Move selection up + +|Wheel \| WheelDown +|Move selection down + +|Released \| Button1 +|Choose item + +|=== + +== Events + +Events are sent depending on a used list type. + +.ListView Events +|=== +|Event |Description + +|MenuViewOpenSelectedItemEvent +|Active item is requested to get opened. + +|MenuViewSelectedItemChangedEvent +|Active item is changed. + +|=== diff --git a/spring-shell-docs/modules/ROOT/pages/tui/views/menubar.adoc b/spring-shell-docs/modules/ROOT/pages/tui/views/menubar.adoc index aa8f995e..1bc6be88 100644 --- a/spring-shell-docs/modules/ROOT/pages/tui/views/menubar.adoc +++ b/spring-shell-docs/modules/ROOT/pages/tui/views/menubar.adoc @@ -6,3 +6,32 @@ ifndef::snippets[:snippets: ../../../../../src/test/java/org/springframework/she _MenuBarView_ is a base implementation providing functionality to draw a menu bar. Inherits xref:tui/views/box.adoc[]. + +== Default Bindings +Default _key bindigs_ are: + +.Key +|=== +|Command |Description + +|CursorLeft +|Move selection left + +|CursorRight +|Move selection right + +|=== + +Default _mouse bindigs_ are: + +.Mouse +|=== +|Command |Description + +|Released \| Button1 +|Choose item + +|=== + +== Events +Does not have any events. diff --git a/spring-shell-docs/src/test/java/org/springframework/shell/docs/ButtonViewSnippets.java b/spring-shell-docs/src/test/java/org/springframework/shell/docs/ButtonViewSnippets.java new file mode 100644 index 00000000..511fa5f7 --- /dev/null +++ b/spring-shell-docs/src/test/java/org/springframework/shell/docs/ButtonViewSnippets.java @@ -0,0 +1,35 @@ +/* + * Copyright 2023 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.springframework.shell.docs; + +import org.springframework.shell.component.view.control.ButtonView; + +class ButtonViewSnippets { + + class Dump1 { + + void dump1() { + // tag::sample[] + ButtonView view = new ButtonView(); + view.setText("text"); + view.setAction(() -> { + // do something when selected + }); + // end::sample[] + } + } + +}