Skip to content

Commit

Permalink
Merge pull request #24 from CS2103AUG2016-T17-C1/marktask
Browse files Browse the repository at this point in the history
Marktask
  • Loading branch information
howitzerg committed Oct 27, 2016
2 parents cab0597 + 4721777 commit 9658224
Show file tree
Hide file tree
Showing 18 changed files with 609 additions and 25 deletions.
2 changes: 1 addition & 1 deletion docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

### Architecture

<img src="images/Architecture2.png" width="600"><br>
<img src="images/Architecture.png" width="600"><br>
The **_Architecture Diagram_** given above explains the high-level design of the App.
Given below is a quick overview of each component.

Expand Down
6 changes: 6 additions & 0 deletions src/main/java/seedu/task/logic/Logic.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,11 @@ public interface Logic {

/** Returns the filtered list of tasks */
ObservableList<ReadOnlyTask> getFilteredTaskList();

//@@author A0127720M
/** Returns the filtered list of marked tasks */
ObservableList<ReadOnlyTask> getFilteredMarkedTaskList();
//@@author


}
7 changes: 7 additions & 0 deletions src/main/java/seedu/task/logic/LogicManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,11 @@ public CommandResult execute(String commandText) {
public ObservableList<ReadOnlyTask> getFilteredTaskList() {
return model.getFilteredTaskList();
}

//@@author A0127720M
@Override
public ObservableList<ReadOnlyTask> getFilteredMarkedTaskList() {
return model.getFilteredMarkedTaskList();
}
//@@author
}
46 changes: 46 additions & 0 deletions src/main/java/seedu/task/logic/commands/MarkCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package seedu.task.logic.commands;

import seedu.task.commons.core.Messages;
import seedu.task.commons.core.UnmodifiableObservableList;
import seedu.task.model.task.ReadOnlyTask;
import seedu.task.model.task.UniqueTaskList.DuplicateTaskException;
import seedu.task.model.task.UniqueTaskList.TaskNotFoundException;

//@@author A0127720M

public class MarkCommand extends Command{

public static final String COMMAND_WORD = "mark";
public static final String MESSAGE_SUCCESS = "Marks a given task: $1%s ";
public static final Object MESSAGE_USAGE = " ";
private int targetIndex;


//Construct a new mark command
public MarkCommand(int targetIndex) {
this.targetIndex = targetIndex;
}

@Override
public CommandResult execute() {
//Check index
UnmodifiableObservableList<ReadOnlyTask> lastShownList = model.getFilteredTaskList();

if (lastShownList.size() < targetIndex) {
indicateAttemptToExecuteIncorrectCommand();
return new CommandResult(Messages.MESSAGE_INVALID_TASK_DISPLAYED_INDEX);
}

//mark a task
ReadOnlyTask taskToMark = lastShownList.get(targetIndex - 1);
try {
model.markTask(taskToMark);
} catch (TaskNotFoundException pnfe) {
assert false : "The target task cannot be missing";
} catch (DuplicateTaskException e) {
assert false: "Redundant tasks";
}

return new CommandResult(String.format(MESSAGE_SUCCESS, taskToMark));
}
}
22 changes: 19 additions & 3 deletions src/main/java/seedu/task/logic/parser/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,12 @@ public Command parseCommand(String userInput) {

case ClearCommand.COMMAND_WORD:
return new ClearCommand();


//@@author A0127720M
case MarkCommand.COMMAND_WORD:
return prepareMark(arguments);
//@@author

case FindCommand.COMMAND_WORD:
return prepareFind(arguments);

Expand All @@ -101,7 +106,9 @@ public Command parseCommand(String userInput) {
}
}

/**


/**
* Parses arguments in the context of the add task command.
*
* @param args full command args string
Expand Down Expand Up @@ -216,8 +223,17 @@ private Command prepareSelect(String args) {

return new SelectCommand(index.get());
}
//@@author A0127720M
private Command prepareMark(String arguments) {
Optional<Integer> index = parseIndex(arguments);
if(!index.isPresent()){
return new IncorrectCommand(
String.format(MESSAGE_INVALID_COMMAND_FORMAT, MarkCommand.MESSAGE_USAGE));
}


return new MarkCommand(index.get());
}
//@@author

/**
* Returns the specified index in the {@code command} IF a positive unsigned integer is given as the index.
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/seedu/task/model/Model.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

import java.util.Set;

import javafx.collections.ObservableList;
import seedu.task.commons.core.UnmodifiableObservableList;
import seedu.task.model.task.ReadOnlyTask;
import seedu.task.model.task.Task;
import seedu.task.model.task.UniqueTaskList;
import seedu.task.model.task.UniqueTaskList.DuplicateTaskException;
import seedu.task.model.task.UniqueTaskList.TaskNotFoundException;

/**
* The API of the Model component.
Expand Down Expand Up @@ -39,13 +41,22 @@ public interface Model {

/** Returns the filtered task list as an {@code UnmodifiableObservableList<ReadOnlyTask>} */
UnmodifiableObservableList<ReadOnlyTask> getFilteredTaskList();

ObservableList<ReadOnlyTask> getFilteredMarkedTaskList();

/** Updates the filter of the filtered task list to show all tasks */
void updateFilteredListToShowAll();

/** Updates the filter of the filtered task list to filter by the given keywords*/
void updateFilteredTaskList(Set<String> keywords);

//@@author A0127720M
/** Marks the given task
* @throws DuplicateTaskException */
void markTask(ReadOnlyTask taskToMark) throws TaskNotFoundException, DuplicateTaskException;
//@@author





Expand Down
29 changes: 27 additions & 2 deletions src/main/java/seedu/task/model/ModelManager.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package seedu.task.model;

import javafx.collections.ObservableList;
import javafx.collections.transformation.FilteredList;
import seedu.task.commons.core.ComponentManager;
import seedu.task.commons.core.LogsCenter;
Expand All @@ -9,6 +10,7 @@
import seedu.task.model.task.ReadOnlyTask;
import seedu.task.model.task.Task;
import seedu.task.model.task.UniqueTaskList;
import seedu.task.model.task.UniqueTaskList.DuplicateTaskException;
import seedu.task.model.task.UniqueTaskList.TaskNotFoundException;

import java.util.Set;
Expand All @@ -23,6 +25,7 @@ public class ModelManager extends ComponentManager implements Model {

private final TaskManager taskManager;
private final FilteredList<Task> filteredTasks;
private final FilteredList<Task> filteredMarkedTasks;

/**
* Initializes a ModelManager with the given TaskManager
Expand All @@ -37,6 +40,7 @@ public ModelManager(TaskManager src, UserPrefs userPrefs) {

taskManager = new TaskManager(src);
filteredTasks = new FilteredList<>(taskManager.getTasks());
filteredMarkedTasks = new FilteredList<>(taskManager.getMarkedTasks());
}

public ModelManager() {
Expand All @@ -46,6 +50,7 @@ public ModelManager() {
public ModelManager(ReadOnlyTaskManager initialData, UserPrefs userPrefs) {
taskManager = new TaskManager(initialData);
filteredTasks = new FilteredList<>(taskManager.getTasks());
filteredMarkedTasks = new FilteredList<>(taskManager.getMarkedTasks());
}

@Override
Expand Down Expand Up @@ -99,14 +104,31 @@ public synchronized void editTask(ReadOnlyTask target, Task newTask) throws Uniq
taskManager.editTask(target, newTask);
indicateTaskManagerChanged();
}


//@@author A0127720M

@Override
public void markTask(ReadOnlyTask taskToMark) throws TaskNotFoundException, DuplicateTaskException {
//mark a task
taskManager.mark(taskToMark);
indicateTaskManagerChanged();
}
//@@author
//=========== Filtered Task List Accessors ===============================================================

@Override
public UnmodifiableObservableList<ReadOnlyTask> getFilteredTaskList() {
return new UnmodifiableObservableList<>(filteredTasks);
}


//@@author A0127720M
@Override
public ObservableList<ReadOnlyTask> getFilteredMarkedTaskList() {
return new UnmodifiableObservableList<>(filteredMarkedTasks);
}
//@@author


@Override
public void updateFilteredListToShowAll() {
filteredTasks.setPredicate(null);
Expand Down Expand Up @@ -174,5 +196,8 @@ public String toString() {
}






}
11 changes: 10 additions & 1 deletion src/main/java/seedu/task/model/ReadOnlyTaskManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import seedu.task.model.tag.Tag;
import seedu.task.model.tag.UniqueTagList;
import seedu.task.model.task.ReadOnlyTask;
import seedu.task.model.task.UniqueMarkedTaskList;
import seedu.task.model.task.UniqueTaskList;

/**
Expand All @@ -26,5 +27,13 @@ public interface ReadOnlyTaskManager {
* Returns an unmodifiable view of tags list
*/
List<Tag> getTagList();


//@@author A0127720M
UniqueMarkedTaskList getUniqueMarkedList();

/**
* Returns an unmodifiable view of unmarked tasks list
*/
List<ReadOnlyTask> getMarkedTaskList();
//@@author
}
Loading

0 comments on commit 9658224

Please sign in to comment.