Skip to content

Commit

Permalink
Task highlighting (#179)
Browse files Browse the repository at this point in the history
* Add jump to list request event

* Make highlighting disappear after several seconds

* A bit clean up

* Highlight existing task when adding duplicates

* Remove sop

* Update ui diagrams

* Enable selection only when needed

* Update color to be more obvious

* Support highlighting for rename/schedule task

* Update highlight color

* Disable click on the list

* Change shortcut key of helpwindow to be ctrl+H

* Update task card date time format

* add shortchut key as ctrl-z for undo

* Fix the mainwindow request focusing automatically issue

* Update task card handle for gui tests

* Extend gui test time

* Extend some gui test time

* Add icons for different panels

* Some ui updates

* Updates for gui tests

* Some font size changes

* Remove split divider

* Remove unnecessary imports

* Format time

* Update time format in gui task card handle

* Update messages to remove any index

* Update gui test

* Update task panel name
  • Loading branch information
fanwgwg authored Nov 1, 2016
1 parent 4481f72 commit 4101954
Show file tree
Hide file tree
Showing 37 changed files with 456 additions and 237 deletions.
Binary file modified docs/diagrams/Diagrams.pptx
Binary file not shown.
Binary file modified docs/images/UiClassDiagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package seedu.agendum.commons.events.ui;

import seedu.agendum.commons.events.BaseEvent;
import seedu.agendum.model.task.Task;

//@@author A0148031R
/**
* Indicates a request to jump to the list of tasks
*/
public class JumpToListRequestEvent extends BaseEvent {

public final Task targetTask;
public final boolean hasMultipleTasks;

public JumpToListRequestEvent(Task task, boolean hasMultipleTasks) {
this.targetTask = task;
this.hasMultipleTasks = hasMultipleTasks;
}

@Override
public String toString() {
return this.getClass().getSimpleName();
}

}
5 changes: 2 additions & 3 deletions src/main/java/seedu/agendum/logic/commands/MarkCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class MarkCommand extends Command {
+ "(The id must be a positive number)\n"
+ "Example: " + COMMAND_WORD + " 1 3 5-6";

public static final String MESSAGE_MARK_TASK_SUCCESS = "Marked Task(s): %1$s";
public static final String MESSAGE_MARK_TASK_SUCCESS = "Marked Task(s)!";
public static final String MESSAGE_DUPLICATE = "Hey, the task already exists";

public ArrayList<Integer> targetIndexes;
Expand Down Expand Up @@ -63,8 +63,7 @@ public CommandResult execute() {
return new CommandResult(MESSAGE_DUPLICATE);
}

return new CommandResult(String.format(MESSAGE_MARK_TASK_SUCCESS,
CommandResult.tasksToString(tasksToMark, targetIndexes)));
return new CommandResult(MESSAGE_MARK_TASK_SUCCESS);
}

private boolean isAnyIndexInvalid(UnmodifiableObservableList<ReadOnlyTask> lastShownList) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/seedu/agendum/logic/commands/RenameCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class RenameCommand extends Command {
+ COMMAND_FORMAT + "\n"
+ "Example: " + COMMAND_WORD + " 2 Watch Star Trek";

public static final String MESSAGE_SUCCESS = "Task #%1$s renamed: %2$s";
public static final String MESSAGE_SUCCESS = "Task renamed: %1$s";
public static final String MESSAGE_DUPLICATE_TASK = "Hey, the task already exists";

public int targetIndex = -1;
Expand Down Expand Up @@ -60,7 +60,7 @@ public CommandResult execute() {
} catch (TaskNotFoundException e) {
assert false : "The target task cannot be missing";
}
return new CommandResult(String.format(MESSAGE_SUCCESS, targetIndex, newTaskName));
return new CommandResult(String.format(MESSAGE_SUCCESS, newTaskName));

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class ScheduleCommand extends Command {
+ "(The id must be a positive number)\n"
+ "Example: " + COMMAND_WORD + " 2 from 7am to 9am";

public static final String MESSAGE_SUCCESS = "Rescheduled Task #%1$s: %2$s";
public static final String MESSAGE_SUCCESS = "Task rescheduled: %1$s";
public static final String MESSAGE_DUPLICATE_TASK = "This task already exists!";

public int targetIndex = -1;
Expand Down Expand Up @@ -70,7 +70,7 @@ public CommandResult execute() {
assert false : "The target task cannot be missing";
}

return new CommandResult(String.format(MESSAGE_SUCCESS, targetIndex, updatedTask));
return new CommandResult(String.format(MESSAGE_SUCCESS, updatedTask));
}

//@author
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/seedu/agendum/logic/commands/UnmarkCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class UnmarkCommand extends Command {
+ "(The id must be a positive number)\n"
+ "Example: " + COMMAND_WORD + " 11-13 15";

public static final String MESSAGE_UNMARK_TASK_SUCCESS = "Unmarked Task(s): %1$s";
public static final String MESSAGE_UNMARK_TASK_SUCCESS = "Unmarked Task(s)!";
public static final String MESSAGE_DUPLICATE = "Hey, the task already exists";

public ArrayList<Integer> targetIndexes;
Expand Down Expand Up @@ -63,8 +63,7 @@ public CommandResult execute() {
return new CommandResult(MESSAGE_DUPLICATE);
}

return new CommandResult(String.format(MESSAGE_UNMARK_TASK_SUCCESS,
CommandResult.tasksToString(tasksToUnmark, targetIndexes)));
return new CommandResult(MESSAGE_UNMARK_TASK_SUCCESS);
}

private boolean isAnyIndexInvalid(UnmodifiableObservableList<ReadOnlyTask> lastShownList) {
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/seedu/agendum/model/task/ReadOnlyTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ public interface ReadOnlyTask {
boolean isCompleted();
boolean isUpcoming();
boolean isOverdue();
boolean isEvent();
boolean hasDeadline();
boolean hasTime();
Optional<LocalDateTime> getStartDateTime();
Optional<LocalDateTime> getEndDateTime();
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/seedu/agendum/model/task/Task.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@ public boolean hasTime() {
return (getStartDateTime().isPresent() || getEndDateTime().isPresent());
}

@Override
public boolean isEvent() {
return getStartDateTime().isPresent();
}

@Override
public boolean hasDeadline() {
return !getStartDateTime().isPresent() && getEndDateTime().isPresent();
}

@Override
public Optional<LocalDateTime> getStartDateTime() {
return Optional.ofNullable(startDateTime);
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/seedu/agendum/model/task/UniqueTaskList.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import seedu.agendum.commons.util.CollectionUtil;
import seedu.agendum.commons.core.EventsCenter;
import seedu.agendum.commons.core.LogsCenter;
import seedu.agendum.commons.events.ui.JumpToListRequestEvent;
import seedu.agendum.commons.exceptions.DuplicateDataException;

import java.util.*;
Expand Down Expand Up @@ -60,10 +62,13 @@ public void add(Task toAdd) throws DuplicateTaskException {

if (contains(toAdd)) {
logger.fine("[TASK LIST] --- Duplicate Task: " + toAdd.getDetailedText());
EventsCenter.getInstance().post(new JumpToListRequestEvent(toAdd, false));
throw new DuplicateTaskException();
}

internalList.add(toAdd);
EventsCenter.getInstance().post(new JumpToListRequestEvent(toAdd, false));

logger.fine("[TASK LIST] --- Added a Task: " + toAdd.getDetailedText());
}

Expand Down Expand Up @@ -107,10 +112,12 @@ public boolean update(ReadOnlyTask toUpdate, Task updatedTask)

if (contains(updatedTask)) {
logger.fine("[TASK LIST] --- Duplicate Task: " + toUpdate.getDetailedText());
EventsCenter.getInstance().post(new JumpToListRequestEvent(updatedTask, true));
throw new DuplicateTaskException();
}

internalList.set(taskIndex, updatedTask);
EventsCenter.getInstance().post(new JumpToListRequestEvent(updatedTask, true));
logger.fine("[TASK LIST] --- Updated Task: " + toUpdate.getDetailedText()
+ " updated to " + updatedTask.getDetailedText());

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/seedu/agendum/ui/CommandBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class CommandBox extends UiPart {
private static final String FIND_COMMAND = "find ";
private static final String HELP_COMMAND = "help";
private static final String RESULT_FEEDBACK = "Result: ";
private static final String ERROR = "error";
private static final String FIND_COMMAND_REMINDER_MESSAGE = "Showing search results now, press ESC to go back and"
+ " view all tasks";

Expand Down Expand Up @@ -184,7 +185,7 @@ private void restoreCommandText() {
* Sets the command box style to indicate an error
*/
private void setStyleToIndicateIncorrectCommand() {
commandTextField.getStyleClass().add("error");
commandTextField.getStyleClass().add(ERROR);
}

}
38 changes: 36 additions & 2 deletions src/main/java/seedu/agendum/ui/CompletedTasksPanel.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
package seedu.agendum.ui;

import javafx.animation.PauseTransition;
import javafx.application.Platform;
import javafx.collections.ObservableList;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.scene.control.Control;
import javafx.scene.control.ListCell;
import javafx.scene.control.ListView;
import javafx.scene.control.MultipleSelectionModel;
import javafx.scene.control.SelectionMode;
import javafx.scene.input.MouseEvent;
import javafx.util.Duration;
import seedu.agendum.model.task.ReadOnlyTask;
import seedu.agendum.model.task.Task;

//@@author A0148031R
/**
Expand All @@ -15,6 +22,7 @@
public class CompletedTasksPanel extends TasksPanel {
private static final String FXML = "CompletedTasksPanel.fxml";
private static ObservableList<ReadOnlyTask> mainTaskList;
private MultipleSelectionModel<ReadOnlyTask> selectionModel;

@FXML
private ListView<ReadOnlyTask> completedTasksListView;
Expand All @@ -29,12 +37,38 @@ protected void setConnections(ObservableList<ReadOnlyTask> taskList) {
mainTaskList = taskList;
completedTasksListView.setItems(taskList.filtered(task -> task.isCompleted()));
completedTasksListView.setCellFactory(listView -> new CompletedTasksListViewCell());
configure();
}

private void configure() {
selectionModel = completedTasksListView.getSelectionModel();
completedTasksListView.setSelectionModel(null);
completedTasksListView.addEventFilter(MouseEvent.MOUSE_PRESSED, new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
event.consume();
}
});
}

public void scrollTo(int index) {
public void scrollTo(Task task, boolean hasMultipleTasks) {
Platform.runLater(() -> {

int index = mainTaskList.indexOf(task) - mainTaskList.filtered(t -> !t.isCompleted()).size();
completedTasksListView.scrollTo(index);
completedTasksListView.getSelectionModel().clearAndSelect(index);
completedTasksListView.setSelectionModel(selectionModel);

if(hasMultipleTasks) {
completedTasksListView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
completedTasksListView.getSelectionModel().select(index);
} else {
completedTasksListView.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
completedTasksListView.getSelectionModel().clearAndSelect(index);
}

PauseTransition delay = new PauseTransition(Duration.seconds(5));
delay.setOnFinished(event -> completedTasksListView.getSelectionModel().clearSelection(index));
delay.play();
});
}

Expand Down
40 changes: 38 additions & 2 deletions src/main/java/seedu/agendum/ui/FloatingTasksPanel.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
package seedu.agendum.ui;

import javafx.animation.PauseTransition;
import javafx.application.Platform;
import javafx.collections.ObservableList;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.scene.control.Control;
import javafx.scene.control.ListCell;
import javafx.scene.control.ListView;
import javafx.scene.control.MultipleSelectionModel;
import javafx.scene.control.SelectionMode;
import javafx.scene.input.MouseEvent;
import javafx.util.Duration;
import seedu.agendum.model.task.ReadOnlyTask;
import seedu.agendum.model.task.Task;

//@@author A0148031R
/**
Expand All @@ -15,6 +22,7 @@
public class FloatingTasksPanel extends TasksPanel {
private static final String FXML = "FloatingTasksPanel.fxml";
private static ObservableList<ReadOnlyTask> mainTaskList;
private MultipleSelectionModel<ReadOnlyTask> selectionModel;

@FXML
private ListView<ReadOnlyTask> floatingTasksListView;
Expand All @@ -29,12 +37,39 @@ protected void setConnections(ObservableList<ReadOnlyTask> taskList) {
mainTaskList = taskList;
floatingTasksListView.setItems(taskList.filtered(task -> !task.isCompleted() && !task.hasTime()));
floatingTasksListView.setCellFactory(listView -> new FloatingTasksListViewCell());
configure();
}

private void configure() {
selectionModel = floatingTasksListView.getSelectionModel();
floatingTasksListView.setSelectionModel(null);
floatingTasksListView.addEventFilter(MouseEvent.MOUSE_PRESSED, new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
event.consume();
}
});
}

public void scrollTo(int index) {
public void scrollTo(Task task, boolean hasMultipleTasks) {
Platform.runLater(() -> {

int index = mainTaskList.indexOf(task) -
mainTaskList.filtered(t -> (t.hasTime() && !t.isCompleted())).size();
floatingTasksListView.scrollTo(index);
floatingTasksListView.getSelectionModel().clearAndSelect(index);
floatingTasksListView.setSelectionModel(selectionModel);

if(hasMultipleTasks) {
floatingTasksListView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
floatingTasksListView.getSelectionModel().select(index);
} else {
floatingTasksListView.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
floatingTasksListView.getSelectionModel().clearAndSelect(index);
}

PauseTransition delay = new PauseTransition(Duration.seconds(4));
delay.setOnFinished(event -> floatingTasksListView.getSelectionModel().clearSelection(index));
delay.play();
});
}

Expand All @@ -53,6 +88,7 @@ protected void updateItem(ReadOnlyTask task, boolean empty) {
setText(null);
} else {
setGraphic(TaskCard.load(task, mainTaskList.indexOf(task) + 1).getLayout());
// scrollTo();
}
}
}
Expand Down
27 changes: 15 additions & 12 deletions src/main/java/seedu/agendum/ui/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ public class MainWindow extends UiPart {

private static final String ICON = "/images/agendum_icon.png";
private static final String FXML = "MainWindow.fxml";
public static final String LIST_COMMAND = "list";
private static final String LIST_COMMAND = "list";
private static final String UNDO_COMMAND = "undo";

private Logic logic;

Expand Down Expand Up @@ -123,7 +124,7 @@ private void configure(String appTitle, String toDoListName, Config config, User
* Set shortcut key for help menu item
*/
private void setAccelerators() {
helpMenuItem.setAccelerator(KeyCombination.valueOf("F5"));
helpMenuItem.setAccelerator(new KeyCodeCombination(KeyCode.H, KeyCombination.CONTROL_DOWN));
}

/**
Expand All @@ -132,14 +133,15 @@ private void setAccelerators() {
private void configureHelpWindowToggle() {
scene.addEventFilter(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() {
KeyCombination toggleHelpWindow = new KeyCodeCombination(KeyCode.H, KeyCombination.CONTROL_DOWN);

KeyCombination undo = new KeyCodeCombination(KeyCode.Z, KeyCombination.CONTROL_DOWN);
@Override
public void handle(KeyEvent evt) {
if (toggleHelpWindow.match(evt) && messagePlaceHolder.getChildren().size() == 0) {
openHelpWindow();
} else if (toggleHelpWindow.match(evt) && messagePlaceHolder.getChildren().size() != 0) {
closeHelpWindow();

} else if(undo.match(evt)) {
logic.execute(UNDO_COMMAND);
}
}
});
Expand Down Expand Up @@ -203,16 +205,17 @@ public AnchorPane getFloatingTasksPlaceHolder() {
return floatingTasksPlaceHolder;
}

public TasksPanel getUpcomingTasksPanel() {
return (UpcomingTasksPanel)this.upcomingTasksPanel;
public UpcomingTasksPanel getUpcomingTasksPanel() {
return (UpcomingTasksPanel) this.upcomingTasksPanel;
}
public TasksPanel getCompletedTasksPanel() {
return (CompletedTasksPanel)this.completedTasksPanel;

public CompletedTasksPanel getCompletedTasksPanel() {
return (CompletedTasksPanel) this.completedTasksPanel;
}

public TasksPanel getFloatingasksPanel() {
return (FloatingTasksPanel)this.floatingTasksPanel;

public FloatingTasksPanel getFloatingasksPanel() {
return (FloatingTasksPanel) this.floatingTasksPanel;

}

/**
Expand Down
Loading

0 comments on commit 4101954

Please sign in to comment.