Skip to content

Commit

Permalink
fix: this will probably fix missing selection information on Linux
Browse files Browse the repository at this point in the history
I is hard to test this, as normally a selection should be given when the method is triggered.
Fixes #6085
  • Loading branch information
stefan-kolb committed Mar 14, 2020
1 parent 383391d commit e6e27a9
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/main/java/org/jabref/gui/actions/ActionHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import javafx.beans.binding.Bindings;
import javafx.beans.binding.BooleanExpression;
import javafx.collections.ObservableList;

import org.jabref.gui.StateManager;
import org.jabref.model.entry.BibEntry;
Expand All @@ -30,10 +31,18 @@ public static BooleanExpression isFieldSetForSelectedEntry(Field field, StateMan
}

public static BooleanExpression isAnyFieldSetForSelectedEntry(List<Field> fields, StateManager stateManager) {
BibEntry entry = stateManager.getSelectedEntries().get(0);
ObservableList<BibEntry> selectedEntries = stateManager.getSelectedEntries();

// binding should be recreated on every right click
// not sure why selectedEntries might be empty, see https://github.com/JabRef/jabref/issues/6085
if (selectedEntries.isEmpty()) {
return Bindings.createBooleanBinding(() -> false, selectedEntries);
}

BibEntry entry = selectedEntries.get(0);
return Bindings.createBooleanBinding(
() -> entry.getFields().stream().anyMatch(fields::contains),
entry.getFieldsObservable(),
stateManager.getSelectedEntries());
selectedEntries);
}
}

0 comments on commit e6e27a9

Please sign in to comment.