forked from nus-cs2103-AY1920S1/addressbook-level3
-
Notifications
You must be signed in to change notification settings - Fork 6
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 #117 from mannggoo/fix-edit-command
Fix edit command
- Loading branch information
Showing
13 changed files
with
169 additions
and
27 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
42 changes: 42 additions & 0 deletions
42
src/main/java/seedu/address/logic/commands/AddEventCommand.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,42 @@ | ||
package seedu.address.logic.commands; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
import seedu.address.commons.core.item.Item; | ||
import seedu.address.logic.commands.exceptions.CommandException; | ||
import seedu.address.model.ItemModel; | ||
|
||
/** | ||
* Adds an Event to the item model. | ||
*/ | ||
public class AddEventCommand extends AddCommand { | ||
|
||
public static final String SHOW_EVENT_VIEW = "E"; | ||
public static final String MESSAGE_SUCCESS = "New Event added: %1$s"; | ||
|
||
public AddEventCommand(Item item) { | ||
super(item); | ||
} | ||
|
||
@Override | ||
public CommandResult execute(ItemModel model) throws CommandException { | ||
requireNonNull(model); | ||
|
||
// Check if item already exists, else, add it to the model. | ||
if (model.hasItem(toAdd)) { | ||
throw new CommandException(MESSAGE_DUPLICATE_ITEM); | ||
} else { | ||
model.addItem(toAdd); | ||
} | ||
|
||
// Notify Ui to change the view the that of the newly added item. | ||
try { | ||
model.setVisualList(SHOW_EVENT_VIEW); | ||
} catch (Exception e) { | ||
// should not enter here as itemType is definitely valid. | ||
} | ||
|
||
//return new CommandResult(String.format(MESSAGE_SUCCESS, toAdd)); | ||
return new CommandResult(String.format(MESSAGE_SUCCESS, toAdd), SHOW_EVENT_VIEW); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/main/java/seedu/address/logic/commands/AddReminderCommand.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,42 @@ | ||
package seedu.address.logic.commands; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
import seedu.address.commons.core.item.Item; | ||
import seedu.address.logic.commands.exceptions.CommandException; | ||
import seedu.address.model.ItemModel; | ||
|
||
/** | ||
* Adds a Reminder to the item model. | ||
*/ | ||
public class AddReminderCommand extends AddCommand { | ||
|
||
public static final String SHOW_REMINDER_VIEW = "R"; | ||
public static final String MESSAGE_SUCCESS = "New Reminder added: %1$s"; | ||
|
||
public AddReminderCommand(Item item) { | ||
super(item); | ||
} | ||
|
||
@Override | ||
public CommandResult execute(ItemModel model) throws CommandException { | ||
requireNonNull(model); | ||
|
||
// Check if item already exists, else, add it to the model. | ||
if (model.hasItem(toAdd)) { | ||
throw new CommandException(MESSAGE_DUPLICATE_ITEM); | ||
} else { | ||
model.addItem(toAdd); | ||
} | ||
|
||
// Notify Ui to change the view the that of the newly added item. | ||
try { | ||
model.setVisualList(SHOW_REMINDER_VIEW); | ||
} catch (Exception e) { | ||
// should not enter here as itemType is definitely valid. | ||
} | ||
|
||
//return new CommandResult(String.format(MESSAGE_SUCCESS, toAdd)); | ||
return new CommandResult(String.format(MESSAGE_SUCCESS, toAdd), SHOW_REMINDER_VIEW); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
src/main/java/seedu/address/logic/commands/AddTaskCommand.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,42 @@ | ||
package seedu.address.logic.commands; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
import seedu.address.commons.core.item.Item; | ||
import seedu.address.logic.commands.exceptions.CommandException; | ||
import seedu.address.model.ItemModel; | ||
|
||
/** | ||
* Adds a Task to the item model. | ||
*/ | ||
public class AddTaskCommand extends AddCommand { | ||
|
||
public static final String SHOW_TASK_VIEW = "T"; | ||
public static final String MESSAGE_SUCCESS = "New Task added: %1$s"; | ||
|
||
public AddTaskCommand(Item item) { | ||
super(item); | ||
} | ||
|
||
@Override | ||
public CommandResult execute(ItemModel model) throws CommandException { | ||
requireNonNull(model); | ||
|
||
// Check if item already exists, else, add it to the model. | ||
if (model.hasItem(toAdd)) { | ||
throw new CommandException(MESSAGE_DUPLICATE_ITEM); | ||
} else { | ||
model.addItem(toAdd); | ||
} | ||
|
||
// Notify Ui to change the view the that of the newly added item. | ||
try { | ||
model.setVisualList(SHOW_TASK_VIEW); | ||
} catch (Exception e) { | ||
// should not enter here as itemType is definitely valid. | ||
} | ||
|
||
//return new CommandResult(String.format(MESSAGE_SUCCESS, toAdd)); | ||
return new CommandResult(String.format(MESSAGE_SUCCESS, toAdd), SHOW_TASK_VIEW); | ||
} | ||
} |
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
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
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
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