diff --git a/src/main/java/seedu/address/ui/MainWindow.java b/src/main/java/seedu/address/ui/MainWindow.java index 480d6f270dd..d96e71b9e04 100644 --- a/src/main/java/seedu/address/ui/MainWindow.java +++ b/src/main/java/seedu/address/ui/MainWindow.java @@ -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; @@ -36,7 +37,10 @@ public class MainWindow extends UiPart { private ResultDisplay resultDisplay; private HelpWindow helpWindow; private ViewWindow viewWindow; + private CommandListPanel commandListPanel; + @FXML + private VBox personList; @FXML private FlowPane calendar; @FXML @@ -53,6 +57,8 @@ public class MainWindow extends UiPart { @FXML private StackPane statusbarPlaceholder; + @FXML + private StackPane commandListPanelPlaceholder; /** * Creates a {@code MainWindow} with the given {@code Stage} and {@code Logic}. @@ -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()); @@ -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. */ @@ -185,6 +217,10 @@ public PersonListPanel getPersonListPanel() { return personListPanel; } + public CommandListPanel getCommandListPanel() { + return commandListPanel; + } + /** * Executes the command and returns the result. * @@ -204,6 +240,12 @@ private CommandResult executeCommand(String commandText) throws CommandException handleView(); } + if (commandResult.isShowHistory()) { + toggleHistoryList(); + } else { + toggleStudentList(); + } + if (commandResult.isExit()) { handleExit(); } diff --git a/src/main/resources/view/MainWindow.fxml b/src/main/resources/view/MainWindow.fxml index e477d799605..fa55ab85643 100644 --- a/src/main/resources/view/MainWindow.fxml +++ b/src/main/resources/view/MainWindow.fxml @@ -51,6 +51,7 @@ +