Skip to content

Commit

Permalink
Add warning for empty BibTeX keys in entry editor (#5025)
Browse files Browse the repository at this point in the history
* added a warning icon for empty Bibtex keys in entry editor

* fixed formatting issue in FieldCheckers.java

* modified logic and error message in ValidBibtexKeyCheck.checkValue

* Revert "fixed formatting issue in FieldCheckers.java"

This reverts commit 9271562.

* Revert "modified logic and error message in ValidBibtexKeyCheck.checkValue"

This reverts commit bad8856.

* changed status message for empty BibTeX keys to one in localization resources

* ordered class imports alphabetically in FieldCheckers.java

* added entry to CHANGELOG.md for issue #4440

* removed explanation text for issue 4440 fix and updated boolean toggle for empty or null BibTeX keys
  • Loading branch information
ms111ds authored and tobiasdiez committed Jun 9, 2019
1 parent 3f89897 commit 9cc4e65
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- We changed the title of Group Dialog to "Add subgroup" from "Edit group" when we select Add subgroup option.
- We enable import button only if entries are selected. [#4755](https://github.com/JabRef/jabref/issues/4755)
- We made modifications to improve contrast of UI elements. [#4583](https://github.com/JabRef/jabref/issues/4583)
- We added a warning for empty BibTeX keys in the entry editor. [#4440](https://github.com/JabRef/jabref/issues/4440)
- We added an option in the settings to set the default action in JabRef when right clicking on any entry in any database and selecting "Open folder". [#4763](https://github.com/JabRef/jabref/issues/4763)
- The Medline fetcher now normalizes the author names according to the BibTeX-Standard [#4345](https://github.com/JabRef/jabref/issues/4345)
- We added an option on the Linked File Viewer to rename the attached file of an entry directly on the JabRef. [#4844](https://github.com/JabRef/jabref/issues/4844)
Expand Down Expand Up @@ -125,7 +126,6 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- We fixed an issue where the JabRef Icon in the macOS launchpad was not displayed correctly [#5003](https://github.com/JabRef/jabref/issues/5003)



### Removed
- The feature to "mark entries" was removed and merged with the groups functionality. For migration, a group is created for every value of the `__markedentry` field and the entry is added to this group.
- The number column was removed.
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/org/jabref/logic/integrity/FieldCheckers.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import org.jabref.logic.journals.JournalAbbreviationRepository;
import org.jabref.model.database.BibDatabaseContext;
import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.FieldName;
import org.jabref.model.entry.InternalBibtexFields;
import org.jabref.model.metadata.FilePreferences;
Expand All @@ -15,7 +16,7 @@

public class FieldCheckers {

private Multimap<String, ValueChecker> fieldChecker;
private final Multimap<String, ValueChecker> fieldChecker;

public FieldCheckers(BibDatabaseContext databaseContext, FilePreferences filePreferences, JournalAbbreviationRepository abbreviationRepository, boolean enforceLegalKey) {
fieldChecker = getAllMap(databaseContext, filePreferences, abbreviationRepository, enforceLegalKey);
Expand Down Expand Up @@ -49,6 +50,7 @@ private static Multimap<String, ValueChecker> getAllMap(BibDatabaseContext datab
fieldCheckers.put(FieldName.URL, new UrlChecker());
fieldCheckers.put(FieldName.YEAR, new YearChecker());
fieldCheckers.put(FieldName.KEY, new ValidBibtexKeyChecker(enforceLegalKey));
fieldCheckers.put(BibEntry.KEY_FIELD, new ValidBibtexKeyChecker(enforceLegalKey));

if (databaseContext.isBiblatexMode()) {
fieldCheckers.put(FieldName.DATE, new DateChecker());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import org.jabref.logic.bibtexkeypattern.BibtexKeyGenerator;
import org.jabref.logic.l10n.Localization;
import org.jabref.model.strings.StringUtil;

/**
* Makes sure the key is legal
Expand All @@ -18,7 +19,12 @@ public ValidBibtexKeyChecker(boolean enforceLegalKey) {

@Override
public Optional<String> checkValue(String value) {
if (StringUtil.isNullOrEmpty(value)) {
return Optional.of(Localization.lang("empty BibTeX key"));
}

String cleaned = BibtexKeyGenerator.cleanKey(value, enforceLegalKey);

if (cleaned.equals(value)) {
return Optional.empty();
} else {
Expand Down

0 comments on commit 9cc4e65

Please sign in to comment.