Skip to content

Commit f29c292

Browse files
author
Martin Plieske
committed
refactored tooltip to only display new line if there is a description
1 parent f06af04 commit f29c292

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/main/java/de/doubleslash/keeptime/view/ProjectsListViewController.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,14 +283,22 @@ private Node createListEntryForProject(final Project p) {
283283
private void updateTooltip(final Project p) {
284284
final Pane pane = (Pane) projectSelectionNodeMap.get(p);
285285
final Label projectNameLabel = (Label) pane.getChildren().get(0);
286-
final String tooltipText = String.format("%s%n%s", p.getName(), p.getDescription());
286+
final String tooltipText = createTooltipTextForProject(p);
287287
final Tooltip projectTooltip = projectNameLabel.getTooltip();
288288
if (projectTooltip == null) {
289289
projectNameLabel.setTooltip(new Tooltip());
290290
}
291291
projectNameLabel.getTooltip().setText(tooltipText);
292292
}
293293

294+
private String createTooltipTextForProject(final Project p) {
295+
if (p.getDescription() == null || p.getDescription().isEmpty()) {
296+
return p.getName();
297+
} else {
298+
return String.format("%s%n%s", p.getName(), p.getDescription());
299+
}
300+
}
301+
294302
private Dialog<Project> setupEditProjectDialog(final String title, final String headerText, final Project project) {
295303
final Dialog<Project> dialog = new Dialog<>();
296304
dialog.setTitle(title);

0 commit comments

Comments
 (0)