forked from nus-cs2103-AY2021S1/tp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
158 additions
and
2 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,62 @@ | ||
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.group.StudentInfo; | ||
|
||
/** | ||
* An UI component that displays information of a {@code StudentInfo}. | ||
*/ | ||
public class StudentInfoCard extends UiPart<Region> { | ||
|
||
private static final String FXML = "StudentInfoListCard.fxml"; | ||
|
||
public final StudentInfo studentInfo; | ||
|
||
@FXML | ||
private HBox cardPane; | ||
@FXML | ||
private Label name; | ||
@FXML | ||
private Label id; | ||
@FXML | ||
private Label studentNumber; | ||
@FXML | ||
private Label attendance; | ||
@FXML | ||
private Label participation; | ||
|
||
/** | ||
* Creates a {@code StudentCard} with the given {@code Student} and index to display. | ||
*/ | ||
public StudentInfoCard(StudentInfo studentInfo, int displayedIndex) { | ||
super(FXML); | ||
this.studentInfo = studentInfo; | ||
id.setText(displayedIndex + ". "); | ||
name.setText(studentInfo.getStudent().getName()); | ||
studentNumber.setText(studentInfo.getStudent().getStudentNumber()); | ||
attendance.setText(studentInfo.getAttendance().getAttendance() ? "Present" : "Absent"); | ||
participation.setText(String.valueOf(studentInfo.getParticipation().getScore())); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
// short circuit if same object | ||
if (other == this) { | ||
return true; | ||
} | ||
|
||
// instanceof handles nulls | ||
if (!(other instanceof StudentInfoCard)) { | ||
return false; | ||
} | ||
|
||
// state check | ||
StudentInfoCard card = (StudentInfoCard) other; | ||
return id.getText().equals(card.id.getText()) | ||
&& studentInfo.equals(card.studentInfo); | ||
} | ||
|
||
} |
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,51 @@ | ||
package seedu.address.ui; | ||
|
||
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.group.StudentInfo; | ||
|
||
import java.util.logging.Logger; | ||
|
||
/** | ||
* Panel containing the list of student information. | ||
*/ | ||
public class StudentInfoListPanel extends UiPart<Region> { | ||
|
||
private static final String FXML = "StudentInfoListPanel.fxml"; | ||
private final Logger logger = LogsCenter.getLogger(StudentInfoListPanel.class); | ||
|
||
@FXML | ||
private ListView<StudentInfo> studentInfoListView; | ||
|
||
/** | ||
* Creates a {@code StudentInfoListPanel} with the given {@code ObservableList}. | ||
*/ | ||
public StudentInfoListPanel(ObservableList<StudentInfo> studentInfoList) { | ||
super(FXML); | ||
studentInfoListView.setItems(studentInfoList); | ||
studentInfoListView.setCellFactory(listView -> new StudentInfoListPanel.StudentInfoListViewCell()); | ||
} | ||
|
||
/** | ||
* Custom {@code ListCell} that displays the graphics of a {@code StudentInfo} using a {@code StudentInfoCard}. | ||
*/ | ||
class StudentInfoListViewCell extends ListCell<StudentInfo> { | ||
|
||
@Override | ||
protected void updateItem(StudentInfo studentInfo, boolean empty) { | ||
super.updateItem(studentInfo, empty); | ||
|
||
if (empty || studentInfo == null) { | ||
setGraphic(null); | ||
setText(null); | ||
} else { | ||
setGraphic(new StudentInfoCard(studentInfo, 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<?import javafx.geometry.Insets?> | ||
<?import javafx.scene.control.Label?> | ||
<?import javafx.scene.layout.HBox?> | ||
<?import javafx.scene.layout.GridPane?> | ||
<?import javafx.scene.layout.ColumnConstraints?> | ||
<?import javafx.scene.layout.Region?> | ||
<?import javafx.scene.layout.VBox?> | ||
|
||
|
||
<HBox id="cardPane" fx:id="cardPane" xmlns="http://javafx.com/javafx/8" 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" styleClass="cell_big_label" text="\$name" /> | ||
<Label fx:id="studentNumber" styleClass="cell_small_label" text="\$studentNumber" /> | ||
<Label fx:id="attendance" styleClass="cell_small_label" text="\$attendance" /> | ||
<Label fx:id="participation" styleClass="cell_small_label" text="\$participation" /> | ||
</HBox> | ||
</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,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<?import javafx.scene.control.ListView?> | ||
<?import javafx.scene.layout.VBox?> | ||
|
||
<VBox xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"> | ||
<ListView fx:id="studentInfoListView" 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