Skip to content

Commit

Permalink
Merge pull request #109 from itsnotsherm/polish-UI
Browse files Browse the repository at this point in the history
Polish View Window log display UI
  • Loading branch information
itsnotsherm authored Nov 7, 2024
2 parents 99f6aed + 8b18a93 commit 6eb86bc
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
29 changes: 14 additions & 15 deletions src/main/java/seedu/address/ui/ViewWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
import java.util.logging.Logger;

import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.scene.control.Label;
import javafx.scene.control.ListCell;
import javafx.scene.control.ListView;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import seedu.address.commons.core.LogsCenter;
import seedu.address.model.person.Log;
Expand Down Expand Up @@ -42,7 +42,9 @@ public class ViewWindow extends UiPart<Stage> {
@FXML
private FlowPane tags;
@FXML
private ListView<Log> logListView;
private VBox logListContainer;

private ObservableList<Log> logList;

private ViewWindow(Stage root, String feedbackDisplayText, Person person) {
super(FXML, root);
Expand All @@ -57,8 +59,7 @@ private ViewWindow(Stage root, String feedbackDisplayText, Person person) {
person.getTags().stream()
.sorted(Comparator.comparing(tag -> tag.tagName))
.forEach(tag -> tags.getChildren().add(new Label(tag.tagName)));
logListView.setItems(FXCollections.observableArrayList(person.getLogEntries().getLogs()));
logListView.setCellFactory(listView -> new LogListViewCell());
logList = FXCollections.observableArrayList(person.getLogEntries().getLogs());
}

/**
Expand All @@ -74,6 +75,8 @@ public ViewWindow(String feedbackDisplayText, Person person) {
* Shows the view window.
*/
public void show() {
displayLogs();

logger.fine("Showing view page on a patient.");
getRoot().show();
getRoot().centerOnScreen();
Expand All @@ -93,17 +96,13 @@ public void hide() {
getRoot().hide();
}

static class LogListViewCell extends ListCell<Log> {
@Override
protected void updateItem(Log log, boolean empty) {
super.updateItem(log, empty);
private void displayLogs() {
logListContainer.getChildren().clear();

if (empty || log == null) {
setGraphic(null);
setText(null);
} else {
setGraphic(new Label(log.toString()));
}
for (Log log : logList) {
Label logLabel = new Label(log.toString());
logLabel.getStyleClass().add("label-bright");
logListContainer.getChildren().add(logLabel);
}
}
}
6 changes: 5 additions & 1 deletion src/main/resources/view/ViewWindow.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@
<Insets top="10" right="10" bottom="10" left="10" />
</padding>
<ScrollPane styleClass="dialog-pane" fitToHeight="true" fitToWidth="true" VBox.vgrow="ALWAYS" >
<ListView fx:id="logListView" />
<VBox fx:id="logListContainer" styleClass="pane-with-border" VBox.vgrow="ALWAYS">
<padding>
<Insets top="10" right="10" bottom="10" left="10" />
</padding>
</VBox>
</ScrollPane>
</VBox>
</VBox>
Expand Down

0 comments on commit 6eb86bc

Please sign in to comment.