forked from nus-cs2103-AY2324S1/tp
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #88 from pra-navi/branch-taskGUI
feat: Implement GUI for Task List
- Loading branch information
Showing
21 changed files
with
235 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,5 +5,5 @@ | |
"email": "invalid@email!3e", | ||
"address": "4th street" | ||
} ], | ||
"tasks": [] | ||
"tasks" : [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,5 +43,5 @@ | |
"address" : "4th street", | ||
"tags" : [ ] | ||
} ], | ||
"tasks": [] | ||
"tasks" : [] | ||
} |
Oops, something went wrong.