Skip to content

Commit

Permalink
Merge team repo master into local
Browse files Browse the repository at this point in the history
  • Loading branch information
potaotototo committed Oct 24, 2024
2 parents b944ea4 + 1422ba6 commit 317650c
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 11 deletions.
17 changes: 17 additions & 0 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,23 @@ How the this feature works:
Note that although this is shown as a single step in the diagram above (for simplicity), in the code it takes several interactions (between the command object and the `Model`) to achieve.
1. The result of the command execution is encapsulated as a `CommandResult` object which is returned back from `Logic`.

### Display feature
The `DisplayCommand` allows users to display a specified person in the addressbook.
It uses `DisplayCommandParser` to parse the user input and create an `DisplayCommand` object, which modifies the `lastViewedPerson` object in the `Model`.

The following sequence diagram illustrates the interactions that take place within the `Logic` component when the user executes the `addRemarkCommand`, taking `execute("remark 1 -a Good progress")` API call as an example.

<puml src="diagrams/DisplaySequenceDiagram.puml" alt="Interactions Inside the Logic Component when a display command is called" />

<box type="info" seamless>

How the this feature works:

1. When `Logic` is called upon to execute a command, it is passed to an `AddressBookParser` object which in turn creates a parser that matches the command `display` (i.e., `DisplayCommandParser`) and uses it to parse the command.
1. This results in a `Command` object (more precisely, an object of one of its subclasses e.g., `DisplayCommand`) which is executed by the `LogicManager`.
1. The command can communicate with the `Model` when it is executed.<br>
Note that although this is shown as a single step in the diagram above (for simplicity), in the code it takes several interactions (between the command object and the `Model`) to achieve.
1. The result of the command execution is encapsulated as a `CommandResult` object which is returned back from `Logic`.

### \[Proposed\] Undo/redo feature

Expand Down
54 changes: 54 additions & 0 deletions docs/diagrams/DisplaySequence.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
@startuml DisplaySequence

participant ":LogicManager" as Logic
participant ":DisplayCommand" as Command
participant ":Model" as Model
participant ":PersonList" as PersonList

alt Display by Index
Logic -> Command : execute(model)
activate Command

Command -> Model : getFilteredPersonList()
activate Model
Model --> Command : filteredList
deactivate Model

Command -> Command : getPersonToDisplayByIndex(model, index)
activate Command
alt index >= list.size
Command --> Logic : throw CommandException\n(invalid index)
else valid index
Command -> PersonList : get(index)
activate PersonList
PersonList --> Command : person
deactivate PersonList
end
deactivate Command

else Display by Name
Logic -> Command : execute(model)
activate Command

Command -> Command : getPersonToDisplayByName(model, name)
activate Command
Command -> Model : findPersonByName(name)
activate Model
Model --> Command : person
deactivate Model

alt person == null
Command --> Logic : throw CommandException\n(invalid name)
end
deactivate Command
end

Command -> Model : displayPerson(person)
activate Model
Model --> Command
deactivate Model

Command --> Logic : CommandResult
deactivate Command

@enduml
9 changes: 3 additions & 6 deletions src/main/resources/view/DisplayCardPanel.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
<?import javafx.scene.control.ListView?>
<?import javafx.scene.layout.VBox?>

<?import javafx.scene.layout.HBox?>
<HBox>
<VBox xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1">
<ListView fx:id="displayCardListView" />
</VBox>
</HBox>
<VBox xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1" VBox.vgrow="ALWAYS">
<ListView fx:id="displayCardListView" VBox.vgrow="ALWAYS"/>
</VBox>
15 changes: 10 additions & 5 deletions src/main/resources/view/MainWindow.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,17 @@
</MenuBar>

<!-- SplitPane to place person list and display card side by side -->
<SplitPane VBox.vgrow="ALWAYS" dividerPositions="0.3">
<SplitPane xmlns="http://javafx.com/javafx/17"
xmlns:fx="http://javafx.com/fxml/1"
VBox.vgrow="ALWAYS"
dividerPositions="0.3">
<!-- Left: Person List -->
<StackPane fx:id="personListPanelPlaceholder" minWidth="340" prefWidth="340" />

<!-- Right: DisplayCard -->
<StackPane fx:id="displayCardPanelPlaceholder" minWidth="800" prefWidth="800" styleClass="right-pane"/>
<StackPane fx:id="personListPanelPlaceholder"
minWidth="200"
maxWidth="200"/> <!-- Add maxWidth to fix the width -->
<!-- Right: Display Card -->
<StackPane fx:id="displayCardPanelPlaceholder"
minWidth="200"/>
</SplitPane>

<!-- Result Display -->
Expand Down

0 comments on commit 317650c

Please sign in to comment.