Skip to content

Commit

Permalink
Truncate UI.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
howenc committed Nov 7, 2023
1 parent 60640de commit 159d48e
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 25 deletions.
10 changes: 10 additions & 0 deletions src/main/java/seedu/address/model/meeting/Location.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/seedu/address/model/person/Email.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/seedu/address/model/tag/Tag.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/seedu/address/ui/MeetingCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -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")));
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/seedu/address/ui/PersonCard.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ 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"
: "LC: " + time.format(DateTimeFormatter.ofPattern("dd.MM.yyyy HHmm")));
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())));
}
}
2 changes: 1 addition & 1 deletion src/main/resources/view/MainWindow.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<?import javafx.scene.layout.VBox?>
<?import javafx.stage.Stage?>

<fx:root minHeight="600" minWidth="450" onCloseRequest="#handleExit" title="OutBook" type="javafx.stage.Stage" xmlns="http://javafx.com/javafx/20.0.1" xmlns:fx="http://javafx.com/fxml/1">
<fx:root minHeight="600" minWidth="750" onCloseRequest="#handleExit" title="OutBook" type="javafx.stage.Stage" xmlns="http://javafx.com/javafx/20.0.1" xmlns:fx="http://javafx.com/fxml/1">
<icons>
<Image url="@/images/address_book_32.png" />
</icons>
Expand Down
11 changes: 3 additions & 8 deletions src/main/resources/view/MeetingScheduleCard.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,9 @@
<Insets bottom="5" left="15" right="5" top="5" />
</padding>
<HBox alignment="CENTER_LEFT" spacing="5">
<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="id" styleClass="cell_big_label" />
<Label fx:id="title" styleClass="cell_big_label" text="\$first" wrapText="true" />
<Region HBox.hgrow="ALWAYS"/>
<Region HBox.hgrow="ALWAYS" />
<Label fx:id="status" styleClass="cell_status_label" />
</HBox>
<FlowPane fx:id="tags" />
Expand All @@ -43,7 +38,7 @@
<Label fx:id="secondSpacer" styleClass="cell_small_label" text="\$spacer" />
<Label fx:id="end" styleClass="cell_small_label" text="\$end" />
</HBox>
<Label fx:id="l" styleClass="cell_small_label" text="\$l" />
<Label fx:id="l" styleClass="cell_small_label" text="\$l" wrapText="true" />
</VBox>
<rowConstraints>
<RowConstraints />
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/view/MeetingSchedulePanel.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<?import javafx.scene.control.ListView?>
<?import javafx.scene.layout.VBox?>

<VBox xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1">
<ListView fx:id="meetingScheduleView" VBox.vgrow="ALWAYS"/>
<VBox minWidth="200.0" prefWidth="250.0" xmlns="http://javafx.com/javafx/20.0.1" xmlns:fx="http://javafx.com/fxml/1">
<ListView fx:id="meetingScheduleView" VBox.vgrow="ALWAYS" />
</VBox>
13 changes: 4 additions & 9 deletions src/main/resources/view/PersonListCard.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,14 @@
<Insets bottom="5" left="15" right="5" top="5" />
</padding>
<HBox alignment="CENTER_LEFT" spacing="5">
<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="\$first" />
<Label fx:id="id" styleClass="cell_big_label" />
<Label fx:id="name" styleClass="cell_big_label" text="\$name" wrapText="true" />
<Region HBox.hgrow="ALWAYS" />
<Label fx:id="status" styleClass="cell_status_label" text="\$status" contentDisplay="RIGHT" />
<Label fx:id="status" contentDisplay="RIGHT" styleClass="cell_status_label" text="\$status" />
</HBox>
<FlowPane fx:id="tags" />
<Label fx:id="phone" styleClass="cell_small_label" text="\$phone" />
<Label fx:id="email" styleClass="cell_small_label" text="\$email" />
<Label fx:id="email" styleClass="cell_small_label" text="\$email" wrapText="true" />
<Label fx:id="lastContactedTime" styleClass="cell_small_label" text="\$lastContactedTime" />
</VBox>
<rowConstraints>
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/view/PersonListPanel.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
<?import javafx.scene.control.ListView?>
<?import javafx.scene.layout.VBox?>

<VBox xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1">
<VBox minWidth="200.0" prefWidth="210.0" xmlns="http://javafx.com/javafx/20.0.1" xmlns:fx="http://javafx.com/fxml/1">
<ListView fx:id="personListView" VBox.vgrow="ALWAYS" />
</VBox>

0 comments on commit 159d48e

Please sign in to comment.