forked from nus-cs2103-AY1718S2/addressbook-level4
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request nus-cs2103-AY1718S2#45 from CS2103JAN2018-T15-B2/v…
…1.3YuxiangSg V1.3 yuxiangsg
Showing
43 changed files
with
982 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/main/java/seedu/address/commons/events/ui/CalendarFocusEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package seedu.address.commons.events.ui; | ||
|
||
import java.time.LocalDate; | ||
|
||
import seedu.address.commons.events.BaseEvent; | ||
|
||
/** | ||
* Represents a calendar GUI focus date request | ||
*/ | ||
public class CalendarFocusEvent extends BaseEvent { | ||
public final LocalDate dateToLook; | ||
|
||
public CalendarFocusEvent(LocalDate dateToLook) { | ||
this.dateToLook = dateToLook; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return this.getClass().getSimpleName(); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/seedu/address/commons/events/ui/CalendarUnfocusEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package seedu.address.commons.events.ui; | ||
|
||
import seedu.address.commons.events.BaseEvent; | ||
|
||
/** | ||
* Represents a calendar GUI unfocus date request | ||
*/ | ||
public class CalendarUnfocusEvent extends BaseEvent { | ||
@Override | ||
public String toString() { | ||
return this.getClass().getSimpleName(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
src/main/java/seedu/address/logic/commands/EditAppointmentCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package seedu.address.logic.commands; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_END_INTERVAL; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_NAME; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_SEARCH_TEXT; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_START_INTERVAL; | ||
|
||
import seedu.address.logic.commands.exceptions.CommandException; | ||
import seedu.address.model.calendar.AppointmentEntry; | ||
import seedu.address.model.calendar.exceptions.EditApointmentFailException; | ||
|
||
/** | ||
* Edit an appointment in the address book's calendar. | ||
*/ | ||
public class EditAppointmentCommand extends UndoableCommand { | ||
public static final String COMMAND_WORD = "edit_appointment"; | ||
|
||
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Edits an appointment in the calendar. " | ||
+ "Parameters: " | ||
+ PREFIX_SEARCH_TEXT + "SEARCH TEXT " | ||
+ PREFIX_NAME + "NEW NAME " | ||
+ PREFIX_START_INTERVAL + "NEW START DATE TIME " | ||
+ PREFIX_END_INTERVAL + "NEW END DATE TIME" | ||
+ "\nExample: " + COMMAND_WORD + " " | ||
+ PREFIX_SEARCH_TEXT + "Meet Peter " | ||
+ PREFIX_NAME + "Meet John " | ||
+ PREFIX_START_INTERVAL + "14/08/2018 06:12 " | ||
+ PREFIX_END_INTERVAL + "14/08/2018 07:12 "; | ||
|
||
public static final String MESSAGE_SUCCESS = "Appointment Edited: %1$s"; | ||
public static final String MESSAGE_FAIL_EDIT_APPOINTMENT = "appointment do not exit or duplicate new title"; | ||
|
||
private final AppointmentEntry toEdit; | ||
private final String searchText; | ||
|
||
/** | ||
* Creates an AddCommand to add the specified {@code AppointmentEntry} | ||
*/ | ||
public EditAppointmentCommand(String searchText, AppointmentEntry appointmentEntry) { | ||
requireNonNull(appointmentEntry); | ||
toEdit = appointmentEntry; | ||
this.searchText = searchText; | ||
} | ||
|
||
@Override | ||
public CommandResult executeUndoableCommand() throws CommandException { | ||
requireNonNull(model); | ||
try { | ||
model.editAppointment(searchText, toEdit); | ||
return new CommandResult(String.format(MESSAGE_SUCCESS, toEdit)); | ||
} catch (EditApointmentFailException e) { | ||
throw new CommandException(MESSAGE_FAIL_EDIT_APPOINTMENT); | ||
} | ||
|
||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
return other == this // short circuit if same object | ||
|| (other instanceof EditAppointmentCommand // instanceof handles nulls | ||
&& toEdit.equals(((EditAppointmentCommand) other).toEdit)); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
src/main/java/seedu/address/logic/commands/LookDateCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package seedu.address.logic.commands; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_DATE_FOCUS; | ||
|
||
import java.time.LocalDate; | ||
|
||
import seedu.address.commons.core.EventsCenter; | ||
import seedu.address.commons.events.ui.CalendarFocusEvent; | ||
|
||
/** | ||
* Look at a specific date give the date to look | ||
*/ | ||
public class LookDateCommand extends Command { | ||
public static final String COMMAND_WORD = "look"; | ||
|
||
public static final String DATE_VALIDATION = "d/MM/yyyy"; | ||
|
||
public static final String MESSAGE_DATE_CONSTRAINTS = | ||
"Date should be in the format of dd/MM/yyyy"; | ||
|
||
public static final String MESSAGE_USAGE = COMMAND_WORD | ||
+ ": Focus on a given date ." | ||
+ "Parameters: " | ||
+ PREFIX_DATE_FOCUS + "DATE TO FOCUS " | ||
+ "\nExample: " + COMMAND_WORD + " " | ||
+ PREFIX_DATE_FOCUS + "11/03/2018"; | ||
|
||
public static final String FOCUS_DATE_MESSAGE = "FOCUS ON DATE"; | ||
|
||
/** | ||
* Creates an RemoveAppointmentCommand to remove the specified {@code searchText} | ||
*/ | ||
final LocalDate dateToLook; | ||
|
||
public LookDateCommand(LocalDate dateToLook) { | ||
requireNonNull(dateToLook); | ||
this.dateToLook = dateToLook; | ||
} | ||
|
||
@Override | ||
public CommandResult execute() { | ||
EventsCenter.getInstance().post(new CalendarFocusEvent(dateToLook)); | ||
return new CommandResult(FOCUS_DATE_MESSAGE); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
src/main/java/seedu/address/logic/commands/RemoveAppointmentsCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package seedu.address.logic.commands; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
import static seedu.address.logic.parser.CliSyntax.PREFIX_SEARCH_TEXT; | ||
|
||
import seedu.address.logic.commands.exceptions.CommandException; | ||
import seedu.address.model.calendar.exceptions.AppointmentNotFoundException; | ||
|
||
/** | ||
* removes appointment whose title match with the searchText in the address book's calendar. | ||
*/ | ||
|
||
public class RemoveAppointmentsCommand extends UndoableCommand { | ||
|
||
public static final String COMMAND_WORD = "remove_appointment"; | ||
|
||
public static final String MESSAGE_USAGE = COMMAND_WORD | ||
+ ": remove appointment whose title match with the search text in the calendar. " | ||
+ "Parameters: " | ||
+ PREFIX_SEARCH_TEXT + "SEARCH TEXT " | ||
+ "\nExample: " + COMMAND_WORD + " " | ||
+ PREFIX_SEARCH_TEXT + "title of the appointment "; | ||
|
||
public static final String MESSAGE_SUCCESS = "Appointment with title %1$s removed"; | ||
public static final String MESSAGE_NO_SUCH_APPOINTMENT = "No such appointment exists in the calendar"; | ||
|
||
private final String searchText; | ||
|
||
/** | ||
* Creates an RemoveAppointmentCommand to remove the specified {@code searchText} | ||
*/ | ||
public RemoveAppointmentsCommand(String searchText) { | ||
requireNonNull(searchText); | ||
this.searchText = searchText; | ||
} | ||
|
||
@Override | ||
protected CommandResult executeUndoableCommand() throws CommandException { | ||
try { | ||
model.removeAppointment(searchText); | ||
return new CommandResult(String.format(MESSAGE_SUCCESS, searchText)); | ||
} catch (AppointmentNotFoundException e) { | ||
throw new CommandException(MESSAGE_NO_SUCH_APPOINTMENT); | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/seedu/address/logic/commands/ReturnMonthViewCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package seedu.address.logic.commands; | ||
|
||
import seedu.address.commons.core.EventsCenter; | ||
import seedu.address.commons.events.ui.CalendarUnfocusEvent; | ||
|
||
/** | ||
* return to month view for the calendar GUI. | ||
*/ | ||
public class ReturnMonthViewCommand extends Command { | ||
public static final String COMMAND_WORD = "back"; | ||
|
||
public static final String MESSAGE_USAGE = COMMAND_WORD + ": Unfocus the Calendar to Month view.\n" | ||
+ "Example: " + COMMAND_WORD; | ||
|
||
public static final String RETURN_MONTH_VIEW_MESSAGE = "Calendar back to Month view"; | ||
|
||
@Override | ||
public CommandResult execute() { | ||
EventsCenter.getInstance().post(new CalendarUnfocusEvent()); | ||
return new CommandResult(RETURN_MONTH_VIEW_MESSAGE); | ||
} | ||
} |
Oops, something went wrong.