diff --git a/src/main/java/seedu/address/ui/DescriptionBox.java b/src/main/java/seedu/address/ui/DescriptionBox.java deleted file mode 100644 index 40d90521f4f..00000000000 --- a/src/main/java/seedu/address/ui/DescriptionBox.java +++ /dev/null @@ -1,72 +0,0 @@ -package seedu.address.ui; - -import javafx.beans.property.SimpleStringProperty; -import javafx.collections.FXCollections; -import javafx.collections.ObservableList; -import javafx.fxml.FXML; -import javafx.scene.control.TableColumn; -import javafx.scene.control.TableView; -import javafx.scene.control.cell.PropertyValueFactory; -import javafx.scene.layout.Region; -import seedu.address.model.person.Person; - - - -/** - * Display Table class that is to be swapped out from the Person list. - */ -public class DescriptionBox extends UiPart { - private static final String FXML = "DescriptionBox.fxml"; - @FXML - private TableColumn field; - @FXML - private TableColumn description; - @FXML - private TableView table; - private final ObservableList data; - private final DisplayPerson displayPerson; - - /** - * Display table for the display command - */ - public DescriptionBox(Person person) { - //Constructor should take in a person class in the future - super(FXML); - displayPerson = new DisplayPerson(person); - data = displayPerson.getFieldDescriptions(); - - field.setCellValueFactory(new PropertyValueFactory<>("field")); - description.setCellValueFactory(new PropertyValueFactory<>("description")); - - table.setEditable(true); - table.setItems(data); - } - private static class DisplayPerson { - // Change method to utilise optionals instead of directly assuming the fields exist in the Person - // person.getField().map(person -> String).orElse(DEFAULT) - - private static final String DESCRIPTION_FIELD = "Description"; - - private final FieldDescription description; - - public DisplayPerson(Person person) { - this.description = new FieldDescription(DESCRIPTION_FIELD, person.getDescription().toString()); - } - - private ObservableList getFieldDescriptions() { - return FXCollections.observableArrayList(description); - } - - public static class FieldDescription { - private final SimpleStringProperty fieldProperty; - private final SimpleStringProperty descriptionProperty; - - public FieldDescription(String field, String description) { - fieldProperty = new SimpleStringProperty(field); - descriptionProperty = new SimpleStringProperty(description); - } - - } - } -} - diff --git a/src/main/java/seedu/address/ui/DisplayCard.java b/src/main/java/seedu/address/ui/DisplayCard.java index c423ae55249..fd89fa5fed7 100644 --- a/src/main/java/seedu/address/ui/DisplayCard.java +++ b/src/main/java/seedu/address/ui/DisplayCard.java @@ -33,7 +33,9 @@ public class DisplayCard extends UiPart { /** - * Creates a {@code PersonCode} with the given {@code Person} and index to display. + * Constructs a DisplayCard for displaying details of a specified field from a person's record. + * This card extracts the field name and description from {@code fieldDescription} and assigns them + * to the labels in the UI. */ public DisplayCard(DisplayListPanel.FieldDescription fieldDescription) { super(FXML); diff --git a/src/main/java/seedu/address/ui/DisplayListPanel.java b/src/main/java/seedu/address/ui/DisplayListPanel.java index 25a49a3c74f..9806dbd3055 100644 --- a/src/main/java/seedu/address/ui/DisplayListPanel.java +++ b/src/main/java/seedu/address/ui/DisplayListPanel.java @@ -19,7 +19,7 @@ /** - * Panel containing the list of persons. + * Represents the panel that displays the list of persons within the application. */ public class DisplayListPanel extends UiPart { private static final String FXML = "DisplayListPanel.fxml"; @@ -59,6 +59,12 @@ public DisplayListPanel(Person person, CommandBox.CommandExecutor commandExecuto }); } + /** + * Handles key press events in the description text area, + * specifically looking for the ENTER key to execute update commands. + * + * @param keyCode the key code associated with the key event. + */ @FXML private void handleDescriptionEntered(KeyCode keyCode) { @@ -79,6 +85,9 @@ private void handleDescriptionEntered(KeyCode keyCode) { } } + /** + * Resets the style of the description text area to the default style. + */ private void setStyleToDefault() { descriptionTextArea.getStyleClass().remove(CommandBox.ERROR_STYLE_CLASS); } @@ -98,8 +107,6 @@ private void setStyleToIndicateCommandFailure() { private class DisplayPerson { - // Change method to utilise optionals instead of directly assuming the fields exist in the Person - // person.getField().map(person -> String).orElse(DEFAULT) private static final String NAME_FIELD = "Name"; private static final String PHONE_FIELD = "Phone"; diff --git a/src/main/java/seedu/address/ui/DisplayTable.java b/src/main/java/seedu/address/ui/DisplayTable.java deleted file mode 100644 index 109350ed0d9..00000000000 --- a/src/main/java/seedu/address/ui/DisplayTable.java +++ /dev/null @@ -1,96 +0,0 @@ -package seedu.address.ui; - -import javafx.beans.property.SimpleStringProperty; -import javafx.collections.FXCollections; -import javafx.collections.ObservableList; -import javafx.fxml.FXML; -import javafx.scene.control.TableColumn; -import javafx.scene.control.TableView; -import javafx.scene.control.cell.PropertyValueFactory; -import javafx.scene.layout.Region; -import seedu.address.model.person.Person; - -/** - * Display Table class that is to be swapped out from the Person list. - */ -public class DisplayTable extends UiPart { - private static final String FXML = "DisplayTable.fxml"; - @FXML - private TableColumn field; - @FXML - private TableColumn description; - @FXML - private TableView table; - private final ObservableList data; - private final DisplayPerson displayPerson; - - /** - * Display table for the display command - */ - public DisplayTable(Person person) { - //Constructor should take in a person class in the future - super(FXML); - displayPerson = new DisplayPerson(person); - data = displayPerson.getFieldDescriptions(); - - field.setCellValueFactory(new PropertyValueFactory<>("field")); - description.setCellValueFactory(new PropertyValueFactory<>("description")); - - table.setEditable(true); - table.setItems(data); - } - private static class DisplayPerson { - // Change method to utilise optionals instead of directly assuming the fields exist in the Person - // person.getField().map(person -> String).orElse(DEFAULT) - - private static final String NAME_FIELD = "Name"; - private static final String PHONE_FIELD = "Phone"; - private static final String EMAIL_FIELD = "Email"; - private static final String ADDRESS_FIELD = "Address"; - private static final String NOK_FIELD = "Next of Kin"; - - private final FieldDescription name; - private final FieldDescription phone; - private final FieldDescription email; - private final FieldDescription address; - private final FieldDescription nok; - - public DisplayPerson(Person person) { - this.name = new FieldDescription(NAME_FIELD, person.getName().toString()); - this.email = new FieldDescription(EMAIL_FIELD, person.getEmail().toString()); - this.phone = new FieldDescription(PHONE_FIELD, person.getPhone().toString()); - this.address = new FieldDescription(ADDRESS_FIELD, person.getAddress().toString()); - this.nok = new FieldDescription(NOK_FIELD, person.getNextOfKin().toString()); - } - - private ObservableList getFieldDescriptions() { - return FXCollections.observableArrayList(name, email, phone, address, nok); - } - - public static class FieldDescription { - private final SimpleStringProperty fieldProperty; - private final SimpleStringProperty descriptionProperty; - - public FieldDescription(String field, String description) { - fieldProperty = new SimpleStringProperty(field); - descriptionProperty = new SimpleStringProperty(description); - } - public SimpleStringProperty fieldProperty() { - return fieldProperty; - } - public SimpleStringProperty descriptionProperty() { - return descriptionProperty; - } - public String getFieldProperty() { - return fieldProperty.get(); - } - public void setDescriptionProperty(String fName) { - descriptionProperty.set(fName); - } - public String getDescriptionProperty() { - return descriptionProperty.get(); - } - } - } -} -