<commit_before>package seedu.taskboss.ui;

import java.text.SimpleDateFormat;
import java.util.Date;

import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Region;
import seedu.taskboss.commons.util.AppUtil;
import seedu.taskboss.model.task.PriorityLevel;
import seedu.taskboss.model.task.ReadOnlyTask;

public class TaskCard extends UiPart<Region> {

    private static final String CSS_CARDPANE_OVERDUE = "-fx-background-color: #FFF7F8; -fx-border-color: #FF0097;"
            + " -fx-border-width: 1 2 1 2;";
    private static final String RECURRENCE_NONE = "NONE";
    private static final String PATH_IMAGE_URGENT = "/images/urgentImage.png";
    private static final String FXML = "TaskListCard.fxml";

    @FXML
    private HBox cardPane;
    @FXML
    private Label name;
    @FXML
    private Label id;
    @FXML
    private ImageView priorityLevel;
    @FXML
    private Label startDateTime;
    @FXML
    private Label endDateTime;
    @FXML
    private Label information;
    @FXML
    private Label recurrence;
    @FXML
    private FlowPane categories;

    //@@author A0143157J
    public TaskCard(ReadOnlyTask task, int displayedIndex) {
        super(FXML);
        initOverdueTaskCss(task);
        initName(task);
        initId(displayedIndex);
        initPriority(task);
        initStartDateTime(task);
        initEndDateTime(task);
        initInformation(task);
        initRecurrence(task);
        initCategories(task);
    }

    /**
     * Initialises CSS properties for a task that is overdue
     */
    private void initOverdueTaskCss(ReadOnlyTask task) {
        Date currDate = new Date();
        if (task.getEndDateTime() == null || task.getEndDateTime().getDate() == null) {
            return;
        }
        Date taskEndDate = task.getEndDateTime().getDate();
        if (isOverdueTask(taskEndDate, currDate, task)) {
            setCardPaneOverdueStyle();
        }
    }

    /**
     * Returns true if a task is overdue by comparing current time with the task's end date time
     */
    private boolean isOverdueTask(Date taskEndDate, Date currDate, ReadOnlyTask task) {
        boolean isOverdue = currDate.after(taskEndDate);
        SimpleDateFormat sdfNoTime = new SimpleDateFormat("MMM dd, yyyy");

        if (!isOverdue) {
            return false;
        } else if (isOverdue) {
            // account for special case (taskEndDate == today) that is marked as true for .after() in the API
            // ie. ed/today (without time) should not be overdue
            if (sdfNoTime.format(taskEndDate).equals(sdfNoTime.format(currDate)) && !task.getEndDateTime().isTimeInferred()) {
                return true;
            } else if (!sdfNoTime.format(taskEndDate).equals(sdfNoTime.format(currDate))) {
                return true;
            }
        }

        return false;
    }

    /**
     * Sets CSS style for the cardPane of overdue tasks
     */
    private void setCardPaneOverdueStyle() {
        cardPane.setStyle(CSS_CARDPANE_OVERDUE);
    }

    /**
     * Initialises name
     */
    private void initName(ReadOnlyTask task) {
        name.setText(task.getName().fullName);
    }

    /**
     * Initialises id
     */
    private void initId(int displayedIndex) {<commit_msg>Fix >120 char error::TaskCard<commit_after>package seedu.taskboss.ui;

import java.text.SimpleDateFormat;
import java.util.Date;

import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Region;
import seedu.taskboss.commons.util.AppUtil;
import seedu.taskboss.model.task.PriorityLevel;
import seedu.taskboss.model.task.ReadOnlyTask;

public class TaskCard extends UiPart<Region> {

    private static final String CSS_CARDPANE_OVERDUE = "-fx-background-color: #FFF7F8; -fx-border-color: #FF0097;"
            + " -fx-border-width: 1 2 1 2;";
    private static final String RECURRENCE_NONE = "NONE";
    private static final String PATH_IMAGE_URGENT = "/images/urgentImage.png";
    private static final String FXML = "TaskListCard.fxml";

    @FXML
    private HBox cardPane;
    @FXML
    private Label name;
    @FXML
    private Label id;
    @FXML
    private ImageView priorityLevel;
    @FXML
    private Label startDateTime;
    @FXML
    private Label endDateTime;
    @FXML
    private Label information;
    @FXML
    private Label recurrence;
    @FXML
    private FlowPane categories;

    //@@author A0143157J
    public TaskCard(ReadOnlyTask task, int displayedIndex) {
        super(FXML);
        initOverdueTaskCss(task);
        initName(task);
        initId(displayedIndex);
        initPriority(task);
        initStartDateTime(task);
        initEndDateTime(task);
        initInformation(task);
        initRecurrence(task);
        initCategories(task);
    }

    /**
     * Initialises CSS properties for a task that is overdue
     */
    private void initOverdueTaskCss(ReadOnlyTask task) {
        Date currDate = new Date();
        if (task.getEndDateTime() == null || task.getEndDateTime().getDate() == null) {
            return;
        }
        Date taskEndDate = task.getEndDateTime().getDate();
        if (isOverdueTask(taskEndDate, currDate, task)) {
            setCardPaneOverdueStyle();
        }
    }

    /**
     * Returns true if a task is overdue by comparing current time with the task's end date time
     */
    private boolean isOverdueTask(Date taskEndDate, Date currDate, ReadOnlyTask task) {
        boolean isOverdue = currDate.after(taskEndDate);
        SimpleDateFormat sdfNoTime = new SimpleDateFormat("MMM dd, yyyy");

        if (!isOverdue) {
            return false;
        } else if (isOverdue) {
            // account for special case (taskEndDate == today) that is marked as true for .after() in the API
            // ie. ed/today (without time) should not be overdue
            if (sdfNoTime.format(taskEndDate).equals(sdfNoTime.format(currDate))
                    && !task.getEndDateTime().isTimeInferred()) {
                return true;
            } else if (!sdfNoTime.format(taskEndDate).equals(sdfNoTime.format(currDate))) {
                return true;
            }
        }

        return false;
    }

    /**
     * Sets CSS style for the cardPane of overdue tasks
     */
    private void setCardPaneOverdueStyle() {
        cardPane.setStyle(CSS_CARDPANE_OVERDUE);
    }

    /**
     * Initialises name
     */
    private void initName(ReadOnlyTask task) {
        name.setText(task.getName().fullName);
    }

    /**
     * Initialises id
     */
    private void initId(int displayedIndex) {
{'fraction_non_alphanumeric': 0.0983439860546194, 'fraction_numerical': 0.00537478210342824, 'mean_word_length': 2.600941422594142, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '925262', 'n_tokens_mistral': 2099, 'n_tokens_neox': 2039, 'n_words': 503}