Skip to content

Commit 6cb738d

Browse files
authored
Fixed display of groups and links column in MainTable (#5985)
* Fixed display of groups and links column in MainTable * CHANGELOG.md
1 parent 808ee45 commit 6cb738d

File tree

2 files changed

+26
-21
lines changed

2 files changed

+26
-21
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
4444
- We fixed an issue where opening a library from the recent libraries menu was not possible. [#5939](https://github.com/JabRef/jabref/issues/5939)
4545
- We fixed an issue where the most bottom group in the list got lost, if it was dragged on itself. [#5983](https://github.com/JabRef/jabref/issues/5983)
4646
- We fixed an issue where changing entry type doesn't always work when biblatex source is shown. [#5905](https://github.com/JabRef/jabref/issues/5905)
47+
- We fixed an issue where the group and the link column were not updated after changing the entry in the main table. [#5985](https://github.com/JabRef/jabref/issues/5985)
4748

4849
### Removed
4950

src/main/java/org/jabref/gui/maintable/BibEntryTableViewModel.java

+25-21
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import java.util.Optional;
88
import java.util.stream.Collectors;
99

10+
import javafx.beans.binding.Bindings;
1011
import javafx.beans.binding.ObjectBinding;
1112
import javafx.beans.property.SimpleObjectProperty;
1213
import javafx.beans.value.ObservableValue;
@@ -18,6 +19,7 @@
1819
import org.jabref.model.entry.FileFieldParser;
1920
import org.jabref.model.entry.LinkedFile;
2021
import org.jabref.model.entry.field.Field;
22+
import org.jabref.model.entry.field.InternalField;
2123
import org.jabref.model.entry.field.SpecialField;
2224
import org.jabref.model.entry.field.StandardField;
2325
import org.jabref.model.groups.AbstractGroup;
@@ -52,31 +54,33 @@ public ObservableValue<List<LinkedFile>> getLinkedFiles() {
5254
return EasyBind.map(getField(StandardField.FILE), FileFieldParser::parse);
5355
}
5456

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));
6470
}
6571

6672
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();
7174
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+
});
7883
}
79-
80-
return matchedGroups;
84+
return new SimpleObjectProperty<>(Collections.emptyList());
8185
}
8286
}

0 commit comments

Comments
 (0)