You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
packageseedu.geekeep.commons.events.model;
importseedu.geekeep.commons.core.TaskCategory;
importseedu.geekeep.commons.events.BaseEvent;
/** Indicates it is time to switch the tabs in mainwindow*/publicclassSwitchTaskCategoryEventextendsBaseEvent {
publicTaskCategorycategory;
publicSwitchTaskCategoryEvent(TaskCategorycategory) {
this.category = category;
}
@OverridepublicStringtoString() {
returnthis.getClass().getSimpleName();
}
}
packageseedu.geekeep.logic.commands;
importjava.util.HashSet;
importjava.util.Optional;
importjava.util.Set;
importseedu.geekeep.commons.exceptions.IllegalValueException;
importseedu.geekeep.model.tag.Tag;
importseedu.geekeep.model.tag.UniqueTagList;
importseedu.geekeep.model.task.DateTime;
/** * Finds and lists all tasks in GeeKeep whose title contains any of the argument keywords. Keyword matching is case * sensitive. */publicclassFindCommandextendsCommand {
publicstaticfinalStringCOMMAND_WORD = "find";
publicstaticfinalStringMESSAGE_USAGE = COMMAND_WORD + ": Finds all tasks which titles contain any of "
+ "the specified keywords (case-sensitive)\n"
+ "and/or which date is within the specified time duration "
+ "and/or which tag list contains any of the specified tags.\n "
+ "Parameters: [KEYWORD...] [a/AFTER_DATETIME] [b/BEFORE_DATETIME] [t/TAGS...]\n"
+ "Example: " + COMMAND_WORD + " CS3230 Midterm a/04-04-17 0000 t/exam";
publicstaticfinalStringMESSAGE_TIME_CONSTRAINTS = "The before date and time must be later than "
+ "the after date and time.";
publicstaticfinalStringMESSAGE_SUCCESS = "\nGeeKeep is showing all the tasks which:\n";
privatefinalSet<String> keywords;
privatefinalUniqueTagListtags;
privatefinalDateTimeearliestTime;
privatefinalDateTimelatestTime;
//Message with all the filter information added.privateStringdatailedSuccessMsg = MESSAGE_SUCCESS;
publicFindCommand(Set<String> keywords, Optional<String> earliestTime,
Optional<String> latestTime,
Set<String> tags) throwsIllegalValueException {
this.keywords = keywords;
finalSet<Tag> tagSet = newHashSet<>();
for (StringtagName : tags) {
tagSet.add(newTag(tagName));
}
this.tags = newUniqueTagList(tagSet);
if (earliestTime.isPresent()) {
this.earliestTime = newDateTime(earliestTime.get());
} else {
this.earliestTime = DateTime.getMin();
}
if (latestTime.isPresent()) {
this.latestTime = newDateTime(latestTime.get());
} else {
this.latestTime = DateTime.getMax();
}
if (this.earliestTime.compare(this.latestTime) > 0) {
thrownewIllegalValueException(MESSAGE_TIME_CONSTRAINTS);
}
addFilterMessage(keywords, earliestTime, latestTime, tags);
}
privatevoidaddFilterMessage(Set<String> keywords, Optional<String> earliestTime,
Optional<String> latestTime,
Set<String> tags) {
if (!keywords.isEmpty()) {
datailedSuccessMsg += "Contains the keyword(s) " + keywords + " in title\n";
}
if (earliestTime.isPresent()) {
datailedSuccessMsg += "Happens after "
+ earliestTime.get() + "\n";
}
if (latestTime.isPresent()) {
datailedSuccessMsg += "Happens before "
+ latestTime.get() + "\n";
}
if (!tags.isEmpty()) {
datailedSuccessMsg += "Contains the tags " + tags + "\n";
}
}
publicStringgetDetailedSuccessMsg() {
returnthis.datailedSuccessMsg;
}
@OverridepublicCommandResultexecute() {
model.updateFilteredTaskList(keywords, earliestTime, latestTime, tags);
returnnewCommandResult(getMessageForTaskListShownSummary(model.getFilteredTaskList().size())
+ getDetailedSuccessMsg());
}
}
@Override/** * Filters the task list by keywords, time and tags. * @param keywords, if it is empty, then every task is satisfactory. Otherwise, tasks which * don't match any of the keywords will be filtered out. * @param earlistTime, the time after which a task should happen. * @param latestTime, the time before which a task should happen. * @param tags, if it is empty, then every task is satisfactory. Otherwise, tasks which don't * contain any of the tags will be filtered out. */publicvoidupdateFilteredTaskList(Set<String> keywords, DateTimeearlistTime,
DateTimelatestTime, UniqueTagListtags) {
updateFilteredTaskList(newPredicateExpression(newTitleQualifier(keywords)),
newPredicateExpression(newTimeQualifier(earlistTime, latestTime)),
newPredicateExpression(newTagQualifier(tags)));
raise(newSwitchTaskCategoryEvent(TaskCategory.ALL));
}
privatevoidupdateFilteredTaskList(Expression... expressions) {
filteredTasks.setPredicate(task -> {
booleanisSatisfactory = true;
for (Expressionexpression : expressions) {
isSatisfactory = isSatisfactory && expression.satisfies(task);
}
returnisSatisfactory;
});
}
\java\seedu\geekeep\model\ModelManager.java
privateclassTitleQualifierimplementsQualifier {
privateSet<String> titleKeyWords;
TitleQualifier(Set<String> nameKeyWords) {
this.titleKeyWords = nameKeyWords;
}
@Overridepublicbooleanrun(ReadOnlyTasktask) {
if (titleKeyWords.isEmpty()) {
//every task satisfies, because the qualifier is emptyreturntrue;
} else {
returntitleKeyWords.stream()
.filter(keyword-> StringUtil.containsWordIgnoreCase(task.getTitle().title, keyword))
.findAny().isPresent();
}
}
}
privateclassTimeQualifierimplementsQualifier {
privateDateTimeearliestTime;
privateDateTimelatestTime;
privateTimeQualifier(DateTimeearliestTime, DateTimelatestTime) {
this.earliestTime = earliestTime;
this.latestTime = latestTime;
}
@Overridepublicbooleanrun(ReadOnlyTasktask) {
returnbefore(task) && after(task);
}
privatebooleanbefore(ReadOnlyTasktask) {
if (task.isFloatingTask()) { // assuming floating tasks meet all the time requirements.returntrue;
} else {
returntask.getReferenceDateTime().compare(latestTime) <= 0;
}
}
privatebooleanafter(ReadOnlyTasktask) {
if (task.isFloatingTask()) {
returntrue;
} else {
returntask.getReferenceDateTime().compare(earliestTime) >= 0;
}
}
}
privateclassTagQualifierimplementsQualifier {
privateUniqueTagListtags;
privateTagQualifier(UniqueTagListtags) {
this.tags = tags;
}
@Overridepublicbooleanrun(ReadOnlyTasktask) {
if (tags.isEmpty()) {
//every task satisfies, because the qualifier is emptyreturntrue;
} else {
returntags.toSet().stream()
.filter(tag -> task.getTags().contains(tag))
.findAny().isPresent();
}
}
}
//with the constraint of DD-MM-YY, the max date time should be 2099-12-31 2359//and the min date time should be 2000-01-01 0000;publicstaticfinalStringMAX_TIME = "31-12-99 2359";
publicstaticfinalStringMIN_TIME = "01-01-00 0000";
\java\seedu\geekeep\model\task\DateTime.java
/** * Returns the min date time GeeKeep currently supports */publicstaticDateTimegetMin() {
DateTimeminDateTime = null;
//It is guaranteed that there is no exception throwntry {
minDateTime = newDateTime(MIN_TIME);
} catch (IllegalValueExceptione) {
}
returnminDateTime;
}
/** * Returns the max date time GeeKeep currently supports */publicstaticDateTimegetMax() {
DateTimemaxDateTime = null;
//It is guaranteed that there is no exception throwntry {
maxDateTime = newDateTime(MAX_TIME);
} catch (IllegalValueExceptione) {
}
returnmaxDateTime;
}
/** * Get the task's DateTime that is used to compare date time. * For events, the startDateTime is used for comparison. * For deadlines, the endDateTime is used for comparison. * @return DateTime object */DateTimegetReferenceDateTime();
/** * Compares this task's type priority with another. * @param otherTask * @return a comparator value, negative if less, positive if greater */publicintcomparePriority(ReadOnlyTaskotherTask);
/** * Compares this task's reference datetime with another in chronological order. * @param otherTask * @return a comparator value, negative if less, positive if greater */intcompareDate(ReadOnlyTaskotherTask);
/** * Compares this task's type priority and reference datetime with another. * Compares this task's title with another in lexicographic order if both are floating tasks. * @param otherTask * @return a comparator value, negative if less, positive if greater */publicintcomparePriorityAndDatetimeAndTitle(ReadOnlyTaskotherTask);
/** * Compares this task's title with another in lexicographic order. * @param otherTask * @return a comparator value, negative if less, positive if greater */publicintcompareTitle(ReadOnlyTaskotherTask);
\java\seedu\geekeep\model\task\Task.java
@Override/** * Get the task's priority which determines the ordering of index * @return int value of Priority */publicintgetPriority() {
if (isEvent()) {
returnEVENT_PRIORITY;
} elseif (isFloatingTask()) {
returnFLOATING_TASK_PRIORITY;
} else {
assertisDeadline();
returnDEADLINE_PRIORITY;
}
}
\java\seedu\geekeep\ui\CommandBox.java
/** * Sets the command box style to indicate a failed command. */privatevoidsetStyleToIndicateCommandFailure() {
ObservableList<String> styleClass = commandTextField.getStyleClass();
if (!styleClass.contains(ERROR_STYLE_CLASS)) {
commandTextField.getStyleClass().add(ERROR_STYLE_CLASS);
}
}