package seedu.jimi.logic.commands;

import java.util.HashSet;
import java.util.Set;

import seedu.jimi.commons.exceptions.IllegalValueException;
import seedu.jimi.model.tag.Tag;
import seedu.jimi.model.tag.UniqueTagList;
import seedu.jimi.model.task.FloatingTask;
import seedu.jimi.model.task.Name;

/**
 * 
 * @author zexuan
 *
 * Edits an existing task/event in Jimi.
 */
public class EditCommand extends Command{

    public static final String COMMAND_WORD = "edit";

    public static final String MESSAGE_USAGE = COMMAND_WORD + ": Edits an existing task/event in Jimi. "
            + "Example: " + COMMAND_WORD
            + "2 by 10th July at 12 pm";

    public static final String MESSAGE_SUCCESS = "Updated task details: %1$s";
    public static final String MESSAGE_DUPLICATE_TASK = "This task already exists in Jimi";

    private final int taskIndex; //index of task/event to be edited

    /**
     * Convenience constructor using raw values.
     * //TODO: change to support FloatingTask, Task and Events types as well
     * 
     * @throws IllegalValueException if any of the raw values are invalid
     */
    public EditCommand(String name, Set<String> tags, int taskIndex) throws IllegalValueException {
        final Set<Tag> tagSet = new HashSet<>();
        for (String tagName : tags) {
            tagSet.add(new Tag(tagName));
        }
        this.taskIndex = taskIndex;
    }
    
    @Override
    public CommandResult execute() {
        
        return null;
    }

}

@@ -78,16 +78,116 @@
 l.Set;%0A%0A
+import seedu.jimi.commons.core.Messages;%0Aimport seedu.jimi.commons.core.UnmodifiableObservableList;%0A
 import s
@@ -391,16 +391,126 @@
 sk.Name;
+%0Aimport seedu.jimi.model.task.ReadOnlyTask;%0Aimport seedu.jimi.model.task.UniqueTaskList.TaskNotFoundException;
 %0A%0A/**%0A *
@@ -902,16 +902,26 @@
 MESSAGE_
+EDIT_TASK_
 SUCCESS 
@@ -1112,16 +1112,81 @@
 e edited
+%0A    private UniqueTagList newTagList;%0A    private Name newName; 
 %0A%0A    /*
@@ -1686,94 +1686,1196 @@
     
-%7D%0A    %0A    @Override%0A    public CommandResult execute() %7B%0A        %0A        return null
+    %0A        //if new fields are to be edited, instantiate them%0A        if(name != null) %7B%0A            this.newName = new Name(name);%0A        %7D%0A        if(tagSet != null) %7B%0A            this.newTagList = new UniqueTagList(tagSet);%0A        %7D%0A    %7D%0A    %0A    @Override%0A    public CommandResult execute() %7B%0A        UnmodifiableObservableList%3CReadOnlyTask%3E lastShownList = model.getFilteredTaskList();%0A%0A        if (lastShownList.size() %3C taskIndex) %7B%0A            indicateAttemptToExecuteIncorrectCommand();%0A            return new CommandResult(Messages.MESSAGE_INVALID_TASK_DISPLAYED_INDEX);%0A        %7D%0A%0A        ReadOnlyTask taskToEdit = lastShownList.get(taskIndex - 1);%0A        %0A        try %7B%0A            model.deleteTask(taskToEdit); //delete %0A            %0A            UniqueTagList oldTagSet = taskToEdit.getTags();%0A            Name oldName = taskToEdit.getName();%0A            %0A            if(newName != null && !oldName.equals(newName))%7B%0A                %0A            %7D%0A            %0A        %7D catch (TaskNotFoundException pnfe) %7B%0A            assert false : %22The target task cannot be missing%22;%0A        %7D%0A%0A        return new CommandResult(String.format(MESSAGE_EDIT_TASK_SUCCESS, taskToEdit))
 ;%0A  

Add checks for null name and tagSet, half implemented execute()