Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Border for group color indicator and some space for tooltip #5190

Merged
merged 2 commits into from
Aug 18, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -122,29 +124,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