package seedu.ezdo.logic.commands;

import seedu.ezdo.commons.core.EventsCenter;
import seedu.ezdo.commons.core.Messages;
import seedu.ezdo.commons.core.UnmodifiableObservableList;
import seedu.ezdo.commons.events.ui.JumpToListRequestEvent;
import seedu.ezdo.logic.commands.exceptions.CommandException;
import seedu.ezdo.model.todo.ReadOnlyTask;

/**
 * Selects a task identified using its last displayed index from ezDo.
 */
public class SelectCommand extends Command {

    public final int targetIndex;

    public static final String COMMAND_WORD = "select";

    public static final String MESSAGE_USAGE = COMMAND_WORD
            + ": Selects the task identified by the index number used in the last task listing.\n"
            + "Parameters: INDEX (must be a positive integer)\n"
            + "Example: " + COMMAND_WORD + " 1";

    public static final String MESSAGE_SELECT_TASK_SUCCESS = "Selected Task: %1$s";

    public SelectCommand(int targetIndex) {
        this.targetIndex = targetIndex;
    }

    @Override
    public CommandResult execute() throws CommandException {

        UnmodifiableObservableList<ReadOnlyTask> lastShownList = model.getFilteredTaskList();

        if (lastShownList.size() < targetIndex) {
            throw new CommandException(Messages.MESSAGE_INVALID_TASK_DISPLAYED_INDEX);
        }

        EventsCenter.getInstance().post(new JumpToListRequestEvent(targetIndex - 1));
        return new CommandResult(String.format(MESSAGE_SELECT_TASK_SUCCESS, targetIndex));

    }

}

@@ -29,16 +29,45 @@
 mands;%0A%0A
+import java.util.ArrayList;%0A%0A
 import s
@@ -263,16 +263,73 @@
 tEvent;%0A
+import seedu.ezdo.commons.util.MultipleIndexCommandUtil;%0A
 import s
@@ -424,16 +424,51 @@
 nlyTask;
+%0Aimport seedu.ezdo.model.todo.Task;
 %0A%0A/**%0A *
@@ -590,43 +590,8 @@
  %7B%0A%0A
-    public final int targetIndex;%0A%0A
     
@@ -1000,16 +1000,117 @@
 : %251$s%22;
+%0A    private final ArrayList%3CInteger%3E targetIndexes;%0A    private final ArrayList%3CTask%3E tasksToToggle;
 %0A%0A    pu
@@ -1132,23 +1132,34 @@
 and(
-int targetI
+ArrayList%3CInteger%3E i
 ndex
+es
 ) %7B%0A
@@ -1186,22 +1186,96 @@
 ndex
+es
  = 
-targetIndex
+new ArrayList%3CInteger%3E(indexes);%0A        this.tasksToToggle = new ArrayList%3CTask%3E()
 ;%0A  
@@ -1461,16 +1461,55 @@
      if 
+(!MultipleIndexCommandUtil.isIndexValid
 (lastSho
@@ -1518,17 +1518,9 @@
 List
-.size() %3C
+,
  tar
@@ -1527,16 +1527,19 @@
 getIndex
+es)
 ) %7B%0A    
@@ -1627,24 +1627,348 @@
 ;%0A        %7D%0A
+        %0A        if (!MultipleIndexCommandUtil.isDone(lastShownList, targetIndexes)) %7B%0A            throw new CommandException(Messages.MESSAGE_TASK_DONE);%0A        %7D%0A        %0A        MultipleIndexCommandUtil.addTasksToList(tasksToToggle, lastShownList, targetIndexes);%0A        model.toggleTasksSelect(tasksToToggle);%0A        
 %0A        Eve
@@ -2038,16 +2038,45 @@
 ndex
- - 
+es.get(targetIndexes.size()-1)-
 1));%0A
+%0A
     
@@ -2158,16 +2158,18 @@
 getIndex
+es
 ));%0A%0A   

Update SelectCommand.java