diff --git a/src/main/java/seedu/address/logic/commands/ViewLoansCommand.java b/src/main/java/seedu/address/logic/commands/ViewLoansCommand.java index 1ab9af86d50..77c7ab5440e 100644 --- a/src/main/java/seedu/address/logic/commands/ViewLoansCommand.java +++ b/src/main/java/seedu/address/logic/commands/ViewLoansCommand.java @@ -28,6 +28,7 @@ public CommandResult execute(Model model) { } else { model.updateFilteredLoanList(PREDICATE_SHOW_ALL_ACTIVE_LOANS); } + model.setIsLoansTab(true); return new CommandResult(MESSAGE_SUCCESS, false, false, true); } } diff --git a/src/main/java/seedu/address/model/ModelManager.java b/src/main/java/seedu/address/model/ModelManager.java index cd0ec29d0ce..dc223243cb7 100644 --- a/src/main/java/seedu/address/model/ModelManager.java +++ b/src/main/java/seedu/address/model/ModelManager.java @@ -221,8 +221,10 @@ public BooleanProperty getIsLoansTab() { @Override public void setIsLoansTab(Boolean isLoansTab) { + System.out.println("Method setIsLoansTab called inside ModelManager"); if (isLoansTab) { this.isAnalyticsTab.setValue(false); + this.isPersonTab.setValue(false); } this.isLoansTab.setValue(isLoansTab); } @@ -234,14 +236,17 @@ public BooleanProperty getIsAnalyticsTab() { @Override public void setToPersonTab() { + System.out.println("Method setToPersonTab called inside ModelManager"); this.isLoansTab.setValue(false); this.isAnalyticsTab.setValue(false); + this.setIsPersonTab(true); } @Override public void setIsAnalyticsTab(Boolean isAnalyticsTab) { if (isAnalyticsTab) { this.isLoansTab.setValue(false); + this.isPersonTab.setValue(false); } this.isAnalyticsTab.setValue(isAnalyticsTab); } @@ -265,6 +270,7 @@ public BooleanProperty getIsPersonTab() { @Override public void setIsPersonTab(Boolean isPersonTab) { + System.out.println("Method setIsPersonTab called inside ModelManager"); if (isPersonTab) { this.isLoansTab.setValue(false); this.isAnalyticsTab.setValue(false); @@ -274,6 +280,7 @@ public void setIsPersonTab(Boolean isPersonTab) { @Override public void setDualPanel() { + System.out.println("Method setDualPanel called inside ModelManager"); this.isLoansTab.setValue(true); this.isPersonTab.setValue(true); this.isAnalyticsTab.setValue(false); diff --git a/src/main/java/seedu/address/ui/LoanListPanel.java b/src/main/java/seedu/address/ui/LoanListPanel.java index c54a903f7d9..6b85b6b8cdc 100644 --- a/src/main/java/seedu/address/ui/LoanListPanel.java +++ b/src/main/java/seedu/address/ui/LoanListPanel.java @@ -31,8 +31,6 @@ public LoanListPanel(ObservableList loanList, ObservableList perso super(FXML); loanListView.setItems(loanList); loanListView.setCellFactory(listView -> new LoanListViewCell()); -// personListView.setItems(personList); -// personListView.setCellFactory(listView -> new PersonListViewCell()); } /** diff --git a/src/main/java/seedu/address/ui/MainWindow.java b/src/main/java/seedu/address/ui/MainWindow.java index 63aeef228ce..f5b03e8858b 100644 --- a/src/main/java/seedu/address/ui/MainWindow.java +++ b/src/main/java/seedu/address/ui/MainWindow.java @@ -185,9 +185,8 @@ private void initializeLocalListeners() { } private void toggleTabs() { - // At most one can be active at a time - // assert (!(this.isLoansTab.getValue() && this.isAnalyticsTab.getValue())); - + // At most one of these can be active at a time + assert (!(this.isLoansTab.getValue() && this.isAnalyticsTab.getValue())); if (isPersonTab.getValue() && isLoansTab.getValue()) { // Default to person list panel clearAllPlaceholders(); @@ -198,19 +197,24 @@ private void toggleTabs() { VBox.setVgrow(loanList, Priority.ALWAYS); loanListPanelPlaceholder.getChildren().add(loanListPanel.getRoot()); VBox.setVgrow(analytics, Priority.NEVER); + personListPanelPlaceholder.setMaxHeight(240); + System.out.println("Both tabs are active"); } else if (isPersonTab.getValue()) { // Default to person list panel clearAllPlaceholders(); + personListPanelPlaceholder.setMaxHeight(Double.POSITIVE_INFINITY); VBox.setVgrow(personList, Priority.ALWAYS); VBox.setVgrow(loanList, Priority.NEVER); VBox.setVgrow(analytics, Priority.NEVER); personListPanelPlaceholder.getChildren().add(personListPanel.getRoot()); + System.out.println("Only person tab is active"); } else if (this.isLoansTab.getValue()) { clearAllPlaceholders(); VBox.setVgrow(loanList, Priority.ALWAYS); VBox.setVgrow(personList, Priority.NEVER); VBox.setVgrow(analytics, Priority.NEVER); loanListPanelPlaceholder.getChildren().add(loanListPanel.getRoot()); + System.out.println("Only loans tab is active"); } else { clearAllPlaceholders(); VBox.setVgrow(analytics, Priority.ALWAYS); @@ -293,7 +297,7 @@ private CommandResult executeCommand(String commandText) throws CommandException handleExit(); } // Enable/Disable the loan tab based on whether command is loan related - logic.setIsLoansTab(commandResult.isLoanRelated()); + // logic.setIsLoansTab(commandResult.isLoanRelated()); return commandResult; } catch (CommandException | ParseException e) { diff --git a/src/test/java/seedu/address/logic/commands/AddCommandTest.java b/src/test/java/seedu/address/logic/commands/AddCommandTest.java index 9727afecd2d..fedd16dd75e 100644 --- a/src/test/java/seedu/address/logic/commands/AddCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/AddCommandTest.java @@ -209,6 +209,21 @@ public ObjectProperty getDashboardData() { throw new AssertionError("This method should not be called."); } + @Override + public BooleanProperty getIsPersonTab() { + throw new AssertionError("This method should not be called."); + } + + @Override + public void setIsPersonTab(Boolean isPersonTab) { + throw new AssertionError("This method should not be called."); + } + + @Override + public void setDualPanel() { + throw new AssertionError("This method should not be called."); + } + @Override public void deleteLoan(Loan loan) { throw new AssertionError("This method should not be called.");