Skip to content

Commit

Permalink
Remove wrapper for getReferencedEntry
Browse files Browse the repository at this point in the history
  • Loading branch information
k3KAW8Pnf7mkmdSMPHz27 committed Jul 22, 2021
1 parent abcdcad commit 1b50be6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.jabref.gui.specialfields.SpecialFieldValueViewModel;
import org.jabref.gui.util.uithreadaware.UiThreadBinding;
import org.jabref.logic.importer.util.FileFieldParser;
import org.jabref.model.database.BibDatabase;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.LinkedFile;
Expand All @@ -39,10 +40,12 @@ public class BibEntryTableViewModel {
private final EasyBinding<List<LinkedFile>> linkedFiles;
private final EasyBinding<Map<Field, String>> linkedIdentifiers;
private final Binding<List<AbstractGroup>> matchedGroups;
private final BibDatabase bibDatabase;

public BibEntryTableViewModel(BibEntry entry, BibDatabaseContext bibDatabaseContext, ObservableValue<MainTableFieldValueFormatter> fieldValueFormatter) {
this.entry = entry;
this.fieldValueFormatter = fieldValueFormatter;
this.bibDatabase = bibDatabaseContext.getDatabase();

this.linkedFiles = getField(StandardField.FILE).map(FileFieldParser::parse).orElse(Collections.emptyList());
this.linkedIdentifiers = createLinkedIdentifiersBinding(entry);
Expand Down Expand Up @@ -114,7 +117,7 @@ public ObservableValue<String> getFields(OrFields fields) {
}

ArrayList<Observable> observables = new ArrayList<>(List.of(entry.getObservables()));
Optional<BibEntry> referenced = fieldValueFormatter.getValue().getReferencedEntry(entry);
Optional<BibEntry> referenced = bibDatabase.getReferencedEntry(entry);
referenced.ifPresent(bibEntry -> observables.addAll(List.of(bibEntry.getObservables())));
observables.add(fieldValueFormatter);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,4 @@ private String formatFieldWithAuthorValue(final String nameToFormat) {
case NATBIB -> authors.latexFree().getAsNatbib();
};
}

/***
* Finds the entry in the crossref field
* @param entry the entry to be searched
* @return The referenced entry
*/
public Optional<BibEntry> getReferencedEntry(BibEntry entry) {
return bibDatabase.getReferencedEntry(entry);
}
}

0 comments on commit 1b50be6

Please sign in to comment.