Skip to content

Commit

Permalink
Merge pull request #26 from CS2103AUG2016-F11-C2/v0.1_HongWei
Browse files Browse the repository at this point in the history
UI ready for v0.2
  • Loading branch information
Justin Ng authored Oct 13, 2016
2 parents a855b2b + f43211f commit b2ff40a
Show file tree
Hide file tree
Showing 12 changed files with 200 additions and 68 deletions.
1 change: 1 addition & 0 deletions src/main/java/seedu/address/MainApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -186,4 +186,5 @@ public void handleExitAppRequestEvent(ExitAppRequestEvent event) {
public static void main(String[] args) {
launch(args);
}

}
5 changes: 3 additions & 2 deletions src/main/java/seedu/address/commons/core/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
public class Config {

public static final String DEFAULT_CONFIG_FILE = "config.json";
public static final String APPTITLE = "CMDo - Tasks Made Simpler";

// Config values customizable through config file
private String appTitle = "Address App";
private String appTitle = "CMDo App";
private Level logLevel = Level.INFO;
private String userPrefsFilePath = "preferences.json";
private String toDoListFilePath = "data/todolist.xml";
Expand All @@ -22,7 +23,7 @@ public Config() {
}

public String getAppTitle() {
return appTitle;
return APPTITLE;
}

public void setAppTitle(String appTitle) {
Expand Down
105 changes: 102 additions & 3 deletions src/main/java/seedu/address/ui/CMDoController.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
package seedu.address.ui;

import seedu.address.logic.parser.*;
import seedu.address.model.task.Task;
import seedu.address.model.task.Detail;
import seedu.address.model.task.Done;
import seedu.address.model.task.Priority;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.*;
import javafx.scene.control.*;
import javafx.scene.layout.*;
Expand Down Expand Up @@ -45,9 +51,9 @@ public class CMDoController {

//Shows the task list in the main panel
@FXML
private VBox taskPanel;
private ListView<HBox> taskPanel;

//shows to user the current status of their commands e.g. All tasks listed!
//shows to user the current status and information of their commands e.g. All tasks listed!
@FXML
private Label infoToUser;

Expand All @@ -59,7 +65,100 @@ public void readKeyboardInput(KeyEvent event) throws Exception {

private void runCommand(String keyboardInput) {
MainParser parser = MainParser.getInstance();
parser.parseCommand(keyboardInput);
parser.parseCommand(keyboardInput);
}

public void updateDisplayToUser(String display) {
infoToUser.setText(display);
}

public Label getInfoToUser() {
return infoToUser;
}

public void updateTasksOverviewPanel(ObservableList<Task> taskObservableList) {
//Integer tasksInInbox = 0;
Integer overdueNumber = 0;
Integer todayNumber = 0;
Integer thisWeekNumber = 0;
Integer thisMonthNumber = 0;
Integer somedayNumber = 0;
Integer totalTasksNumber = taskObservableList.size();

//To figure out logic to increment task numbers

//Setting
today.setText(todayNumber.toString());
thisWeek.setText(thisWeekNumber.toString());
thisMonth.setText(thisMonthNumber.toString());
someday.setText(somedayNumber.toString());
totalTasks.setText(totalTasksNumber.toString());

}

/*
* Setters
*/
private void setItemsToTaskPanel(ObservableList<HBox> taskbox ) {
taskPanel.setItems(taskbox);
}

/*
* Getters for the different task fields
* Calls the task details from seedu.address.model.task.
* Task Index needs to be incremented. DueDate and DueTime set to null if null
*/
private int getTaskIndex(ObservableList<Task> taskObservableList, Task task) {
return taskObservableList.indexOf(task) + 1;
}

private String getTaskDueDate(Task task) {
return task.getFriendlyDate() == null ? null : task.getFriendlyDate();
}

private String getTaskDueTime(Task task) {
return task.getFriendlyTime() == null ? null : task.getFriendlyTime();
}



//To update the main panel
public void updateMainDisplay(ObservableList<Task> taskObservableList) {
ObservableList<HBox> taskBox = FXCollections.observableArrayList();

for (Task task : taskObservableList) {
int taskIndex = getTaskIndex(taskObservableList, task);
String taskTitle = task.getDetail().details;
String taskDueDate = getTaskDueDate(task);
String taskDueTime = getTaskDueTime(task);
String taskPriority = task.getPriority().value;

// Done isDone = task.checkDone();

CMDoTaskBox newTaskBox = new CMDoTaskBox(taskIndex,
taskTitle,
taskDueDate,
taskDueTime,
taskPriority);
}

setItemsToTaskPanel(taskBox);
}


public HBox addHBox(int taskIndex, String taskTitle, String taskDueDate,
String taskDueTime, String taskPriority) {
HBox hbox = new HBox();
hbox.setSpacing(10);
Label id = new Label(Integer.toString(taskIndex));
Label title = new Label(taskTitle);
Label startTime = new Label(taskDueDate);
Label endTime = new Label(taskDueTime);
Label priority = new Label(taskPriority);

if (taskPriority != null) {
hbox.getChildren().addAll(priority);
}
return hbox;
}
}
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/ui/CMDoTaskBox.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package seedu.address.ui;

import seedu.address.MainApp;
import seedu.address.model.task.Detail;
import javafx.scene.layout.*;

import java.util.logging.Logger;
Expand Down Expand Up @@ -74,7 +75,6 @@ private void loadFXML() {
cmdoLoader.setController(this);
cmdoLoader.load();
} catch(Exception e) {
logger.severe("Cannot load task box.");
e.printStackTrace();
}
}
Expand Down
15 changes: 13 additions & 2 deletions src/main/java/seedu/address/ui/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class MainWindow extends UiPart {
private Logic logic;

// Independent Ui parts residing in this Ui container
//private WelcomeMessage welcomeMessage;
private BrowserPanel browserPanel;
private TaskListPanel taskListPanel;
private ResultDisplay resultDisplay;
Expand All @@ -43,6 +44,9 @@ public class MainWindow extends UiPart {

private String addressBookName;

//@FXML
//private Stage welcomeMessagePlaceholder;

@FXML
private AnchorPane browserPlaceholder;

Expand Down Expand Up @@ -77,7 +81,7 @@ public String getFxmlPath() {
}

public static MainWindow load(Stage primaryStage, Config config, UserPrefs prefs, Logic logic) {

MainWindow mainWindow = UiPartLoader.loadUiPart(primaryStage, new MainWindow());
mainWindow.configure(config.getAppTitle(), config.getToDoListName(), config, prefs, logic);
return mainWindow;
Expand Down Expand Up @@ -108,6 +112,7 @@ private void setAccelerators() {
}

void fillInnerParts() {
//welcomeMessage = WelcomeMessage.load(welcomeMessagePlaceholder);
browserPanel = BrowserPanel.load(browserPlaceholder);
taskListPanel = TaskListPanel.load(primaryStage, getTaskListPlaceholder(), logic.getFilteredTaskList(true));
resultDisplay = ResultDisplay.load(primaryStage, getResultDisplayPlaceholder());
Expand Down Expand Up @@ -163,7 +168,13 @@ public GuiSettings getCurrentGuiSetting() {
return new GuiSettings(primaryStage.getWidth(), primaryStage.getHeight(),
(int) primaryStage.getX(), (int) primaryStage.getY());
}

/*
@FXML
public void handleWelcome() {
WelcomeMessage welcomeMessage = WelcomeMessage.load(primaryStage);
welcomeMessage.show();
}
*/
@FXML
public void handleHelp() {
HelpWindow helpWindow = HelpWindow.load(primaryStage);
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/seedu/address/ui/TaskCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import javafx.scene.Node;
import javafx.scene.control.Label;
import javafx.scene.layout.HBox;
import javafx.scene.paint.Color;
import seedu.address.model.task.ReadOnlyTask;

public class TaskCard extends UiPart{
Expand Down Expand Up @@ -47,6 +48,7 @@ public void initialize() {
dbt.setText(task.getDueByTime().getFriendlyString());
priority.setText(task.getPriority().value);
tags.setText(task.tagsString());
tags.setTextFill(Color.GOLD);
}

public HBox getLayout() {
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/seedu/address/ui/UiManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.google.common.eventbus.Subscribe;
import javafx.application.Platform;
import javafx.fxml.FXMLLoader;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.image.Image;
Expand All @@ -25,7 +26,7 @@
*/
public class UiManager extends ComponentManager implements Ui {
private static final Logger logger = LogsCenter.getLogger(UiManager.class);
private static final String ICON_APPLICATION = "/images/address_book_32.png";
private static final String ICON_APPLICATION = "/images/Logo.png";

private Logic logic;
private Config config;
Expand Down
48 changes: 48 additions & 0 deletions src/main/java/seedu/address/ui/WelcomeMessage.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package seedu.address.ui;

import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;
import seedu.address.commons.core.LogsCenter;
import java.util.logging.Logger;

public class WelcomeMessage extends UiPart {
private static final Logger logger = LogsCenter.getLogger(WelcomeMessage.class);
private static final String FXML = "CMDoWelcome.fxml";
private static final String ICON = "/images/Logo.png";
private static final String TITLE = "Welcome";

private Stage welcomeStage;

private static AnchorPane welcomePane;

@Override
public void setNode(Node node) {
welcomePane = (AnchorPane) node;
}

@Override
public String getFxmlPath() {
return FXML;
}

public static WelcomeMessage load(Stage welcomeMessageStage) {
logger.fine("Showing welcome page.");
WelcomeMessage welcomeMessage = UiPartLoader.loadUiPart(welcomeMessageStage, welcomePane, new WelcomeMessage());
welcomeMessage.configure();
return welcomeMessage;
}

private void configure(){
Scene scene = new Scene(welcomePane);
//Null passed as the parent stage to make it non-modal.
welcomeStage = createDialogStage(TITLE, null, scene);
welcomeStage.setMaximized(true); //TODO: set a more appropriate initial size
setIcon(welcomeStage, ICON);
}

public void show() {
welcomeStage.showAndWait();
}
}
Binary file added src/main/resources/images/Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 13 additions & 13 deletions src/main/resources/view/MainWindow.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,28 @@
<Insets bottom="5.0" left="10.0" right="10.0" top="5.0" />
</padding>
</AnchorPane>
<AnchorPane fx:id="resultDisplayPlaceholder" maxHeight="100" minHeight="100" prefHeight="100" styleClass="anchor-pane-with-border" VBox.vgrow="NEVER">
<padding>
<Insets bottom="5.0" left="10.0" right="10.0" top="5.0" />
</padding>
</AnchorPane>
<SplitPane id="splitPane" fx:id="splitPane" dividerPositions="0.4" VBox.vgrow="ALWAYS">
<SplitPane id="splitPane" fx:id="splitPane" dividerPositions="0.17338995046001415" VBox.vgrow="ALWAYS">
<items>
<VBox fx:id="taskList" minWidth="340" prefWidth="340">
<VBox fx:id="taskList" minWidth="240.0" prefHeight="100.0" prefWidth="731.0">
<padding>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
</padding>
<children>
<AnchorPane fx:id="taskListPanelPlaceholder" VBox.vgrow="ALWAYS" />
<AnchorPane fx:id="browserPlaceholder" prefWidth="1.0">
<padding>
<Insets bottom="10" left="10" right="10" top="10" />
</padding>
</AnchorPane>
</children>
</VBox>
<AnchorPane fx:id="browserPlaceholder" prefWidth="340">
<padding>
<Insets bottom="10" left="10" right="10" top="10" />
</padding>
</AnchorPane>
<AnchorPane fx:id="taskListPanelPlaceholder" prefHeight="100.0" prefWidth="670.0" />
</items>
</SplitPane>
<AnchorPane fx:id="statusbarPlaceholder" VBox.vgrow="NEVER" />
<AnchorPane fx:id="resultDisplayPlaceholder" prefHeight="20.0" styleClass="anchor-pane-with-border" VBox.vgrow="NEVER">
<padding>
<Insets bottom="5.0" left="10.0" right="10.0" top="5.0" />
</padding>
</AnchorPane>
</children>
</VBox>
8 changes: 4 additions & 4 deletions src/main/resources/view/ResultDisplay.fxml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.layout.AnchorPane?>
<?import java.net.URL?>
<AnchorPane styleClass="anchor-pane-with-border" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"
fx:controller="seedu.address.ui.ResultDisplay">
<?import javafx.scene.layout.AnchorPane?>

<AnchorPane styleClass="anchor-pane-with-border" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1" fx:controller="seedu.address.ui.ResultDisplay">
<stylesheets>
<URL value="@DarkTheme.css" />
<URL value="@Extensions.css" />
<URL value="@DarkTheme.css" />
</stylesheets>
</AnchorPane>
Loading

0 comments on commit b2ff40a

Please sign in to comment.