Skip to content

Commit

Permalink
Fix bug for list command and select (#201)
Browse files Browse the repository at this point in the history
* Fix bug for list command and select

* Add documentation
  • Loading branch information
t-cheepeng committed Nov 5, 2019
1 parent f9e6bd2 commit 27b8526
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 18 deletions.
2 changes: 1 addition & 1 deletion docs/team/t-cheepeng.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

== Overview

My team of 4 computer science students were tasked with changing a basic command line application. Our team
My team of 5 computer science students were tasked with changing a basic command line application. Our team
decided to morph the application into ExerHealth. **ExerHealth** is a desktop application used for tracking
and scheduling the user's exercises. The application has statistical analysis of exercises users have completed
in the past. Additionally, it also acts as a personal trainer by suggesting different exercises which both
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/seedu/exercise/ui/ExerciseListPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public ExerciseListPanel(ObservableList<Exercise> exerciseList) {
exerciseListView.getFocusModel().focusedItemProperty().addListener(getDefaultListViewListener());
}

public ListView<Exercise> getExerciseListView() {
public ListView<Exercise> getResourceListView() {
return exerciseListView;
}

Expand All @@ -54,6 +54,11 @@ protected void selectGivenIndex(int index) {
}
}

@Override
protected void resetListSelection() {
exerciseListView.getSelectionModel().clearSelection();
}

/**
* Custom {@code ListCell} that displays the graphics of a {@code Exercise} using a {@code ExerciseInfoPanel}.
*/
Expand Down
27 changes: 19 additions & 8 deletions src/main/java/seedu/exercise/ui/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ public class MainWindow extends UiPart<Stage> {
private HelpWindow helpWindow;
private ResolveWindow resolveWindow;
private CustomPropertiesWindow customPropertiesWindow;
private ExerciseListPanel exerciseListPanel;
private RegimeListPanel regimeListPanel;
private ScheduleListPanel scheduleListPanel;
private SuggestionListPanel suggestionListPanel;
private ResourceListPanel exerciseListPanel;
private ResourceListPanel regimeListPanel;
private ResourceListPanel scheduleListPanel;
private ResourceListPanel suggestionListPanel;
private InfoDisplayPanel infoDisplayPanel;
private StatsDisplayPanel statsDisplayPanel;

Expand Down Expand Up @@ -112,19 +112,19 @@ void fillInnerParts() {

exerciseListPanel = new ExerciseListPanel(logic.getSortedExerciseList());
exerciseListTabPlaceholder = new Tab();
exerciseListTabPlaceholder.setContent((exerciseListPanel).getExerciseListView());
exerciseListTabPlaceholder.setContent(exerciseListPanel.getResourceListView());

regimeListPanel = new RegimeListPanel(logic.getSortedRegimeList());
regimeListTabPlaceholder = new Tab();
regimeListTabPlaceholder.setContent(regimeListPanel.getRegimeListView());
regimeListTabPlaceholder.setContent(regimeListPanel.getResourceListView());

scheduleListPanel = new ScheduleListPanel(logic.getSortedScheduleList());
scheduleListTabPlaceholder = new Tab();
scheduleListTabPlaceholder.setContent(scheduleListPanel.getScheduleListView());
scheduleListTabPlaceholder.setContent(scheduleListPanel.getResourceListView());

suggestionListPanel = new SuggestionListPanel(logic.getSuggestedExerciseList());
suggestionListTabPlaceholder = new Tab();
suggestionListTabPlaceholder.setContent(suggestionListPanel.getSuggestionListView());
suggestionListTabPlaceholder.setContent(suggestionListPanel.getResourceListView());

resourceListPanelPlaceholder.getTabs().add(exerciseListTabPlaceholder);
resourceListPanelPlaceholder.getTabs().add(regimeListTabPlaceholder);
Expand Down Expand Up @@ -222,6 +222,7 @@ private CommandResult executeCommand(String commandText) throws CommandException
resultDisplay.setFeedbackToUser(commandResult.getFeedbackToUser());
setChart();
setStats();
resetResourceListTabs();

shouldShowWindowsBasedOnCommandResult(commandResult);
shouldExitAppBasedOnCommandResult(commandResult);
Expand All @@ -235,6 +236,16 @@ private CommandResult executeCommand(String commandText) throws CommandException
}
}

/**
* Resets the selection models of the resource list panels on the left of the GUI.
*/
private void resetResourceListTabs() {
exerciseListPanel.resetListSelection();
regimeListPanel.resetListSelection();
scheduleListPanel.resetListSelection();
suggestionListPanel.resetListSelection();
}

/**
* Checks if a secondary window should be shown based on the command results.
* Method will show the windows if it is to be shown.
Expand Down
14 changes: 10 additions & 4 deletions src/main/java/seedu/exercise/ui/RegimeListPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ public RegimeListPanel(ObservableList<Regime> regimeList) {
regimeListView.getFocusModel().focusedItemProperty().addListener(getDefaultListViewListener());
}

public ListView<Regime> getRegimeListView() {
return regimeListView;
}

@Override
protected void selectGivenIndex(int index) {
if (index >= 0) {
Expand All @@ -46,6 +42,16 @@ protected void selectGivenIndex(int index) {
}
}

@Override
protected void resetListSelection() {
regimeListView.getSelectionModel().clearSelection();
}

@Override
protected ListView<Regime> getResourceListView() {
return regimeListView;
}

/**
* Custom {@code ListCell} that displays the graphics of a {@code Regime} using a {@code RegimeCard}.
*/
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/seedu/exercise/ui/ResourceListPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ public void onChanged(Change<? extends Resource> change) {

protected abstract void selectGivenIndex(int index);

protected abstract void resetListSelection();

protected abstract ListView<? extends Resource> getResourceListView();

/**
* Listener for item selection events in this {@code ResourceListPanel}.
*/
Expand Down
14 changes: 10 additions & 4 deletions src/main/java/seedu/exercise/ui/ScheduleListPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ public ScheduleListPanel(ObservableList<Schedule> scheduleList) {
scheduleListView.getFocusModel().focusedItemProperty().addListener(getDefaultListViewListener());
}

public ListView<Schedule> getScheduleListView() {
return scheduleListView;
}

@Override
protected void selectGivenIndex(int index) {
if (index >= 0) {
Expand All @@ -46,6 +42,16 @@ protected void selectGivenIndex(int index) {
}
}

@Override
protected void resetListSelection() {
scheduleListView.getSelectionModel().clearSelection();
}

@Override
protected ListView<Schedule> getResourceListView() {
return scheduleListView;
}

/**
* Custom {@code ListCell} that displays the graphics of a {@code Schedule} using a {@code ScheduleCard}.
*/
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/seedu/exercise/ui/SuggestionListPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ protected void selectGivenIndex(int index) {
}
}

@Override
protected void resetListSelection() {
suggestionListView.getSelectionModel().clearSelection();
}

@Override
protected ListView<Exercise> getResourceListView() {
return suggestionListView;
}

/**
* Custom {@code ListCell} that displays the graphics of a {@code Exercise} using a {@code ExerciseInfoPanel}.
*/
Expand Down

0 comments on commit 27b8526

Please sign in to comment.