forked from nus-cs2103-AY2324S2/tp
-
Notifications
You must be signed in to change notification settings - Fork 4
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 #32 from Wyrkx/master
Add simple UI and sample data. Codecov can be ignored for changes that are not practical to test.
- Loading branch information
Showing
15 changed files
with
220 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ignore: | ||
- "src/main/java/tutorpro/ui/StudentCard.java" |
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 |
---|---|---|
|
@@ -56,7 +56,7 @@ public static Student[] getSampleStudents() { | |
getTagSet(), new Level("J1"), getSubjectSet("Physics")), | ||
new Student(new Name("David Li"), new Phone("91031282"), new Email("[email protected]"), | ||
new Address("Blk 436 Serangoon Gardens Street 26, #16-43"), | ||
getTagSet(), new Level("UNI"), getSubjectSet("Chemistry, Biology")), | ||
getTagSet(), new Level("UNI"), getSubjectSet("Chemistry", "Biology")), | ||
new Student(new Name("Irfan Ibrahim"), new Phone("92492021"), new Email("[email protected]"), | ||
new Address("Blk 47 Tampines Street 20, #17-35"), | ||
getTagSet(), new Level("K2"), getSubjectSet("Reading")), | ||
|
@@ -68,7 +68,7 @@ public static Student[] getSampleStudents() { | |
|
||
public static ReadOnlyAddressBook getSampleAddressBook() { | ||
AddressBook sampleAb = new AddressBook(); | ||
for (Person samplePerson : getSamplePersons()) { | ||
for (Person samplePerson : getSampleStudents()) { | ||
sampleAb.addPerson(samplePerson); | ||
} | ||
return sampleAb; | ||
|
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,67 @@ | ||
package tutorpro.ui; | ||
|
||
import java.util.Comparator; | ||
|
||
import javafx.fxml.FXML; | ||
import javafx.scene.control.Label; | ||
import javafx.scene.layout.FlowPane; | ||
import javafx.scene.layout.HBox; | ||
import javafx.scene.layout.Region; | ||
import tutorpro.model.person.student.Student; | ||
|
||
/** | ||
* An UI component that displays information of a {@code Person}. | ||
*/ | ||
public class StudentCard extends UiPart<Region> { | ||
|
||
private static final String FXML = "StudentListCard.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 Student student; | ||
|
||
@FXML | ||
private HBox cardPane; | ||
@FXML | ||
private Label name; | ||
@FXML | ||
private Label id; | ||
@FXML | ||
private Label phone; | ||
@FXML | ||
private Label address; | ||
@FXML | ||
private Label email; | ||
@FXML | ||
private FlowPane tags; | ||
@FXML | ||
private Label level; | ||
@FXML | ||
private FlowPane subjects; | ||
|
||
/** | ||
* Creates a {@code PersonCode} with the given {@code Person} and index to display. | ||
*/ | ||
public StudentCard(Student student, int displayedIndex) { | ||
super(FXML); | ||
this.student = student; | ||
id.setText(displayedIndex + ". "); | ||
name.setText(student.getName().fullName); | ||
phone.setText(student.getPhone().value); | ||
address.setText(student.getAddress().value); | ||
email.setText(student.getEmail().value); | ||
level.setText(student.getLevel().toString()); | ||
student.getTags().stream() | ||
.sorted(Comparator.comparing(tag -> tag.tagName)) | ||
.forEach(tag -> tags.getChildren().add(new Label(tag.tagName))); | ||
student.getSubjects().stream() | ||
.sorted(Comparator.comparing(subject -> subject.toString())) | ||
.forEach(subject -> subjects.getChildren().add(new Label(subject.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
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,38 @@ | ||
<?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.FlowPane?> | ||
<?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"> | ||
<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" /> | ||
</HBox> | ||
<FlowPane fx:id="tags" /> | ||
<FlowPane fx:id="subjects" /> | ||
<Label fx:id="level" styleClass="cell_small_label" text="\$level" /> | ||
<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" /> | ||
</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
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