From 752c54d5d96fbfd2861970a8fb86463f0ac1ad86 Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Tue, 16 Aug 2016 22:46:03 +0200 Subject: [PATCH 1/2] Fixed name column rendering #1499 and #1531 --- CHANGELOG.md | 3 ++ .../jabref/gui/maintable/MainTableColumn.java | 11 ++++--- .../sf/jabref/model/entry/AuthorListTest.java | 31 +++++++++++++++++++ 3 files changed, 40 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b8778bc8c7..104bc31d8cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -67,6 +67,9 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# - Fixed NullPointerException when trying to set a special field or mark an entry through the menu without having an open database - Fixed [#1257](https://github.com/JabRef/jabref/issues/1324): Preferences for the BibTeX key generator set in a version prior to 3.2 are now migrated automatically to the new version - Fixed [#1716](https://github.com/JabRef/jabref/issues/1716): `@`-Symbols stored in BibTeX fields no longer break the database +- Fixed [#1499](https://github.com/JabRef/jabref/issues/1499): {} braces are now treated correctly in in author/editor +- Fixed [#1531](https://github.com/JabRef/jabref/issues/1531): \relax can be used for abbreviation of author names + ### Removed - It is not longer possible to choose to convert HTML sub- and superscripts to equations diff --git a/src/main/java/net/sf/jabref/gui/maintable/MainTableColumn.java b/src/main/java/net/sf/jabref/gui/maintable/MainTableColumn.java index bdadc4ee509..42f2c637b07 100644 --- a/src/main/java/net/sf/jabref/gui/maintable/MainTableColumn.java +++ b/src/main/java/net/sf/jabref/gui/maintable/MainTableColumn.java @@ -78,7 +78,7 @@ public String getDisplayName() { * * @return true if the bibtex fields contains author or editor */ - public boolean isNameColumn() { + private boolean isNameColumn() { for (String field : bibtexFields) { if (InternalBibtexFields.getFieldExtras(field).contains(FieldProperties.PERSON_NAMES)) { return true; @@ -129,13 +129,14 @@ public Object getColumnValue(BibEntry entry) { } } - if (content != null) { - content = toUnicode.format(content); + if (isNameColumn()) { + content = MainTableNameFormatter.formatName(content); } - if (isNameColumn()) { - return MainTableNameFormatter.formatName(content); + if (content != null) { + content = toUnicode.format(content).trim(); } + return content; } diff --git a/src/test/java/net/sf/jabref/model/entry/AuthorListTest.java b/src/test/java/net/sf/jabref/model/entry/AuthorListTest.java index 67fb4020593..4d37157bb11 100644 --- a/src/test/java/net/sf/jabref/model/entry/AuthorListTest.java +++ b/src/test/java/net/sf/jabref/model/entry/AuthorListTest.java @@ -375,6 +375,37 @@ public void testGetAuthor() { Assert.assertEquals("von Neumann", author.getLastOnly()); Assert.assertEquals("Neumann, Jr, J.", author.getNameForAlphabetization()); Assert.assertEquals("von", author.getVon()); + + } + + @Test + public void testCompanyAuthor() { + Author author = AuthorList.parse("{JabRef Developers}").getAuthor(0); + Assert.assertNull(author.getFirst()); + Assert.assertNull(author.getFirstAbbr()); + Assert.assertEquals("JabRef Developers", author.getLast()); + Assert.assertNull(author.getJr()); + Assert.assertNull(author.getVon()); + } + + @Test + public void testCompanyAuthorWithLowerCaseWord() { + Author author = AuthorList.parse("{JabRef Developers on Fire}").getAuthor(0); + Assert.assertNull(author.getFirst()); + Assert.assertNull(author.getFirstAbbr()); + Assert.assertEquals("JabRef Developers on Fire", author.getLast()); + Assert.assertNull(author.getJr()); + Assert.assertNull(author.getVon()); + } + + @Test + public void testAbbreviationWithRelax() { + Author author = AuthorList.parse("{\\relax Ch}ristoph Cholera").getAuthor(0); + Assert.assertEquals("{\\relax Ch}ristoph", author.getFirst()); + Assert.assertEquals("{\\relax Ch}.", author.getFirstAbbr()); + Assert.assertEquals("Cholera", author.getLast()); + Assert.assertNull(author.getJr()); + Assert.assertNull(author.getVon()); } @Test From eb1b43237223a11eac7d30648127126ddca953ad Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Wed, 17 Aug 2016 09:01:18 +0200 Subject: [PATCH 2/2] Fixed comments --- CHANGELOG.md | 2 +- .../sf/jabref/model/entry/AuthorListTest.java | 21 ++++++------------- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 104bc31d8cd..7d941cf2a42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -68,7 +68,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# - Fixed [#1257](https://github.com/JabRef/jabref/issues/1324): Preferences for the BibTeX key generator set in a version prior to 3.2 are now migrated automatically to the new version - Fixed [#1716](https://github.com/JabRef/jabref/issues/1716): `@`-Symbols stored in BibTeX fields no longer break the database - Fixed [#1499](https://github.com/JabRef/jabref/issues/1499): {} braces are now treated correctly in in author/editor -- Fixed [#1531](https://github.com/JabRef/jabref/issues/1531): \relax can be used for abbreviation of author names +- Fixed [#1531](https://github.com/JabRef/jabref/issues/1531): `\relax` can be used for abbreviation of author names ### Removed diff --git a/src/test/java/net/sf/jabref/model/entry/AuthorListTest.java b/src/test/java/net/sf/jabref/model/entry/AuthorListTest.java index 4d37157bb11..d91816f6462 100644 --- a/src/test/java/net/sf/jabref/model/entry/AuthorListTest.java +++ b/src/test/java/net/sf/jabref/model/entry/AuthorListTest.java @@ -381,31 +381,22 @@ public void testGetAuthor() { @Test public void testCompanyAuthor() { Author author = AuthorList.parse("{JabRef Developers}").getAuthor(0); - Assert.assertNull(author.getFirst()); - Assert.assertNull(author.getFirstAbbr()); - Assert.assertEquals("JabRef Developers", author.getLast()); - Assert.assertNull(author.getJr()); - Assert.assertNull(author.getVon()); + Author expected = new Author(null, null, null, "JabRef Developers", null); + Assert.assertEquals(expected, author); } @Test public void testCompanyAuthorWithLowerCaseWord() { Author author = AuthorList.parse("{JabRef Developers on Fire}").getAuthor(0); - Assert.assertNull(author.getFirst()); - Assert.assertNull(author.getFirstAbbr()); - Assert.assertEquals("JabRef Developers on Fire", author.getLast()); - Assert.assertNull(author.getJr()); - Assert.assertNull(author.getVon()); + Author expected = new Author(null, null, null, "JabRef Developers on Fire", null); + Assert.assertEquals(expected, author); } @Test public void testAbbreviationWithRelax() { Author author = AuthorList.parse("{\\relax Ch}ristoph Cholera").getAuthor(0); - Assert.assertEquals("{\\relax Ch}ristoph", author.getFirst()); - Assert.assertEquals("{\\relax Ch}.", author.getFirstAbbr()); - Assert.assertEquals("Cholera", author.getLast()); - Assert.assertNull(author.getJr()); - Assert.assertNull(author.getVon()); + Author expected = new Author("{\\relax Ch}ristoph", "{\\relax Ch}.", null, "Cholera", null); + Assert.assertEquals(expected, author); } @Test