Skip to content

Commit

Permalink
Merge e0ed714 into 7c7cd32
Browse files Browse the repository at this point in the history
  • Loading branch information
t-cheepeng committed Nov 9, 2019
2 parents 7c7cd32 + e0ed714 commit 38bbc13
Show file tree
Hide file tree
Showing 26 changed files with 187 additions and 101 deletions.
107 changes: 107 additions & 0 deletions data/exercisedatabase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
{
"jsonResources" : [ {
"name" : "Bench Press",
"date" : "07/11/2019",
"calories" : "150",
"quantity" : "40",
"unit" : "counts",
"muscles" : [ "Chest", "Triceps" ],
"customProperties" : { }
}, {
"name" : "Bicep Curl",
"date" : "07/11/2019",
"calories" : "20",
"quantity" : "10",
"unit" : "kg",
"muscles" : [ "Biceps" ],
"customProperties" : { }
}, {
"name" : "Crunches",
"date" : "07/11/2019",
"calories" : "20",
"quantity" : "10",
"unit" : "counts",
"muscles" : [ "Abs" ],
"customProperties" : { }
}, {
"name" : "Deadlift",
"date" : "07/11/2019",
"calories" : "100",
"quantity" : "100",
"unit" : "kg",
"muscles" : [ "Legs", "Back", "Hamstring", "Butt" ],
"customProperties" : { }
}, {
"name" : "Farmer Walk",
"date" : "07/11/2019",
"calories" : "50",
"quantity" : "20",
"unit" : "kg",
"muscles" : [ "Shoulders", "Forearms" ],
"customProperties" : { }
}, {
"name" : "High Jumper",
"date" : "07/11/2019",
"calories" : "20",
"quantity" : "10",
"unit" : "counts",
"muscles" : [ "Legs" ],
"customProperties" : { }
}, {
"name" : "Jumping jacks",
"date" : "07/11/2019",
"calories" : "20",
"quantity" : "100",
"unit" : "counts",
"muscles" : [ "Legs" ],
"customProperties" : { }
}, {
"name" : "Pull Ups",
"date" : "07/11/2019",
"calories" : "20",
"quantity" : "100",
"unit" : "counts",
"muscles" : [ "Back" ],
"customProperties" : { }
}, {
"name" : "Push Ups",
"date" : "07/11/2019",
"calories" : "20",
"quantity" : "100",
"unit" : "counts",
"muscles" : [ "Chest", "Triceps" ],
"customProperties" : { }
}, {
"name" : "Run",
"date" : "07/11/2019",
"calories" : "200",
"quantity" : "10",
"unit" : "km",
"muscles" : [ "Legs" ],
"customProperties" : { }
}, {
"name" : "Sit ups",
"date" : "07/11/2019",
"calories" : "20",
"quantity" : "100",
"unit" : "counts",
"muscles" : [ "Abs" ],
"customProperties" : { }
}, {
"name" : "Squat Bender",
"date" : "07/11/2019",
"calories" : "20",
"quantity" : "100",
"unit" : "counts",
"muscles" : [ "Legs" ],
"customProperties" : { }
}, {
"name" : "Squats",
"date" : "07/11/2019",
"calories" : "100",
"quantity" : "100",
"unit" : "counts",
"muscles" : [ "Quads", "Legs", "Butt" ],
"customProperties" : { }
} ]
}
4 changes: 4 additions & 0 deletions docs/UserGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,9 @@ image::EditExerciseAfter2.png[]

Deleting a certain exercise information from ExerHealth.

[NOTE]
Deleting an exercise from ExerHealth will not cause it to be deleted from your list of regimes and schedules. If you wish to delete an exercise from a regime, refer to <<deleteExerciseFromRegime>>. If you wish to complete a scheduled regime, refer to <<schedulecomplete>>

Format: `delete t/exercise i/INDEX`

****
Expand All @@ -252,6 +255,7 @@ Expected result:

image::deleteExerciseAfter.png[]

[[deleteExerciseFromRegime]]
==== Deleting exercise from scheduling regime

Deletes exercises from a certain scheduling regime.
Expand Down
2 changes: 1 addition & 1 deletion docs/diagrams/ScheduleConflictSequenceDiagram.puml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ deactivate Model
Logic --[LOGIC_COLOR]> Ui: CommandResult("Schedule Conflict")
deactivate Logic

Ui -[UI_COLOR]> Ui: createResolveWindow()
Ui -[UI_COLOR]> Ui: showResolveWindow()
activate Ui UI_COLOR_T1
return
Ui --[UI_COLOR]> User
Expand Down
Binary file modified docs/images/ScheduleConflict.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/team/garylyp.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/team/t-cheepeng.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ at a particular date. However, this difficulty was remedied as described in *Maj
** Justification: This feature will allow users the flexibility to select which exercises they wish to do from the conflicting scheduled regimes. It also allows users to store the resolved regime and use it in the future.
** Highlights: This enhancement works well with *major enhancement 1* as there is a direct link between the two. The implementation of this feature was particularly challenging because multiple resources had to be kept track of. Also, there was a need to prevent users from proceeding on with normal usage of the program until they resolve the scheduling conflict. The aforementioned requirement was technically challenging and multiple facets had to be considered in the implementation of the feature.

* *Minor enhancement 1*: Added the display panel in the center of our UI to display more information on the selected resource on the left panel of our UI.
* *Minor enhancement 1*: Added the display panel in the center of our UI to display more information of the selected resource.

* *Code contributed*: [https://nus-cs2103-ay1920s1.github.io/tp-dashboard/#search=t-cheepeng&sort=groupTitle&sortWithin=title&since=2019-09-06&timeframe=commit&mergegroup=false&groupSelect=groupByRepos&breakdown=false[RepoSense]]

Expand Down
Binary file removed docs/team/t-cheepeng.pdf
Binary file not shown.
3 changes: 3 additions & 0 deletions src/main/java/seedu/exercise/MainApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public void init() throws Exception {
logic = new LogicManager(model, storage);

ui = new UiManager(logic);
setState(State.NORMAL);
}

/**
Expand Down Expand Up @@ -303,6 +304,8 @@ public static State getState() {
*/
public static void setState(State newState) {
requireAllNonNull(newState);
logger.info("Application state changing from " + getState() + " to " + newState.toString());

state = newState;
}
}
3 changes: 3 additions & 0 deletions src/main/java/seedu/exercise/logic/LogicManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
* The main LogicManager of the app.
*/
public class LogicManager implements Logic {

public static final String FILE_OPS_ERROR_MESSAGE = "Could not save data to file: ";
private final Logger logger = LogsCenter.getLogger(LogicManager.class);

Expand All @@ -51,6 +52,7 @@ public CommandResult execute(String commandText) throws CommandException, ParseE
CommandResult commandResult;
Command command = exerciseBookParser.parseCommand(commandText);
if (!isCommandExecutedInCorrectState(command)) {
logger.info(command.getClass().getSimpleName() + " executed in wrong state: State." + MainApp.getState());
throw new CommandException(String.format(MESSAGE_INVALID_CONTEXT, command.getClass().getSimpleName()));
}

Expand All @@ -59,6 +61,7 @@ public CommandResult execute(String commandText) throws CommandException, ParseE
try {
saveAllData();
} catch (IOException ioe) {
logger.info(FILE_OPS_ERROR_MESSAGE + ioe);
throw new CommandException(FILE_OPS_ERROR_MESSAGE + ioe, ioe);
}

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/seedu/exercise/model/ModelManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,9 @@ public Schedule resolveConflict(Name name, List<Index> indexFromSchedule, List<I
addCombinedRegime(resolvedSchedule.getRegime());
addResolvedSchedule(resolvedSchedule);
}

logger.info("Schedule conflict resolved: " + resolvedSchedule.getRegimeName()
+ " on " + resolvedSchedule.getDate());
return resolvedSchedule;
}

Expand All @@ -287,6 +290,7 @@ public void setConflict(Conflict conflict) {
requireMainAppState(State.IN_CONFLICT);
requireNonNull(conflict);

logger.info("Conflict set:\n" + conflict);
this.conflict = conflict;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,6 @@ public int hashCode() {

@Override
public String toString() {
return "" + resources.asUnmodifiableObservableList().size() + " exercises.";
return "" + resources.asUnmodifiableObservableList().size() + " resources.";
}
}
6 changes: 6 additions & 0 deletions src/main/java/seedu/exercise/model/UserPrefs.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Objects;
import java.util.logging.Logger;

import seedu.exercise.commons.core.GuiSettings;
import seedu.exercise.commons.core.LogsCenter;

/**
* Represents User's preferences.
*/
public class UserPrefs implements ReadOnlyUserPrefs {

private static final Logger logger = LogsCenter.getLogger(UserPrefs.class);

private GuiSettings guiSettings = new GuiSettings();
private Path exerciseBookFilePath = Paths.get("data" , "exercisebook.json");
private Path propertyBookFilePath = Paths.get("data", "propertybook.json");
Expand Down Expand Up @@ -43,6 +47,8 @@ public void resetData(ReadOnlyUserPrefs newUserPrefs) {
setRegimeBookFilePath(newUserPrefs.getRegimeBookFilePath());
setPropertyBookFilePath(newUserPrefs.getPropertyBookFilePath());
setAllExerciseBookFilePath(newUserPrefs.getAllExerciseBookFilePath());

logger.info("All user preferences reset to:\n" + newUserPrefs);
}

public GuiSettings getGuiSettings() {
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/seedu/exercise/model/conflict/Conflict.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,10 @@ public boolean equals(Object other) {
public int hashCode() {
return Objects.hash(scheduled, conflicted);
}

@Override
public String toString() {
return "Scheduled: " + scheduled.getRegimeName() + "\nConflicting: " + conflicted.getRegimeName()
+ "\nDate of conflict: " + scheduled.getDate();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.logging.Logger;
import java.util.stream.Collectors;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRootName;

import seedu.exercise.commons.core.LogsCenter;
import seedu.exercise.commons.exceptions.IllegalValueException;
import seedu.exercise.model.property.CustomProperty;
import seedu.exercise.model.property.PropertyBook;
Expand All @@ -21,6 +23,8 @@
@JsonRootName(value = "propertybook")
public class JsonSerializablePropertyBook {

private static final Logger logger = LogsCenter.getLogger(JsonSerializablePropertyBook.class);

private final List<JsonAdaptedCustomProperty> customProperties = new ArrayList<>();

/**
Expand Down Expand Up @@ -58,6 +62,7 @@ public PropertyBook toModelBook() throws IllegalValueException {
CustomProperty modelProperty = jsonCustomProperty.toModelType();
if (propertyBook.hasClashingPrefixOrName(modelProperty)) {
propertyBook.clearCustomProperties();
logger.info("Duplicates found in serializable property book.");
throw new IllegalValueException(MESSAGE_DUPLICATE_NAME_OR_PREFIX);
}
propertyBook.addCustomProperty(modelProperty);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/exercise/storage/StorageBook.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
public class StorageBook implements Storage {

private static final Logger logger = LogsCenter.getLogger(StorageBook.class);

private ResourceBookStorage<Exercise> exerciseBookStorage;
private ResourceBookStorage<Exercise> exerciseDatabaseStorage;
private ResourceBookStorage<Regime> regimeBookStorage;
private ResourceBookStorage<Schedule> scheduleBookStorage;
private UserPrefsStorage userPrefsStorage;
private PropertyBookStorage propertyBookStorage;


public StorageBook(ResourceBookStorage<Exercise> exerciseBookStorage,
ResourceBookStorage<Exercise> exerciseDatabaseStorage,
ResourceBookStorage<Regime> regimeBookStorage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.logging.Logger;
import java.util.stream.Collectors;

import seedu.exercise.commons.core.LogsCenter;
import seedu.exercise.commons.exceptions.IllegalValueException;
import seedu.exercise.model.ReadOnlyResourceBook;
import seedu.exercise.model.resource.Resource;
Expand All @@ -19,6 +21,8 @@ public abstract class SerializableResourceBook<T extends JsonAdaptedResource<U>,

public static final String MESSAGE_DUPLICATE_RESOURCE = "The list has duplicate exercises/regimes/schedules.";

private static final Logger logger = LogsCenter.getLogger(SerializableResourceBook.class);

private final List<T> jsonResources = new ArrayList<>();

public SerializableResourceBook(List<T> jsonResources) {
Expand All @@ -44,6 +48,7 @@ public ReadOnlyResourceBook<U> toModelType(Class<U> clazz, Comparator<U> compara
for (JsonAdaptedResource jsonResource : jsonResources) {
U resourceModel = clazz.cast(jsonResource.toModelType());
if (resourceBook.hasResource(resourceModel)) {
logger.info("The list to convert has duplicates.");
throw new IllegalValueException(MESSAGE_DUPLICATE_RESOURCE);
}
resourceBook.addResource(resourceModel);
Expand Down
16 changes: 0 additions & 16 deletions src/main/java/seedu/exercise/ui/ExerciseListPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import static java.util.Objects.requireNonNull;

import javafx.application.Platform;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.scene.control.Label;
Expand Down Expand Up @@ -39,21 +38,6 @@ public void setPanelTitleText(String title) {
exerciseTitle.setText(title);
}

@Override
protected void selectGivenIndex(int index) {
if (index >= 0) {
/*
An extremely hacky way to get the list to select, focus and scroll to the newly changed item.
Without this method, when any add/edit commands are supplied, the ListChangeListener attached to
ObservableList is called first without the list actually changing its structure. So when the index
is provided, the listview is not updated and thus cannot be focused on.
So the solution is to make this focusing operation be done at a slightly later time when the
list view has been updated to reflect the commands changes
*/
Platform.runLater(() -> selectFocusAndScrollTo(exerciseListView, index));
}
}

@Override
protected void resetListSelection() {
exerciseListView.getSelectionModel().clearSelection();
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/seedu/exercise/ui/InfoDisplayPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,13 @@ public void update(Resource resource) {
infoPanelPlaceholder.getChildren().clear();
if (resource instanceof Exercise) {
infoPanelPlaceholder.getChildren().add(new ExerciseInfoPanel((Exercise) resource).getRoot());
logCurrentInfoShown("exercise");
} else if (resource instanceof Regime) {
infoPanelPlaceholder.getChildren().add(new RegimeInfoPanel((Regime) resource).getRoot());
logCurrentInfoShown("regime");
} else if (resource instanceof Schedule) {
infoPanelPlaceholder.getChildren().add(new ScheduleInfoPanel((Schedule) resource).getRoot());
logCurrentInfoShown("schedule");
}
}

Expand All @@ -48,5 +51,10 @@ public void update(Resource resource) {
public void showDefaultMessage() {
infoPanelPlaceholder.getChildren().clear();
infoPanelPlaceholder.getChildren().add(new Label(DEFAULT_MESSAGE));
logCurrentInfoShown("default message");
}

private void logCurrentInfoShown(String infoShown) {
logger.info("Info panel displaying " + infoShown);
}
}
3 changes: 3 additions & 0 deletions src/main/java/seedu/exercise/ui/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ private void initListenersForResourceListPanels() {
regimeListPanel.setOnItemSelectListener(getListener());
scheduleListPanel.setOnItemSelectListener(getListener());
suggestionListPanel.setOnItemSelectListener(getListener());

logger.info("Listeners for resource list panels set");
}

private ResourceListPanel.OnItemSelectListener getListener() {
Expand Down Expand Up @@ -344,6 +346,7 @@ private void handleExit() {
* Checks if a the resource list has to change based on the {@code CommandResult}
*/
private void updateResourceListTab(CommandResult commandResult, int index) {
logger.info("Changing resource list panel to show " + commandResult.getShowListResourceType());
switch (commandResult.getShowListResourceType()) {
case NULL:
//no change to GUI
Expand Down
Loading

0 comments on commit 38bbc13

Please sign in to comment.