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

Some ui enhancement #173

Merged
merged 18 commits into from
Oct 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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.
1 change: 0 additions & 1 deletion src/main/java/seedu/agendum/logic/commands/AddCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ public CommandResult execute() {
} catch (UniqueTaskList.DuplicateTaskException e) {
return new CommandResult(MESSAGE_DUPLICATE_TASK);
}

}

public static String getName() {
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/seedu/agendum/model/UserPrefs.java
Original file line number Diff line number Diff line change
@@ -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;

/**
Expand All @@ -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){
Expand Down
41 changes: 35 additions & 6 deletions src/main/java/seedu/agendum/ui/CommandBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -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() {
Expand Down Expand Up @@ -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() {
Expand Down
55 changes: 0 additions & 55 deletions src/main/java/seedu/agendum/ui/CompletedTaskCard.java

This file was deleted.

54 changes: 11 additions & 43 deletions src/main/java/seedu/agendum/ui/CompletedTasksPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<ReadOnlyTask> mainTaskList;

@FXML
private ListView<ReadOnlyTask> 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<ReadOnlyTask> taskList) {
protected void setConnections(ObservableList<ReadOnlyTask> taskList) {
mainTaskList = taskList;
CompletedTasksPanel completedTasksPanel = UiPartLoader.loadUiPart(primaryStage, CompletedTasksPlaceholder, new CompletedTasksPanel());
completedTasksPanel.configure(taskList);
return completedTasksPanel;
}

private void configure(ObservableList<ReadOnlyTask> taskList) {
setConnections(taskList);
addToPlaceholder();
}

private void setConnections(ObservableList<ReadOnlyTask> 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) {
Expand All @@ -72,8 +37,12 @@ public void scrollTo(int index) {
completedTasksListView.getSelectionModel().clearAndSelect(index);
});
}

class completedTasksListViewCell extends ListCell<ReadOnlyTask> {

class CompletedTasksListViewCell extends ListCell<ReadOnlyTask> {
public CompletedTasksListViewCell() {
prefWidthProperty().bind(completedTasksListView.widthProperty());
setMaxWidth(Control.USE_PREF_SIZE);
}

@Override
protected void updateItem(ReadOnlyTask task, boolean empty) {
Expand All @@ -87,5 +56,4 @@ protected void updateItem(ReadOnlyTask task, boolean empty) {
}
}
}

}
87 changes: 0 additions & 87 deletions src/main/java/seedu/agendum/ui/DoItAnytimePanel.java

This file was deleted.

Loading