Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/change-ui' into v0.2-release
Browse files Browse the repository at this point in the history
  • Loading branch information
burnflare committed Oct 12, 2016
2 parents 79a3f70 + 0c56cb6 commit 6ba2d00
Show file tree
Hide file tree
Showing 29 changed files with 815 additions and 145 deletions.
16 changes: 8 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ allprojects {
}

shadowJar {
archiveName = "addressbook.jar"
archiveName = "agendum.jar"

manifest {
attributes "Main-Class": "seedu.address.MainApp"
attributes "Main-Class": "seedu.agendum.MainApp"
}

destinationDir = file("${buildDir}/jar/")
Expand Down Expand Up @@ -115,8 +115,8 @@ tasks.coveralls {
onlyIf { System.env.'CI' }
}

class AddressBookTest extends Test {
public AddressBookTest() {
class AgendumTest extends Test {
public AgendumTest() {
forkEvery = 1
systemProperty 'testfx.setup.timeout', '60000'
}
Expand All @@ -130,7 +130,7 @@ class AddressBookTest extends Test {
}
}

task guiTests(type: AddressBookTest) {
task guiTests(type: AgendumTest) {
include 'guitests/**'

jacoco {
Expand All @@ -139,16 +139,16 @@ task guiTests(type: AddressBookTest) {
}


task nonGuiTests(type: AddressBookTest) {
include 'seedu/address/**'
task nonGuiTests(type: AgendumTest) {
include 'seedu/agendum/**'

jacoco {
destinationFile = new File("${buildDir}/jacoco/test.exec")
}
}

// Test mode depends on whether headless task has been run
task allTests(type: AddressBookTest) {
task allTests(type: AgendumTest) {
jacoco {
destinationFile = new File("${buildDir}/jacoco/test.exec")
}
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/seedu/agendum/logic/Logic.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,8 @@ public interface Logic {

/** Returns the filtered list of tasks */
ObservableList<ReadOnlyTask> getFilteredTaskList();

/** Returns list of completed tasks */
ObservableList<ReadOnlyTask> getCompletedTaskList();

}
8 changes: 8 additions & 0 deletions src/main/java/seedu/agendum/logic/LogicManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,12 @@ public CommandResult execute(String commandText) {
public ObservableList<ReadOnlyTask> getFilteredTaskList() {
return model.getFilteredTaskList();
}

/**
* Requires implementation here
*/
@Override
public ObservableList<ReadOnlyTask> getCompletedTaskList() {
return null;
}
}
14 changes: 6 additions & 8 deletions src/main/java/seedu/agendum/ui/CommandBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class CommandBox extends UiPart {

private AnchorPane placeHolderPane;
private AnchorPane commandPane;
private ResultDisplay resultDisplay;
private ResultPopUp resultPopUp;
String previousCommandTest;

private Logic logic;
Expand All @@ -31,15 +31,15 @@ public class CommandBox extends UiPart {
private CommandResult mostRecentResult;

public static CommandBox load(Stage primaryStage, AnchorPane commandBoxPlaceholder,
ResultDisplay resultDisplay, Logic logic) {
ResultPopUp resultPopUp, Logic logic) {
CommandBox commandBox = UiPartLoader.loadUiPart(primaryStage, commandBoxPlaceholder, new CommandBox());
commandBox.configure(resultDisplay, logic);
commandBox.configure(resultPopUp, logic);
commandBox.addToPlaceholder();
return commandBox;
}

public void configure(ResultDisplay resultDisplay, Logic logic) {
this.resultDisplay = resultDisplay;
public void configure(ResultPopUp resultPopUp, Logic logic) {
this.resultPopUp = resultPopUp;
this.logic = logic;
registerAsAnEventHandler(this);
}
Expand All @@ -66,7 +66,6 @@ public void setPlaceholder(AnchorPane pane) {
this.placeHolderPane = pane;
}


@FXML
private void handleCommandInputChanged() {
//Take a copy of the command text
Expand All @@ -77,11 +76,10 @@ private void handleCommandInputChanged() {
*/
setStyleToIndicateCorrectCommand();
mostRecentResult = logic.execute(previousCommandTest);
resultDisplay.postMessage(mostRecentResult.feedbackToUser);
resultPopUp.postMessage(mostRecentResult.feedbackToUser);
logger.info("Result: " + mostRecentResult.feedbackToUser);
}


/**
* Sets the command box style to indicate a correct command.
*/
Expand Down
56 changes: 56 additions & 0 deletions src/main/java/seedu/agendum/ui/CompletedTaskCard.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
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;

public class CompletedTaskCard extends UiPart {

private static final String FXML = "CompletedTaskCard.fxml";

@FXML
private HBox cardPane;
@FXML
private Label name;
@FXML
private Label id;
@FXML
private Label tags;

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 + ". ");
tags.setText(task.tagsString());
}

public HBox getLayout() {
return cardPane;
}

@Override
public void setNode(Node node) {
cardPane = (HBox)node;
}

@Override
public String getFxmlPath() {
return FXML;
}
}
106 changes: 106 additions & 0 deletions src/main/java/seedu/agendum/ui/CompletedTasksPanel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
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.commons.events.ui.TaskPanelSelectionChangedEvent;
import seedu.agendum.model.task.ReadOnlyTask;
import seedu.agendum.commons.core.LogsCenter;

/**
* Panel contains the list of completed tasks
*/
public class CompletedTasksPanel extends UiPart {
private final Logger logger = LogsCenter.getLogger(CompletedTasksPanel.class);
private static final String FXML = "CompletedTasksPanel.fxml";
private AnchorPane panel;
private AnchorPane placeHolderPane;

@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) {
CompletedTasksPanel completedTasksPanel = UiPartLoader.loadUiPart(primaryStage, CompletedTasksPlaceholder, new CompletedTasksPanel());
completedTasksPanel.configure(taskList);
return completedTasksPanel;
}

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

private void setConnections(ObservableList<ReadOnlyTask> completedTasks) {
completedTasksListView.setItems(completedTasks);
completedTasksListView.setCellFactory(listView -> new completedTasksListViewCell());
setEventHandlerForSelectionChangeEvent();
}

private void addToPlaceholder() {
SplitPane.setResizableWithParent(placeHolderPane, false);
placeHolderPane.getChildren().add(panel);
}

private void setEventHandlerForSelectionChangeEvent() {
completedTasksListView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
if (newValue != null) {
logger.fine("Selection in task list panel changed to : '" + newValue + "'");
raise(new TaskPanelSelectionChangedEvent(newValue));
}
});
}

public void scrollTo(int index) {
Platform.runLater(() -> {
completedTasksListView.scrollTo(index);
completedTasksListView.getSelectionModel().clearAndSelect(index);
});
}

class completedTasksListViewCell extends ListCell<ReadOnlyTask> {

public completedTasksListViewCell() {
}

@Override
protected void updateItem(ReadOnlyTask task, boolean empty) {
super.updateItem(task, empty);

if (empty || task == null) {
setGraphic(null);
setText(null);
} else {
setGraphic(CompletedTaskCard.load(task, getIndex() + 1).getLayout());
}
}
}

}
48 changes: 28 additions & 20 deletions src/main/java/seedu/agendum/ui/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
import javafx.fxml.FXML;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuItem;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyCodeCombination;
import javafx.scene.input.KeyCombination;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.VBox;
Expand All @@ -21,7 +24,7 @@
*/
public class MainWindow extends UiPart {

private static final String ICON = "/images/address_book_32.png";
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;
Expand All @@ -30,8 +33,9 @@ public class MainWindow extends UiPart {

// Independent Ui parts residing in this Ui container
private BrowserPanel browserPanel;
private TaskListPanel taskListPanel;
private ResultDisplay resultDisplay;
private UpcomingTasksPanel upcomingTasksPanel;
private CompletedTasksPanel completedTasksPanel;
private ResultPopUp resultPopUp;
private StatusBarFooter statusBarFooter;
private CommandBox commandBox;
private Config config;
Expand All @@ -53,15 +57,14 @@ public class MainWindow extends UiPart {
private MenuItem helpMenuItem;

@FXML
private AnchorPane taskListPanelPlaceholder;

private AnchorPane upcomingTasksPlaceHolder;
@FXML
private AnchorPane resultDisplayPlaceholder;

private AnchorPane completedTasksPlaceHolder;
@FXML
private AnchorPane statusbarPlaceholder;


public MainWindow() {
super();
}
Expand Down Expand Up @@ -104,15 +107,16 @@ private void configure(String appTitle, String toDoListName, Config config, User
}

private void setAccelerators() {
helpMenuItem.setAccelerator(KeyCombination.valueOf("F1"));
helpMenuItem.setAccelerator(new KeyCodeCombination(KeyCode.H, KeyCombination.ALT_DOWN));
}

void fillInnerParts() {
browserPanel = BrowserPanel.load(browserPlaceholder);
taskListPanel = TaskListPanel.load(primaryStage, getTaskListPlaceholder(), logic.getFilteredTaskList());
resultDisplay = ResultDisplay.load(primaryStage, getResultDisplayPlaceholder());
upcomingTasksPanel = UpcomingTasksPanel.load(primaryStage, getUpcomingTasksPlaceHolder(), logic.getFilteredTaskList());
completedTasksPanel = CompletedTasksPanel.load(primaryStage, getCompletedTasksPlaceHolder(), logic.getCompletedTaskList());
resultPopUp = ResultPopUp.load(primaryStage);
statusBarFooter = StatusBarFooter.load(primaryStage, getStatusbarPlaceholder(), config.getToDoListFilePath());
commandBox = CommandBox.load(primaryStage, getCommandBoxPlaceholder(), resultDisplay, logic);
commandBox = CommandBox.load(primaryStage, getCommandBoxPlaceholder(), resultPopUp, logic);
}

private AnchorPane getCommandBoxPlaceholder() {
Expand All @@ -122,13 +126,13 @@ private AnchorPane getCommandBoxPlaceholder() {
private AnchorPane getStatusbarPlaceholder() {
return statusbarPlaceholder;
}

private AnchorPane getResultDisplayPlaceholder() {
return resultDisplayPlaceholder;
public AnchorPane getUpcomingTasksPlaceHolder() {
return upcomingTasksPlaceHolder;
}

public AnchorPane getTaskListPlaceholder() {
return taskListPanelPlaceholder;
public AnchorPane getCompletedTasksPlaceHolder() {
return completedTasksPlaceHolder;
}

public void hide() {
Expand Down Expand Up @@ -182,8 +186,12 @@ private void handleExit() {
raise(new ExitAppRequestEvent());
}

public TaskListPanel getTaskListPanel() {
return this.taskListPanel;
public UpcomingTasksPanel getUpcomingTasksPanel() {
return this.upcomingTasksPanel;
}

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

public void loadTaskPage(ReadOnlyTask task) {
Expand Down
Loading

0 comments on commit 6ba2d00

Please sign in to comment.