Skip to content

Commit

Permalink
update developer guide for tabbing between books
Browse files Browse the repository at this point in the history
  • Loading branch information
guowei42 committed Oct 19, 2022
1 parent 75c6fd1 commit 5d57e8c
Show file tree
Hide file tree
Showing 18 changed files with 227 additions and 11 deletions.
17 changes: 12 additions & 5 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -338,15 +338,22 @@ Given below is an example usage scenario and how the creation of new TAB mechani
Step 1: User enters the `new` command into the Command-Line Interface (CLI) or user navigates via `Files -> New Book` to
create a new TAB.

TODO: Add sequence diagram
The following sequence diagram shows how creation of new book work:
![Creating New Book](images/CreateNewBookSequenceDiagram.png)

Step 1.1: User adds X amount of TABs (up to 5)
Step 1.1: User adds X amount of TABs (up to 5):

TODO: Add State diagram
![Swapping Books](images/CreatingNewBookState0.png)

Step 2: User enters the `swap` command or navigates via `Files -> New Book` to toggle between TABs.
![Swapping Books](images/CreatingNewBookState1.png)

TODO: Add sequence diagram
Step 2: User enters the `swap` command or navigates via `Files -> New Book` to toggle between TABs:

![Swapping Books](images/SwapState0.png)

The following sequence diagram shows how swapping works:
NOTE: Sequence Diagram Only includes added portions
![Swapping Books](images/SwapBooksSequenceDiagram.png)

**Design Considerations**

Expand Down
54 changes: 54 additions & 0 deletions docs/diagrams/CreateNewBookSequenceDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
@startuml
'https://plantuml.com/sequence-diagram
!include style.puml
box UiPart UI_COLOR_T1
participant ":MainWindow" as MainWindow UI_COLOR
end box

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

box Model MODEL_COLOR_T1
participant ":ModelManager" as ModelManager MODEL_COLOR
end box

box ReadOnlyUserPrefs PREF_COLOR
participant ":UserPrefs" as UserPrefs PREF_COLOR_T1
end box
[-> MainWindow : handleNewBook()
activate MainWindow

MainWindow -> LogicManager : addAddressBook()
activate LogicManager

LogicManager -> ModelManager : addAddressBook()
activate ModelManager

ModelManager -> UserPrefs : addAddressBook()
activate UserPrefs

UserPrefs --> ModelManager
deactivate UserPrefs

ModelManager --> LogicManager
deactivate ModelManager

LogicManager -> ModelManager : getAllAddressBookFilePath()
activate ModelManager

ModelManager -> UserPrefs : getAllAddressBookFilePath()
activate UserPrefs

UserPrefs --> ModelManager
deactivate UserPrefs

ModelManager --> LogicManager
deactivate ModelManager

LogicManager --> MainWindow : result
deactivate LogicManager

[<--MainWindow
deactivate LogicManager
@enduml
21 changes: 21 additions & 0 deletions docs/diagrams/CreatingNewBookState0.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@startuml
!include style.puml
skinparam ClassFontColor #000000
skinparam ClassBorderColor #000000

title Initial state

package States <<rectangle>> {
class State1 as "addressBook.json"
class State2 as "addressBook1.json"
class State3 as "addressBook2.json"
}

State1 -[hidden]right-> State2
State2 -[hidden]right-> State3
hide State2
hide State3

class Pointer as "Currently Loaded Book" #FFFFFF
Pointer -up-> State1
@end
22 changes: 22 additions & 0 deletions docs/diagrams/CreatingNewBookState1.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
@startuml
!include style.puml
skinparam ClassFontColor #000000
skinparam ClassBorderColor #000000

title After command "new" or clicking "New Book" button

package States <<rectangle>> {
class State1 as "addressBook.json"
class State2 as "addressBook1.json"
class State3 as "addressBook2.json"
}

State1 -[hidden]right-> State2
State2 -[hidden]right-> State3

hide State3

class Pointer as "Currently Loaded Book" #FFFFFF

Pointer -up-> State1
@end
84 changes: 84 additions & 0 deletions docs/diagrams/SwapBooksSequenceDiagram.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
@startuml
'https://plantuml.com/sequence-diagram
!include style.puml
box UiPart UI_COLOR_T1
participant ":MainWindow" as MainWindow UI_COLOR
end box

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



box Model MODEL_COLOR_T1
participant ":ModelManager" as ModelManager MODEL_COLOR
end box

box Storage STORAGE_COLOR_T1
participant ":Storage" as Storage STORAGE_COLOR
end box

box ReadOnlyUserPrefs PREF_COLOR
participant ":UserPrefs" as UserPrefs PREF_COLOR_T1
end box

[-> MainWindow : handleSwap()
activate MainWindow

MainWindow -> LogicManager : swapAddressBook()
activate LogicManager



LogicManager -> ModelManager : getNextAddressBookPath()
activate ModelManager

ModelManager -> UserPrefs : getNextAddressBookPath()
activate UserPrefs

UserPrefs -> UserPrefs : incrementIndex()
activate UserPrefs

UserPrefs --> UserPrefs
deactivate UserPrefs

UserPrefs -> UserPrefs : setAddressBookFilePath(Path)
activate UserPrefs

UserPrefs --> UserPrefs
deactivate UserPrefs

UserPrefs --> ModelManager : result
deactivate UserPrefs

ModelManager --> LogicManager
deactivate ModelManager



LogicManager -> Storage : readAddressBook(Path)
activate Storage

Storage --> LogicManager
deactivate Storage

LogicManager -> Storage : setAddressBook(AddressBookStorage)
activate Storage

Storage --> LogicManager
deactivate Storage


LogicManager -> ModelManager : setAddressBook(ReadOnlyAddressBook)
activate ModelManager

ModelManager --> LogicManager
deactivate ModelManager

LogicManager --> MainWindow
deactivate LogicManager

[<--MainWindow
deactivate LogicManager
@enduml
22 changes: 22 additions & 0 deletions docs/diagrams/SwapState0.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
@startuml
!include style.puml
skinparam ClassFontColor #000000
skinparam ClassBorderColor #000000

title After command "swap" or clicking "Swap Book" button

package States <<rectangle>> {
class State1 as "addressBook.json"
class State2 as "addressBook1.json"
class State3 as "addressBook2.json"
}

State1 -[hidden]right-> State2
State2 -[hidden]right-> State3

hide State3

class Pointer as "Currently Loaded Book" #FFFFFF

Pointer -up-> State2
@end
2 changes: 1 addition & 1 deletion docs/diagrams/UndoRedoState0.puml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ State2 -[hidden]right-> State3
hide State2
hide State3

class Pointer as "Current State" #FFFFF
class Pointer as "Current State" #FFFFFF
Pointer -up-> State1
@end
2 changes: 1 addition & 1 deletion docs/diagrams/UndoRedoState1.puml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ State2 -[hidden]right-> State3

hide State3

class Pointer as "Current State" #FFFFF
class Pointer as "Current State" #FFFFFF

Pointer -up-> State2
@end
2 changes: 1 addition & 1 deletion docs/diagrams/UndoRedoState2.puml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ package States <<rectangle>> {
State1 -[hidden]right-> State2
State2 -[hidden]right-> State3

class Pointer as "Current State" #FFFFF
class Pointer as "Current State" #FFFFFF

Pointer -up-> State3
@end
2 changes: 1 addition & 1 deletion docs/diagrams/UndoRedoState3.puml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ package States <<rectangle>> {
State1 -[hidden]right-> State2
State2 -[hidden]right-> State3

class Pointer as "Current State" #FFFFF
class Pointer as "Current State" #FFFFFF

Pointer -up-> State2
@end
2 changes: 1 addition & 1 deletion docs/diagrams/UndoRedoState4.puml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ package States <<rectangle>> {
State1 -[hidden]right-> State2
State2 -[hidden]right-> State3

class Pointer as "Current State" #FFFFF
class Pointer as "Current State" #FFFFFF

Pointer -up-> State2
@end
2 changes: 1 addition & 1 deletion docs/diagrams/UndoRedoState5.puml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ package States <<rectangle>> {
State1 -[hidden]right-> State2
State2 -[hidden]right-> State3

class Pointer as "Current State" #FFFFF
class Pointer as "Current State" #FFFFFF

Pointer -up-> State3
note right on link: State ab2 deleted.
Expand Down
6 changes: 6 additions & 0 deletions docs/diagrams/style.puml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
!define UI_COLOR_T3 #166800
!define UI_COLOR_T4 #0E4100

!define PREF_COLOR #Violet
!define PREF_COLOR_T1 #DarkOrchid
!define PREF_COLOR_T2 #DarkMagenta
!define PREF_COLOR_T3 #DarkSlateBlue
!define PREF_COLOR_T4 #Indigo

!define LOGIC_COLOR #3333C4
!define LOGIC_COLOR_T1 #C8C8FA
!define LOGIC_COLOR_T2 #6A6ADC
Expand Down
Binary file added docs/images/CreateNewBookSequenceDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/CreatingNewBookState0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/CreatingNewBookState1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/SwapBooksSequenceDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/SwapState0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5d57e8c

Please sign in to comment.