From ccc4074f4872881d795aa56851483f3e4a034b49 Mon Sep 17 00:00:00 2001 From: belligerentbeagle Date: Sat, 13 Apr 2024 01:52:39 +0800 Subject: [PATCH 1/2] Add PUML Implementation Diagram for Command History --- docs/DeveloperGuide.md | 8 ++++- .../CommandHistorySequenceDiagram.puml | 35 +++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 docs/diagrams/CommandHistorySequenceDiagram.puml diff --git a/docs/DeveloperGuide.md b/docs/DeveloperGuide.md index dda421e186f..4d1004a3b3b 100644 --- a/docs/DeveloperGuide.md +++ b/docs/DeveloperGuide.md @@ -221,7 +221,13 @@ This section describes some noteworthy details on how certain features are imple ### Command History Retrieval -**TODO** +Let's consider the scenario where the user wants to retrieve the last command executed. The user can do this by +pressing the UP key on +the keyboard. + +The UP key press event is captured by the `CommandBox` class, which then +retrieves the last command from the `CommandHistory` Singleton object. + {{ newPage }} diff --git a/docs/diagrams/CommandHistorySequenceDiagram.puml b/docs/diagrams/CommandHistorySequenceDiagram.puml new file mode 100644 index 00000000000..937b06019cd --- /dev/null +++ b/docs/diagrams/CommandHistorySequenceDiagram.puml @@ -0,0 +1,35 @@ +@startuml +!include style.puml +skinparam ArrowFontStyle plain + +box Command History UI_COLOR_T2 +participant ":CommandBox" as Model UI_COLOR_T3 +participant ":CommandHistory" as ModelCH UI_COLOR_T3 +end box + +[-> Model : keyPress(e) +activate Model + +Model -> Model : handleKeyPressEvent(e) +Model -> Model : handleArrowKeyPress(e) +activate Model +Model -> ModelCH : getInstance() +activate ModelCH +ModelCH --> Model : +deactivate ModelCH + +Model -> ModelCH : getCommandHistory(direction) +activate ModelCH + +ModelCH -> ModelCH : +ModelCH -> ModelCH : +ModelCH -> ModelCH : +ModelCH --> Model : previousCommand +deactivate ModelCH + +Model -> Model : setText(previousCommand) + +[<-- Model +deactivate Model + +@enduml From 690aa2dff65d11a1b5ba90daaab7106e165c09f7 Mon Sep 17 00:00:00 2001 From: belligerentbeagle Date: Sat, 13 Apr 2024 14:58:32 +0800 Subject: [PATCH 2/2] Improve clarity --- docs/diagrams/CommandHistorySequenceDiagram.puml | 3 --- 1 file changed, 3 deletions(-) diff --git a/docs/diagrams/CommandHistorySequenceDiagram.puml b/docs/diagrams/CommandHistorySequenceDiagram.puml index 937b06019cd..79ff5e3036a 100644 --- a/docs/diagrams/CommandHistorySequenceDiagram.puml +++ b/docs/diagrams/CommandHistorySequenceDiagram.puml @@ -21,9 +21,6 @@ deactivate ModelCH Model -> ModelCH : getCommandHistory(direction) activate ModelCH -ModelCH -> ModelCH : -ModelCH -> ModelCH : -ModelCH -> ModelCH : ModelCH --> Model : previousCommand deactivate ModelCH