Skip to content

Commit

Permalink
no message
Browse files Browse the repository at this point in the history
  • Loading branch information
zoebelle-pang committed Apr 4, 2024
1 parent 4d63bbc commit 2f394f9
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/main/java/seedu/address/ui/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import seedu.address.commons.core.GuiSettings;
import seedu.address.commons.core.LogsCenter;
Expand All @@ -36,7 +37,10 @@ public class MainWindow extends UiPart<Stage> {
private ResultDisplay resultDisplay;
private HelpWindow helpWindow;
private ViewWindow viewWindow;
private CommandListPanel commandListPanel;

@FXML
private VBox personList;
@FXML
private FlowPane calendar;
@FXML
Expand All @@ -53,6 +57,8 @@ public class MainWindow extends UiPart<Stage> {

@FXML
private StackPane statusbarPlaceholder;
@FXML
private StackPane commandListPanelPlaceholder;

/**
* Creates a {@code MainWindow} with the given {@code Stage} and {@code Logic}.
Expand Down Expand Up @@ -118,6 +124,11 @@ void fillInnerParts() {
personListPanel = new PersonListPanel(logic.getFilteredPersonList());
personListPanelPlaceholder.getChildren().add(personListPanel.getRoot());

commandListPanel = new CommandListPanel(logic.getCommandHistory());
commandListPanelPlaceholder.getChildren().add(commandListPanel.getRoot());

personList.getChildren().remove(commandListPanelPlaceholder);

resultDisplay = new ResultDisplay();
resultDisplayPlaceholder.getChildren().add(resultDisplay.getRoot());

Expand Down Expand Up @@ -146,12 +157,33 @@ private void setWindowDefaultSize(GuiSettings guiSettings) {
@FXML
public void handleHelp() {
if (!helpWindow.isShowing()) {
viewWindow = new ViewWindow(logic);
helpWindow.show();
} else {
helpWindow.focus();
}
}

/**
* Hides the student list and shows the command history list.
*/
public void toggleHistoryList() {
if (personList.getChildren().contains(personListPanelPlaceholder)) {
personList.getChildren().remove(personListPanelPlaceholder);
personList.getChildren().add(commandListPanelPlaceholder);
}
}

/**
* Hides the command history list and shows the student list.
*/
public void toggleStudentList() {
if (personList.getChildren().contains(commandListPanelPlaceholder)) {
personList.getChildren().remove(commandListPanelPlaceholder);
personList.getChildren().add(personListPanelPlaceholder);
}
}

/**
* Opens the view schedule window or focuses on it if it's already opened.
*/
Expand Down Expand Up @@ -185,6 +217,10 @@ public PersonListPanel getPersonListPanel() {
return personListPanel;
}

public CommandListPanel getCommandListPanel() {
return commandListPanel;
}

/**
* Executes the command and returns the result.
*
Expand All @@ -204,6 +240,12 @@ private CommandResult executeCommand(String commandText) throws CommandException
handleView();
}

if (commandResult.isShowHistory()) {
toggleHistoryList();
} else {
toggleStudentList();
}

if (commandResult.isExit()) {
handleExit();
}
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/view/MainWindow.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
<Insets top="10" right="10" bottom="10" left="10" />
</padding>
<StackPane fx:id="personListPanelPlaceholder" VBox.vgrow="ALWAYS"/>
<StackPane fx:id="commandListPanelPlaceholder" VBox.vgrow="ALWAYS"/>
</VBox>

<StackPane fx:id="statusbarPlaceholder" VBox.vgrow="NEVER" />
Expand Down

0 comments on commit 2f394f9

Please sign in to comment.