From d0614e88dfea7f5ca70c3d3853eb8162164f5824 Mon Sep 17 00:00:00 2001 From: KrashKart Date: Sun, 20 Oct 2024 15:39:03 +0800 Subject: [PATCH 1/5] Change initialisation behaviour New users start with an empty list --- src/main/java/seedu/address/MainApp.java | 11 +++++++---- .../seedu/address/model/util/EmptyDataUtil.java | 13 +++++++++++++ .../seedu/address/model/util/SampleDataUtil.java | 1 - 3 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 src/main/java/seedu/address/model/util/EmptyDataUtil.java diff --git a/src/main/java/seedu/address/MainApp.java b/src/main/java/seedu/address/MainApp.java index 173fa156ced..91858a54630 100644 --- a/src/main/java/seedu/address/MainApp.java +++ b/src/main/java/seedu/address/MainApp.java @@ -21,7 +21,7 @@ import seedu.address.model.ReadOnlyCampusConnect; import seedu.address.model.ReadOnlyUserPrefs; import seedu.address.model.UserPrefs; -import seedu.address.model.util.SampleDataUtil; +import seedu.address.model.util.EmptyDataUtil; import seedu.address.storage.CampusConnectStorage; import seedu.address.storage.JsonCampusConnectStorage; import seedu.address.storage.JsonUserPrefsStorage; @@ -80,10 +80,13 @@ private Model initModelManager(Storage storage, ReadOnlyUserPrefs userPrefs) { try { campusConnectOptional = storage.readCampusConnect(); if (!campusConnectOptional.isPresent()) { - logger.info("Creating a new data file " + storage.getCampusConnectFilePath() - + " populated with a sample CampusConnect."); + // logger.info("Creating a new data file " + storage.getCampusConnectFilePath() + // + " populated with a sample CampusConnect."); + + logger.info("Creating a new data file at: " + storage.getCampusConnectFilePath()); } - initialData = campusConnectOptional.orElseGet(SampleDataUtil::getSampleCampusConnect); + // initialData = campusConnectOptional.orElseGet(SampleDataUtil::getSampleCampusConnect); + initialData = campusConnectOptional.orElseGet(EmptyDataUtil::getSampleCampusConnect); } catch (DataLoadingException e) { logger.warning("Data file at " + storage.getCampusConnectFilePath() + " could not be loaded." + " Will be starting with an empty CampusConnect."); diff --git a/src/main/java/seedu/address/model/util/EmptyDataUtil.java b/src/main/java/seedu/address/model/util/EmptyDataUtil.java new file mode 100644 index 00000000000..56cc55e1ad4 --- /dev/null +++ b/src/main/java/seedu/address/model/util/EmptyDataUtil.java @@ -0,0 +1,13 @@ +package seedu.address.model.util; + +import seedu.address.model.CampusConnect; +import seedu.address.model.ReadOnlyCampusConnect; + +/** + * Contains utility method for populating {@code CampusConnect} with empty data. + */ +public class EmptyDataUtil { + public static ReadOnlyCampusConnect getSampleCampusConnect() { + return new CampusConnect(); + } +} diff --git a/src/main/java/seedu/address/model/util/SampleDataUtil.java b/src/main/java/seedu/address/model/util/SampleDataUtil.java index c63cb2fd44b..15429433097 100644 --- a/src/main/java/seedu/address/model/util/SampleDataUtil.java +++ b/src/main/java/seedu/address/model/util/SampleDataUtil.java @@ -49,5 +49,4 @@ public static Set getTagSet(String... strings) { .map(Tag::new) .collect(Collectors.toSet()); } - } From cb2266e253773cc13e75eac5d980232a02e76223 Mon Sep 17 00:00:00 2001 From: KrashKart Date: Sun, 20 Oct 2024 16:26:31 +0800 Subject: [PATCH 2/5] Beautify GUI and add contact list empty messages --- .../seedu/address/logic/commands/AbstractFindCommand.java | 6 ++++++ .../java/seedu/address/logic/commands/DeleteCommand.java | 7 ++++++- src/main/java/seedu/address/ui/MainWindow.java | 3 +++ src/main/resources/view/PersonListCard.fxml | 1 - src/main/resources/view/PersonListPanel.fxml | 2 +- 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/main/java/seedu/address/logic/commands/AbstractFindCommand.java b/src/main/java/seedu/address/logic/commands/AbstractFindCommand.java index b7d9b2b2983..b5e469f2d62 100644 --- a/src/main/java/seedu/address/logic/commands/AbstractFindCommand.java +++ b/src/main/java/seedu/address/logic/commands/AbstractFindCommand.java @@ -42,6 +42,12 @@ protected ContainsKeywordsPredicate getPredicate() { public CommandResult execute(Model model) { requireNonNull(model); model.updateFilteredPersonList(this.predicate); + + // if the result find list is empty + if (model.getFilteredPersonList().isEmpty()) { + return new CommandResult(String.format("No persons found!")); + } + return new CommandResult( String.format(Messages.MESSAGE_PERSONS_LISTED_OVERVIEW, model.getFilteredPersonList().size())); } diff --git a/src/main/java/seedu/address/logic/commands/DeleteCommand.java b/src/main/java/seedu/address/logic/commands/DeleteCommand.java index 1135ac19b74..903678c8ca9 100644 --- a/src/main/java/seedu/address/logic/commands/DeleteCommand.java +++ b/src/main/java/seedu/address/logic/commands/DeleteCommand.java @@ -42,7 +42,12 @@ public CommandResult execute(Model model) throws CommandException { Person personToDelete = lastShownList.get(targetIndex.getZeroBased()); model.deletePerson(personToDelete); - return new CommandResult(String.format(MESSAGE_DELETE_PERSON_SUCCESS, Messages.format(personToDelete))); + + String result = String.format(MESSAGE_DELETE_PERSON_SUCCESS, personToDelete); + if (model.getFilteredPersonList().isEmpty()) { + result += "\nThe contact list is empty! :("; + } + return new CommandResult(result); } @Override diff --git a/src/main/java/seedu/address/ui/MainWindow.java b/src/main/java/seedu/address/ui/MainWindow.java index a61d11cd688..0d5b4d859ad 100644 --- a/src/main/java/seedu/address/ui/MainWindow.java +++ b/src/main/java/seedu/address/ui/MainWindow.java @@ -115,6 +115,9 @@ void fillInnerParts() { resultDisplay = new ResultDisplay(); resultDisplayPlaceholder.getChildren().add(resultDisplay.getRoot()); + if (logic.getFilteredPersonList().isEmpty()) { + resultDisplay.setFeedbackToUser("The contact list is empty! :("); + } StatusBarFooter statusBarFooter = new StatusBarFooter(logic.getCampusConnectFilePath()); statusbarPlaceholder.getChildren().add(statusBarFooter.getRoot()); diff --git a/src/main/resources/view/PersonListCard.fxml b/src/main/resources/view/PersonListCard.fxml index c6f33eb1e2f..f672f6ab9fa 100644 --- a/src/main/resources/view/PersonListCard.fxml +++ b/src/main/resources/view/PersonListCard.fxml @@ -29,7 +29,6 @@