Skip to content

Commit

Permalink
Merge 248b124 into f82ba83
Browse files Browse the repository at this point in the history
  • Loading branch information
Yichen-D committed Nov 1, 2016
2 parents f82ba83 + 248b124 commit 71e3eaa
Show file tree
Hide file tree
Showing 17 changed files with 79 additions and 60 deletions.
1 change: 1 addition & 0 deletions src/main/java/seedu/address/MainApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public void init() throws Exception {
ui = new UiManager(logic, config, userPrefs);

initEventsCenter();

}

private String getApplicationParameter(String parameterName){
Expand Down
1 change: 1 addition & 0 deletions src/main/java/seedu/address/model/Model.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,5 @@ public interface Model {

/** Sets the system time. */
void setSystemTime(AgendaTimeRangeChangedEvent atrce);

}
87 changes: 40 additions & 47 deletions src/main/java/seedu/address/model/ModelManager.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package seedu.address.model;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashSet;
Expand Down Expand Up @@ -46,7 +45,7 @@ public class ModelManager extends ComponentManager implements Model {
private Expression previousExpression;
private TaskDate previousDate;

// @@author A0135782Y
//@@author A0135782Y
/**
* Initializes a ModelManager with the given TaskList TaskList and its
* variables should not be null
Expand All @@ -64,16 +63,17 @@ public ModelManager(TaskMaster src, UserPrefs userPrefs) {
if (RecurringTaskManager.getInstance().updateAnyRecurringTasks()) {
indicateTaskListChanged();
}
previousExpression = new PredicateExpression(new InitialQualifier());
previousDate = new TaskDate(new Date(System.currentTimeMillis()));
previousExpression = new PredicateExpression(new InitialQualifier());

}

// @@author
//@@author
public ModelManager() {
this(new TaskMaster(), new UserPrefs());
}

// @@author A0135782Y
//@@author A0135782Y
public ModelManager(ReadOnlyTaskMaster initialData, UserPrefs userPrefs) {
taskMaster = new TaskMaster(initialData);
tasks = taskMaster.getTasks();
Expand All @@ -83,11 +83,10 @@ public ModelManager(ReadOnlyTaskMaster initialData, UserPrefs userPrefs) {
if (RecurringTaskManager.getInstance().updateAnyRecurringTasks()) {
indicateTaskListChanged();
}
previousExpression = new PredicateExpression(new InitialQualifier());
previousDate = new TaskDate(new Date(System.currentTimeMillis()));
showTaskToday();
previousExpression = new PredicateExpression(new InitialQualifier());
}
// @@author
//@@author

@Override
public void resetData(ReadOnlyTaskMaster newData) {
Expand All @@ -111,17 +110,17 @@ public synchronized void deleteTask(TaskOccurrence target) throws TaskNotFoundEx
indicateTaskListChanged();
}

// @@author A0147995H
//@@author A0147995H
@Override
public synchronized void editTask(Task target, Name name, UniqueTagList tags, TaskDate startDate, TaskDate endDate,
RecurringType recurringType) throws TaskNotFoundException, TimeslotOverlapException {
taskMaster.updateTask(target, name, tags, startDate, endDate, recurringType);
indicateTaskListChanged();
updateFilteredTaskList(previousExpression);
}
// @@author
//@@author

// @@author A0135782Y
//@@author A0135782Y
@Override
public synchronized void addTask(Task task) throws UniqueTaskList.DuplicateTaskException, TimeslotOverlapException {
taskMaster.addTask(task);
Expand All @@ -130,7 +129,7 @@ public synchronized void addTask(Task task) throws UniqueTaskList.DuplicateTaskE
indicateTaskListChanged();
}

// @@author A0147967J
//@@author A0147967J
@Override
public synchronized void archiveTask(TaskOccurrence target) throws TaskNotFoundException {
taskMaster.archiveTask(target);
Expand All @@ -143,7 +142,7 @@ public synchronized void archiveTask(TaskOccurrence target) throws TaskNotFoundE
public void changeDirectory(String filePath) {
raise(new FilePathChangeEvent(filePath));
}
// @@author
//@@author

// =========== Filtered Task List Accessory ===============================================================

Expand All @@ -170,24 +169,32 @@ public void updateFilteredTaskList(Set<String> keywords, Set<String> tags, Date
new PredicateExpression(new FindQualifier(keywords, tags, startDate, endDate, deadline)));
}

//@@A0147967J
@Override
public void updateFilteredTaskList(Expression expression) {
previousExpression = expression;
filteredTaskComponents.setPredicate(expression::satisfies);
}


@Override
public Expression getPreviousExpression() {
return previousExpression;
}

@Override
public TaskDate getPreviousDate(){
return previousDate;
}

@Override
@Subscribe
public void setSystemTime(AgendaTimeRangeChangedEvent atrce){
previousDate = atrce.getInputDate();
updateFilteredTaskList(new HashSet<String>(), new HashSet<String>(),
DateFormatterUtil.getStartOfDay(atrce.getInputDate().getDate()), DateFormatterUtil.getEndOfDay(atrce.getInputDate().getDate()), null);
}

public void showTaskToday() {
Date date = DateFormatterUtil.localDateToDate(LocalDate.now());
updateFilteredTaskList(new HashSet<String>(), new HashSet<String>(),
DateFormatterUtil.getStartOfDay(date), DateFormatterUtil.getEndOfDay(date), null);
}
//@@author

// ========== Inner classes/interfaces used for filtering ==================================================

Expand Down Expand Up @@ -216,35 +223,31 @@ interface Qualifier {

}

// @@author A0147967J
private class TypeQualifier implements Qualifier {
private TaskType typeKeyWords;

TypeQualifier(TaskType typeKeyWords) {
this.typeKeyWords = typeKeyWords;
}
//@@author A0147967J
private class InitialQualifier implements Qualifier {

@Override
public boolean run(TaskOccurrence task) {
return task.getTaskReference().getTaskType().equals(typeKeyWords) && !task.isArchived();
return true;
}

}

private class InitialQualifier implements Qualifier {
private class TypeQualifier implements Qualifier {
private TaskType typeKeyWords;

InitialQualifier() {
TypeQualifier(TaskType typeKeyWords) {
this.typeKeyWords = typeKeyWords;
}

@Override
public boolean run(TaskOccurrence task) {
return true;
return task.getTaskReference().getTaskType().equals(typeKeyWords) && !task.isArchived();
}

}
// @@author

// @@author A0135782Y

//@@author A0135782Y
private class ArchiveQualifier implements Qualifier {
private boolean isArchived;

Expand All @@ -258,9 +261,9 @@ public boolean run(TaskOccurrence task) {
}

}
// @@author
//@@author

// @@author A0147995H
//@@author A0147995H
private class NameQualifier implements Qualifier {
private Set<String> nameKeyWords;

Expand Down Expand Up @@ -419,16 +422,6 @@ public boolean run(TaskOccurrence task) {
}

}
// @@author
//@@author

@Override
public Expression getPreviousExpression() {
// TODO Auto-generated method stub
return previousExpression;
}

@Override
public TaskDate getPreviousDate(){
return previousDate;
}
}
4 changes: 4 additions & 0 deletions src/main/java/seedu/address/ui/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,10 @@ public void loadTaskPage(ReadOnlyTask task) {
public void releaseResources() {
browserPanel.freeResources();
}

public void switchToInitialTab() {
logic.execute("find from 12am to tomorrow 12am");
}


}
4 changes: 1 addition & 3 deletions src/main/java/seedu/address/ui/NavbarPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import java.util.Date;
import java.util.Locale;
import java.util.logging.Logger;
import javafx.application.Platform;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
Expand All @@ -19,7 +18,6 @@
import seedu.address.commons.events.ui.NavigationSelectionChangedEvent;
import seedu.address.logic.commands.FindCommand;
import seedu.address.logic.commands.ListCommand;
import seedu.address.logic.commands.ViewCommand;

public class NavbarPanel extends UiPart {

Expand Down Expand Up @@ -102,7 +100,7 @@ public String getNavigationCommand(String navigation) {
switch (navigation) {

case NAVBAR_TODAY:
command = ViewCommand.COMMAND_WORD + " by today";
command = FindCommand.COMMAND_WORD + " from 12am to tomorrow 12am";
return command;
case NAVBAR_DEADLINES:
day = new Date(System.currentTimeMillis() + 24 * 60 * 60 * 1000);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/seedu/address/ui/UiManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public void start(Stage primaryStage) {
mainWindow = MainWindow.load(primaryStage, config, prefs, logic);
mainWindow.show(); //This should be called before creating other UI parts
mainWindow.fillInnerParts();
mainWindow.switchToInitialTab();
} catch (Throwable e) {
logger.severe(StringUtil.getDetails(e));
showFatalErrorDialogAndShutdown("Fatal error during initializing", e);
Expand Down
8 changes: 4 additions & 4 deletions src/main/resources/view/DarkTheme.css
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,17 @@
-fx-text-fill: white;
}

#navbarView .list-cell:even:filled {
#navbarView .list-cell:odd:filled {
-fx-background-color: derive(#f7882f, 20%);
}

#navbarView .list-cell:odd:filled {
#navbarView .list-cell:even:filled {
-fx-background-color: derive(#f7c331, 50%);
}
#navbarView .list-cell:odd:filled .image-view{
#navbarView .list-cell:even:filled .image-view{
-fx-image:url('/images/ddl_icon.png');
}
#navbarView .list-cell:even:filled .image-view{
#navbarView .list-cell:odd:filled .image-view{
-fx-image:url('/images/task_icon.png');
-fx-alignment:left;
}
Expand Down
1 change: 1 addition & 0 deletions src/test/java/guitests/AddCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class AddCommandTest extends TaskMasterGuiTest {

@Test
public void add() {
commandBox.runCommand("list"); //switch to all tasks first
// add one floatingTask
TestTask[] currentList = td.getTypicalTasks();
TestTask taskToAdd = td.hoon;
Expand Down
1 change: 1 addition & 0 deletions src/test/java/guitests/BlockCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class BlockCommandTest extends TaskMasterGuiTest {

@Test
public void block() {
commandBox.runCommand("list"); //switch to all tasks first
// block one slot
TestTask[] currentList = td.getTypicalTasks();
TestTask slotToBlock = td.block1;
Expand Down
1 change: 1 addition & 0 deletions src/test/java/guitests/ClearCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class ClearCommandTest extends TaskMasterGuiTest {

@Test
public void clear() {
commandBox.runCommand("list"); //switch to all tasks first

TaskOccurrence[] taskComponents = TestUtil.convertTasksToDateComponents(td.getTypicalTasks());
//verify a non-empty list can be cleared
Expand Down
10 changes: 7 additions & 3 deletions src/test/java/guitests/CompleteCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,28 @@ public class CompleteCommandTest extends TaskMasterGuiTest {

@Test
public void complete() {
commandBox.runCommand("list"); //switch to all tasks first

// done the first in the list
TestTask[] currentList = td.getTypicalTasks();
TestTask[] completed = new TestTask[3];
int targetIndex = 1;
completed[0] = currentList[targetIndex - 1];
assertCompleteSuccess(targetIndex, currentList);
currentList = TestUtil.removeTaskFromList(currentList, targetIndex);

// done the last in the list
targetIndex = currentList.length;
completed[2] = currentList[targetIndex - 1];
assertCompleteSuccess(targetIndex, currentList);

currentList = TestUtil.removeTaskFromList(currentList, targetIndex);

// done from the middle of the list
targetIndex = 3;
completed[1] = currentList[targetIndex - 1];
assertCompleteSuccess(targetIndex, currentList);

currentList = TestUtil.removeTaskFromList(currentList, targetIndex);

// invalid index
commandBox.runCommand("done " + currentList.length + 1);
assertResultMessage("The task index provided is invalid");
Expand All @@ -58,7 +62,7 @@ public void complete() {
*/
private void assertCompleteSuccess(int targetIndexOneIndexed, final TestTask[] currentList) {
TestTask taskToComplete = currentList[targetIndexOneIndexed - 1]; // -1
TestTask[] expectedRemainder = currentList;
TestTask[] expectedRemainder = TestUtil.removeTaskFromList(currentList, targetIndexOneIndexed);

commandBox.runCommand("done " + targetIndexOneIndexed);

Expand Down
1 change: 1 addition & 0 deletions src/test/java/guitests/DeleteCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class DeleteCommandTest extends TaskMasterGuiTest {

@Test
public void delete() {
commandBox.runCommand("list"); //switch to all tasks first

//delete the first in the list
TestTask[] currentList = td.getTypicalTasks();
Expand Down
1 change: 1 addition & 0 deletions src/test/java/guitests/EditCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class EditCommandTest extends TaskMasterGuiTest {

@Test
public void edit() throws IllegalValueException {
commandBox.runCommand("list"); //switch to all tasks first

// Fix Index first to see edit effect
// edit deadline
Expand Down
8 changes: 8 additions & 0 deletions src/test/java/guitests/NavbarPanelTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class NavbarPanelTest extends TaskMasterGuiTest {
private final String NAVBAR_INCOMING_DEADLINES = " Incoming Deadlines";
private final String NAVBAR_FLOATING_TASKS = " Floating Tasks";
private final String NAVBAR_COMPLETED = " Completed";
private final String NAVBAR_TODAY = " Today";

@Test
public void navigateToFloatingTasks() {
Expand Down Expand Up @@ -49,9 +50,16 @@ public void navigateToAllTasks() {
@Test
public void navigateToCompletedOnes() {
// Navigate to completed ones
commandBox.runCommand("list"); //switch to all tasks first
commandBox.runCommand("done 1");
assertResult(NAVBAR_COMPLETED, td.trash.getLastAppendedComponent());
}

@Test
public void navigateToToday() {
// Navigate to today's tasks, here should be none.
assertResult(NAVBAR_TODAY);
}

private void assertResult(String navigation, TaskOccurrence... expectedHits) {
navbar.navigateTo(navigation);
Expand Down
1 change: 1 addition & 0 deletions src/test/java/guitests/SelectCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class SelectCommandTest extends TaskMasterGuiTest {

@Test
public void selectTask_nonEmptyList() {
commandBox.runCommand("list"); //switch to all tasks first

assertSelectionInvalid(20); //invalid index
assertNoTaskSelected();
Expand Down
Loading

0 comments on commit 71e3eaa

Please sign in to comment.