diff --git a/docs/diagrams/Diagrams.pptx b/docs/diagrams/Diagrams.pptx index 940760a35109..015062ee1802 100644 Binary files a/docs/diagrams/Diagrams.pptx and b/docs/diagrams/Diagrams.pptx differ diff --git a/docs/images/UiClassDiagram.png b/docs/images/UiClassDiagram.png index 282a9d930b34..3db1531b6fa1 100644 Binary files a/docs/images/UiClassDiagram.png and b/docs/images/UiClassDiagram.png differ diff --git a/src/main/java/seedu/agendum/logic/commands/AddCommand.java b/src/main/java/seedu/agendum/logic/commands/AddCommand.java index 9ae71b4c7f11..c3a985c6aa2e 100644 --- a/src/main/java/seedu/agendum/logic/commands/AddCommand.java +++ b/src/main/java/seedu/agendum/logic/commands/AddCommand.java @@ -79,7 +79,6 @@ public CommandResult execute() { } catch (UniqueTaskList.DuplicateTaskException e) { return new CommandResult(MESSAGE_DUPLICATE_TASK); } - } public static String getName() { diff --git a/src/main/java/seedu/agendum/model/UserPrefs.java b/src/main/java/seedu/agendum/model/UserPrefs.java index f200fddb86d5..cb89bbe11285 100644 --- a/src/main/java/seedu/agendum/model/UserPrefs.java +++ b/src/main/java/seedu/agendum/model/UserPrefs.java @@ -1,7 +1,8 @@ package seedu.agendum.model; import seedu.agendum.commons.core.GuiSettings; - +import java.awt.Dimension; +import java.awt.Toolkit; import java.util.Objects; /** @@ -19,14 +20,17 @@ public void updateLastUsedGuiSetting(GuiSettings guiSettings) { this.guiSettings = guiSettings; } + //@@author A0148031R public UserPrefs(){ - this.setGuiSettings(500, 500, 0, 0); + Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); + this.setGuiSettings(screenSize.getWidth(), screenSize.getHeight(), 0, 0); } public void setGuiSettings(double width, double height, int x, int y) { guiSettings = new GuiSettings(width, height, x, y); } + //@@author @Override public boolean equals(Object other) { if (other == this){ diff --git a/src/main/java/seedu/agendum/ui/CommandBox.java b/src/main/java/seedu/agendum/ui/CommandBox.java index 7bdf53237b6c..5f4183285dd5 100644 --- a/src/main/java/seedu/agendum/ui/CommandBox.java +++ b/src/main/java/seedu/agendum/ui/CommandBox.java @@ -3,12 +3,17 @@ import com.google.common.eventbus.Subscribe; import javafx.fxml.FXML; +import javafx.geometry.Pos; import javafx.scene.Node; +import javafx.scene.control.ContentDisplay; +import javafx.scene.control.Label; import javafx.scene.control.SplitPane; import javafx.scene.control.TextField; import javafx.scene.input.KeyCode; import javafx.scene.input.KeyEvent; import javafx.scene.layout.AnchorPane; +import javafx.scene.layout.StackPane; +import javafx.scene.paint.Color; import javafx.stage.Stage; import seedu.agendum.commons.events.ui.IncorrectCommandAttemptedEvent; import seedu.agendum.logic.Logic; @@ -24,9 +29,15 @@ public class CommandBox extends UiPart { private final Logger logger = LogsCenter.getLogger(CommandBox.class); private static final String FXML = "CommandBox.fxml"; + 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 FIND_COMMAND_REMINDER_MESSAGE = "Showing search results now, press ESC to go back and" + + " view all tasks"; private AnchorPane placeHolderPane; private AnchorPane commandPane; + private StackPane messagePlaceHolder; private ResultPopUp resultPopUp; private static CommandBoxHistory commandBoxHistory; @@ -36,21 +47,23 @@ public class CommandBox extends UiPart { private TextField commandTextField; private CommandResult mostRecentResult; - public static CommandBox load(Stage primaryStage, AnchorPane commandBoxPlaceholder, + public static CommandBox load(Stage primaryStage, AnchorPane commandBoxPlaceholder, StackPane messagePlaceHolder, ResultPopUp resultPopUp, Logic logic) { CommandBox commandBox = UiPartLoader.loadUiPart(primaryStage, commandBoxPlaceholder, new CommandBox()); - commandBox.configure(resultPopUp, logic); + commandBox.configure(resultPopUp, messagePlaceHolder, logic); commandBox.addToPlaceholder(); commandBoxHistory = new CommandBoxHistory(); return commandBox; } - public void configure(ResultPopUp resultPopUp, Logic logic) { + public void configure(ResultPopUp resultPopUp, StackPane messagePlaceHolder, Logic logic) { this.resultPopUp = resultPopUp; + this.messagePlaceHolder = messagePlaceHolder; this.logic = logic; registerAsAnEventHandler(this); registerArrowKeyEventFilter(); registerTabKeyEventFilter(); + postMessage(null); } private void addToPlaceholder() { @@ -80,17 +93,33 @@ private void handleCommandInputChanged() { //Take a copy of the command text commandBoxHistory.saveNewCommand(commandTextField.getText()); String previousCommandTest = commandBoxHistory.getLastCommand(); + if(previousCommandTest.toLowerCase().trim().startsWith(FIND_COMMAND) && + previousCommandTest.toLowerCase().trim().length() > FIND_COMMAND.length()) { + postMessage(FIND_COMMAND_REMINDER_MESSAGE); + } /* We assume the command is correct. If it is incorrect, the command box will be changed accordingly * in the event handling code {@link #handleIncorrectCommandAttempted} */ - + setStyleToIndicateCorrectCommand(); mostRecentResult = logic.execute(previousCommandTest); - if(!previousCommandTest.toLowerCase().equals("help")) { + if(!previousCommandTest.toLowerCase().equals(HELP_COMMAND)) { resultPopUp.postMessage(mostRecentResult.feedbackToUser); } - logger.info("Result: " + mostRecentResult.feedbackToUser); + logger.info(RESULT_FEEDBACK + mostRecentResult.feedbackToUser); + } + + private void postMessage(String message) { + if(message == null) { + this.messagePlaceHolder.setMaxHeight(0); + } else { + Label label = new Label(message); + label.setTextFill(Color.web("#ffffff")); + label.setContentDisplay(ContentDisplay.CENTER); + this.messagePlaceHolder.setAlignment(Pos.CENTER_LEFT); + this.messagePlaceHolder.getChildren().add(label); + } } private void registerArrowKeyEventFilter() { diff --git a/src/main/java/seedu/agendum/ui/CompletedTaskCard.java b/src/main/java/seedu/agendum/ui/CompletedTaskCard.java deleted file mode 100644 index 7da244bc3973..000000000000 --- a/src/main/java/seedu/agendum/ui/CompletedTaskCard.java +++ /dev/null @@ -1,55 +0,0 @@ -package seedu.agendum.ui; - -import javafx.fxml.FXML; - -import javafx.scene.Node; -import javafx.scene.control.Label; -import javafx.scene.layout.HBox; -import seedu.agendum.model.task.ReadOnlyTask; - -//@@author A0148031R -public class CompletedTaskCard extends UiPart { - - private static final String FXML = "CompletedTaskCard.fxml"; - - @FXML - private HBox cardPane; - @FXML - private Label name; - @FXML - private Label id; - - private ReadOnlyTask task; - private int displayedIndex; - - public CompletedTaskCard(){ - - } - - public static CompletedTaskCard load(ReadOnlyTask task, int displayedIndex){ - CompletedTaskCard card = new CompletedTaskCard(); - card.task = task; - card.displayedIndex = displayedIndex; - return UiPartLoader.loadUiPart(card); - } - - @FXML - public void initialize() { - name.setText(task.getName().fullName); - id.setText(displayedIndex + ". "); - } - - public HBox getLayout() { - return cardPane; - } - - @Override - public void setNode(Node node) { - cardPane = (HBox)node; - } - - @Override - public String getFxmlPath() { - return FXML; - } -} diff --git a/src/main/java/seedu/agendum/ui/CompletedTasksPanel.java b/src/main/java/seedu/agendum/ui/CompletedTasksPanel.java index cc62abd4e7c1..96177c04b8b6 100644 --- a/src/main/java/seedu/agendum/ui/CompletedTasksPanel.java +++ b/src/main/java/seedu/agendum/ui/CompletedTasksPanel.java @@ -3,67 +3,32 @@ import javafx.application.Platform; import javafx.collections.ObservableList; import javafx.fxml.FXML; -import javafx.scene.Node; +import javafx.scene.control.Control; import javafx.scene.control.ListCell; import javafx.scene.control.ListView; -import javafx.scene.control.SplitPane; -import javafx.scene.layout.AnchorPane; -import javafx.stage.Stage; import seedu.agendum.model.task.ReadOnlyTask; //@@author A0148031R /** * Panel contains the list of completed tasks */ -public class CompletedTasksPanel extends UiPart { +public class CompletedTasksPanel extends TasksPanel { private static final String FXML = "CompletedTasksPanel.fxml"; - private AnchorPane panel; - private AnchorPane placeHolderPane; private static ObservableList mainTaskList; @FXML private ListView completedTasksListView; - public CompletedTasksPanel() { - super(); - } - - @Override - public void setNode(Node node) { - panel = (AnchorPane) node; - } - @Override public String getFxmlPath() { return FXML; } @Override - public void setPlaceholder(AnchorPane pane) { - this.placeHolderPane = pane; - } - - public static CompletedTasksPanel load(Stage primaryStage, AnchorPane CompletedTasksPlaceholder, - ObservableList taskList) { + protected void setConnections(ObservableList taskList) { mainTaskList = taskList; - CompletedTasksPanel completedTasksPanel = UiPartLoader.loadUiPart(primaryStage, CompletedTasksPlaceholder, new CompletedTasksPanel()); - completedTasksPanel.configure(taskList); - return completedTasksPanel; - } - - private void configure(ObservableList taskList) { - setConnections(taskList); - addToPlaceholder(); - } - - private void setConnections(ObservableList taskList) { - completedTasksListView.setItems(taskList.filtered(ReadOnlyTask::isCompleted)); - completedTasksListView.setCellFactory(listView -> new completedTasksListViewCell()); - } - - private void addToPlaceholder() { - SplitPane.setResizableWithParent(placeHolderPane, false); - placeHolderPane.getChildren().add(panel); + completedTasksListView.setItems(taskList.filtered(task -> task.isCompleted())); + completedTasksListView.setCellFactory(listView -> new CompletedTasksListViewCell()); } public void scrollTo(int index) { @@ -72,8 +37,12 @@ public void scrollTo(int index) { completedTasksListView.getSelectionModel().clearAndSelect(index); }); } - - class completedTasksListViewCell extends ListCell { + + class CompletedTasksListViewCell extends ListCell { + public CompletedTasksListViewCell() { + prefWidthProperty().bind(completedTasksListView.widthProperty()); + setMaxWidth(Control.USE_PREF_SIZE); + } @Override protected void updateItem(ReadOnlyTask task, boolean empty) { @@ -87,5 +56,4 @@ protected void updateItem(ReadOnlyTask task, boolean empty) { } } } - } diff --git a/src/main/java/seedu/agendum/ui/DoItAnytimePanel.java b/src/main/java/seedu/agendum/ui/DoItAnytimePanel.java deleted file mode 100644 index 1db48c0a2acb..000000000000 --- a/src/main/java/seedu/agendum/ui/DoItAnytimePanel.java +++ /dev/null @@ -1,87 +0,0 @@ -package seedu.agendum.ui; - -import javafx.application.Platform; -import javafx.collections.ObservableList; -import javafx.fxml.FXML; -import javafx.scene.Node; -import javafx.scene.control.ListCell; -import javafx.scene.control.ListView; -import javafx.scene.control.SplitPane; -import javafx.scene.layout.AnchorPane; -import javafx.stage.Stage; -import seedu.agendum.model.task.ReadOnlyTask; - -//@@author A0148031R -/** - * Panel contains the list of uncompleted floating tasks - */ -public class DoItAnytimePanel extends UiPart { - private static final String FXML = "DoItAnytimePanel.fxml"; - private AnchorPane panel; - private AnchorPane placeHolderPane; - private static ObservableList mainTaskList; - - @FXML - private ListView anytimeTasksListView; - - @Override - public void setNode(Node node) { - panel = (AnchorPane) node; - } - - @Override - public String getFxmlPath() { - return FXML; - } - - @Override - public void setPlaceholder(AnchorPane pane) { - this.placeHolderPane = pane; - } - - public static DoItAnytimePanel load(Stage primaryStage, AnchorPane OtherTasksPlaceholder, - ObservableList taskList) { - mainTaskList = taskList; - DoItAnytimePanel otherTasksPanel = UiPartLoader.loadUiPart(primaryStage, OtherTasksPlaceholder, new DoItAnytimePanel()); - otherTasksPanel.configure(taskList); - return otherTasksPanel; - } - - private void configure(ObservableList taskList) { - setConnections(taskList.filtered(task -> !task.isCompleted() && !task.hasTime())); - addToPlaceholder(); - } - - private void setConnections(ObservableList otherTasks) { - anytimeTasksListView.setItems(otherTasks); - anytimeTasksListView.setCellFactory(listView -> new otherTasksListViewCell()); - } - - private void addToPlaceholder() { - SplitPane.setResizableWithParent(placeHolderPane, false); - placeHolderPane.getChildren().add(panel); - } - - public void scrollTo(int index) { - Platform.runLater(() -> { - anytimeTasksListView.scrollTo(index); - anytimeTasksListView.getSelectionModel().clearAndSelect(index); - }); - } - - class otherTasksListViewCell extends ListCell { - - @Override - protected void updateItem(ReadOnlyTask task, boolean empty) { - super.updateItem(task, empty); - - if (empty || task == null) { - setGraphic(null); - setText(null); - } else { - setGraphic(TaskCard.load(task, mainTaskList.indexOf(task) + 1).getLayout()); - } - } - } - -} diff --git a/src/main/java/seedu/agendum/ui/DoItSoonPanel.java b/src/main/java/seedu/agendum/ui/DoItSoonPanel.java deleted file mode 100644 index d8f1e2d260ae..000000000000 --- a/src/main/java/seedu/agendum/ui/DoItSoonPanel.java +++ /dev/null @@ -1,95 +0,0 @@ -package seedu.agendum.ui; - -import java.util.logging.Logger; - -import javafx.application.Platform; -import javafx.collections.ObservableList; -import javafx.fxml.FXML; -import javafx.scene.Node; -import javafx.scene.control.ListCell; -import javafx.scene.control.ListView; -import javafx.scene.control.SplitPane; -import javafx.scene.layout.AnchorPane; -import javafx.stage.Stage; -import seedu.agendum.model.task.ReadOnlyTask; -import seedu.agendum.commons.core.LogsCenter; - -//@@author A0148031R -/** - * Panel contains the list of all uncompleted tasks with time - */ -public class DoItSoonPanel extends UiPart { - private final Logger logger = LogsCenter.getLogger(DoItSoonPanel.class); - private static final String FXML = "DoItSoonPanel.fxml"; - private AnchorPane panel; - private AnchorPane placeHolderPane; - private static ObservableList mainTaskList; - - @FXML - private ListView timeTasksListView; - - public DoItSoonPanel() { - super(); - } - - @Override - public void setNode(Node node) { - panel = (AnchorPane) node; - } - - @Override - public String getFxmlPath() { - return FXML; - } - - @Override - public void setPlaceholder(AnchorPane pane) { - this.placeHolderPane = pane; - } - - public static DoItSoonPanel load(Stage primaryStage, AnchorPane AllTasksPlaceholder, - ObservableList taskList) { - mainTaskList = taskList; - DoItSoonPanel allTasksPanel = UiPartLoader.loadUiPart(primaryStage, AllTasksPlaceholder, new DoItSoonPanel()); - allTasksPanel.configure(taskList); - return allTasksPanel; - } - - private void configure(ObservableList allTasks) { - setConnections(allTasks); - addToPlaceholder(); - } - - private void setConnections(ObservableList allTasks) { - timeTasksListView.setItems(allTasks.filtered(task -> task.hasTime() && !task.isCompleted())); - timeTasksListView.setCellFactory(listView -> new allTasksListViewCell()); - } - - private void addToPlaceholder() { - SplitPane.setResizableWithParent(placeHolderPane, false); - placeHolderPane.getChildren().add(panel); - } - - public void scrollTo(int index) { - Platform.runLater(() -> { - timeTasksListView.scrollTo(index); - timeTasksListView.getSelectionModel().clearAndSelect(index); - }); - } - - class allTasksListViewCell extends ListCell { - - @Override - protected void updateItem(ReadOnlyTask task, boolean empty) { - super.updateItem(task, empty); - - if (empty || task == null) { - setGraphic(null); - setText(null); - } else { - setGraphic(TaskCard.load(task, mainTaskList.indexOf(task) + 1).getLayout()); - } - } - } - -} diff --git a/src/main/java/seedu/agendum/ui/FloatingTasksPanel.java b/src/main/java/seedu/agendum/ui/FloatingTasksPanel.java new file mode 100644 index 000000000000..81d586983d13 --- /dev/null +++ b/src/main/java/seedu/agendum/ui/FloatingTasksPanel.java @@ -0,0 +1,59 @@ +package seedu.agendum.ui; + +import javafx.application.Platform; +import javafx.collections.ObservableList; +import javafx.fxml.FXML; +import javafx.scene.control.Control; +import javafx.scene.control.ListCell; +import javafx.scene.control.ListView; +import seedu.agendum.model.task.ReadOnlyTask; + +//@@author A0148031R +/** + * Panel contains the list of uncompleted floating tasks + */ +public class FloatingTasksPanel extends TasksPanel { + private static final String FXML = "FloatingTasksPanel.fxml"; + private static ObservableList mainTaskList; + + @FXML + private ListView floatingTasksListView; + + @Override + public String getFxmlPath() { + return FXML; + } + + @Override + protected void setConnections(ObservableList taskList) { + mainTaskList = taskList; + floatingTasksListView.setItems(taskList.filtered(task -> !task.isCompleted() && !task.hasTime())); + floatingTasksListView.setCellFactory(listView -> new FloatingTasksListViewCell()); + } + + public void scrollTo(int index) { + Platform.runLater(() -> { + floatingTasksListView.scrollTo(index); + floatingTasksListView.getSelectionModel().clearAndSelect(index); + }); + } + + class FloatingTasksListViewCell extends ListCell { + public FloatingTasksListViewCell() { + prefWidthProperty().bind(floatingTasksListView.widthProperty()); + setMaxWidth(Control.USE_PREF_SIZE); + } + + @Override + protected void updateItem(ReadOnlyTask task, boolean empty) { + super.updateItem(task, empty); + + if (empty || task == null) { + setGraphic(null); + setText(null); + } else { + setGraphic(TaskCard.load(task, mainTaskList.indexOf(task) + 1).getLayout()); + } + } + } +} diff --git a/src/main/java/seedu/agendum/ui/HelpWindow.java b/src/main/java/seedu/agendum/ui/HelpWindow.java index a0c77b5e740c..0c068486c355 100644 --- a/src/main/java/seedu/agendum/ui/HelpWindow.java +++ b/src/main/java/seedu/agendum/ui/HelpWindow.java @@ -143,6 +143,7 @@ private void handleKeyInput(Scene scene) { public void handle(KeyEvent evt) { if (evt.getCode().equals(KeyCode.ESCAPE)) { dialogStage.close(); + primaryStage.requestFocus(); } else if (toggleHelpWindow.match(evt)) { if (dialogStage.isFocused()) { primaryStage.requestFocus(); diff --git a/src/main/java/seedu/agendum/ui/MainWindow.java b/src/main/java/seedu/agendum/ui/MainWindow.java index e6788c257854..a045ed68cbc5 100644 --- a/src/main/java/seedu/agendum/ui/MainWindow.java +++ b/src/main/java/seedu/agendum/ui/MainWindow.java @@ -11,6 +11,7 @@ import javafx.scene.input.KeyCombination; import javafx.scene.input.KeyEvent; import javafx.scene.layout.AnchorPane; +import javafx.scene.layout.StackPane; import javafx.scene.layout.VBox; import javafx.stage.Stage; import seedu.agendum.commons.core.Config; @@ -27,15 +28,14 @@ public class MainWindow extends UiPart { private static final String ICON = "/images/agendum_icon.png"; private static final String FXML = "MainWindow.fxml"; - public static final int MIN_HEIGHT = 600; - public static final int MIN_WIDTH = 450; + public static final String LIST_COMMAND = "list"; private Logic logic; // Independent Ui parts residing in this Ui container - private DoItSoonPanel allTasksPanel; - private CompletedTasksPanel completedTasksPanel; - private DoItAnytimePanel otherTasksPanel; + private TasksPanel upcomingTasksPanel; + private TasksPanel completedTasksPanel; + private TasksPanel floatingTasksPanel; private ResultPopUp resultPopUp; private StatusBarFooter statusBarFooter; private CommandBox commandBox; @@ -57,16 +57,19 @@ public class MainWindow extends UiPart { private MenuItem helpMenuItem; @FXML - private AnchorPane allTasksPlaceHolder; + private AnchorPane upcomingTasksPlaceHolder; @FXML private AnchorPane completedTasksPlaceHolder; @FXML - private AnchorPane otherTasksPlaceHolder; + private AnchorPane floatingTasksPlaceHolder; @FXML private AnchorPane statusbarPlaceholder; + + @FXML + private StackPane messagePlaceHolder; public MainWindow() { super(); @@ -100,15 +103,12 @@ private void configure(String appTitle, String toDoListName, Config config, User //Configure the UI setTitle(appTitle); setIcon(ICON); - setWindowMinSize(); setWindowDefaultSize(prefs); scene = new Scene(rootLayout); - primaryStage.setScene(scene); - primaryStage.setOnCloseRequest(e -> Platform.exit()); - setAccelerators(); + handleEscape(); configureHelpWindowToggle(); } @@ -134,32 +134,39 @@ public void handle(KeyEvent evt) { //@@author A0148031R void fillInnerParts() { - allTasksPanel = DoItSoonPanel.load(primaryStage, getAllTasksPlaceHolder(), logic.getFilteredTaskList()); - completedTasksPanel = CompletedTasksPanel.load(primaryStage, getCompletedTasksPlaceHolder(), logic.getFilteredTaskList()); - otherTasksPanel = DoItAnytimePanel.load(primaryStage, getOtherTasksPlaceHolder(), logic.getFilteredTaskList()); + upcomingTasksPanel = UpcomingTasksPanel.load(primaryStage, getUpcomingTasksPlaceHolder(), + logic.getFilteredTaskList(), new UpcomingTasksPanel()); + completedTasksPanel = CompletedTasksPanel.load(primaryStage, getCompletedTasksPlaceHolder(), + logic.getFilteredTaskList(), new CompletedTasksPanel()); + floatingTasksPanel = FloatingTasksPanel.load(primaryStage, getFloatingTasksPlaceHolder(), + logic.getFilteredTaskList(), new FloatingTasksPanel()); resultPopUp = ResultPopUp.load(primaryStage); statusBarFooter = StatusBarFooter.load(primaryStage, getStatusbarPlaceholder(), config.getToDoListFilePath()); - commandBox = CommandBox.load(primaryStage, getCommandBoxPlaceholder(), resultPopUp, logic); + commandBox = CommandBox.load(primaryStage, getCommandBoxPlaceholder(), messagePlaceHolder, resultPopUp, logic); } private AnchorPane getCommandBoxPlaceholder() { return commandBoxPlaceholder; } + + public StackPane getMessagePlaceHolder() { + return messagePlaceHolder; + } private AnchorPane getStatusbarPlaceholder() { return statusbarPlaceholder; } - public AnchorPane getAllTasksPlaceHolder() { - return allTasksPlaceHolder; + public AnchorPane getUpcomingTasksPlaceHolder() { + return upcomingTasksPlaceHolder; } public AnchorPane getCompletedTasksPlaceHolder() { return completedTasksPlaceHolder; } - public AnchorPane getOtherTasksPlaceHolder() { - return otherTasksPlaceHolder; + public AnchorPane getFloatingTasksPlaceHolder() { + return floatingTasksPlaceHolder; } public void hide() { @@ -169,24 +176,20 @@ public void hide() { private void setTitle(String appTitle) { primaryStage.setTitle(appTitle); } - + /** * Sets the default size based on user preferences. */ protected void setWindowDefaultSize(UserPrefs prefs) { primaryStage.setHeight(prefs.getGuiSettings().getWindowHeight()); primaryStage.setWidth(prefs.getGuiSettings().getWindowWidth()); + if (prefs.getGuiSettings().getWindowCoordinates() != null) { primaryStage.setX(prefs.getGuiSettings().getWindowCoordinates().getX()); primaryStage.setY(prefs.getGuiSettings().getWindowCoordinates().getY()); } } - private void setWindowMinSize() { - primaryStage.setMinHeight(MIN_HEIGHT); - primaryStage.setMinWidth(MIN_WIDTH); - } - /** * Returns the current size and the position of the main Window. */ @@ -195,6 +198,7 @@ public GuiSettings getCurrentGuiSetting() { (int) primaryStage.getX(), (int) primaryStage.getY()); } + //@@author A0148031R @FXML public void handleHelp() { HelpWindow helpWindow = HelpWindow.load(primaryStage); @@ -203,6 +207,19 @@ public void handleHelp() { helpWindow.show(); } } + + private void handleEscape() { + scene.addEventFilter(KeyEvent.KEY_PRESSED, new EventHandler() { + @Override + public void handle(KeyEvent evt) { + if (evt.getCode().equals(KeyCode.ESCAPE) && messagePlaceHolder.getChildren().size() != 0) { + messagePlaceHolder.getChildren().remove(0); + messagePlaceHolder.setMaxHeight(0); + logic.execute(LIST_COMMAND); + } + } + }); + } public void show() { primaryStage.show(); @@ -216,11 +233,15 @@ private void handleExit() { raise(new ExitAppRequestEvent()); } - public DoItSoonPanel getAllTasksPanel() { - return this.allTasksPanel; + public TasksPanel getUpcomingTasksPanel() { + return (UpcomingTasksPanel)this.upcomingTasksPanel; + } + + public TasksPanel getCompletedTasksPanel() { + return (CompletedTasksPanel)this.completedTasksPanel; } - public CompletedTasksPanel getCompletedTasksPanel() { - return this.completedTasksPanel; + public TasksPanel getFloatingasksPanel() { + return (FloatingTasksPanel)this.floatingTasksPanel; } } diff --git a/src/main/java/seedu/agendum/ui/TaskCard.java b/src/main/java/seedu/agendum/ui/TaskCard.java index 28c156c186c3..3cbf55b6b12b 100644 --- a/src/main/java/seedu/agendum/ui/TaskCard.java +++ b/src/main/java/seedu/agendum/ui/TaskCard.java @@ -28,9 +28,7 @@ public class TaskCard extends UiPart { private ReadOnlyTask task; private String displayedIndex; - public TaskCard(){ - - } + public TaskCard() {} public static TaskCard load(ReadOnlyTask task, int Index){ TaskCard card = new TaskCard(); diff --git a/src/main/java/seedu/agendum/ui/TasksPanel.java b/src/main/java/seedu/agendum/ui/TasksPanel.java new file mode 100644 index 000000000000..bb7fcb4f60da --- /dev/null +++ b/src/main/java/seedu/agendum/ui/TasksPanel.java @@ -0,0 +1,56 @@ +package seedu.agendum.ui; + +import javafx.collections.ObservableList; +import javafx.scene.Node; +import javafx.scene.control.SplitPane; +import javafx.scene.layout.AnchorPane; +import javafx.stage.Stage; +import seedu.agendum.model.task.ReadOnlyTask; + +//@@author A0148031R +/** + * Panel contains the list of tasks + */ +public class TasksPanel extends UiPart{ + private AnchorPane panel; + private AnchorPane placeHolderPane; + + public TasksPanel() { + super(); + } + + @Override + public void setNode(Node node) { + panel = (AnchorPane) node; + } + + @Override + public String getFxmlPath() { + return null; + } + + @Override + public void setPlaceholder(AnchorPane pane) { + this.placeHolderPane = pane; + } + + public static TasksPanel load(Stage primaryStage, AnchorPane tasksPlaceholder, + ObservableList taskList, TasksPanel tasksPanelType) { + TasksPanel tasksPanel = UiPartLoader.loadUiPart(primaryStage, tasksPlaceholder, tasksPanelType); + tasksPanel.configure(taskList); + return tasksPanel; + } + + private void configure(ObservableList taskList) { + setConnections(taskList); + addToPlaceholder(); + } + + private void addToPlaceholder() { + SplitPane.setResizableWithParent(placeHolderPane, false); + placeHolderPane.getChildren().add(panel); + } + + protected void setConnections(ObservableList allTasks) {}; + +} diff --git a/src/main/java/seedu/agendum/ui/UpcomingTasksPanel.java b/src/main/java/seedu/agendum/ui/UpcomingTasksPanel.java new file mode 100644 index 000000000000..d8d12397726b --- /dev/null +++ b/src/main/java/seedu/agendum/ui/UpcomingTasksPanel.java @@ -0,0 +1,62 @@ +package seedu.agendum.ui; + + +import javafx.application.Platform; +import javafx.collections.ObservableList; +import javafx.fxml.FXML; +import javafx.scene.control.Control; +import javafx.scene.control.ListCell; +import javafx.scene.control.ListView; +import seedu.agendum.model.task.ReadOnlyTask; + +//@@author A0148031R +/** + * Panel contains the list of all uncompleted tasks with time + */ +public class UpcomingTasksPanel extends TasksPanel { + private static final String FXML = "UpcomingTasksPanel.fxml"; + private static ObservableList mainTaskList; + + @FXML + private ListView upcomingTasksListView; + + @Override + public String getFxmlPath() { + return FXML; + } + + @Override + protected void setConnections(ObservableList taskList) { + mainTaskList = taskList; + upcomingTasksListView.setItems(taskList.filtered(task -> task.hasTime() && !task.isCompleted())); + upcomingTasksListView.setCellFactory(listView -> new upcomingTasksListViewCell()); + } + + public void scrollTo(int index) { + Platform.runLater(() -> { + upcomingTasksListView.scrollTo(index); + upcomingTasksListView.getSelectionModel().clearAndSelect(index); + }); + } + + class upcomingTasksListViewCell extends ListCell { + + public upcomingTasksListViewCell() { + prefWidthProperty().bind(upcomingTasksListView.widthProperty()); + setMaxWidth(Control.USE_PREF_SIZE); + } + + @Override + protected void updateItem(ReadOnlyTask task, boolean empty) { + super.updateItem(task, empty); + + if (empty || task == null) { + setGraphic(null); + setText(null); + } else { + setGraphic(TaskCard.load(task, mainTaskList.indexOf(task) + 1).getLayout()); + } + } + } + +} diff --git a/src/main/resources/view/DarkTheme.css b/src/main/resources/view/DarkTheme.css index 9dc516ba0019..c81d500995ce 100644 --- a/src/main/resources/view/DarkTheme.css +++ b/src/main/resources/view/DarkTheme.css @@ -18,7 +18,7 @@ } .split-pane:horizontal .split-pane-divider { - -fx-border-color: transparent #1d1d1d transparent #1d1d1d; + -fx-border-color: transparent; -fx-background-color: transparent, derive(#1d1d1d, 10%); } @@ -34,12 +34,19 @@ .anchor-pane-with-border { -fx-background-color: derive(#1d1d1d, 20%); - -fx-border-color: derive(#1d1d1d, 10%); + -fx-border-color: transparent; + -fx-border-top-width: 1px; +} + +.stack-pane { + -fx-background-color: derive(#1d1d1d, 20%); + -fx-border-color: transparent; -fx-border-top-width: 1px; } .status-bar { -fx-background-color: derive(#1d1d1d, 20%); + -fx-border-color: transparent; -fx-text-fill: white; } @@ -58,7 +65,7 @@ .status-bar-with-border { -fx-background-color: derive(#1d1d1d, 30%); - -fx-border-color: derive(#1d1d1d, 25%); + -fx-border-color: transparent; -fx-border-width: 1px; } @@ -173,44 +180,6 @@ -fx-text-fill: white; } -.scroll-bar .increment-button { - -fx-opacity: 0; -} - -.scroll-bar .decrement-button { - -fx-opacity: 0; -} - -.scroll-bar { - -fx-background-color: transparent; -} - -.scroll-bar .track-background { - -fx-opacity: 0; - -fx-background-color: transparent; - -fx-background-insets: 0; -} - -.scroll-bar .track { - -fx-opacity: 0; - -fx-background-color: transparent; - -fx-border-color:transparent; -} - -.scroll-bar:horizontal .thumb { - -fx-background-color: rgba(255,255,255,0.5); - -fx-background-insets: 4 0 4 0; - -fx-background-radius: 2em; -} - -.scroll-bar:hover .thumb { - -fx-background-color: rgba(0,0,0,0.3); -} - -.scroll-bar:pressed .thumb { - -fx-background-color: rgba(0,0,0,0.3); -} - .list-view .scroll-bar:vertical .increment-arrow, .list-view .scroll-bar:vertical .decrement-arrow, .list-view .scroll-bar:vertical .increment-button, @@ -218,6 +187,13 @@ -fx-padding:0; } +.list-view .scroll-bar:horizontal .increment-arrow, +.list-view .scroll-bar:horizontal .decrement-arrow, +.list-view .scroll-bar:horizontal .increment-button, +.list-view .scroll-bar:horizontal .decrement-button { + -fx-padding:0; +} + .list-view { -fx-background-radius: 10; } diff --git a/src/main/resources/view/Extensions.css b/src/main/resources/view/Extensions.css index 606c927d9a42..2890622f6aaa 100644 --- a/src/main/resources/view/Extensions.css +++ b/src/main/resources/view/Extensions.css @@ -6,7 +6,7 @@ .tag-selector { -fx-border-width: 1; - -fx-border-color: white; + -fx-border-color: transparent; -fx-border-radius: 3; -fx-background-radius: 3; } diff --git a/src/main/resources/view/DoItAnytimePanel.fxml b/src/main/resources/view/FloatingTasksPanel.fxml similarity index 82% rename from src/main/resources/view/DoItAnytimePanel.fxml rename to src/main/resources/view/FloatingTasksPanel.fxml index 6f90634cf689..28c0833a34ce 100644 --- a/src/main/resources/view/DoItAnytimePanel.fxml +++ b/src/main/resources/view/FloatingTasksPanel.fxml @@ -7,9 +7,9 @@ - + - + diff --git a/src/main/resources/view/MainWindow.fxml b/src/main/resources/view/MainWindow.fxml index 4d030c768265..8283222a495d 100644 --- a/src/main/resources/view/MainWindow.fxml +++ b/src/main/resources/view/MainWindow.fxml @@ -7,9 +7,11 @@ + + @@ -35,6 +37,11 @@ + + + + + @@ -42,12 +49,12 @@ - + - + diff --git a/src/main/resources/view/ResultPopUp.fxml b/src/main/resources/view/ResultPopUp.fxml index 8c6666d2b6a6..6424e5bcf6d4 100644 --- a/src/main/resources/view/ResultPopUp.fxml +++ b/src/main/resources/view/ResultPopUp.fxml @@ -4,8 +4,9 @@ + - diff --git a/src/main/resources/view/TaskCard.fxml b/src/main/resources/view/TaskCard.fxml index a416d1e76aa1..57ef97345db5 100644 --- a/src/main/resources/view/TaskCard.fxml +++ b/src/main/resources/view/TaskCard.fxml @@ -10,11 +10,12 @@ + - + @@ -24,16 +25,12 @@ - + - + diff --git a/src/main/resources/view/TasksPanel.css b/src/main/resources/view/TasksPanel.css index c86a2a25fbc8..1b2f444e04f2 100644 --- a/src/main/resources/view/TasksPanel.css +++ b/src/main/resources/view/TasksPanel.css @@ -29,7 +29,7 @@ } .cell_big_label { - -fx-font-size: 16pt; + -fx-font-size: 14pt; -fx-opacity: 0.9; } diff --git a/src/main/resources/view/DoItSoonPanel.fxml b/src/main/resources/view/UpcomingTasksPanel.fxml similarity index 77% rename from src/main/resources/view/DoItSoonPanel.fxml rename to src/main/resources/view/UpcomingTasksPanel.fxml index c48f808ef466..edf43b71ec85 100644 --- a/src/main/resources/view/DoItSoonPanel.fxml +++ b/src/main/resources/view/UpcomingTasksPanel.fxml @@ -6,9 +6,9 @@ - + - + diff --git a/src/test/java/guitests/ToDoListGuiTest.java b/src/test/java/guitests/ToDoListGuiTest.java index 8c07ab9335fc..a19cdb168aa0 100644 --- a/src/test/java/guitests/ToDoListGuiTest.java +++ b/src/test/java/guitests/ToDoListGuiTest.java @@ -40,8 +40,8 @@ public abstract class ToDoListGuiTest { */ protected MainGuiHandle mainGui; protected MainMenuHandle mainMenu; - protected DoItSoonPanelHandle doItSoonPanel; - protected DoItAnytimePanelHandle doItAnytimePanel; + protected UpcomingTasksHandle doItSoonPanel; + protected FloatingTasksPanelHandle doItAnytimePanel; protected CompletedTasksPanelHandle completedTasksPanel; protected ResultDisplayHandle resultDisplay; protected CommandBoxHandle commandBox; diff --git a/src/test/java/guitests/guihandles/DoItAnytimePanelHandle.java b/src/test/java/guitests/guihandles/FloatingTasksPanelHandle.java similarity index 96% rename from src/test/java/guitests/guihandles/DoItAnytimePanelHandle.java rename to src/test/java/guitests/guihandles/FloatingTasksPanelHandle.java index f6ca7ad38f29..7f5906e4c101 100644 --- a/src/test/java/guitests/guihandles/DoItAnytimePanelHandle.java +++ b/src/test/java/guitests/guihandles/FloatingTasksPanelHandle.java @@ -21,14 +21,14 @@ /** * Provides a handle for the panel containing the task list. */ -public class DoItAnytimePanelHandle extends GuiHandle { +public class FloatingTasksPanelHandle extends GuiHandle { public static final int NOT_FOUND = -1; public static final String CARD_PANE_ID = "#cardPane"; - private static final String TASK_LIST_VIEW_ID = "#anytimeTasksListView"; + private static final String TASK_LIST_VIEW_ID = "#floatingTasksListView"; - public DoItAnytimePanelHandle(GuiRobot guiRobot, Stage primaryStage) { + public FloatingTasksPanelHandle(GuiRobot guiRobot, Stage primaryStage) { super(guiRobot, primaryStage, TestApp.APP_TITLE); } diff --git a/src/test/java/guitests/guihandles/MainGuiHandle.java b/src/test/java/guitests/guihandles/MainGuiHandle.java index 8eed328efc6d..ce5bbf3968a3 100644 --- a/src/test/java/guitests/guihandles/MainGuiHandle.java +++ b/src/test/java/guitests/guihandles/MainGuiHandle.java @@ -15,12 +15,12 @@ public MainGuiHandle(GuiRobot guiRobot, Stage primaryStage) { super(guiRobot, primaryStage, TestApp.APP_TITLE); } - public DoItSoonPanelHandle getDoItSoonPanel() { - return new DoItSoonPanelHandle(guiRobot, primaryStage); + public UpcomingTasksHandle getDoItSoonPanel() { + return new UpcomingTasksHandle(guiRobot, primaryStage); } - public DoItAnytimePanelHandle getDoItAnytimePanel() { - return new DoItAnytimePanelHandle(guiRobot, primaryStage); + public FloatingTasksPanelHandle getDoItAnytimePanel() { + return new FloatingTasksPanelHandle(guiRobot, primaryStage); } public CompletedTasksPanelHandle getCompletedTasksPanel() { diff --git a/src/test/java/guitests/guihandles/DoItSoonPanelHandle.java b/src/test/java/guitests/guihandles/UpcomingTasksHandle.java similarity index 96% rename from src/test/java/guitests/guihandles/DoItSoonPanelHandle.java rename to src/test/java/guitests/guihandles/UpcomingTasksHandle.java index 158188ddcc10..294f6a7fe1a9 100644 --- a/src/test/java/guitests/guihandles/DoItSoonPanelHandle.java +++ b/src/test/java/guitests/guihandles/UpcomingTasksHandle.java @@ -21,14 +21,14 @@ /** * Provides a handle for the panel containing the task list. */ -public class DoItSoonPanelHandle extends GuiHandle { +public class UpcomingTasksHandle extends GuiHandle { public static final int NOT_FOUND = -1; public static final String CARD_PANE_ID = "#cardPane"; - private static final String TASK_LIST_VIEW_ID = "#timeTasksListView"; + private static final String TASK_LIST_VIEW_ID = "#upcomingTasksListView"; - public DoItSoonPanelHandle(GuiRobot guiRobot, Stage primaryStage) { + public UpcomingTasksHandle(GuiRobot guiRobot, Stage primaryStage) { super(guiRobot, primaryStage, TestApp.APP_TITLE); }