package seedu.taskitty.ui;

import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.scene.Node;
import javafx.scene.control.TextArea;
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;
import seedu.taskitty.commons.util.FxViewUtil;

/**
 * A ui for the status bar that is displayed at the header of the application.
 */
public class ResultDisplay extends UiPart {
    public static final String RESULT_DISPLAY_ID = "resultDisplay";
    private static final String STATUS_BAR_STYLE_SHEET = "result-display";
    private TextArea resultDisplayArea;
    private final StringProperty displayed = new SimpleStringProperty("");

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

    private AnchorPane placeHolder;

    private AnchorPane mainPane;

    public static ResultDisplay load(Stage primaryStage, AnchorPane placeHolder) {
        ResultDisplay statusBar = UiPartLoader.loadUiPart(primaryStage, placeHolder, new ResultDisplay());
        statusBar.configure();
        return statusBar;
    }

    public void configure() {
        resultDisplayArea = new TextArea();
        resultDisplayArea.setEditable(false);
        resultDisplayArea.setId(RESULT_DISPLAY_ID);
        resultDisplayArea.getStyleClass().removeAll();
        resultDisplayArea.getStyleClass().add(STATUS_BAR_STYLE_SHEET);
        resultDisplayArea.setText("");
        resultDisplayArea.textProperty().bind(displayed);
        postMessage("Welcome User! Here is your agenda for today:");
        FxViewUtil.applyAnchorBoundaryParameters(resultDisplayArea, 0.0, 0.0, 0.0, 0.0);
        mainPane.getChildren().add(resultDisplayArea);
        FxViewUtil.applyAnchorBoundaryParameters(mainPane, 0.0, 0.0, 0.0, 0.0);
        placeHolder.getChildren().add(mainPane);
    }

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

    @Override
    public void setPlaceholder(AnchorPane placeholder) {
        this.placeHolder = placeholder;
    }

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

    public void postMessage(String message) {
        displayed.setValue(message);
    }

}

@@ -561,32 +561,234 @@
 esult-display%22;%0A
+    private static final String WELCOME_MESSAGE = %22Welcome! Here is your agenda for today:%22;%0A    private static final String WELCOME_MESSAGE_WITH_OVERDUE_DEADLINES = %22Welcome! You have overdue tasks.%22;%0A
     private Text
@@ -811,16 +811,16 @@
 ayArea;%0A
-
     priv
@@ -885,16 +885,55 @@
 rty(%22%22);
+%0A    private static boolean hasOverdue;
 %0A%0A    pr
@@ -1720,68 +1720,178 @@
     
-postMessage(%22Welcome User! Here is your agenda for today:%22);
+if (!hasOverdue) %7B%0A        %09System.out.println(%22isnt overdue%22);%0A        %09postMessage(WELCOME_MESSAGE);%0A        %7D else %7B%0A        %09displayOverdueWelcomeMessage();%0A        %7D
 %0A   
@@ -2499,24 +2499,24 @@
  message) %7B%0A
-
         disp
@@ -2545,12 +2545,203 @@
 );%0A    %7D
+%0A    %0A    public void displayOverdueWelcomeMessage() %7B%0A    %09postMessage(WELCOME_MESSAGE_WITH_OVERDUE_DEADLINES);%0A    %7D%0A    %0A    public static void setOverdue() %7B%0A    %09hasOverdue = true;%0A    %7D
 %0A%0A%7D%0A

Add alternative welcome message that includes case of presence of overdue tasks