Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task highlighting #179

Merged
merged 37 commits into from
Nov 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
d353f04
Add jump to list request event
Oct 30, 2016
945c5c3
Make highlighting disappear after several seconds
Oct 30, 2016
e88e5f7
A bit clean up
Oct 30, 2016
af49cb1
Highlight existing task when adding duplicates
Oct 30, 2016
be58ae8
Remove sop
Oct 30, 2016
aff5456
Update ui diagrams
Oct 30, 2016
cf07f58
Enable selection only when needed
Oct 31, 2016
61e6ee7
Merge branch 'master' into task-highlighting
Oct 31, 2016
1c6dceb
Update color to be more obvious
Oct 31, 2016
c6a04cc
Support highlighting for rename/schedule task
Oct 31, 2016
7bd139a
Update highlight color
Oct 31, 2016
a199551
Disable click on the list
Oct 31, 2016
a9409ed
Change shortcut key of helpwindow to be ctrl+H
Oct 31, 2016
2047040
Update task card date time format
Oct 31, 2016
b6bd256
add shortchut key as ctrl-z for undo
Oct 31, 2016
15a3fe6
Merge branch 'master' into task-highlighting
fanwgwg Oct 31, 2016
204cdc0
Fix the mainwindow request focusing automatically issue
Oct 31, 2016
be16c05
Update task card handle for gui tests
Oct 31, 2016
1be0e59
Extend gui test time
Oct 31, 2016
18a9b5e
Extend some gui test time
Oct 31, 2016
95f03a5
Add icons for different panels
Oct 31, 2016
52a3cc0
Some ui updates
Oct 31, 2016
43ef8f1
Updates for gui tests
Oct 31, 2016
ad2c933
Some font size changes
Oct 31, 2016
6b94919
Remove split divider
Oct 31, 2016
19ac3e6
Remove unnecessary imports
Oct 31, 2016
efec900
Format time
rachx Nov 1, 2016
ceb36f2
Merge master into task-highlighting
Nov 1, 2016
b6fc141
Update time format in gui task card handle
Nov 1, 2016
d14ca51
Update messages to remove any index
rachx Nov 1, 2016
2d63ae7
Merge branch 'master' into task-highlighting
rachx Nov 1, 2016
56f107a
Update gui test
Nov 1, 2016
83e428d
Merge branch 'task-highlighting' of https://github.com/CS2103AUG2016-…
Nov 1, 2016
4d2b026
Update task panel name
Nov 1, 2016
9f09f1a
merged remote into local (remove indices)
rachx Nov 1, 2016
ece7bae
Merge branch 'master' into task-highlighting
Nov 1, 2016
49b352f
Merge branch 'master' into task-highlighting
Nov 1, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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