Skip to content

Commit

Permalink
Finalize command history documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
aureliony committed Apr 14, 2024
1 parent 7e73262 commit 08cf17f
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 8 deletions.
12 changes: 11 additions & 1 deletion docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -397,14 +397,24 @@ The following activity diagram summarizes what happens when a user executes a ne
The `CommandHistory` class is an abstraction for a command history data structure.
It stores all command strings that were successfully executed by the user.

When the user executes a command successfully, `LogicManager` calls the `add()` method in `CommandHistory` to store the command string.

<puml src="diagrams/CommandHistoryAddSequenceDiagram.puml" />
<br><br>


`CommandExecutor` is an interface that has the methods `execute()`, `getPreviousCommandText()` and `getNextCommandText()`.
A private nested class `RecordedCommandExecutor` in `MainWindow` implements this interface.

When the user presses the `UP` key, a `KeyEvent` is generated by JavaFX, which is then handled by the `CommandBox` class through the `handleKeyPressed()` method.

The following sequence diagram shows the interaction between the classes when the user presses the `UP` key.
Note that `TextField` is a class in JavaFX. `CommandBox` has a `textField` attribute.

<puml src="diagrams/CommandHistorySequenceDiagram.puml" />
<puml src="diagrams/CommandHistoryUpSequenceDiagram.puml" />
<br><br>

A similar interaction occurs when the user presses the `DOWN` key.

--------------------------------------------------------------------------------------------------------------------

Expand Down
22 changes: 22 additions & 0 deletions docs/diagrams/CommandHistoryAddSequenceDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
@startuml
!include style.puml
skinparam ArrowFontStyle plain

box Logic LOGIC_COLOR_T1
participant ":LogicManager" as LogicManager LOGIC_COLOR
participant ":CommandHistory" as CommandHistory LOGIC_COLOR
end box

-> LogicManager : execute(commandText)
activate LogicManager

LogicManager -> CommandHistory : add(commandText)
activate CommandHistory

CommandHistory --> LogicManager : commandText
deactivate CommandHistory

<-- LogicManager : commandResult
deactivate LogicManager

@enduml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ skinparam ArrowFontStyle plain

box UI UI_COLOR_T1
participant ":CommandBox" as CommandBox UI_COLOR
participant ":CommandExecutor" as CommandExecutor UI_COLOR
participant ":RecordedCommandExecutor" as RecordedCommandExecutor UI_COLOR
end box

box Logic LOGIC_COLOR_T1
Expand All @@ -19,10 +19,10 @@ participant ":TextField" as TextField JAVAFX_COLOR
-> CommandBox : handleKeyPressed(event)
activate CommandBox

CommandBox -> CommandExecutor : getPreviousCommandText()
activate CommandExecutor
CommandBox -> RecordedCommandExecutor : getPreviousCommandText()
activate RecordedCommandExecutor

CommandExecutor -> LogicManager : getPreviousCommandText()
RecordedCommandExecutor -> LogicManager : getPreviousCommandText()
activate LogicManager

LogicManager -> CommandHistory : getPrevious()
Expand All @@ -31,11 +31,11 @@ activate CommandHistory
CommandHistory --> LogicManager : commandText
deactivate CommandHistory

LogicManager --> CommandExecutor : commandText
LogicManager --> RecordedCommandExecutor : commandText
deactivate LogicManager

CommandExecutor --> CommandBox : commandText
deactivate CommandExecutor
RecordedCommandExecutor --> CommandBox : commandText
deactivate RecordedCommandExecutor

CommandBox -> TextField : setText(commandText)
activate TextField
Expand Down

0 comments on commit 08cf17f

Please sign in to comment.