Skip to content

Commit

Permalink
Merge pull request nus-cs2103-AY2425S1#77 from ethan-goh/change-ui
Browse files Browse the repository at this point in the history
Change UI
  • Loading branch information
JYL27 authored Oct 24, 2024
2 parents 4d6ee69 + be94ec5 commit 1d7567d
Show file tree
Hide file tree
Showing 10 changed files with 640 additions and 42 deletions.
2 changes: 2 additions & 0 deletions src/main/java/seedu/address/logic/commands/CommandResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public CommandResult(String feedbackToUser) {
this(feedbackToUser, false, false);
}



public String getFeedbackToUser() {
return feedbackToUser;
}
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 @@ -34,6 +34,7 @@ public class MainWindow extends UiPart<Stage> {
private PersonListPanel personListPanel;
private ResultDisplay resultDisplay;
private HelpWindow helpWindow;
private PersonDetails personDetails;

@FXML
private StackPane commandBoxPlaceholder;
Expand All @@ -50,6 +51,9 @@ public class MainWindow extends UiPart<Stage> {
@FXML
private StackPane statusbarPlaceholder;

@FXML
private StackPane personDetailsPlaceholder;

/**
* Creates a {@code MainWindow} with the given {@code Stage} and {@code Logic}.
*/
Expand Down Expand Up @@ -121,6 +125,9 @@ void fillInnerParts() {

CommandBox commandBox = new CommandBox(this::executeCommand);
commandBoxPlaceholder.getChildren().add(commandBox.getRoot());

PersonDetails personDetails = new PersonDetails(logic.getPersonToDisplay());
personDetailsPlaceholder.getChildren().add(personDetails.getRoot());
}

/**
Expand Down
26 changes: 17 additions & 9 deletions src/main/java/seedu/address/ui/PersonCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

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 javafx.scene.layout.StackPane;
import seedu.address.model.person.Person;

/**
Expand Down Expand Up @@ -39,10 +39,16 @@ public class PersonCard extends UiPart<Region> {
@FXML
private Label email;
@FXML
private FlowPane tags;
private Label tag;
@FXML
private Label course;

@FXML
private Label module;

@FXML
private StackPane tagPane;

/**
* Creates a {@code PersonCode} with the given {@code Person} and index to display.
*/
Expand All @@ -53,19 +59,21 @@ public PersonCard(Person person, int displayedIndex) {
name.setText(person.getName().fullName);
studentId.setText("StudentID: " + person.getStudentId().value);
phone.setText(person.getPhone().value);
address.setText(person.getAddress().value);
email.setText(person.getEmail().value);
tag.setText(person.getTag().role.getRole());
course.setText(person.getCourse().course);
course.getStyleClass().add("bold-text");

FlowPane singleTagFlowPane = new FlowPane();
Label tagLabel = new Label(person.getTag().toString());
singleTagFlowPane.getChildren().add(tagLabel);
tags.getChildren().add(singleTagFlowPane);
if (person.getTag().role.getRole().equalsIgnoreCase("Student")) {
tagPane.getStyleClass().add("student-pane");
} else if (person.getTag().role.getRole().equalsIgnoreCase("Tutor")) {
tagPane.getStyleClass().add("tutor-pane");
}

String modulesAsString = person.getModules().stream()
.map(m -> m.toString() + "\n")
.reduce("", (x, y) -> x + y);

course.setText(modulesAsString.isEmpty() ? "No enrolled modules" : modulesAsString);
module.setText(modulesAsString.isEmpty() ? "No enrolled modules" : modulesAsString);
/*person.getTags().stream()
.sorted(Comparator.comparing(tag -> tag.tagName))
.forEach(tag -> tags.getChildren().add(new Label(tag.tagName)));*/
Expand Down
75 changes: 75 additions & 0 deletions src/main/java/seedu/address/ui/PersonDetails.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
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.person.Person;
/**
* A UI component that displays detailed information of a {@code Person}.
*/
public class PersonDetails extends UiPart<Region> {
private static final String FXML = "PersonDetails.fxml";


public final Person person;

@javafx.fxml.FXML
private HBox cardPane;
@FXML
private Label name;
@FXML
private Label id;
@FXML
private Label studentId;
@FXML
private Label phone;
@FXML
private Label address;
@FXML
private Label email;
@FXML
private Label tag;
@FXML
private Label course;
@FXML
private Label module;
/**
* Creates a {@code PersonDetails} with the given {@code Person}.
*
* @param person The person whose details are to be displayed.
*/
public PersonDetails(Person person) {
super(FXML);
this.person = person;
updateDetails(person);
}

/**
* Updates the labels with the details of the given {@code Person}.
*/
public void updateDetails(Person person) {
if (person != null) {
name.setText(person.getName().fullName);
studentId.setText("StudentID\n" + person.getStudentId().value);
phone.setText("Contact Number\n" + person.getPhone().value);
tag.setText(person.getTag().role.getRole());
address.setText("Address\n" + person.getAddress().value);
email.setText("Email Address\n" + person.getEmail().value);
course.setText("Course\n" + person.getCourse().course);
String modulesAsString = person.getModules().stream()
.map(m -> m.toString() + "\n")
.reduce("", (x, y) -> x + y);
module.setText("Modules\n" + (modulesAsString.isEmpty() ? "No enrolled modules" : modulesAsString));
} else {
name.setText("");
studentId.setText("");
phone.setText("");
address.setText("");
email.setText("");
tag.setText("");
course.setText("");
module.setText("");
}
}
}
2 changes: 1 addition & 1 deletion src/main/resources/view/CommandBox.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.StackPane?>

<StackPane styleClass="stack-pane" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1">
<StackPane xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1">
<TextField fx:id="commandTextField" onAction="#handleCommandEntered" promptText="Enter command here..."/>
</StackPane>

Loading

0 comments on commit 1d7567d

Please sign in to comment.