|
7 | 7 | import java.util.Optional;
|
8 | 8 | import java.util.stream.Collectors;
|
9 | 9 |
|
| 10 | +import javafx.beans.binding.Bindings; |
10 | 11 | import javafx.beans.binding.ObjectBinding;
|
11 | 12 | import javafx.beans.property.SimpleObjectProperty;
|
12 | 13 | import javafx.beans.value.ObservableValue;
|
|
18 | 19 | import org.jabref.model.entry.FileFieldParser;
|
19 | 20 | import org.jabref.model.entry.LinkedFile;
|
20 | 21 | import org.jabref.model.entry.field.Field;
|
| 22 | +import org.jabref.model.entry.field.InternalField; |
21 | 23 | import org.jabref.model.entry.field.SpecialField;
|
22 | 24 | import org.jabref.model.entry.field.StandardField;
|
23 | 25 | import org.jabref.model.groups.AbstractGroup;
|
@@ -52,31 +54,33 @@ public ObservableValue<List<LinkedFile>> getLinkedFiles() {
|
52 | 54 | return EasyBind.map(getField(StandardField.FILE), FileFieldParser::parse);
|
53 | 55 | }
|
54 | 56 |
|
55 |
| - public ObservableValue<Map<Field,String>> getLinkedIdentifiers() { |
56 |
| - SimpleObjectProperty<Map<Field,String>> linkedIdentifiers = new SimpleObjectProperty<>(new HashMap<>()); |
57 |
| - |
58 |
| - entry.getField(StandardField.URL).ifPresent(value -> linkedIdentifiers.getValue().put(StandardField.URL, value)); |
59 |
| - entry.getField(StandardField.DOI).ifPresent(value -> linkedIdentifiers.getValue().put(StandardField.DOI, value)); |
60 |
| - entry.getField(StandardField.URI).ifPresent(value -> linkedIdentifiers.getValue().put(StandardField.URI, value)); |
61 |
| - entry.getField(StandardField.EPRINT).ifPresent(value -> linkedIdentifiers.getValue().put(StandardField.EPRINT, value)); |
62 |
| - |
63 |
| - return linkedIdentifiers; |
| 57 | + public ObservableValue<Map<Field, String>> getLinkedIdentifiers() { |
| 58 | + return Bindings.createObjectBinding(() -> { |
| 59 | + Map<Field, String> linkedIdentifiers = new HashMap<>(); |
| 60 | + entry.getField(StandardField.URL).ifPresent(value -> linkedIdentifiers.put(StandardField.URL, value)); |
| 61 | + entry.getField(StandardField.DOI).ifPresent(value -> linkedIdentifiers.put(StandardField.DOI, value)); |
| 62 | + entry.getField(StandardField.URI).ifPresent(value -> linkedIdentifiers.put(StandardField.URI, value)); |
| 63 | + entry.getField(StandardField.EPRINT).ifPresent(value -> linkedIdentifiers.put(StandardField.EPRINT, value)); |
| 64 | + return linkedIdentifiers; |
| 65 | + }, |
| 66 | + getEntry().getFieldBinding(StandardField.URL), |
| 67 | + getEntry().getFieldBinding(StandardField.DOI), |
| 68 | + getEntry().getFieldBinding(StandardField.URI), |
| 69 | + getEntry().getFieldBinding(StandardField.EPRINT)); |
64 | 70 | }
|
65 | 71 |
|
66 | 72 | public ObservableValue<List<AbstractGroup>> getMatchedGroups(BibDatabaseContext database) {
|
67 |
| - SimpleObjectProperty<List<AbstractGroup>> matchedGroups = new SimpleObjectProperty<>(Collections.emptyList()); |
68 |
| - |
69 |
| - Optional<GroupTreeNode> root = database.getMetaData() |
70 |
| - .getGroups(); |
| 73 | + Optional<GroupTreeNode> root = database.getMetaData().getGroups(); |
71 | 74 | if (root.isPresent()) {
|
72 |
| - List<AbstractGroup> groups = root.get().getMatchingGroups(entry) |
73 |
| - .stream() |
74 |
| - .map(GroupTreeNode::getGroup) |
75 |
| - .collect(Collectors.toList()); |
76 |
| - groups.remove(root.get().getGroup()); |
77 |
| - matchedGroups.setValue(groups); |
| 75 | + return EasyBind.map(entry.getFieldBinding(InternalField.GROUPS), field -> { |
| 76 | + List<AbstractGroup> groups = root.get().getMatchingGroups(entry) |
| 77 | + .stream() |
| 78 | + .map(GroupTreeNode::getGroup) |
| 79 | + .collect(Collectors.toList()); |
| 80 | + groups.remove(root.get().getGroup()); |
| 81 | + return groups; |
| 82 | + }); |
78 | 83 | }
|
79 |
| - |
80 |
| - return matchedGroups; |
| 84 | + return new SimpleObjectProperty<>(Collections.emptyList()); |
81 | 85 | }
|
82 | 86 | }
|
0 commit comments