From be29e740bd2c6647a94631644d880c236729990e Mon Sep 17 00:00:00 2001 From: Carl Christian Snethlage <50491877+calixtus@users.noreply.github.com> Date: Sun, 18 Aug 2019 14:21:03 +0200 Subject: [PATCH] Border for group color indicator and some space for tooltip (#5190) * Initial * Removed Border behind transparent groupRectangle, rewording --- .../gui/maintable/MainTableColumnFactory.java | 53 ++++++++++++------- 1 file changed, 34 insertions(+), 19 deletions(-) diff --git a/src/main/java/org/jabref/gui/maintable/MainTableColumnFactory.java b/src/main/java/org/jabref/gui/maintable/MainTableColumnFactory.java index f3ae887b505..2c2845638e5 100644 --- a/src/main/java/org/jabref/gui/maintable/MainTableColumnFactory.java +++ b/src/main/java/org/jabref/gui/maintable/MainTableColumnFactory.java @@ -9,6 +9,7 @@ import javax.swing.undo.UndoManager; +import javafx.geometry.Pos; import javafx.scene.Node; import javafx.scene.control.ContextMenu; import javafx.scene.control.MenuItem; @@ -16,7 +17,8 @@ import javafx.scene.control.Tooltip; import javafx.scene.input.MouseButton; import javafx.scene.input.MouseEvent; -import javafx.scene.layout.BorderPane; +import javafx.scene.layout.Pane; +import javafx.scene.layout.StackPane; import javafx.scene.paint.Color; import javafx.scene.shape.Rectangle; @@ -123,29 +125,42 @@ public MainTableColumnFactory(BibDatabaseContext database, ColumnPreferences pre new ValueTableCellFactory>() .withGraphic(this::createGroupColorRegion) .install(column); + column.setStyle("-fx-padding: 0 0 0 0;"); column.setSortable(true); return column; } private Node createGroupColorRegion(BibEntryTableViewModel entry, List matchedGroups) { - Rectangle rectangle = new Rectangle(); - rectangle.setWidth(3); - rectangle.setHeight(20); - Color color = matchedGroups.stream() - .flatMap(group -> OptionalUtil.toStream(group.getColor())) - .findFirst() - .orElse(Color.TRANSPARENT); - rectangle.setFill(color); - - String matchedGroupsString = matchedGroups.stream() - .map(AbstractGroup::getName) - .collect(Collectors.joining(", ")); - Tooltip tooltip = new Tooltip(Localization.lang("Entry is contained in the following groups:") + "\n" + matchedGroupsString); - Tooltip.install(rectangle, tooltip); - - BorderPane container = new BorderPane(); - container.setLeft(rectangle); - return container; + Color groupColor = matchedGroups.stream() + .flatMap(group -> OptionalUtil.toStream(group.getColor())) + .findFirst() + .orElse(Color.TRANSPARENT); + + if (groupColor != Color.TRANSPARENT) { + Rectangle border = new Rectangle(); + border.setWidth(5); + border.setHeight(20); + border.setFill(Color.DARKGRAY); + + Rectangle groupRectangle = new Rectangle(); + groupRectangle.setWidth(3); + groupRectangle.setHeight(18); + groupRectangle.setFill(groupColor); + + StackPane container = new StackPane(); + container.setMinWidth(10); + container.setAlignment(Pos.CENTER); + + container.getChildren().addAll(border,groupRectangle); + + String matchedGroupsString = matchedGroups.stream() + .map(AbstractGroup::getName) + .collect(Collectors.joining(", ")); + Tooltip tooltip = new Tooltip(Localization.lang("Entry is contained in the following groups:") + "\n" + matchedGroupsString); + Tooltip.install(container, tooltip); + return container; + } + return new Pane(); } private List> createNormalColumns() {