Skip to content

Commit

Permalink
Border for group color indicator and some space for tooltip (#5190)
Browse files Browse the repository at this point in the history
* Initial

* Removed Border behind transparent groupRectangle, rewording
  • Loading branch information
calixtus authored and Siedlerchr committed Aug 18, 2019
1 parent 7388374 commit be29e74
Showing 1 changed file with 34 additions and 19 deletions.
53 changes: 34 additions & 19 deletions src/main/java/org/jabref/gui/maintable/MainTableColumnFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@

import javax.swing.undo.UndoManager;

import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.MenuItem;
import javafx.scene.control.TableColumn;
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;

Expand Down Expand Up @@ -123,29 +125,42 @@ public MainTableColumnFactory(BibDatabaseContext database, ColumnPreferences pre
new ValueTableCellFactory<BibEntryTableViewModel, List<AbstractGroup>>()
.withGraphic(this::createGroupColorRegion)
.install(column);
column.setStyle("-fx-padding: 0 0 0 0;");
column.setSortable(true);
return column;
}

private Node createGroupColorRegion(BibEntryTableViewModel entry, List<AbstractGroup> 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<TableColumn<BibEntryTableViewModel, ?>> createNormalColumns() {
Expand Down

0 comments on commit be29e74

Please sign in to comment.