Skip to content

Commit

Permalink
Merge branch 'master' into v1.3userguideupdates
Browse files Browse the repository at this point in the history
  • Loading branch information
purivirakarin authored Apr 4, 2024
2 parents cde0ac6 + 93ac353 commit 6153722
Show file tree
Hide file tree
Showing 64 changed files with 880 additions and 1,270 deletions.
6 changes: 4 additions & 2 deletions src/main/java/seedu/address/MainApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@
import seedu.address.storage.JsonNetConnectStorage;
import seedu.address.storage.JsonUserPrefsStorage;
import seedu.address.storage.NetConnectStorage;
import seedu.address.storage.StateStorage;
import seedu.address.storage.Storage;
import seedu.address.storage.StorageManager;
import seedu.address.storage.TextStateStorage;
import seedu.address.storage.UserPrefsStorage;
import seedu.address.ui.Ui;
import seedu.address.ui.UiManager;
Expand Down Expand Up @@ -58,8 +60,8 @@ public void init() throws Exception {
UserPrefsStorage userPrefsStorage = new JsonUserPrefsStorage(config.getUserPrefsFilePath());
UserPrefs userPrefs = initPrefs(userPrefsStorage);
NetConnectStorage netConnectStorage = new JsonNetConnectStorage(userPrefs.getNetConnectFilePath());

storage = new StorageManager(netConnectStorage, userPrefsStorage);
StateStorage stateStorage = new TextStateStorage();
storage = new StorageManager(netConnectStorage, userPrefsStorage, stateStorage);

model = initModelManager(storage, userPrefs);

Expand Down
69 changes: 0 additions & 69 deletions src/main/java/seedu/address/commons/core/index/Index.java

This file was deleted.

8 changes: 4 additions & 4 deletions src/main/java/seedu/address/commons/util/StringUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ public static boolean containsWordIgnoreCase(String sentence, String word) {

/**
* Returns true if the {@code source} contains the {@code target}.
* Ignores case, and a partial match also returns true.
* Ignores case, and a partial match returns true.
* <br>examples:<pre>
* hasPartialMatchIgnoreCase("ABc def", "abc") == true
* hasPartialMatchIgnoreCase("ABc def", "DEF") == true
* hasPartialMatchIgnoreCase("abc", "ABc def") == true
* hasPartialMatchIgnoreCase("DEF", "ABc def") == true
* // partial match, compared to return false in {@link #containsWordIgnoreCase(String, String)}
* hasPartialMatchIgnoreCase("ABc def", "AB") == true
* hasPartialMatchIgnoreCase("AB", "ABc def") == true
* </pre>
*
* @param target cannot be null, cannot be empty
Expand Down
1 change: 0 additions & 1 deletion src/main/java/seedu/address/logic/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public class Messages {

public static final String MESSAGE_UNKNOWN_COMMAND = "Unknown command";
public static final String MESSAGE_INVALID_COMMAND_FORMAT = "Invalid command format! \n%1$s";
public static final String MESSAGE_INVALID_PERSON_DISPLAYED_INDEX = "The person index provided is invalid";
public static final String MESSAGE_CANNOT_RELATE_ITSELF = "Cannot relate a person to his/herself.";
public static final String MESSAGE_RELATION_EXISTS = "This relation already exists.";
public static final String MESSAGE_RELATION_NOT_EXISTS = "This relation does not exist.";
Expand Down
23 changes: 21 additions & 2 deletions src/main/java/seedu/address/logic/commands/ClearCommand.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package seedu.address.logic.commands;

import static java.util.Objects.requireNonNull;
import static seedu.address.ui.MainWindow.handleDestructiveCommands;

import seedu.address.model.Model;
import seedu.address.model.NetConnect;
Expand All @@ -11,12 +12,30 @@
public class ClearCommand extends Command {

public static final String COMMAND_WORD = "clear";
public static final String MESSAGE_SUCCESS = "Address book has been cleared!";
public static final String CLEAR_SUCCESS_MESSAGE = "Address book has been cleared!";
public static final String CLEAR_CANCELLED_MESSAGE = "Clear command cancelled";
private static boolean doNotSkipConfirmation = true;

@Override
public CommandResult execute(Model model) {
requireNonNull(model);

if (doNotSkipConfirmation) {
boolean isConfirmed = handleDestructiveCommands(false, true);
if (!isConfirmed) {
return new CommandResult(CLEAR_CANCELLED_MESSAGE, false, false);
}
}

model.setNetConnect(new NetConnect());
return new CommandResult(MESSAGE_SUCCESS);
return new CommandResult(CLEAR_SUCCESS_MESSAGE, false, false);
}

public static void setUpForTesting() {
doNotSkipConfirmation = false;
}

public static void cleanUpAfterTesting() {
doNotSkipConfirmation = true;
}
}
21 changes: 20 additions & 1 deletion src/main/java/seedu/address/logic/commands/DeleteCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static java.util.Objects.requireNonNull;
import static seedu.address.logic.parser.CliSyntax.PREFIX_ID;
import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME;
import static seedu.address.ui.MainWindow.handleDestructiveCommands;

import java.util.Objects;

Expand Down Expand Up @@ -40,7 +41,8 @@ public class DeleteCommand extends Command {
+ "Example: " + COMMAND_WORD + " i/1";

public static final String MESSAGE_DELETE_PERSON_SUCCESS = "Deleted Person: %1$s";

public static final String MESSAGE_DELETE_CANCELLED = "Delete cancelled";
private static boolean doNotSkipConfirmation = true;
private final Id targetId;
private final Name targetName;

Expand All @@ -52,6 +54,7 @@ private DeleteCommand(Id targetId, Name name) {
/**
* Factory method to create a {@code DeleteCommand} that deletes a Person
* by the given id.
*
* @param id The id of the {@code Person} to be deleted
* @return {@code DeleteCommand} to delete by id
*/
Expand All @@ -63,6 +66,7 @@ public static DeleteCommand byId(Id id) {
/**
* Factory method to create a {@code DeleteCommand} that deletes a Person
* by the given name.
*
* @param name The name of the {@code Person} to be deleted
* @return {@code DeleteCommand} to delete by name
*/
Expand All @@ -76,6 +80,13 @@ public CommandResult execute(Model model) throws CommandException {
requireNonNull(model);
assert targetId != null ^ targetName != null;

if (doNotSkipConfirmation) {
boolean isConfirmed = handleDestructiveCommands(true, false);
if (!isConfirmed) {
return new CommandResult(MESSAGE_DELETE_CANCELLED, false, false);
}
}

Person personToDelete = getPersonToDelete(model);

boolean showList = !model.getFilteredPersonList().contains(personToDelete);
Expand Down Expand Up @@ -126,6 +137,14 @@ public boolean equals(Object other) {
&& Objects.equals(targetName, otherDeleteCommand.targetName);
}

public static void setUpForTesting() {
doNotSkipConfirmation = false;
}

public static void cleanUpAfterTesting() {
doNotSkipConfirmation = true;
}

@Override
public String toString() {
return new ToStringBuilder(this)
Expand Down
34 changes: 26 additions & 8 deletions src/main/java/seedu/address/logic/commands/FindCommand.java
Original file line number Diff line number Diff line change
@@ -1,26 +1,44 @@
package seedu.address.logic.commands;

import static java.util.Objects.requireNonNull;
import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME;
import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_REMARK;
import static seedu.address.logic.parser.CliSyntax.PREFIX_ROLE;
import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG;

import seedu.address.commons.util.ToStringBuilder;
import seedu.address.logic.Messages;
import seedu.address.model.Model;
import seedu.address.model.person.Person;
import seedu.address.model.person.filter.Filter;
import seedu.address.model.person.filter.NetConnectPredicate;

/**
* Finds and lists all persons in address book whose name contains any of the argument keywords.
* Keyword matching is case insensitive.
* Finds and lists all persons in NetConnect whose information matches any of the given arguments.
* Keyword matching is case-insensitive.
* Find command supports finding by: name, tag, role, and remark.
*/
public class FindCommand extends Command {

public static final String COMMAND_WORD = "find";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Finds all persons whose names contain any of "
+ "the specified keywords (case-insensitive) and displays them as a list with index numbers.\n"
+ "Parameters: find [n/NAME] [t/TAG] [p/PHONE] [role/ROLE] [r/REMARK]\n"
+ "Example: " + COMMAND_WORD + "n/Alice";
public static final String MESSAGE_USAGE = COMMAND_WORD
+ ": Finds all persons whose information matches any of the given arguments.\n"
+ "Only one type of argument can be given per " + COMMAND_WORD + " command.\n"
+ "Name, phone, tag and role cannot be empty. "
+ "Remark can be empty to find persons with no remarks.\n"
+ "Parameters: "
+ "[" + PREFIX_NAME + "NAME]... "
+ "[" + PREFIX_PHONE + "PHONE]..."
+ "[" + PREFIX_TAG + "TAG]... "
+ "[" + PREFIX_ROLE + "ROLE]... "
+ "[" + PREFIX_REMARK + "REMARK]... \n"
+ "Examples: \n"
+ COMMAND_WORD + " n/alice n/bob n/charlie\n"
+ COMMAND_WORD + " p/91278539 p/83489532\n"
+ COMMAND_WORD + " t/friends t/colleagues\n"
+ COMMAND_WORD + " role/client\n"
+ COMMAND_WORD + " r/owes money r/quarterly report";

private final NetConnectPredicate<Person> predicate;

Expand All @@ -33,7 +51,7 @@ public CommandResult execute(Model model) {
requireNonNull(model);
model.stackFilters(predicate);
String output = String.format(Messages.MESSAGE_PERSONS_LISTED_OVERVIEW, model.getFilteredPersonList().size())
+ "\n" + String.format(Filter.MESSAGE_FILTERS_APPLIED, model.printFilters());
+ "\n" + model.printFilters();
return new CommandResult(output);
}

Expand Down
59 changes: 0 additions & 59 deletions src/main/java/seedu/address/logic/commands/FindNumCommand.java

This file was deleted.

Loading

0 comments on commit 6153722

Please sign in to comment.