Skip to content

Commit

Permalink
Merge pull request #75 from jiayushe/add-tasks
Browse files Browse the repository at this point in the history
Implement UI for Tasks
  • Loading branch information
jiayushe authored Oct 15, 2019
2 parents 36348f6 + 21c6bd6 commit dbd4b1c
Show file tree
Hide file tree
Showing 18 changed files with 335 additions and 105 deletions.
2 changes: 1 addition & 1 deletion docs/tutorials/AddRemark.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ We accomplish that by returning a `CommandResult` with an accompanying message.
.RemarkCommand.java
[source, java]
----
package seedu.address.seedu.algobase.commands;
package seedu.address.logic.commands;
import seedu.address.model.Model;
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/seedu/algobase/logic/Logic.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import seedu.algobase.model.plan.Plan;
import seedu.algobase.model.problem.Problem;
import seedu.algobase.model.tag.Tag;
import seedu.algobase.model.task.Task;

/**
* API of the Logic component
Expand Down Expand Up @@ -49,6 +50,9 @@ public interface Logic {
/** Returns an unmodifiable view of the filtered list of plans */
ObservableList<Plan> getProcessedPlanList();

/** Returns an unmodifiable view of the filtered list of tasks */
ObservableList<Task> getProcessedTaskList();

/**
* Returns the user prefs' algobase file path.
*/
Expand Down
14 changes: 10 additions & 4 deletions src/main/java/seedu/algobase/logic/LogicManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import seedu.algobase.model.plan.Plan;
import seedu.algobase.model.problem.Problem;
import seedu.algobase.model.tag.Tag;
import seedu.algobase.model.task.Task;
import seedu.algobase.storage.Storage;

/**
Expand Down Expand Up @@ -60,24 +61,29 @@ public ReadOnlyAlgoBase getAlgoBase() {
}

@Override
public ObservableList<Problem> getProcessedProblemList() {
return model.getFilteredProblemList();
public GuiState getGuiState() {
return model.getGuiState();
}

@Override
public ObservableList<Tag> getFilteredTagList() {
return model.getFilteredTagList();
}

public GuiState getGuiState() {
return model.getGuiState();
public ObservableList<Problem> getProcessedProblemList() {
return model.getFilteredProblemList();
}

@Override
public ObservableList<Plan> getProcessedPlanList() {
return model.getFilteredPlanList();
}

@Override
public ObservableList<Task> getProcessedTaskList() {
return model.getCurrentTaskList();
}

@Override
public Path getAlgoBaseFilePath() {
return model.getAlgoBaseFilePath();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public CommandResult execute(Model model) throws CommandException {
Plan updatedPlan = Plan.createUpdatedPlan(plan, taskSet);
model.setPlan(plan, updatedPlan);

return new CommandResult(String.format(MESSAGE_SUCCESS, task, plan));
return new CommandResult(String.format(MESSAGE_SUCCESS, task, updatedPlan));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import java.util.stream.Stream;

import seedu.algobase.logic.commands.AddCommand;
import seedu.algobase.logic.commands.AddTagCommand;
import seedu.algobase.logic.parser.exceptions.ParseException;
import seedu.algobase.model.tag.Tag;
Expand All @@ -25,7 +24,7 @@ public AddTagCommand parse(String args) throws ParseException {
ArgumentTokenizer.tokenize(args, PREFIX_TAG);
if (!arePrefixesPresent(argMultimap, PREFIX_TAG)
|| !argMultimap.getPreamble().isEmpty()) {
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE));
throw new ParseException(String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddTagCommand.MESSAGE_USAGE));
}
Tag tag = new ParserUtil().parseTag(argMultimap.getValue(PREFIX_TAG).get());
return new AddTagCommand(tag);
Expand Down
49 changes: 25 additions & 24 deletions src/main/java/seedu/algobase/model/AlgoBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import seedu.algobase.model.problem.UniqueProblemList;
import seedu.algobase.model.tag.Tag;
import seedu.algobase.model.tag.UniqueTagList;
import seedu.algobase.model.task.Task;

/**
* Wraps all data at the algobase level
Expand All @@ -32,9 +33,6 @@ public class AlgoBase implements ReadOnlyAlgoBase {
{
problems = new UniqueProblemList();
plans = new PlanList();
}

{
tags = new UniqueTagList();
}

Expand Down Expand Up @@ -103,7 +101,12 @@ public void removeProblem(Problem key) {
problems.remove(key);
}

//// tag methods
@Override
public ObservableList<Problem> getProblemList() {
return problems.asUnmodifiableObservableList();
}

//========== Tag ====================================================================
/**
* Replaces the contents of the Tag list with {@code tags}.
* {@code tags} must not contain duplicate tags.
Expand All @@ -112,9 +115,6 @@ public void setTags(List<Tag> tags) {
this.tags.setTags(tags);
}


//// tag-level operations

/**
* Returns true if a Tag with the same identity as {@code Tag} exists in the algobase.
*/
Expand All @@ -140,9 +140,18 @@ public void setTag(Tag target, Tag editedTag) {
requireNonNull(editedTag);
tags.setTag(target, editedTag);
}

/**
* Removes {@code key} from this {@code AlgoBase}.
* {@code key} must exist in the algobase.
*/
public void removeTag(Tag key) {
tags.remove(key);
}

@Override
public ObservableList<Problem> getProblemList() {
return problems.asUnmodifiableObservableList();
public ObservableList<Tag> getTagList() {
return tags.asUnmodifiableObservableList();
}

//========== Plan ===================================================================
Expand Down Expand Up @@ -174,16 +183,6 @@ public void setPlan(Plan target, Plan editedPlan) {
plans.setPlan(target, editedPlan);
}

/**
* Removes {@code key} from this {@code AlgoBase}.
* {@code key} must exist in the algobase.
*/
public void removeTag(Tag key) {
tags.remove(key);
}

//// util methods

public void removePlan(Plan key) {
plans.remove(key);
}
Expand All @@ -193,6 +192,13 @@ public ObservableList<Plan> getPlanList() {
return plans.asUnmodifiableObservableList();
}

//========== Task ===================================================================

@Override
public ObservableList<Task> getCurrentTaskList() {
return plans.getUnmodifiableObservableTaskList();
}

//========== Util ===================================================================

@Override
Expand All @@ -201,11 +207,6 @@ public String toString() {
// TODO: refine later
}

@Override
public ObservableList<Tag> getTagList() {
return tags.asUnmodifiableObservableList();
}

@Override
public boolean equals(Object other) {
return other == this // short circuit if same object
Expand Down
25 changes: 14 additions & 11 deletions src/main/java/seedu/algobase/model/Model.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@
import seedu.algobase.model.plan.Plan;
import seedu.algobase.model.problem.Problem;
import seedu.algobase.model.tag.Tag;
import seedu.algobase.model.task.Task;

/**
* The API of the Model component.
*/
public interface Model {
/** {@code Predicate} that always evaluate to true */
Predicate<Problem> PREDICATE_SHOW_ALL_PROBLEMS = unused -> true;

/** {@code Predicate} that always evaluate to true */
Predicate<Tag> PREDICATE_SHOW_ALL_TAGS = unused -> true;
Predicate<Plan> PREDICATE_SHOW_ALL_PLANS = unused -> true;

Expand Down Expand Up @@ -70,7 +69,6 @@ public interface Model {

/** Returns the AlgoBase */
ReadOnlyAlgoBase getAlgoBase();
/////

//=========== Problem ===============================================================

Expand Down Expand Up @@ -106,7 +104,15 @@ public interface Model {
* @throws NullPointerException if {@code predicate} is null.
*/
void updateFilteredProblemList(Predicate<Problem> predicate);
/////

/**
* Updates the Problem list according to the given {@code problemComparator}.
* @param problemComparator
* @throws NullPointerException if {@code problemComparator} is null;
*/
void updateSortedProblemList(Comparator<Problem> problemComparator);

//=========== Tag ===================================================================

/**
* Returns true if a Tag with the same identity as {@code Tag} exists in the algobase.
Expand Down Expand Up @@ -160,13 +166,6 @@ public interface Model {
*/
void updateFilteredTagList(Predicate<Tag> predicate);

/**
* Updates the Problem list according to the given {@code problemComparator}.
* @param problemComparator
* @throws NullPointerException if {@code problemComparator} is null;
*/
void updateSortedProblemList(Comparator<Problem> problemComparator);

//=========== Plan ==================================================================

/**
Expand Down Expand Up @@ -202,4 +201,8 @@ public interface Model {
*/
void updateFilteredPlanList(Predicate<Plan> predicate);

//=========== Task ==================================================================

/** Returns an unmodifiable view of the filtered Plan list */
ObservableList<Task> getCurrentTaskList();
}
3 changes: 2 additions & 1 deletion src/main/java/seedu/algobase/model/ModelEnum.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
public enum ModelEnum {
PROBLEM (0, "problem", "Problems"),
TAG (1, "tag", "Tags"),
PLAN (2, "plan", "Training Plans");
PLAN (2, "plan", "Training Plans"),
TASK (3, "task", "Tasks");

private final int displayTabPaneIndex;
private final String commandArgumentValue;
Expand Down
Loading

0 comments on commit dbd4b1c

Please sign in to comment.