Skip to content

Commit

Permalink
Merge pull request #88 from pra-navi/branch-taskGUI
Browse files Browse the repository at this point in the history
feat: Implement GUI for Task List
  • Loading branch information
m1oojv authored Oct 18, 2023
2 parents 46ee0a8 + 92b6ace commit 9264565
Show file tree
Hide file tree
Showing 21 changed files with 235 additions and 23 deletions.
4 changes: 4 additions & 0 deletions src/main/java/seedu/address/logic/Logic.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.ReadOnlyAddressBook;
import seedu.address.model.person.Person;
import seedu.address.model.task.Task;

/**
* API of the Logic component
Expand All @@ -33,6 +34,9 @@ public interface Logic {
/** Returns an unmodifiable view of the filtered list of persons */
ObservableList<Person> getFilteredPersonList();

/** Returns an unmodifiable view of the filtered list of tasks */
ObservableList<Task> getFilteredTaskList();

/**
* Returns the user prefs' address book file path.
*/
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/seedu/address/logic/LogicManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import seedu.address.model.Model;
import seedu.address.model.ReadOnlyAddressBook;
import seedu.address.model.person.Person;
import seedu.address.model.task.Task;
import seedu.address.storage.Storage;

/**
Expand Down Expand Up @@ -71,6 +72,11 @@ public ObservableList<Person> getFilteredPersonList() {
return model.getFilteredPersonList();
}

@Override
public ObservableList<Task> getFilteredTaskList() {
return model.getFilteredTaskList();
}

@Override
public Path getAddressBookFilePath() {
return model.getAddressBookFilePath();
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/seedu/address/model/task/UniqueTaskList.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@

/**
* A list of tasks that enforces uniqueness between its elements and does not allow nulls.
* A task is considered unique by comparing using {@code Task#isSameTask(Task)}. As such, adding and updating
* of tasks uses Task#isSameTask(Task) for equality to ensure that the task being added or updated is
* unique in terms of identity in the UniqueTaskList. However, the removal of a task uses Task#equals(Object)
* to ensure that the task with exactly the same fields will be removed.
* A task is considered unique by comparing using {@code Task#isSameTask(Task)}. As such, adding and updating of
* tasks uses Task#isSameTask(Task) for equality so as to ensure that the task being added or updated is
* unique in terms of identity in the UniqueTaskList. However, the removal of a task uses Task#equals(Task) so
* as to ensure that the task with exactly the same fields will be removed.
*
* Supports a minimal set of list operations.
*
* @see Task#isSameTask(Task)
*/
public class UniqueTaskList implements Iterable<Task> {

private final ObservableList<Task> internalList = FXCollections.observableArrayList();
private final ObservableList<Task> internalUnmodifiableList =
FXCollections.unmodifiableObservableList(internalList);
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/seedu/address/model/util/SampleDataUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
import seedu.address.model.person.Person;
import seedu.address.model.person.Phone;
import seedu.address.model.tag.Tag;
import seedu.address.model.task.Note;
import seedu.address.model.task.Task;
import seedu.address.model.task.Title;

/**
* Contains utility methods for populating {@code AddressBook} with sample data.
Expand Down Expand Up @@ -40,11 +43,22 @@ public static Person[] getSamplePersons() {
};
}

public static Task[] getSampleTasks() {
return new Task[] {
new Task(new Title("Buy Flowers"), new Note("from Gina")),
new Task(new Title("Buy Milk"), new Note("from NTUC"))
};
}

public static ReadOnlyAddressBook getSampleAddressBook() {
AddressBook sampleAb = new AddressBook();
for (Person samplePerson : getSamplePersons()) {
sampleAb.addPerson(samplePerson);
}

for (Task sampleTask : getSampleTasks()) {
sampleAb.addTask(sampleTask);
}
return sampleAb;
}

Expand Down
7 changes: 7 additions & 0 deletions src/main/java/seedu/address/ui/MainWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,16 @@ public class MainWindow extends UiPart<Stage> {

// Independent Ui parts residing in this Ui container
private PersonListPanel personListPanel;
private TaskListPanel taskListPanel;
private ResultDisplay resultDisplay;
private HelpWindow helpWindow;

@FXML
private StackPane commandBoxPlaceholder;

@FXML
private StackPane taskListPanelPlaceholder;

@FXML
private MenuItem helpMenuItem;

Expand Down Expand Up @@ -113,6 +117,9 @@ void fillInnerParts() {
personListPanel = new PersonListPanel(logic.getFilteredPersonList());
personListPanelPlaceholder.getChildren().add(personListPanel.getRoot());

taskListPanel = new TaskListPanel(logic.getFilteredTaskList());
taskListPanelPlaceholder.getChildren().add(taskListPanel.getRoot());

resultDisplay = new ResultDisplay();
resultDisplayPlaceholder.getChildren().add(resultDisplay.getRoot());

Expand Down
46 changes: 46 additions & 0 deletions src/main/java/seedu/address/ui/TaskCard.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package seedu.address.ui;

import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Region;
import seedu.address.model.task.Task;

/**
* An UI component that displays information of a {@code Task}.
*/
public class TaskCard extends UiPart<Region> {

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

/**
* Note: Certain keywords such as "location" and "resources" are reserved keywords in JavaFX.
* As a consequence, UI elements' variable names cannot be set to such keywords
* or an exception will be thrown by JavaFX during runtime.
*
* @see <a href="https://github.com/se-edu/addressbook-level4/issues/336">The issue on AddressBook level 4</a>
*/

public final Task task;

@FXML
private HBox cardPane;
@FXML
private Label title;
@FXML
private Label note;

@FXML
private Label id;

/**
* Creates a {@code TaskCode} with the given {@code Task} and index to display.
*/
public TaskCard(Task task, int displayedIndex) {
super(FXML);
this.task = task;
id.setText(displayedIndex + ". ");
title.setText(task.getTitle().toString());
note.setText(task.getNote().toString());
}
}
49 changes: 49 additions & 0 deletions src/main/java/seedu/address/ui/TaskListPanel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package seedu.address.ui;

import java.util.logging.Logger;

import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.scene.control.ListCell;
import javafx.scene.control.ListView;
import javafx.scene.layout.Region;
import seedu.address.commons.core.LogsCenter;
import seedu.address.model.task.Task;

/**
* Panel containing the list of tasks.
*/
public class TaskListPanel extends UiPart<Region> {
private static final String FXML = "TaskListPanel.fxml";
private final Logger logger = LogsCenter.getLogger(TaskListPanel.class);

@FXML
private ListView<Task> taskListView;

/**
* Creates a {@code TaskListPanel} with the given {@code ObservableList}.
*/
public TaskListPanel(ObservableList<Task> taskList) {
super(FXML);
taskListView.setItems(taskList);
taskListView.setCellFactory(listView -> new TaskListViewCell());
}

/**
* Custom {@code ListCell} that displays the graphics of a {@code Task} using a {@code TaskCard}.
*/
class TaskListViewCell extends ListCell<Task> {
@Override
protected void updateItem(Task task, boolean empty) {
super.updateItem(task, empty);

if (empty || task == null) {
setGraphic(null);
setText(null);
} else {
setGraphic(new TaskCard(task, getIndex() + 1).getRoot());
}
}
}

}
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/ui/UiManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class UiManager implements Ui {
public static final String ALERT_DIALOG_PANE_FIELD_ID = "alertDialogPane";

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/coordimate_icon.png";

private Logic logic;
private MainWindow mainWindow;
Expand Down
Binary file removed src/main/resources/images/calendar.png
Binary file not shown.
7 changes: 7 additions & 0 deletions src/main/resources/view/DarkTheme.css
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,13 @@
-fx-text-fill: #010504;
}

.cell_header_label {
-fx-font-family: "Segoe UI Semibold";
-fx-font-size: 22px;
-fx-padding: 0 0 10 0;
-fx-text-fill: white;
}

.stack-pane {
-fx-background-color: derive(#1d1d1d, 20%);
}
Expand Down
40 changes: 31 additions & 9 deletions src/main/resources/view/MainWindow.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@
<?import javafx.scene.control.Menu?>
<?import javafx.scene.control.MenuBar?>
<?import javafx.scene.control.MenuItem?>
<?import javafx.scene.control.SplitPane?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.layout.StackPane?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.control.SplitPane?>

<fx:root type="javafx.stage.Stage" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1"
title="Address App" minWidth="450" minHeight="600" onCloseRequest="#handleExit">
title="CoordiMate" minWidth="450" minHeight="600" onCloseRequest="#handleExit">
<icons>
<Image url="@/images/address_book_32.png" />
<Image url="@/images/coordimate_icon.png" />
</icons>
<scene>
<Scene>
Expand Down Expand Up @@ -46,12 +47,33 @@
</padding>
</StackPane>

<VBox fx:id="personList" styleClass="pane-with-border" minWidth="340" prefWidth="340" VBox.vgrow="ALWAYS">
<padding>
<Insets top="10" right="10" bottom="10" left="10" />
</padding>
<StackPane fx:id="personListPanelPlaceholder" VBox.vgrow="ALWAYS"/>
</VBox>
<SplitPane dividerPositions="0.50" prefHeight="160" prefWidth="700" VBox.vgrow="ALWAYS">
<AnchorPane minHeight="160" minWidth="200">
<children>
<VBox fx:id="personList" styleClass="pane-with-border" minWidth="160" prefWidth="200"
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0"
AnchorPane.topAnchor="0.0">
<padding>
<Insets top="10" right="10" bottom="10" left="10" />
</padding>
<StackPane fx:id="personListPanelPlaceholder" VBox.vgrow="ALWAYS"/>
</VBox>
</children>
</AnchorPane>

<AnchorPane minHeight="160" minWidth="200">
<children>
<VBox fx:id="taskList" styleClass="pane-with-border" minWidth="160" prefWidth="200"
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0"
AnchorPane.topAnchor="0.0">
<padding>
<Insets top="10" right="10" bottom="10" left="10" />
</padding>
<StackPane fx:id="taskListPanelPlaceholder" VBox.vgrow="ALWAYS"/>
</VBox>
</children>
</AnchorPane>
</SplitPane>

<StackPane fx:id="statusbarPlaceholder" VBox.vgrow="NEVER" />
</VBox>
Expand Down
10 changes: 5 additions & 5 deletions src/main/resources/view/PersonListCard.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@
<Insets top="5" right="5" bottom="5" left="15" />
</padding>
<HBox spacing="5" alignment="CENTER_LEFT">
<Label fx:id="id" styleClass="cell_big_label">
<Label fx:id="id" styleClass="cell_big_label" wrapText="true">
<minWidth>
<!-- Ensures that the label text is never truncated -->
<Region fx:constant="USE_PREF_SIZE" />
</minWidth>
</Label>
<Label fx:id="name" text="\$first" styleClass="cell_big_label" />
<Label fx:id="name" text="\$first" styleClass="cell_big_label" wrapText="true"/>
</HBox>
<FlowPane fx:id="tags" />
<Label fx:id="phone" styleClass="cell_small_label" text="\$phone" />
<Label fx:id="address" styleClass="cell_small_label" text="\$address" />
<Label fx:id="email" styleClass="cell_small_label" text="\$email" />
<Label fx:id="phone" styleClass="cell_small_label" text="\$phone" wrapText="true"/>
<Label fx:id="address" styleClass="cell_small_label" text="\$address" wrapText="true"/>
<Label fx:id="email" styleClass="cell_small_label" text="\$email" wrapText="true"/>
</VBox>
</GridPane>
</HBox>
2 changes: 2 additions & 0 deletions src/main/resources/view/PersonListPanel.fxml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.ListView?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.VBox?>

<VBox xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1">
<Label text="Contact List" styleClass="cell_header_label" />
<ListView fx:id="personListView" VBox.vgrow="ALWAYS" />
</VBox>
32 changes: 32 additions & 0 deletions src/main/resources/view/TaskListCard.fxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.Region?>
<?import javafx.scene.layout.VBox?>

<HBox id="cardPane" fx:id="cardPane" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1">
<GridPane HBox.hgrow="ALWAYS">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10" prefWidth="150" />
</columnConstraints>
<VBox alignment="CENTER_LEFT" minHeight="105" GridPane.columnIndex="0">
<padding>
<Insets top="5" right="5" bottom="5" left="15" />
</padding>
<HBox spacing="5" alignment="CENTER_LEFT">
<Label fx:id="id" styleClass="cell_big_label" wrapText="true">
<minWidth>
<!-- Ensures that the label text is never truncated -->
<Region fx:constant="USE_PREF_SIZE" />
</minWidth>
</Label>
<Label fx:id="title" text="\$title" styleClass="cell_big_label" wrapText="true"/>
</HBox>
<Label fx:id="note" styleClass="cell_small_label" text="\$note" wrapText="true"/>
</VBox>
</GridPane>
</HBox>
10 changes: 10 additions & 0 deletions src/main/resources/view/TaskListPanel.fxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.scene.control.ListView?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.VBox?>

<VBox xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1">
<Label text="Task List" styleClass="cell_header_label" />
<ListView fx:id="taskListView" VBox.vgrow="ALWAYS" />
</VBox>
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"email": "invalid@email!3e",
"address": "4th street"
} ],
"tasks": []
"tasks" : []
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@
"address" : "4th street",
"tags" : [ ]
} ],
"tasks": []
"tasks" : []
}
Loading

0 comments on commit 9264565

Please sign in to comment.