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

Fixing unwanted tree group node expansion selection bug #10111

Merged
merged 3 commits into from
Jul 31, 2023
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve

### Fixed

- We fixed an issue where clicking the group expansion pane/arrow caused the node to be selected, when it should just expand/detract the node - [#10111](https://github.com/JabRef/jabref/pull/10111)
- We fixed an issue where the browser import would add ' characters before the BibTeX entry on Linux. [#9588](https://github.com/JabRef/jabref/issues/9588)
- We fixed an issue where searching for a specific term with the DOAB fetcher lead to an exception. [#9571](https://github.com/JabRef/jabref/issues/9571)
- We fixed an issue where the "Import" -> "Library to import to" did not show the correct library name if two opened libraries had the same suffix. [#9567](https://github.com/JabRef/jabref/issues/9567)
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/gui/groups/GroupTreeView.java
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ private void initialize() {

new ViewModelTreeTableRowFactory<GroupNodeViewModel>()
.withContextMenu(this::createContextMenuForGroup)
.withOnMousePressedEvent((row, event) -> {
.withEventFilter(MouseEvent.MOUSE_PRESSED, (row, event) -> {
if (event.getTarget() instanceof StackPane pane) {
if (pane.getStyleClass().contains("arrow") || pane.getStyleClass().contains("tree-disclosure-node")) {
event.consume();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

import javafx.beans.value.ObservableValue;
import javafx.css.PseudoClass;
import javafx.event.Event;
import javafx.event.EventType;
import javafx.geometry.Bounds;
import javafx.geometry.Point2D;
import javafx.scene.control.ContextMenu;
Expand All @@ -36,6 +38,7 @@ public class ViewModelTreeTableRowFactory<S> implements Callback<TreeTableView<S
private TriConsumer<TreeTableRow<S>, S, ? super DragEvent> toOnDragExited;
private TriConsumer<TreeTableRow<S>, S, ? super DragEvent> toOnDragOver;
private TriConsumer<TreeTableRow<S>, S, ? super MouseDragEvent> toOnMouseDragEntered;
private final Map<EventType<?>, BiConsumer<S, ? super Event>> eventFilters = new HashMap<>();
private final Map<PseudoClass, Callback<TreeTableRow<S>, ObservableValue<Boolean>>> pseudoClasses = new HashMap<>();

public ViewModelTreeTableRowFactory<S> withOnMouseClickedEvent(BiConsumer<S, ? super MouseEvent> event) {
Expand Down Expand Up @@ -114,6 +117,11 @@ public ViewModelTreeTableRowFactory<S> withPseudoClass(PseudoClass pseudoClass,
return this;
}

public ViewModelTreeTableRowFactory<S> withEventFilter(EventType<?> event, BiConsumer<S, ? super Event> toCondition) {
this.eventFilters.putIfAbsent(event, toCondition);
return this;
}

public void install(TreeTableView<S> table) {
table.setRowFactory(this);
}
Expand Down Expand Up @@ -192,6 +200,10 @@ protected void updateItem(S row, boolean empty) {
setOnMouseDragEntered(event -> toOnMouseDragEntered.accept(this, getItem(), event));
}

for (Map.Entry<EventType<?>, BiConsumer<S, ? super Event>> eventFilter : eventFilters.entrySet()) {
addEventFilter(eventFilter.getKey(), event -> eventFilter.getValue().accept(getItem(), event));
}

for (Map.Entry<PseudoClass, Callback<TreeTableRow<S>, ObservableValue<Boolean>>> pseudoClassWithCondition : pseudoClasses.entrySet()) {
ObservableValue<Boolean> condition = pseudoClassWithCondition.getValue().call(this);
subscriptions.add(BindingsHelper.includePseudoClassWhen(
Expand Down