-
-
Couldn't load subscription status.
- Fork 3k
Fix author formatter for unchanged names #6552
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
koppor
merged 117 commits into
JabRef:master
from
k3KAW8Pnf7mkmdSMPHz27:fix-for-issue-6459
Jun 16, 2020
Merged
Changes from all commits
Commits
Show all changes
117 commits
Select commit
Hold shift + click to select a range
fd405cf
Fix Pattern.compile for frequently used regexes
k3KAW8Pnf7mkmdSMPHz27 a6354e3
Fix one additional Pattern.compile
k3KAW8Pnf7mkmdSMPHz27 149ed4f
Fix style and unnecessary escape sequences
k3KAW8Pnf7mkmdSMPHz27 b57f1b2
Fix invalid index in call to substring
k3KAW8Pnf7mkmdSMPHz27 fae093b
Refactor name and javadoc of a regex
k3KAW8Pnf7mkmdSMPHz27 5a23a9a
Fix use of compiled regex for matching department
k3KAW8Pnf7mkmdSMPHz27 6af8c7e
Fix check for uppercase letter
k3KAW8Pnf7mkmdSMPHz27 716f885
Fix usage of uncompiled regex
k3KAW8Pnf7mkmdSMPHz27 cdfd56a
Fix readability?
k3KAW8Pnf7mkmdSMPHz27 b227edb
Add test cases
k3KAW8Pnf7mkmdSMPHz27 ef7f979
Fix `null` appearing as part of author name
k3KAW8Pnf7mkmdSMPHz27 9ac3993
Refactor name of capital regex pattern
k3KAW8Pnf7mkmdSMPHz27 85c96ce
Merge branch 'master' into fix-for-issue-6459
k3KAW8Pnf7mkmdSMPHz27 6ded410
Add debug output for reordering of names in fields
k3KAW8Pnf7mkmdSMPHz27 e8c3007
Merge branch 'master' into fix-for-issue-6459
k3KAW8Pnf7mkmdSMPHz27 72eb1fe
Add helper methods
k3KAW8Pnf7mkmdSMPHz27 2eee8dd
Fix missing negation in "uni" matching
k3KAW8Pnf7mkmdSMPHz27 cc54029
Fix test cases for corporate authors
k3KAW8Pnf7mkmdSMPHz27 1063ae1
Fix to keep all uppercase letters in abbreviation
k3KAW8Pnf7mkmdSMPHz27 ef94758
Fix commented out code
k3KAW8Pnf7mkmdSMPHz27 e80bd8b
Fix key for institution's name containing keyword
k3KAW8Pnf7mkmdSMPHz27 a0ed455
Fix test case for short institution name
k3KAW8Pnf7mkmdSMPHz27 4db0824
Refactor check for institution types
k3KAW8Pnf7mkmdSMPHz27 383fc14
Refactor comments and names improving readability?
k3KAW8Pnf7mkmdSMPHz27 c3e5f09
Refactor to improve readability and closure
k3KAW8Pnf7mkmdSMPHz27 5990c2a
Fix JavaDoc
k3KAW8Pnf7mkmdSMPHz27 0df3cdb
Fix JavaDoc typos
k3KAW8Pnf7mkmdSMPHz27 f0d9601
Fix preliminary order for authors -> latexfree
k3KAW8Pnf7mkmdSMPHz27 6f26a73
Drop logger
k3KAW8Pnf7mkmdSMPHz27 9b717c5
Add convenience methods for cached latexfree names
k3KAW8Pnf7mkmdSMPHz27 5ed9c54
Add name format method for names containing latex
k3KAW8Pnf7mkmdSMPHz27 d6e9e70
Add call to formatNameLatexFree
k3KAW8Pnf7mkmdSMPHz27 2dc664d
Fix unclear statement in JavaDoc
k3KAW8Pnf7mkmdSMPHz27 f0fd4f1
Fix to only keep the first character of each word
k3KAW8Pnf7mkmdSMPHz27 feebf81
Add latexfree Natbib test cases
k3KAW8Pnf7mkmdSMPHz27 d4c2ce3
Fix typo in latex-free test cases
k3KAW8Pnf7mkmdSMPHz27 04abe5e
Add Natbib test with escaped brackets
k3KAW8Pnf7mkmdSMPHz27 3f3ef62
Add Natbib institution test with escaped brackets
k3KAW8Pnf7mkmdSMPHz27 f4fbec1
Add test for latex-free comma separated lastnames
k3KAW8Pnf7mkmdSMPHz27 a256fa8
Add test for latex-free comma separated first name
k3KAW8Pnf7mkmdSMPHz27 4961c53
Add test for latex-free comma separated last name
k3KAW8Pnf7mkmdSMPHz27 a443db0
Fix adherence to JavaDoc and readability(?)
k3KAW8Pnf7mkmdSMPHz27 dd492e6
Fix readability(?)
k3KAW8Pnf7mkmdSMPHz27 71e45d4
Fix CheckStyle issues
k3KAW8Pnf7mkmdSMPHz27 2748dcd
Merge branch 'master' into fix-for-issue-6459
k3KAW8Pnf7mkmdSMPHz27 3b0dda3
Fix CHANGELOG.md
k3KAW8Pnf7mkmdSMPHz27 78b66f7
Fix mistake in BibtexKeyGeneratorTest
k3KAW8Pnf7mkmdSMPHz27 55ef8e7
Add test for oxford comma
k3KAW8Pnf7mkmdSMPHz27 237dc35
Merge branch 'master' into fix-for-issue-6459
k3KAW8Pnf7mkmdSMPHz27 78fade6
Fix miss-capitalization of enum
k3KAW8Pnf7mkmdSMPHz27 3de984d
Fix fields not displayed latex-free
k3KAW8Pnf7mkmdSMPHz27 ecac673
Fix in-line methods in MainTableNameFormatter
k3KAW8Pnf7mkmdSMPHz27 1c4928b
Fix in-line of generateKey() method
k3KAW8Pnf7mkmdSMPHz27 55f3f18
Fix separating tests into parsing/representation
k3KAW8Pnf7mkmdSMPHz27 e6cda69
Fix cache check and simplify expressions
k3KAW8Pnf7mkmdSMPHz27 2e120fd
Drop inlined methods
k3KAW8Pnf7mkmdSMPHz27 8cc947c
Fix most abbreviated abbreviations
k3KAW8Pnf7mkmdSMPHz27 2fc9e16
Drop old formatName method
k3KAW8Pnf7mkmdSMPHz27 b4b3993
Refactor formatNameLatexFree
k3KAW8Pnf7mkmdSMPHz27 3cb6232
Refactor new parse tests
k3KAW8Pnf7mkmdSMPHz27 b3f0d1b
Add more parse tests
k3KAW8Pnf7mkmdSMPHz27 5a27bbc
Drop all test cases containing escaped brackets
k3KAW8Pnf7mkmdSMPHz27 c7578b3
Refactor parse with latex tests
k3KAW8Pnf7mkmdSMPHz27 b8bf4f3
Fix my own spelling mistakes
k3KAW8Pnf7mkmdSMPHz27 cc23e29
Refactor abbreviation name
k3KAW8Pnf7mkmdSMPHz27 24398b4
Add latex-free unformatted authors' strings
k3KAW8Pnf7mkmdSMPHz27 5308717
Add test for latex-free unformatted authors
k3KAW8Pnf7mkmdSMPHz27 b2b523c
Merge branch 'master' into fix-for-issue-6459
k3KAW8Pnf7mkmdSMPHz27 94a46e2
Add change to CHANGELOG.md
k3KAW8Pnf7mkmdSMPHz27 539c616
Revert "Add change to CHANGELOG.md"
k3KAW8Pnf7mkmdSMPHz27 476b5b8
Fix dependence on parse in test cases
k3KAW8Pnf7mkmdSMPHz27 2642cb9
Add AuthorList cache tests
k3KAW8Pnf7mkmdSMPHz27 4ecdbf8
Add AuthorList institution cache test
k3KAW8Pnf7mkmdSMPHz27 b18e60d
Fix readability in a test case
k3KAW8Pnf7mkmdSMPHz27 7e840bc
Fix readability and memory leak
k3KAW8Pnf7mkmdSMPHz27 2bfbd71
Merge branch 'master' into fix-for-issue-6459
k3KAW8Pnf7mkmdSMPHz27 a4cb1ef
Fix int flag, changed to enum
k3KAW8Pnf7mkmdSMPHz27 ac8759b
Fix readability of TEX_NAMES set?
k3KAW8Pnf7mkmdSMPHz27 cea4c5e
Fix JavaDoc after flag changed from int to enum
k3KAW8Pnf7mkmdSMPHz27 03a632c
Fix AuthorList.equals
k3KAW8Pnf7mkmdSMPHz27 e22a098
Fix abbreviation in JavaDoc
k3KAW8Pnf7mkmdSMPHz27 0fd46d7
Refactor name of tests for AuthorListParser
k3KAW8Pnf7mkmdSMPHz27 d50c7cf
Fix re-enable commented out tests
k3KAW8Pnf7mkmdSMPHz27 4b389a6
Add test for first name starting with umlaut
k3KAW8Pnf7mkmdSMPHz27 cd68f6c
Fix update JavaDoc
k3KAW8Pnf7mkmdSMPHz27 f3340b2
Fix unique names in test cases
k3KAW8Pnf7mkmdSMPHz27 10fff4c
Fix a datastructure in AuthorListParser
k3KAW8Pnf7mkmdSMPHz27 b5caec8
Fix typos
k3KAW8Pnf7mkmdSMPHz27 fbe6501
Add missed oxford comma test cases
k3KAW8Pnf7mkmdSMPHz27 7c4faa3
Add test cases for equals
k3KAW8Pnf7mkmdSMPHz27 e028993
Add more equals test cases
k3KAW8Pnf7mkmdSMPHz27 a78460f
Fix typo
k3KAW8Pnf7mkmdSMPHz27 4abe855
Add tests for `hashCode`
k3KAW8Pnf7mkmdSMPHz27 551c6e2
Fix removes unnecessary call to `Map.contains`
k3KAW8Pnf7mkmdSMPHz27 557ffc9
Drop caching of unformatted strings in AuthorList
k3KAW8Pnf7mkmdSMPHz27 581446b
Fix caching of preferences
k3KAW8Pnf7mkmdSMPHz27 0020c21
Refactor static import of format preferences enums
k3KAW8Pnf7mkmdSMPHz27 81c0018
Revert "Drop caching of unformatted strings in..."
k3KAW8Pnf7mkmdSMPHz27 26cf448
Fix for getting unformatted latex-free names
k3KAW8Pnf7mkmdSMPHz27 0942e2c
Refactor the fields loop
k3KAW8Pnf7mkmdSMPHz27 3e562d8
Fix typo in formatFieldValueLatexFree
k3KAW8Pnf7mkmdSMPHz27 7616fbe
Fix reference of bibDatabaseContext in Formatter
k3KAW8Pnf7mkmdSMPHz27 4c457f3
Fix access modifier
k3KAW8Pnf7mkmdSMPHz27 d183705
Fix that removes "LatexFree" when it is implied
k3KAW8Pnf7mkmdSMPHz27 431811a
Fix that restores class variable `entriesFiltered`
k3KAW8Pnf7mkmdSMPHz27 8ad3aaf
Fix handling of DisplayStyle.AS_IS
k3KAW8Pnf7mkmdSMPHz27 a81f1e9
Drop AuthorList caching of unformatted string
k3KAW8Pnf7mkmdSMPHz27 c55b1b6
Merge branch 'fix-for-issue-6459' of https://github.com/k3KAW8Pnf7mkm…
k3KAW8Pnf7mkmdSMPHz27 c8380a8
Merge branch 'master' into fix-for-issue-6459
k3KAW8Pnf7mkmdSMPHz27 6155e14
Add `MainTableFieldValueFormatter` to checkstyle
k3KAW8Pnf7mkmdSMPHz27 1eeddab
Add MainTableFieldValueFormatter to exclusion list
koppor 2ff9553
Fix JavaDoc for `Author.equals`
k3KAW8Pnf7mkmdSMPHz27 2396fb2
Revert "Add `MainTableFieldValueFormatter` to ..."
k3KAW8Pnf7mkmdSMPHz27 b16d457
Merge branch 'fix-for-issue-6459' of https://github.com/k3KAW8Pnf7mkm…
k3KAW8Pnf7mkmdSMPHz27 a9e4f72
Fix JavaDoc description of AuthorList.equals
k3KAW8Pnf7mkmdSMPHz27 d7d692e
Merge branch 'fix-for-issue-6459' of https://github.com/k3KAW8Pnf7mkm…
k3KAW8Pnf7mkmdSMPHz27 0c0e777
Fix JavaDoc adherence with Author.equals
k3KAW8Pnf7mkmdSMPHz27 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
src/main/java/org/jabref/gui/maintable/MainTableFieldValueFormatter.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| package org.jabref.gui.maintable; | ||
|
|
||
| import java.util.Optional; | ||
|
|
||
| import org.jabref.model.database.BibDatabase; | ||
| import org.jabref.model.database.BibDatabaseContext; | ||
| import org.jabref.model.entry.AuthorList; | ||
| import org.jabref.model.entry.BibEntry; | ||
| import org.jabref.model.entry.field.Field; | ||
| import org.jabref.model.entry.field.FieldProperty; | ||
| import org.jabref.model.entry.field.OrFields; | ||
| import org.jabref.preferences.PreferencesService; | ||
|
|
||
| import static org.jabref.gui.maintable.MainTableNameFormatPreferences.AbbreviationStyle; | ||
| import static org.jabref.gui.maintable.MainTableNameFormatPreferences.DisplayStyle; | ||
|
|
||
| public class MainTableFieldValueFormatter { | ||
| private final DisplayStyle displayStyle; | ||
| private final AbbreviationStyle abbreviationStyle; | ||
| private final BibDatabase bibDatabase; | ||
|
|
||
| MainTableFieldValueFormatter(PreferencesService preferences, BibDatabaseContext bibDatabaseContext) { | ||
| MainTableNameFormatPreferences nameFormatPreferences = preferences.getMainTableNameFormatPreferences(); | ||
| this.displayStyle = nameFormatPreferences.getDisplayStyle(); | ||
| this.abbreviationStyle = nameFormatPreferences.getAbbreviationStyle(); | ||
| this.bibDatabase = bibDatabaseContext.getDatabase(); | ||
| } | ||
|
|
||
| /** | ||
| * Format fields for {@link BibEntryTableViewModel}, according to user preferences and with latex translated to | ||
| * unicode if possible. | ||
| * | ||
| * @param fields the fields argument of {@link BibEntryTableViewModel#getFields(OrFields)}. | ||
| * @param entry the BibEntry of {@link BibEntryTableViewModel}. | ||
| * @return The formatted name field. | ||
| */ | ||
| public String formatFieldsValues(final OrFields fields, final BibEntry entry) { | ||
| for (Field field : fields) { | ||
| if (field.getProperties().contains(FieldProperty.PERSON_NAMES) && displayStyle != DisplayStyle.AS_IS) { | ||
| Optional<String> name = entry.getResolvedFieldOrAlias(field, bibDatabase); | ||
|
|
||
| if (name.isPresent()) { | ||
| return formatFieldWithAuthorValue(name.get()); | ||
| } | ||
| } else { | ||
| Optional<String> content = entry.getResolvedFieldOrAliasLatexFree(field, bibDatabase); | ||
|
|
||
| if (content.isPresent()) { | ||
| return content.get(); | ||
| } | ||
| } | ||
| } | ||
| return ""; | ||
| } | ||
|
|
||
| /** | ||
| * Format a name field for the table, according to user preferences and with latex expressions translated if | ||
| * possible. | ||
| * | ||
| * @param nameToFormat The contents of the name field. | ||
| * @return The formatted name field. | ||
| */ | ||
| private String formatFieldWithAuthorValue(final String nameToFormat) { | ||
| if (nameToFormat == null) { | ||
| return null; | ||
| } | ||
|
|
||
| AuthorList authors = AuthorList.parse(nameToFormat); | ||
|
|
||
| if (((displayStyle == DisplayStyle.FIRSTNAME_LASTNAME) | ||
| || (displayStyle == DisplayStyle.LASTNAME_FIRSTNAME)) | ||
| && abbreviationStyle == AbbreviationStyle.LASTNAME_ONLY) { | ||
| return authors.getAsLastNamesLatexFree(false); | ||
| } | ||
|
|
||
| return switch (displayStyle) { | ||
| default -> nameToFormat; | ||
| case FIRSTNAME_LASTNAME -> authors.getAsFirstLastNamesLatexFree( | ||
| abbreviationStyle == AbbreviationStyle.FULL, | ||
| false); | ||
| case LASTNAME_FIRSTNAME -> authors.getAsLastFirstNamesLatexFree( | ||
| abbreviationStyle == AbbreviationStyle.FULL, | ||
| false); | ||
| case NATBIB -> authors.getAsNatbibLatexFree(); | ||
| }; | ||
| } | ||
| } |
54 changes: 0 additions & 54 deletions
54
src/main/java/org/jabref/gui/maintable/MainTableNameFormatter.java
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.