Skip to content

Commit

Permalink
Merge pull request #17 from Lin-Shuang-Shuang/master
Browse files Browse the repository at this point in the history
update pr
  • Loading branch information
Lin-Shuang-Shuang authored Apr 15, 2024
2 parents 162cb7f + d5f4853 commit 0c373b8
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public class EditProjectNameCommand extends RenameCommand {

public static final String MESSAGE_PROJECT_NOT_FOUND = "Project %1$s not found: "
+ "Please make sure the project exists.";
public static final String MESSAGE_RESULTS_IN_DUPLICATE_PROJECT = "Project %1$s already exists: "
+ "Please set the name of the project to be unique.";
private final Name changeTo;
private final Project targetProject;
/**
Expand All @@ -43,9 +45,14 @@ public CommandResult execute(Model model) throws CommandException {
MESSAGE_PROJECT_NOT_FOUND,
Messages.format(targetProject)));
}
Project personToEdit = model.findProject(targetProject.getName());
Project newPerson = personToEdit.createEditedProject(changeTo);
model.setProject(personToEdit, newPerson);
Project projectToEdit = model.findProject(targetProject.getName());
Project newProject = projectToEdit.createEditedProject(changeTo);
if (model.hasProject(newProject)) {
throw new CommandException(String.format(
MESSAGE_RESULTS_IN_DUPLICATE_PROJECT,
Messages.format(newProject)));
}
model.setProject(projectToEdit, newProject);
model.updateFilteredProjectList(PREDICATE_SHOW_ALL_PROJECTS);
return new CommandResult(String.format(
MESSAGE_SUCCESS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public AddPersonCommand parse(String args) throws ParseException {
throw new ParseException(String.format(
MESSAGE_INVALID_COMMAND_FORMAT,
AddPersonCommand.MESSAGE_USAGE));
} catch (IllegalArgumentException e) {
throw new ParseException("Please enter valid names.");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public AddTaskCommand parse(String args) throws ParseException {
Project project = new Project(name);
return new AddTaskCommand(task, project);
} catch (ParseException e) {
throw new ParseException("Names should be alphanumerical and not empty.");
throw e;
} catch (ArrayIndexOutOfBoundsException e) {
throw new ParseException(String.format(
MESSAGE_INVALID_COMMAND_FORMAT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ public AssignPersonCommand parse(String args) throws ParseException {
} catch (IndexOutOfBoundsException e) {
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT,
AssignPersonCommand.MESSAGE_USAGE));
} catch (IllegalArgumentException e) {
throw new ParseException("Please enter valid names.");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import seedu.address.logic.commands.AssignTeamCommand;
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.person.Name;
import seedu.address.model.project.Project;


Expand All @@ -32,7 +33,7 @@ public AssignTeamCommand parse(String args) throws ParseException {
List<String> team = Arrays.stream(members.split(","))
.map(String::trim)
.collect(Collectors.toList());
if (team.stream().anyMatch(member -> member.length() == 0)) {
if (team.stream().anyMatch(member -> (member.length() == 0 || !Name.isValidName(member)))) {
throw new ParseException("Please enter valid names");
}
if ((team.size() == 0) || (projectName.length() == 0)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public DeletePersonCommand parse(String args) throws ParseException {
throw new ParseException("Please enter the member and the project field");
}
return new DeletePersonCommand(new Member(memberName), new Project(new Name(projectName)));
} catch (IllegalArgumentException e) {
throw new ParseException("Please enter valid names.");
} catch (Exception e) {
throw new ParseException(String.format(
MESSAGE_INVALID_COMMAND_FORMAT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,21 @@
* Represents a parse error encountered by a parser.
*/
public class ParseException extends IllegalValueException {

/**
* Constructs a new {@code ParseException} with the specified detail message.
*
* @param message the detail message of the exception
*/
public ParseException(String message) {
super(message);
}

/**
* Constructs a new {@code ParseException} with the specified detail message and cause.
*
* @param message the detail message of the exception
* @param cause the cause of the exception
*/
public ParseException(String message, Throwable cause) {
super(message, cause);
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/view/TaskListPanel.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<Insets left="12" top="12" />
</padding>
</Label>
<VBox fx:id="undoneTaskList" minWidth="280" prefWidth="280" VBox.vgrow="ALWAYS">
<VBox fx:id="undoneTaskList" minWidth="280" prefWidth="280" VBox.vgrow="ALWAYS" maxHeight="335">
<padding>
<Insets bottom="8" left="8" right="8" top="8" />
</padding>
Expand All @@ -44,7 +44,7 @@
<Insets left="12" top="12" />
</padding>
</Label>
<VBox fx:id="doneTaskList" minWidth="280" prefWidth="280" VBox.vgrow="ALWAYS">
<VBox fx:id="doneTaskList" minWidth="280" prefWidth="280" VBox.vgrow="ALWAYS" maxHeight="335">
<padding>
<Insets bottom="8" left="8" right="8" top="8" />
</padding>
Expand All @@ -57,7 +57,7 @@
<Insets left="12" top="12" />
</padding>
</Label>
<VBox fx:id="Comments" minWidth="280" prefWidth="280" VBox.vgrow="ALWAYS">
<VBox fx:id="Comments" minWidth="280" prefWidth="280" VBox.vgrow="ALWAYS" maxHeight="335">
<padding>
<Insets bottom="8" left="8" right="8" top="8" />
</padding>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void parse_compulsoryFieldMissing_failure() {

// missing project name
assertParseFailure(parser, "task",
"Names should be alphanumerical and not empty.");
expectedMessage);

assertParseFailure(parser, "task /to ",
expectedMessage);
Expand Down

0 comments on commit 0c373b8

Please sign in to comment.