From 159d48ea36ce0eaeb76ac05601b47f961dc92879 Mon Sep 17 00:00:00 2001 From: howenc Date: Wed, 8 Nov 2023 00:47:59 +0800 Subject: [PATCH] Truncate UI. 1. The tags, contact email, meeting location will be truncated if the String has over 20, 30, 40 characters respectfully. 2. How these numbers were gotten were from the size of the panels. 3. The details section will not have it truncated as it is the responsibility of the user to make reasonable length items. --- .../java/seedu/address/model/meeting/Location.java | 10 ++++++++++ src/main/java/seedu/address/model/person/Email.java | 10 ++++++++++ src/main/java/seedu/address/model/tag/Tag.java | 10 ++++++++++ src/main/java/seedu/address/ui/MeetingCard.java | 4 ++-- src/main/java/seedu/address/ui/PersonCard.java | 4 ++-- src/main/resources/view/MainWindow.fxml | 2 +- src/main/resources/view/MeetingScheduleCard.fxml | 11 +++-------- src/main/resources/view/MeetingSchedulePanel.fxml | 4 ++-- src/main/resources/view/PersonListCard.fxml | 13 ++++--------- src/main/resources/view/PersonListPanel.fxml | 2 +- 10 files changed, 45 insertions(+), 25 deletions(-) diff --git a/src/main/java/seedu/address/model/meeting/Location.java b/src/main/java/seedu/address/model/meeting/Location.java index b064517f80b..8cb27fb5954 100644 --- a/src/main/java/seedu/address/model/meeting/Location.java +++ b/src/main/java/seedu/address/model/meeting/Location.java @@ -35,6 +35,16 @@ public static boolean isValidLocation(String test) { return test.matches(VALIDATION_REGEX); } + /** + * Returns a truncated Email if it is more than 40 characters long. + */ + public String shortLocation() { + if (this.location.length() > 40) { + return this.location.substring(0, 40) + "..."; + } + return this.location; + } + @Override public String toString() { return location; diff --git a/src/main/java/seedu/address/model/person/Email.java b/src/main/java/seedu/address/model/person/Email.java index c62e512bc29..a5e2b080d52 100644 --- a/src/main/java/seedu/address/model/person/Email.java +++ b/src/main/java/seedu/address/model/person/Email.java @@ -51,6 +51,16 @@ public static boolean isValidEmail(String test) { return test.matches(VALIDATION_REGEX); } + /** + * Returns a truncated Email if it is more than 30 characters long. + */ + public String shortEmail() { + if (this.value.length() > 30) { + return this.value.substring(0, 30) + "..."; + } + return this.value; + } + @Override public String toString() { return value; diff --git a/src/main/java/seedu/address/model/tag/Tag.java b/src/main/java/seedu/address/model/tag/Tag.java index 12f2f9fe17a..32e185f565a 100644 --- a/src/main/java/seedu/address/model/tag/Tag.java +++ b/src/main/java/seedu/address/model/tag/Tag.java @@ -56,6 +56,16 @@ public static boolean isValidTagName(String test) { return test.matches(VALIDATION_REGEX); } + /** + * Returns a truncated Tag if it is more than 20 characters long. + */ + public String shortTagName() { + if (this.tagName.length() >= 20) { + return this.tagName.substring(0, 20) + "..."; + } + return this.tagName; + } + @Override public boolean equals(Object other) { if (other == this) { diff --git a/src/main/java/seedu/address/ui/MeetingCard.java b/src/main/java/seedu/address/ui/MeetingCard.java index 848fcbf7286..9c92038870b 100644 --- a/src/main/java/seedu/address/ui/MeetingCard.java +++ b/src/main/java/seedu/address/ui/MeetingCard.java @@ -61,7 +61,7 @@ public MeetingCard(Meeting meeting, int displayedIndex) { this.meeting = meeting; id.setText(displayedIndex + ". "); title.setText(meeting.getTitle().meetingTitle); - l.setText(meeting.getLocation().location); + l.setText(meeting.getLocation().shortLocation()); LocalDateTime startTime = meeting.getStart(); LocalDateTime endTime = meeting.getEnd(); dateStart.setText(startTime.format(DateTimeFormatter.ofPattern("dd.MM.yyyy"))); @@ -72,7 +72,7 @@ public MeetingCard(Meeting meeting, int displayedIndex) { end.setText(meeting.getEnd().format(DateTimeFormatter.ofPattern("HHmm"))); meeting.getTags().stream() .sorted(Comparator.comparing(tag -> tag.tagName)) - .forEach(tag -> tags.getChildren().add(new Label(tag.tagName))); + .forEach(tag -> tags.getChildren().add(new Label(tag.shortTagName()))); if (meeting.getStatus().isComplete) { status.setText("COMPLETE"); } else { diff --git a/src/main/java/seedu/address/ui/PersonCard.java b/src/main/java/seedu/address/ui/PersonCard.java index c35dbbc0513..49ede2cdfd8 100644 --- a/src/main/java/seedu/address/ui/PersonCard.java +++ b/src/main/java/seedu/address/ui/PersonCard.java @@ -54,7 +54,7 @@ public PersonCard(Person person, int displayedIndex) { id.setText(displayedIndex + ". "); name.setText(person.getName().fullName); phone.setText(person.getPhone().value); - email.setText(person.getEmail().value); + email.setText(person.getEmail().shortEmail()); LocalDateTime time = person.getLastContactedTime(); lastContactedTime.setText(time.isEqual(LocalDateTime.MIN) ? "Not contacted yet" @@ -62,6 +62,6 @@ public PersonCard(Person person, int displayedIndex) { status.setText(person.getStatus().value); person.getTags().stream() .sorted(Comparator.comparing(tag -> tag.tagName)) - .forEach(tag -> tags.getChildren().add(new Label(tag.tagName))); + .forEach(tag -> tags.getChildren().add(new Label(tag.shortTagName()))); } } diff --git a/src/main/resources/view/MainWindow.fxml b/src/main/resources/view/MainWindow.fxml index ab57e7e5474..9ca68c504da 100644 --- a/src/main/resources/view/MainWindow.fxml +++ b/src/main/resources/view/MainWindow.fxml @@ -13,7 +13,7 @@ - + diff --git a/src/main/resources/view/MeetingScheduleCard.fxml b/src/main/resources/view/MeetingScheduleCard.fxml index 8919d55815d..f140d9a702d 100644 --- a/src/main/resources/view/MeetingScheduleCard.fxml +++ b/src/main/resources/view/MeetingScheduleCard.fxml @@ -20,14 +20,9 @@ - + @@ -43,7 +38,7 @@