From 5fcc686c2c4745231de69f2ce9011c136d0fca70 Mon Sep 17 00:00:00 2001 From: Christoph Date: Thu, 10 May 2018 10:58:39 +0200 Subject: [PATCH 01/33] Fix ACM fetcher import of entries (#4019) Removed `&` sign from ID pattern --- CHANGELOG.md | 2 ++ .../java/org/jabref/gui/importer/fetcher/ACMPortalFetcher.java | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a71afa63a38..fbf47a6bbaa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,8 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# We fixed an issue where the export to clipboard functionality could not be invoked [#3994](https://github.com/JabRef/jabref/issues/3994) We fixed an issue with the migration of invalid Look and Feels [#3995, comment](https://github.com/JabRef/jabref/issues/3995#issuecomment-385649448) We fixed an issue where JabRef would no longer start, when the option "Override default font settings" was activated [#3986](https://github.com/JabRef/jabref/issues/3986) +We fixed an issue where fetched entries from the ACM fetcher could not be imported. [#4018](https://github.com/JabRef/jabref/issues/4018) + ### Removed We removed the GTK Look and Feel from the Options, as it leads to freezes in JabRef on MacOSX and Linux [#3995](https://github.com/JabRef/jabref/issues/3995) The GTK Look and Feel is now replaced with the "Nimbus" style as default. diff --git a/src/main/java/org/jabref/gui/importer/fetcher/ACMPortalFetcher.java b/src/main/java/org/jabref/gui/importer/fetcher/ACMPortalFetcher.java index 50d034355aa..cfa133a9958 100644 --- a/src/main/java/org/jabref/gui/importer/fetcher/ACMPortalFetcher.java +++ b/src/main/java/org/jabref/gui/importer/fetcher/ACMPortalFetcher.java @@ -78,7 +78,7 @@ public class ACMPortalFetcher implements PreviewEntryFetcher { private static final Pattern FULL_CITATION_PATTERN = Pattern.compile("([^<]*)"); From b10f941e8c3108c101eb023b491ed81af7961ed5 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Fri, 11 May 2018 11:22:58 +0200 Subject: [PATCH 02/33] Fix casing in java file name. (#4029) --- ...alizationBundleForTEst.java => LocalizationBundleForTest.java} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/test/java/org/jabref/logic/l10n/{LocalizationBundleForTEst.java => LocalizationBundleForTest.java} (100%) diff --git a/src/test/java/org/jabref/logic/l10n/LocalizationBundleForTEst.java b/src/test/java/org/jabref/logic/l10n/LocalizationBundleForTest.java similarity index 100% rename from src/test/java/org/jabref/logic/l10n/LocalizationBundleForTEst.java rename to src/test/java/org/jabref/logic/l10n/LocalizationBundleForTest.java From dae1c81e7ef32f3131c3fd3aba88d41054c62f7e Mon Sep 17 00:00:00 2001 From: Christoph Date: Fri, 11 May 2018 19:00:51 +0200 Subject: [PATCH 03/33] Do not trim or remove whitespace from the title based id fetcher (#4016) * Do not trim text for TitleBasedFetcher Fixes #4014 * add changelog * add trimming epxlicit to fetchers add some tests * move doi trim to parse add test --- CHANGELOG.md | 7 ++++--- src/main/java/org/jabref/gui/EntryTypeDialog.java | 13 +++++++------ .../org/jabref/logic/importer/fetcher/ArXiv.java | 6 ++++-- .../jabref/logic/importer/fetcher/DoiFetcher.java | 1 - .../logic/importer/fetcher/IacrEprintFetcher.java | 6 ++++-- .../java/org/jabref/model/entry/identifier/DOI.java | 4 +++- .../jabref/logic/importer/fetcher/ArXivTest.java | 6 ++++++ .../logic/importer/fetcher/DoiFetcherTest.java | 7 +++++++ .../org/jabref/model/entry/identifier/DOITest.java | 8 ++++++++ 9 files changed, 43 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fbf47a6bbaa..041054e8bdc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,9 +15,10 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# - We added a fetcher based on RFC-IDs. [#3971](https://github.com/JabRef/jabref/issues/3971) ### Fixed -We fixed an issue where the export to clipboard functionality could not be invoked [#3994](https://github.com/JabRef/jabref/issues/3994) -We fixed an issue with the migration of invalid Look and Feels [#3995, comment](https://github.com/JabRef/jabref/issues/3995#issuecomment-385649448) -We fixed an issue where JabRef would no longer start, when the option "Override default font settings" was activated [#3986](https://github.com/JabRef/jabref/issues/3986) +We fixed an issue where the export to clipboard functionality could not be invoked. [#3994](https://github.com/JabRef/jabref/issues/3994) +We fixed an issue with the migration of invalid Look and Feels. [#3995, comment](https://github.com/JabRef/jabref/issues/3995#issuecomment-385649448) +We fixed an issue where JabRef would no longer start, when the option "Override default font settings" was activated. [#3986](https://github.com/JabRef/jabref/issues/3986) +We fixed an issue where JabRef removed whitespace from the Title-fetcher which resulting in no entries being found. [#4014](https://github.com/JabRef/jabref/issues/4014) We fixed an issue where fetched entries from the ACM fetcher could not be imported. [#4018](https://github.com/JabRef/jabref/issues/4018) ### Removed diff --git a/src/main/java/org/jabref/gui/EntryTypeDialog.java b/src/main/java/org/jabref/gui/EntryTypeDialog.java index 84e2a78d4d1..40b19ab5c94 100644 --- a/src/main/java/org/jabref/gui/EntryTypeDialog.java +++ b/src/main/java/org/jabref/gui/EntryTypeDialog.java @@ -73,6 +73,7 @@ public EntryTypeDialog(JabRefFrame frame) { setTitle(Localization.lang("Select entry type")); addWindowListener(new WindowAdapter() { + @Override public void windowClosing(WindowEvent e) { cancelAction.actionPerformed(null); @@ -246,7 +247,6 @@ static class TypeButton extends JButton implements Comparable { private final EntryType type; - TypeButton(String label, EntryType type) { super(label); this.type = type; @@ -263,6 +263,7 @@ public EntryType getType() { } class CancelAction extends AbstractAction { + public CancelAction() { super("Cancel"); } @@ -275,6 +276,7 @@ public void actionPerformed(ActionEvent e) { } private class FetcherWorker extends SwingWorker, Void> { + private boolean fetcherException = false; private String fetcherExceptionMessage = ""; private IdBasedFetcher fetcher = null; @@ -288,10 +290,9 @@ protected Optional doInBackground() throws Exception { generateButton.setText(Localization.lang("Searching...")); }); - Globals.prefs.put(JabRefPreferences.ID_ENTRY_GENERATOR,String.valueOf(comboBox.getSelectedItem())); - searchID = idTextField.getText().trim(); - searchID = searchID.replaceAll(" ", ""); + Globals.prefs.put(JabRefPreferences.ID_ENTRY_GENERATOR, String.valueOf(comboBox.getSelectedItem())); fetcher = WebFetchers.getIdBasedFetchers(Globals.prefs.getImportFormatPreferences()).get(comboBox.getSelectedIndex()); + searchID = idTextField.getText(); if (!searchID.isEmpty()) { try { bibEntry = fetcher.performSearchById(searchID); @@ -311,7 +312,7 @@ protected void done() { if (result.isPresent()) { final BibEntry bibEntry = result.get(); if ((DuplicateCheck.containsDuplicate(frame.getCurrentBasePanel().getDatabase(), bibEntry, frame.getCurrentBasePanel().getBibDatabaseContext().getMode()).isPresent())) { - //If there are duplicates starts ImportInspectionDialog + //If there are duplicates starts ImportInspectionDialog final BasePanel panel = (BasePanel) frame.getTabbedPane().getSelectedComponent(); ImportInspectionDialog diag = new ImportInspectionDialog(frame, panel, Localization.lang("Import"), false); @@ -321,7 +322,7 @@ protected void done() { diag.setVisible(true); diag.toFront(); } else { - // Regenerate CiteKey of imported BibEntry + // Regenerate CiteKey of imported BibEntry new BibtexKeyGenerator(frame.getCurrentBasePanel().getBibDatabaseContext(), Globals.prefs.getBibtexKeyPatternPreferences()).generateAndSetKey(bibEntry); // Update Timestamps if (Globals.prefs.getTimestampPreferences().includeCreatedTimestamp()) { diff --git a/src/main/java/org/jabref/logic/importer/fetcher/ArXiv.java b/src/main/java/org/jabref/logic/importer/fetcher/ArXiv.java index a0829e42406..24b0f338101 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/ArXiv.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/ArXiv.java @@ -258,8 +258,10 @@ public List performSearch(String query) throws FetcherException { @Override public Optional performSearchById(String identifier) throws FetcherException { - return searchForEntryById(identifier).map( - (arXivEntry) -> arXivEntry.toBibEntry(importFormatPreferences.getKeywordSeparator())); + String cleanedIdentifier = identifier.trim(); + cleanedIdentifier = identifier.replaceAll(" ", ""); + + return searchForEntryById(cleanedIdentifier).map((arXivEntry) -> arXivEntry.toBibEntry(importFormatPreferences.getKeywordSeparator())); } @Override diff --git a/src/main/java/org/jabref/logic/importer/fetcher/DoiFetcher.java b/src/main/java/org/jabref/logic/importer/fetcher/DoiFetcher.java index 697df25f5fc..766f2570164 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/DoiFetcher.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/DoiFetcher.java @@ -45,7 +45,6 @@ public HelpFile getHelpPage() { @Override public Optional performSearchById(String identifier) throws FetcherException { Optional doi = DOI.parse(identifier); - try { if (doi.isPresent()) { URL doiURL = new URL(doi.get().getURIAsASCIIString()); diff --git a/src/main/java/org/jabref/logic/importer/fetcher/IacrEprintFetcher.java b/src/main/java/org/jabref/logic/importer/fetcher/IacrEprintFetcher.java index a87989b9481..af03b30b49f 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/IacrEprintFetcher.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/IacrEprintFetcher.java @@ -37,8 +37,10 @@ public class IacrEprintFetcher implements IdBasedFetcher { private static final Logger LOGGER = LoggerFactory.getLogger(IacrEprintFetcher.class); private static final Pattern DATE_FROM_WEBSITE_AFTER_2000_PATTERN = Pattern.compile("[a-z ]+(\\d{1,2} [A-Za-z][a-z]{2} \\d{4})"); - private static final DateTimeFormatter DATE_FORMAT_WEBSITE_AFTER_2000 = DateTimeFormatter.ofPattern("d MMM yyyy", Locale.US); private static final Pattern DATE_FROM_WEBSITE_BEFORE_2000_PATTERN = Pattern.compile("[A-Za-z ]+? ([A-Za-z][a-z]{2,10} \\d{1,2}(th|st|nd|rd)?, \\d{4})\\.?"); + private static final Pattern WITHOUT_LETTERS_SPACE = Pattern.compile("[^0-9/]"); + + private static final DateTimeFormatter DATE_FORMAT_WEBSITE_AFTER_2000 = DateTimeFormatter.ofPattern("d MMM yyyy", Locale.US); private static final DateTimeFormatter DATE_FORMAT_WEBSITE_BEFORE_2000_LONG_MONTHS = DateTimeFormatter.ofPattern("MMMM d['th']['st']['nd']['rd'] yyyy", Locale.US); private static final DateTimeFormatter DATE_FORMAT_WEBSITE_BEFORE_2000_SHORT_MONTHS = DateTimeFormatter.ofPattern("MMM d['th']['st']['nd']['rd'] yyyy", Locale.US); private static final DateTimeFormatter DATE_FORMAT_BIBTEX = DateTimeFormatter.ISO_LOCAL_DATE; @@ -55,7 +57,7 @@ public IacrEprintFetcher(ImportFormatPreferences prefs) { @Override public Optional performSearchById(String identifier) throws FetcherException { - String identifierWithoutLettersAndSpaces = identifier.replaceAll("[^0-9/]", " ").trim(); + String identifierWithoutLettersAndSpaces = WITHOUT_LETTERS_SPACE.matcher(identifier).replaceAll(" ").trim(); if (!IDENTIFIER_PREDICATE.test(identifierWithoutLettersAndSpaces)) { throw new FetcherException(Localization.lang("Invalid identifier: '%0'.", identifier)); diff --git a/src/main/java/org/jabref/model/entry/identifier/DOI.java b/src/main/java/org/jabref/model/entry/identifier/DOI.java index 38c66733758..49c06bd8730 100644 --- a/src/main/java/org/jabref/model/entry/identifier/DOI.java +++ b/src/main/java/org/jabref/model/entry/identifier/DOI.java @@ -95,7 +95,9 @@ public DOI(String doi) { */ public static Optional parse(String doi) { try { - return Optional.of(new DOI(doi)); + String cleanedDOI = doi.trim(); + cleanedDOI = doi.replaceAll(" ", ""); + return Optional.of(new DOI(cleanedDOI)); } catch (IllegalArgumentException | NullPointerException e) { return Optional.empty(); } diff --git a/src/test/java/org/jabref/logic/importer/fetcher/ArXivTest.java b/src/test/java/org/jabref/logic/importer/fetcher/ArXivTest.java index a79142ffc34..3a438659b31 100644 --- a/src/test/java/org/jabref/logic/importer/fetcher/ArXivTest.java +++ b/src/test/java/org/jabref/logic/importer/fetcher/ArXivTest.java @@ -168,6 +168,11 @@ public void searchEntryByIdWith4DigitsAndPrefix() throws Exception { assertEquals(Optional.of(sliceTheoremPaper), finder.performSearchById("arXiv:1405.2249")); } + @Test + public void searchEntryByIdWith4DigitsAndPrefixAndNotTrimmed() throws Exception { + assertEquals(Optional.of(sliceTheoremPaper), finder.performSearchById("arXiv : 1405. 2249")); + } + @Test public void searchEntryByIdWith5Digits() throws Exception { assertEquals(Optional.of( @@ -186,4 +191,5 @@ public void searchIdentifierForSlicePaper() throws Exception { assertEquals(ArXivIdentifier.parse("1405.2249v1"), finder.findIdentifier(sliceTheoremPaper)); } + } diff --git a/src/test/java/org/jabref/logic/importer/fetcher/DoiFetcherTest.java b/src/test/java/org/jabref/logic/importer/fetcher/DoiFetcherTest.java index d268730212b..177d48b7123 100644 --- a/src/test/java/org/jabref/logic/importer/fetcher/DoiFetcherTest.java +++ b/src/test/java/org/jabref/logic/importer/fetcher/DoiFetcherTest.java @@ -48,6 +48,7 @@ public void setUp() { bibEntryDecker2007.setField("doi", "10.1109/icws.2007.59"); } + @Test public void testGetName() { assertEquals("DOI", fetcher.getName()); @@ -80,4 +81,10 @@ public void testPerformSearchInvalidDOI() { assertThrows(FetcherException.class, () -> fetcher.performSearchById("10.1002/9781118257517F")); } + + @Test + public void testPerformSearchNonTrimmedDOI() throws FetcherException { + Optional fetchedEntry = fetcher.performSearchById("http s://doi.org/ 10.1109 /ICWS .2007.59 "); + assertEquals(Optional.of(bibEntryDecker2007), fetchedEntry); + } } diff --git a/src/test/java/org/jabref/model/entry/identifier/DOITest.java b/src/test/java/org/jabref/model/entry/identifier/DOITest.java index 457b779ff75..e1e8636c1f1 100644 --- a/src/test/java/org/jabref/model/entry/identifier/DOITest.java +++ b/src/test/java/org/jabref/model/entry/identifier/DOITest.java @@ -143,4 +143,12 @@ public void findDoiInsideArbitraryText() { public void noDOIFoundInsideArbitraryText() { assertEquals(Optional.empty(), DOI.findInText("text without 28282 a doi")); } + + @Test + public void parseDOIWithWhiteSpace() { + String doiWithSpace = "https : / / doi.org / 10 .1109 /V LHCC.20 04.20"; + assertEquals("https://doi.org/10.1109/VLHCC.2004.20", DOI.parse(doiWithSpace).get().getURIAsASCIIString()); + + } + } From 899d267bb8f1a4e56873896f4fa85ac7d2fd6c6c Mon Sep 17 00:00:00 2001 From: Christoph Date: Sat, 12 May 2018 23:46:26 +0200 Subject: [PATCH 04/33] Shortittle bibtexkeypattern now also discards small words (#4030) * Shortittle bibtexkeypattern now also discards small words Feature Request in the forum: http://discourse.jabref.org/t/jabref-differences-in-shorttitle-between-versions-3-8-1-and-4-not-discounting-the-a-an-of-in-titles/1147 * fix test --- CHANGELOG.md | 1 + .../bibtexkeypattern/BracketedPattern.java | 3 +- .../BibtexKeyGeneratorTest.java | 39 +++++++++++-------- .../MakeLabelWithDatabaseTest.java | 12 +++--- 4 files changed, 32 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 041054e8bdc..66572cb26d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# ### Changed - We added a text file export for 'Find Unlinked Files'. [#3341](https://github.com/JabRef/jabref/issues/3341) - We added a fetcher based on RFC-IDs. [#3971](https://github.com/JabRef/jabref/issues/3971) +- We changed the implementation of the `[shorttitle]` key pattern. It now removes small words like `a`, `an`, `on`, `the` etc. Refer to the help page for a complete overview. [Feature request in the forum](http://discourse.jabref.org/t/jabref-differences-in-shorttitle-between-versions-3-8-1-and-4-not-discounting-the-a-an-of-in-titles/1147) ### Fixed We fixed an issue where the export to clipboard functionality could not be invoked. [#3994](https://github.com/JabRef/jabref/issues/3994) diff --git a/src/main/java/org/jabref/logic/bibtexkeypattern/BracketedPattern.java b/src/main/java/org/jabref/logic/bibtexkeypattern/BracketedPattern.java index 565a6f99166..f88e98b3842 100644 --- a/src/main/java/org/jabref/logic/bibtexkeypattern/BracketedPattern.java +++ b/src/main/java/org/jabref/logic/bibtexkeypattern/BracketedPattern.java @@ -294,7 +294,8 @@ else if (val.matches("edtr\\d+")) { } else if ("fulltitle".equals(val)) { return entry.getResolvedFieldOrAlias(FieldName.TITLE, database).orElse(""); } else if ("shorttitle".equals(val)) { - return getTitleWords(3, entry.getResolvedFieldOrAlias(FieldName.TITLE, database).orElse("")); + return getTitleWords(3, + removeSmallWords(entry.getResolvedFieldOrAlias(FieldName.TITLE, database).orElse(""))); } else if ("shorttitleINI".equals(val)) { return keepLettersAndDigitsOnly( applyModifiers(getTitleWordsWithSpaces(3, entry.getResolvedFieldOrAlias(FieldName.TITLE, database).orElse("")), diff --git a/src/test/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGeneratorTest.java b/src/test/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGeneratorTest.java index 65a4e850b58..9fe07661d70 100644 --- a/src/test/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGeneratorTest.java +++ b/src/test/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGeneratorTest.java @@ -767,23 +767,30 @@ public void veryShortTitle() { */ @Test public void shortTitle() { - // shortTitle is getTitleWords with "3" as count + // shortTitle is getTitleWords with "3" as count and removed small words int count = 3; assertEquals("application migration effort", - BibtexKeyGenerator.getTitleWords(count, TITLE_STRING_ALL_LOWER_FOUR_SMALL_WORDS_ONE_EN_DASH)); - assertEquals("BPEL conformance in", BibtexKeyGenerator.getTitleWords(count, - TITLE_STRING_ALL_LOWER_FIRST_WORD_IN_BRACKETS_TWO_SMALL_WORDS_SMALL_WORD_AFTER_COLON)); - assertEquals("Process Viewing Patterns", BibtexKeyGenerator.getTitleWords(count, TITLE_STRING_CASED)); - assertEquals("BPMN Conformance in", - BibtexKeyGenerator.getTitleWords(count, TITLE_STRING_CASED_ONE_UPPER_WORD_ONE_SMALL_WORD)); - assertEquals("The Difference Between", BibtexKeyGenerator.getTitleWords(count, - TITLE_STRING_CASED_TWO_SMALL_WORDS_SMALL_WORD_AT_THE_BEGINNING)); - assertEquals("Cloud Computing: The", - BibtexKeyGenerator.getTitleWords(count, TITLE_STRING_CASED_TWO_SMALL_WORDS_SMALL_WORD_AFTER_COLON)); + BibtexKeyGenerator.getTitleWords(count, + BibtexKeyGenerator.removeSmallWords(TITLE_STRING_ALL_LOWER_FOUR_SMALL_WORDS_ONE_EN_DASH))); + assertEquals("BPEL conformance open", + BibtexKeyGenerator.getTitleWords(count, + BibtexKeyGenerator.removeSmallWords(TITLE_STRING_ALL_LOWER_FIRST_WORD_IN_BRACKETS_TWO_SMALL_WORDS_SMALL_WORD_AFTER_COLON))); + assertEquals("Process Viewing Patterns", + BibtexKeyGenerator.getTitleWords(count, + BibtexKeyGenerator.removeSmallWords(TITLE_STRING_CASED))); + assertEquals("BPMN Conformance Open", + BibtexKeyGenerator.getTitleWords(count, + BibtexKeyGenerator.removeSmallWords(TITLE_STRING_CASED_ONE_UPPER_WORD_ONE_SMALL_WORD))); + assertEquals("Difference Graph Based", + BibtexKeyGenerator.getTitleWords(count, + BibtexKeyGenerator.removeSmallWords(TITLE_STRING_CASED_TWO_SMALL_WORDS_SMALL_WORD_AT_THE_BEGINNING))); + assertEquals("Cloud Computing: Next", + BibtexKeyGenerator.getTitleWords(count, + BibtexKeyGenerator.removeSmallWords(TITLE_STRING_CASED_TWO_SMALL_WORDS_SMALL_WORD_AFTER_COLON))); assertEquals("Towards Choreography based", - BibtexKeyGenerator.getTitleWords(count, TITLE_STRING_CASED_TWO_SMALL_WORDS_ONE_CONNECTED_WORD)); - assertEquals("On the Measurement", - BibtexKeyGenerator.getTitleWords(count, TITLE_STRING_CASED_FOUR_SMALL_WORDS_TWO_CONNECTED_WORDS)); + BibtexKeyGenerator.getTitleWords(count, BibtexKeyGenerator.removeSmallWords(TITLE_STRING_CASED_TWO_SMALL_WORDS_ONE_CONNECTED_WORD))); + assertEquals("Measurement Design Time", + BibtexKeyGenerator.getTitleWords(count, BibtexKeyGenerator.removeSmallWords(TITLE_STRING_CASED_FOUR_SMALL_WORDS_TWO_CONNECTED_WORDS))); } /** @@ -935,7 +942,7 @@ public void testApplyModifiers() { BibEntry entry = new BibEntry(); entry.setField("title", "Green Scheduling of Whatever"); assertEquals("GSo", BibtexKeyGenerator.generateKey(entry, "shorttitleINI")); - assertEquals("GreenSchedulingof", BibtexKeyGenerator.generateKey(entry, "shorttitle", + assertEquals("GreenSchedulingWhatever", BibtexKeyGenerator.generateKey(entry, "shorttitle", new BibDatabase())); } @@ -950,7 +957,7 @@ public void testcrossrefShorttitle() { database.insertEntry(entry1); entry2.setField("title", "Green Scheduling of Whatever"); - assertEquals("GreenSchedulingof", BibtexKeyGenerator.generateKey(entry1, "shorttitle", + assertEquals("GreenSchedulingWhatever", BibtexKeyGenerator.generateKey(entry1, "shorttitle", database)); } diff --git a/src/test/java/org/jabref/logic/bibtexkeypattern/MakeLabelWithDatabaseTest.java b/src/test/java/org/jabref/logic/bibtexkeypattern/MakeLabelWithDatabaseTest.java index 345d568ff5d..46bea56b6ea 100644 --- a/src/test/java/org/jabref/logic/bibtexkeypattern/MakeLabelWithDatabaseTest.java +++ b/src/test/java/org/jabref/logic/bibtexkeypattern/MakeLabelWithDatabaseTest.java @@ -231,7 +231,7 @@ public void generateKeyTitleAbbr() { public void generateKeyShorttitle() { bibtexKeyPattern.setDefaultValue("[shorttitle]"); new BibtexKeyGenerator(bibtexKeyPattern, database, preferences).generateAndSetKey(entry); - assertEquals(Optional.of("Anawesomepaper"), entry.getCiteKeyOptional()); + assertEquals(Optional.of("awesomepaperJabRef"), entry.getCiteKeyOptional()); } @Test @@ -239,7 +239,7 @@ public void generateKeyShorttitleLowerModified() { bibtexKeyPattern.setDefaultValue("[shorttitle:lower]"); entry.setField("title", "An aweSOme Paper on JabRef"); new BibtexKeyGenerator(bibtexKeyPattern, database, preferences).generateAndSetKey(entry); - assertEquals(Optional.of("anawesomepaper"), entry.getCiteKeyOptional()); + assertEquals(Optional.of("awesomepaperjabref"), entry.getCiteKeyOptional()); } @Test @@ -247,7 +247,7 @@ public void generateKeyShorttitleUpperModified() { bibtexKeyPattern.setDefaultValue("[shorttitle:upper]"); entry.setField("title", "An aweSOme Paper on JabRef"); new BibtexKeyGenerator(bibtexKeyPattern, database, preferences).generateAndSetKey(entry); - assertEquals(Optional.of("ANAWESOMEPAPER"), entry.getCiteKeyOptional()); + assertEquals(Optional.of("AWESOMEPAPERJABREF"), entry.getCiteKeyOptional()); } @Test @@ -255,7 +255,7 @@ public void generateKeyShorttitleTitleCaseModified() { bibtexKeyPattern.setDefaultValue("[shorttitle:title_case]"); entry.setField("title", "An aweSOme Paper on JabRef"); new BibtexKeyGenerator(bibtexKeyPattern, database, preferences).generateAndSetKey(entry); - assertEquals(Optional.of("AnAwesomePaper"), entry.getCiteKeyOptional()); + assertEquals(Optional.of("AwesomePaperJabref"), entry.getCiteKeyOptional()); } @Test @@ -263,7 +263,7 @@ public void generateKeyShorttitleSentenceCaseModified() { bibtexKeyPattern.setDefaultValue("[shorttitle:sentence_case]"); entry.setField("title", "An aweSOme Paper on JabRef"); new BibtexKeyGenerator(bibtexKeyPattern, database, preferences).generateAndSetKey(entry); - assertEquals(Optional.of("Anawesomepaper"), entry.getCiteKeyOptional()); + assertEquals(Optional.of("Awesomepaperjabref"), entry.getCiteKeyOptional()); } @Test @@ -271,7 +271,7 @@ public void generateKeyShorttitleCapitalizeModified() { bibtexKeyPattern.setDefaultValue("[shorttitle:capitalize]"); entry.setField("title", "An aweSOme Paper on JabRef"); new BibtexKeyGenerator(bibtexKeyPattern, database, preferences).generateAndSetKey(entry); - assertEquals(Optional.of("AnAwesomePaper"), entry.getCiteKeyOptional()); + assertEquals(Optional.of("AwesomePaperJabref"), entry.getCiteKeyOptional()); } @Test From ba969d25cefc5da02406516eb5972f3bdc409e03 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Sun, 20 May 2018 22:12:34 +0200 Subject: [PATCH 05/33] Use all-text-fields magic also in BibTeX cleanup. (#4039) --- CHANGELOG.md | 1 + src/main/java/org/jabref/logic/cleanup/Cleanups.java | 9 +++------ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 66572cb26d7..be1e150b49e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# - We added a text file export for 'Find Unlinked Files'. [#3341](https://github.com/JabRef/jabref/issues/3341) - We added a fetcher based on RFC-IDs. [#3971](https://github.com/JabRef/jabref/issues/3971) - We changed the implementation of the `[shorttitle]` key pattern. It now removes small words like `a`, `an`, `on`, `the` etc. Refer to the help page for a complete overview. [Feature request in the forum](http://discourse.jabref.org/t/jabref-differences-in-shorttitle-between-versions-3-8-1-and-4-not-discounting-the-a-an-of-in-titles/1147) +- We streamlined the defaults for a [cleanup of entries](http://help.jabref.org/en/CleanupEntries) in the case of BibTeX. ### Fixed We fixed an issue where the export to clipboard functionality could not be invoked. [#3994](https://github.com/JabRef/jabref/issues/3994) diff --git a/src/main/java/org/jabref/logic/cleanup/Cleanups.java b/src/main/java/org/jabref/logic/cleanup/Cleanups.java index 6cfbe895ac9..22ebc35483f 100644 --- a/src/main/java/org/jabref/logic/cleanup/Cleanups.java +++ b/src/main/java/org/jabref/logic/cleanup/Cleanups.java @@ -36,12 +36,8 @@ public class Cleanups { List recommendedBibTeXFormatters = new ArrayList<>(); recommendedBibTeXFormatters.addAll(defaultFormatters); - recommendedBibTeXFormatters.add(new FieldFormatterCleanup(FieldName.TITLE, new HtmlToLatexFormatter())); - recommendedBibTeXFormatters.add(new FieldFormatterCleanup(FieldName.TITLE, new UnicodeToLatexFormatter())); - recommendedBibTeXFormatters.add(new FieldFormatterCleanup(FieldName.BOOKTITLE, new UnicodeToLatexFormatter())); - recommendedBibTeXFormatters.add(new FieldFormatterCleanup(FieldName.JOURNAL, new UnicodeToLatexFormatter())); - recommendedBibTeXFormatters.add(new FieldFormatterCleanup(FieldName.AUTHOR, new UnicodeToLatexFormatter())); - recommendedBibTeXFormatters.add(new FieldFormatterCleanup(FieldName.EDITOR, new UnicodeToLatexFormatter())); + recommendedBibTeXFormatters.add(new FieldFormatterCleanup(FieldName.INTERNAL_ALL_TEXT_FIELDS_FIELD, new HtmlToLatexFormatter())); + recommendedBibTeXFormatters.add(new FieldFormatterCleanup(FieldName.INTERNAL_ALL_TEXT_FIELDS_FIELD, new UnicodeToLatexFormatter())); recommendedBibTeXFormatters.add(new FieldFormatterCleanup(FieldName.INTERNAL_ALL_TEXT_FIELDS_FIELD, new OrdinalsToSuperscriptFormatter())); RECOMMEND_BIBTEX_ACTIONS = new FieldFormatterCleanups(false, recommendedBibTeXFormatters); @@ -49,6 +45,7 @@ public class Cleanups { recommendedBiblatexFormatters.addAll(defaultFormatters); recommendedBiblatexFormatters.add(new FieldFormatterCleanup(FieldName.TITLE, new HtmlToUnicodeFormatter())); recommendedBiblatexFormatters.add(new FieldFormatterCleanup(FieldName.INTERNAL_ALL_TEXT_FIELDS_FIELD, new LatexToUnicodeFormatter())); + // DO NOT ADD OrdinalsToSuperscriptFormatter here, because this causes issues. See https://github.com/JabRef/jabref/issues/2596. RECOMMEND_BIBLATEX_ACTIONS = new FieldFormatterCleanups(false, recommendedBiblatexFormatters); } From 248e1f6ad1818a99d93d00093076d3dae36e40c3 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Mon, 21 May 2018 11:02:42 +0200 Subject: [PATCH 06/33] Ensure that all formatters contained in Formatters.getAll() are tested --- .../jabref/logic/formatter/FormatterTest.java | 55 +++---------------- 1 file changed, 8 insertions(+), 47 deletions(-) diff --git a/src/test/java/org/jabref/logic/formatter/FormatterTest.java b/src/test/java/org/jabref/logic/formatter/FormatterTest.java index 404759a64e4..35a98f8eb3e 100644 --- a/src/test/java/org/jabref/logic/formatter/FormatterTest.java +++ b/src/test/java/org/jabref/logic/formatter/FormatterTest.java @@ -3,27 +3,7 @@ import java.util.Collections; import java.util.stream.Stream; -import org.jabref.logic.formatter.bibtexfields.ClearFormatter; -import org.jabref.logic.formatter.bibtexfields.HtmlToLatexFormatter; -import org.jabref.logic.formatter.bibtexfields.HtmlToUnicodeFormatter; -import org.jabref.logic.formatter.bibtexfields.LatexCleanupFormatter; -import org.jabref.logic.formatter.bibtexfields.NormalizeDateFormatter; -import org.jabref.logic.formatter.bibtexfields.NormalizeMonthFormatter; -import org.jabref.logic.formatter.bibtexfields.NormalizeNamesFormatter; -import org.jabref.logic.formatter.bibtexfields.NormalizePagesFormatter; -import org.jabref.logic.formatter.bibtexfields.OrdinalsToSuperscriptFormatter; -import org.jabref.logic.formatter.bibtexfields.RegexFormatter; -import org.jabref.logic.formatter.bibtexfields.RemoveBracesFormatter; -import org.jabref.logic.formatter.bibtexfields.UnicodeToLatexFormatter; -import org.jabref.logic.formatter.bibtexfields.UnitsToLatexFormatter; -import org.jabref.logic.formatter.casechanger.CapitalizeFormatter; -import org.jabref.logic.formatter.casechanger.LowerCaseFormatter; import org.jabref.logic.formatter.casechanger.ProtectTermsFormatter; -import org.jabref.logic.formatter.casechanger.SentenceCaseFormatter; -import org.jabref.logic.formatter.casechanger.TitleCaseFormatter; -import org.jabref.logic.formatter.casechanger.UpperCaseFormatter; -import org.jabref.logic.formatter.minifier.MinifyNameListFormatter; -import org.jabref.logic.layout.format.LatexToUnicodeFormatter; import org.jabref.logic.protectedterms.ProtectedTermsLoader; import org.jabref.logic.protectedterms.ProtectedTermsPreferences; import org.jabref.model.cleanup.Formatter; @@ -47,8 +27,6 @@ public static void setUp() { protectedTermsLoader = new ProtectedTermsLoader( new ProtectedTermsPreferences(ProtectedTermsLoader.getInternalLists(), Collections.emptyList(), Collections.emptyList(), Collections.emptyList())); - - } @ParameterizedTest @@ -107,33 +85,16 @@ public void getExampleInputAlwaysNonEmpty(Formatter formatter) { public static Stream getFormatters() { // all classes implementing {@link net.sf.jabref.model.cleanup.Formatter} - // sorted alphabetically // Alternative: Use reflection - https://github.com/ronmamo/reflections // @formatter:off - return Stream.of( - new CapitalizeFormatter(), - new ClearFormatter(), - new HtmlToLatexFormatter(), - new HtmlToUnicodeFormatter(), - new IdentityFormatter(), - new LatexCleanupFormatter(), - new LatexToUnicodeFormatter(), - new LowerCaseFormatter(), - new MinifyNameListFormatter(), - new NormalizeDateFormatter(), - new NormalizeMonthFormatter(), - new NormalizeNamesFormatter(), - new NormalizePagesFormatter(), - new OrdinalsToSuperscriptFormatter(), - new ProtectTermsFormatter(protectedTermsLoader), - new RegexFormatter(), - new RemoveBracesFormatter(), - new SentenceCaseFormatter(), - new TitleCaseFormatter(), - new UnicodeToLatexFormatter(), - new UnitsToLatexFormatter(), - new UpperCaseFormatter()); - + return Stream.concat( + Formatters.getAll().stream(), + // following formatters are not contained in the list of all formatters, because + // - the IdentityFormatter is not offered to the user, + // - the ProtectTermsFormatter needs more configuration + Stream.of( + new IdentityFormatter(), + new ProtectTermsFormatter(protectedTermsLoader))); // @formatter:on } } From b38656b0993a15b7a69dc068dcf944c5b2a95f5c Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Mon, 21 May 2018 11:03:29 +0200 Subject: [PATCH 07/33] Remove obsolete comment (it is contained in getDescription()) --- .../logic/formatter/bibtexfields/RemoveBracesFormatter.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveBracesFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveBracesFormatter.java index 69e7c8c316a..78b1c264299 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveBracesFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveBracesFormatter.java @@ -5,9 +5,6 @@ import org.jabref.logic.l10n.Localization; import org.jabref.model.cleanup.Formatter; -/** - * Removes all matching braces around the string. - */ public class RemoveBracesFormatter implements Formatter { @Override From 3f902da6497284de11b16a430921244b6e94664d Mon Sep 17 00:00:00 2001 From: Christoph Date: Mon, 21 May 2018 14:59:17 +0200 Subject: [PATCH 08/33] New Crowdin translations (#4042) * New translations JabRef_en.properties (Vietnamese) * New translations JabRef_en.properties (Vietnamese) --- src/main/resources/l10n/JabRef_vi.properties | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/resources/l10n/JabRef_vi.properties b/src/main/resources/l10n/JabRef_vi.properties index ef371c89207..323dd8d3d1b 100644 --- a/src/main/resources/l10n/JabRef_vi.properties +++ b/src/main/resources/l10n/JabRef_vi.properties @@ -37,6 +37,7 @@ Accept\ change=Chấp nhận thay đổi Action=Hành động +What\ is\ Mr.\ DLib?=Ông DLib là gì? Add=Thêm @@ -46,7 +47,9 @@ The\ path\ need\ not\ be\ on\ the\ classpath\ of\ JabRef.=Đường dẫn không Add\ a\ (compiled)\ custom\ Importer\ class\ from\ a\ ZIP-archive.=Thêm một lớp ĐịnhdạngNhập tùy biến (được biên dịch) từ một tập tin-zip. The\ ZIP-archive\ need\ not\ be\ on\ the\ classpath\ of\ JabRef.=Tập tin-zip không được trùng với đường dẫn lớp của JabRef. +Add\ a\ regular\ expression\ for\ the\ key\ pattern.=Thêm một biểu thức chính quy cho mẫu chính. +Add\ selected\ entries\ to\ this\ group=Thêm các mục đã chọn vào nhóm này Add\ from\ folder=Thêm từ thư mục @@ -74,6 +77,7 @@ All\ entries\ of\ this\ type\ will\ be\ declared\ typeless.\ Continue?=Tất c All\ fields=Tất cả các dữ liệu +Always\ reformat\ BIB\ file\ on\ save\ and\ export=Luôn luôn định dạng lại file BIB khi lưu và xuất A\ SAX\ exception\ occurred\ while\ parsing\ '%0'\:=Một lỗi SAXException xảy ra khi đang phân tách '%0'\: @@ -439,6 +443,7 @@ Export\ properties=Các tính chất xuất Export\ to\ clipboard=Xuất ra bộ nhớ tạm + Exporting=Đang xuất Extension=Đuôi mở rộng From 6a0739b474ce0f210e5b8bf762e97568f2d7319f Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Mon, 21 May 2018 13:37:30 +0200 Subject: [PATCH 09/33] Add AddBracesFormatter --- CHANGELOG.md | 1 + .../jabref/logic/formatter/Formatters.java | 2 + .../bibtexfields/AddBracesFormatter.java | 42 ++++++++++ src/main/resources/l10n/JabRef_en.properties | 2 + .../bibtexfields/AddBracesFormatterTest.java | 76 +++++++++++++++++++ 5 files changed, 123 insertions(+) create mode 100644 src/main/java/org/jabref/logic/formatter/bibtexfields/AddBracesFormatter.java create mode 100644 src/test/java/org/jabref/logic/formatter/bibtexfields/AddBracesFormatterTest.java diff --git a/CHANGELOG.md b/CHANGELOG.md index be1e150b49e..40193767400 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# - We added a text file export for 'Find Unlinked Files'. [#3341](https://github.com/JabRef/jabref/issues/3341) - We added a fetcher based on RFC-IDs. [#3971](https://github.com/JabRef/jabref/issues/3971) - We changed the implementation of the `[shorttitle]` key pattern. It now removes small words like `a`, `an`, `on`, `the` etc. Refer to the help page for a complete overview. [Feature request in the forum](http://discourse.jabref.org/t/jabref-differences-in-shorttitle-between-versions-3-8-1-and-4-not-discounting-the-a-an-of-in-titles/1147) +- We added a formatter for adding braces around the `title` field. E.g., `title = {ExamPle}` becomes `title = {{ExamPle}}`, which prevents BibTeX to convert it to lower case. You can use it at the [cleanup entries](http://help.jabref.org/en/CleanupEntries) functionality. - We streamlined the defaults for a [cleanup of entries](http://help.jabref.org/en/CleanupEntries) in the case of BibTeX. ### Fixed diff --git a/src/main/java/org/jabref/logic/formatter/Formatters.java b/src/main/java/org/jabref/logic/formatter/Formatters.java index b4930aabe6f..2d9f8b615a1 100644 --- a/src/main/java/org/jabref/logic/formatter/Formatters.java +++ b/src/main/java/org/jabref/logic/formatter/Formatters.java @@ -6,6 +6,7 @@ import java.util.Objects; import java.util.Optional; +import org.jabref.logic.formatter.bibtexfields.AddBracesFormatter; import org.jabref.logic.formatter.bibtexfields.ClearFormatter; import org.jabref.logic.formatter.bibtexfields.EscapeUnderscoresFormatter; import org.jabref.logic.formatter.bibtexfields.HtmlToLatexFormatter; @@ -47,6 +48,7 @@ public class Formatters { ); private static final List OTHERS = Arrays.asList( + new AddBracesFormatter(), new ClearFormatter(), new LatexCleanupFormatter(), new MinifyNameListFormatter(), diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/AddBracesFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/AddBracesFormatter.java new file mode 100644 index 00000000000..be0e8992b56 --- /dev/null +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/AddBracesFormatter.java @@ -0,0 +1,42 @@ +package org.jabref.logic.formatter.bibtexfields; + +import java.util.Objects; + +import org.jabref.logic.l10n.Localization; +import org.jabref.model.cleanup.Formatter; + +public class AddBracesFormatter implements Formatter { + + @Override + public String getName() { + return Localization.lang("Add enclosing braces"); + } + + @Override + public String getKey() { + return "add_braces"; + } + + @Override + public String format(String value) { + Objects.requireNonNull(value); + + if ((value.length() >= 2) && (value.charAt(0) != '{') && (value.charAt(value.length() - 1) != '}')) { + // Title does not start with { and does not end with }, then this formatter can be applied + return "{" + value + "}"; + } else { + return value; + } + } + + @Override + public String getDescription() { + return Localization.lang("Add braces encapsulating the complete field content."); + } + + @Override + public String getExampleInput() { + return "In CDMA"; + } + +} diff --git a/src/main/resources/l10n/JabRef_en.properties b/src/main/resources/l10n/JabRef_en.properties index a374292660b..e40b02ed63d 100644 --- a/src/main/resources/l10n/JabRef_en.properties +++ b/src/main/resources/l10n/JabRef_en.properties @@ -1965,6 +1965,8 @@ Normalizes\ lists\ of\ persons\ to\ the\ BibTeX\ standard.=Normalizes lists of p Normalizes\ the\ date\ to\ ISO\ date\ format.=Normalizes the date to ISO date format. Ordinals\ to\ LaTeX\ superscript=Ordinals to LaTeX superscript Protect\ terms=Protect terms +Add\ enclosing\ braces=Add enclosing braces +Add\ braces\ encapsulating\ the\ complete\ field\ content.=Add braces encapsulating the complete field content. Remove\ enclosing\ braces=Remove enclosing braces Removes\ braces\ encapsulating\ the\ complete\ field\ content.=Removes braces encapsulating the complete field content. Sentence\ case=Sentence case diff --git a/src/test/java/org/jabref/logic/formatter/bibtexfields/AddBracesFormatterTest.java b/src/test/java/org/jabref/logic/formatter/bibtexfields/AddBracesFormatterTest.java new file mode 100644 index 00000000000..7bb7788e462 --- /dev/null +++ b/src/test/java/org/jabref/logic/formatter/bibtexfields/AddBracesFormatterTest.java @@ -0,0 +1,76 @@ +package org.jabref.logic.formatter.bibtexfields; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * Tests in addition to the general tests from {@link org.jabref.logic.formatter.FormatterTest} + */ +class AddBracesFormatterTest { + + private AddBracesFormatter formatter; + + @BeforeEach + public void setUp() { + formatter = new AddBracesFormatter(); + } + + @Test + public void formatAddsSingleEnclosingBraces() { + assertEquals("{test}", formatter.format("test")); + } + + @Test + public void formatKeepsUnmatchedBracesAtBeginning() { + assertEquals("{test", formatter.format("{test")); + } + + @Test + public void formatKeepsUnmatchedBracesAtEnd() { + assertEquals("test}", formatter.format("test}")); + } + + @Test + public void formatKeepsShortString() { + assertEquals("t", formatter.format("t")); + } + + @Test + public void formatKeepsEmptyString() { + assertEquals("", formatter.format("")); + } + + @Test + public void formatKeepsDoubleEnclosingBraces() { + assertEquals("{{test}}", formatter.format("{{test}}")); + } + + @Test + public void formatKeepsTripleEnclosingBraces() { + assertEquals("{{{test}}}", formatter.format("{{{test}}}")); + } + + @Test + public void formatKeepsNonMatchingBraces() { + assertEquals("{A} and {B}", formatter.format("{A} and {B}")); + } + + @Test + public void formatKeepsOnlyMatchingBraces() { + assertEquals("{{A} and {B}}", formatter.format("{{A} and {B}}")); + } + + @Test + public void formatDoesNotRemoveBracesInBrokenString() { + // We opt here for a conservative approach although one could argue that "A} and {B}" is also a valid return + assertEquals("{A} and {B}}", formatter.format("{A} and {B}}")); + } + + @Test + public void formatExample() { + assertEquals("{In CDMA}", formatter.format(formatter.getExampleInput())); + } + +} From 2b62bfb9c493effced9ee8efe502aa0d16c8aa5f Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Mon, 21 May 2018 21:25:31 +0200 Subject: [PATCH 10/33] Add test for unique keys --- .../org/jabref/logic/formatter/FormatterTest.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/test/java/org/jabref/logic/formatter/FormatterTest.java b/src/test/java/org/jabref/logic/formatter/FormatterTest.java index 35a98f8eb3e..0006fbdfbbc 100644 --- a/src/test/java/org/jabref/logic/formatter/FormatterTest.java +++ b/src/test/java/org/jabref/logic/formatter/FormatterTest.java @@ -1,6 +1,7 @@ package org.jabref.logic.formatter; import java.util.Collections; +import java.util.stream.Collectors; import java.util.stream.Stream; import org.jabref.logic.formatter.casechanger.ProtectTermsFormatter; @@ -9,6 +10,7 @@ import org.jabref.model.cleanup.Formatter; import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; @@ -29,6 +31,18 @@ public static void setUp() { Collections.emptyList(), Collections.emptyList())); } + /** + * When a new formatter is added by copy and pasting another formatter, it may happen that the getKey() method is not adapted. This results in duplicate keys, which this test tests for. + */ + @Test + public void allFormatterKeysAreUnique() { + // idea for uniqueness checking by https://stackoverflow.com/a/44032568/873282 + assertFalse(getFormatters().collect(Collectors.groupingBy( + formatter -> formatter.getKey(), + Collectors.counting() + )).entrySet().stream().anyMatch(e -> e.getValue() > 1)); + } + @ParameterizedTest @MethodSource("getFormatters") public void getNameReturnsNotNull(Formatter formatter) { From cd431b482f83c58f594e8d14f2585e2d0bd6c9a3 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Mon, 21 May 2018 22:01:33 +0200 Subject: [PATCH 11/33] Introduce AbstractFormatter to ensure that hashCode and equals are implemented the same way --- .../logic/formatter/AbstractFormatter.java | 18 ++++++++++++++++++ .../logic/formatter/IdentityFormatter.java | 14 +------------- .../bibtexfields/AddBracesFormatter.java | 4 ++-- .../formatter/bibtexfields/ClearFormatter.java | 4 ++-- .../EscapeUnderscoresFormatter.java | 4 ++-- .../bibtexfields/LatexCleanupFormatter.java | 4 ++-- .../bibtexfields/NormalizeDateFormatter.java | 14 ++------------ .../bibtexfields/NormalizeMonthFormatter.java | 4 ++-- .../bibtexfields/NormalizeNamesFormatter.java | 4 ++-- .../bibtexfields/NormalizePagesFormatter.java | 14 ++------------ .../OrdinalsToSuperscriptFormatter.java | 4 ++-- .../formatter/bibtexfields/RegexFormatter.java | 4 ++-- .../bibtexfields/RemoveBracesFormatter.java | 4 ++-- .../RemoveHyphenatedNewlinesFormatter.java | 4 ++-- .../bibtexfields/RemoveNewlinesFormatter.java | 4 ++-- .../bibtexfields/UnitsToLatexFormatter.java | 4 ++-- .../casechanger/CapitalizeFormatter.java | 4 ++-- .../casechanger/LowerCaseFormatter.java | 14 ++------------ .../casechanger/ProtectTermsFormatter.java | 4 ++-- .../casechanger/SentenceCaseFormatter.java | 4 ++-- .../casechanger/TitleCaseFormatter.java | 4 ++-- .../casechanger/UpperCaseFormatter.java | 4 ++-- .../minifier/MinifyNameListFormatter.java | 4 ++-- 23 files changed, 61 insertions(+), 85 deletions(-) create mode 100644 src/main/java/org/jabref/logic/formatter/AbstractFormatter.java diff --git a/src/main/java/org/jabref/logic/formatter/AbstractFormatter.java b/src/main/java/org/jabref/logic/formatter/AbstractFormatter.java new file mode 100644 index 00000000000..28f6bf9ba15 --- /dev/null +++ b/src/main/java/org/jabref/logic/formatter/AbstractFormatter.java @@ -0,0 +1,18 @@ +package org.jabref.logic.formatter; + +import org.jabref.model.cleanup.Formatter; + +/** + * All formatters should implement hashcode and equals in the way the interface {@link Formatter} provides. This superclass ensures this. + */ +public abstract class AbstractFormatter implements Formatter { + @Override + public int hashCode() { + return defaultHashCode(); + } + + @Override + public boolean equals(Object obj) { + return defaultEquals(obj); + } +} diff --git a/src/main/java/org/jabref/logic/formatter/IdentityFormatter.java b/src/main/java/org/jabref/logic/formatter/IdentityFormatter.java index 1056638b512..f633ed5fe5d 100644 --- a/src/main/java/org/jabref/logic/formatter/IdentityFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/IdentityFormatter.java @@ -3,12 +3,11 @@ import java.util.Objects; import org.jabref.logic.l10n.Localization; -import org.jabref.model.cleanup.Formatter; /** * It may seem useless, but is needed as a fallback option */ -public class IdentityFormatter implements Formatter { +public class IdentityFormatter extends AbstractFormatter { @Override public String getName() { @@ -35,15 +34,4 @@ public String getDescription() { public String getExampleInput() { return "JabRef"; } - - @Override - public int hashCode() { - return defaultHashCode(); - } - - @Override - public boolean equals(Object obj) { - return defaultEquals(obj); - } - } diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/AddBracesFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/AddBracesFormatter.java index be0e8992b56..fd54d3afb9e 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/AddBracesFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/AddBracesFormatter.java @@ -2,10 +2,10 @@ import java.util.Objects; +import org.jabref.logic.formatter.AbstractFormatter; import org.jabref.logic.l10n.Localization; -import org.jabref.model.cleanup.Formatter; -public class AddBracesFormatter implements Formatter { +public class AddBracesFormatter extends AbstractFormatter { @Override public String getName() { diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/ClearFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/ClearFormatter.java index ddb2d98b095..b318a3d648e 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/ClearFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/ClearFormatter.java @@ -2,10 +2,10 @@ import java.util.Objects; +import org.jabref.logic.formatter.AbstractFormatter; import org.jabref.logic.l10n.Localization; -import org.jabref.model.cleanup.Formatter; -public class ClearFormatter implements Formatter { +public class ClearFormatter extends AbstractFormatter { @Override public String getName() { diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/EscapeUnderscoresFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/EscapeUnderscoresFormatter.java index 1815d906aa9..33c49ea0388 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/EscapeUnderscoresFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/EscapeUnderscoresFormatter.java @@ -3,10 +3,10 @@ import java.util.Objects; import java.util.regex.Pattern; +import org.jabref.logic.formatter.AbstractFormatter; import org.jabref.logic.l10n.Localization; -import org.jabref.model.cleanup.Formatter; -public class EscapeUnderscoresFormatter implements Formatter { +public class EscapeUnderscoresFormatter extends AbstractFormatter { private static final Pattern UNDERSCORES = Pattern.compile("_"); diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/LatexCleanupFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/LatexCleanupFormatter.java index bcc5407d0a1..0c9598c28ee 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/LatexCleanupFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/LatexCleanupFormatter.java @@ -2,10 +2,10 @@ import java.util.regex.Pattern; +import org.jabref.logic.formatter.AbstractFormatter; import org.jabref.logic.l10n.Localization; -import org.jabref.model.cleanup.Formatter; -public class LatexCleanupFormatter implements Formatter { +public class LatexCleanupFormatter extends AbstractFormatter { private static final Pattern REMOVE_REDUNDANT = Pattern .compile("(?(\\d+:)?\\d+)(?:-{1,2}(?(\\d+:)?\\d+))?\\Z"); @@ -87,14 +87,4 @@ public String getDescription() { public String getExampleInput() { return "1 - 2"; } - - @Override - public int hashCode() { - return defaultHashCode(); - } - - @Override - public boolean equals(Object obj) { - return defaultEquals(obj); - } } diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/OrdinalsToSuperscriptFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/OrdinalsToSuperscriptFormatter.java index 4b9700c7616..5619961ee5d 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/OrdinalsToSuperscriptFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/OrdinalsToSuperscriptFormatter.java @@ -4,13 +4,13 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.jabref.logic.formatter.AbstractFormatter; import org.jabref.logic.l10n.Localization; -import org.jabref.model.cleanup.Formatter; /** * This class transforms ordinal numbers into LaTex superscripts. */ -public class OrdinalsToSuperscriptFormatter implements Formatter { +public class OrdinalsToSuperscriptFormatter extends AbstractFormatter { // find possible superscripts on word boundaries private static final Pattern SUPERSCRIPT_DETECT_PATTERN = Pattern.compile("\\b(\\d+)(st|nd|rd|th)\\b", diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/RegexFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/RegexFormatter.java index 870deeffbb1..602a188fad3 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/RegexFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/RegexFormatter.java @@ -6,10 +6,10 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.jabref.logic.formatter.AbstractFormatter; import org.jabref.logic.l10n.Localization; -import org.jabref.model.cleanup.Formatter; -public class RegexFormatter implements Formatter { +public class RegexFormatter extends AbstractFormatter { private static final Pattern PATTERN_ESCAPED_OPENING_CURLY_BRACE = Pattern.compile("\\\\\\{"); diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveBracesFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveBracesFormatter.java index 78b1c264299..9a0bb09ff89 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveBracesFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveBracesFormatter.java @@ -2,10 +2,10 @@ import java.util.Objects; +import org.jabref.logic.formatter.AbstractFormatter; import org.jabref.logic.l10n.Localization; -import org.jabref.model.cleanup.Formatter; -public class RemoveBracesFormatter implements Formatter { +public class RemoveBracesFormatter extends AbstractFormatter { @Override public String getName() { diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveHyphenatedNewlinesFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveHyphenatedNewlinesFormatter.java index 8c8813fb72b..6663a0d603c 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveHyphenatedNewlinesFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveHyphenatedNewlinesFormatter.java @@ -3,13 +3,13 @@ import java.util.Objects; import java.util.regex.Pattern; +import org.jabref.logic.formatter.AbstractFormatter; import org.jabref.logic.l10n.Localization; -import org.jabref.model.cleanup.Formatter; /** * Removes all hyphenated line breaks in the string. */ -public class RemoveHyphenatedNewlinesFormatter implements Formatter { +public class RemoveHyphenatedNewlinesFormatter extends AbstractFormatter { private static final Pattern HYPHENATED_WORDS = Pattern.compile("(-\r\n|-\n|-\r)"); @Override diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveNewlinesFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveNewlinesFormatter.java index cc70fd70dd3..e28f9f3efe5 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveNewlinesFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveNewlinesFormatter.java @@ -3,13 +3,13 @@ import java.util.Objects; import java.util.regex.Pattern; +import org.jabref.logic.formatter.AbstractFormatter; import org.jabref.logic.l10n.Localization; -import org.jabref.model.cleanup.Formatter; /** * Removes all line breaks in the string. */ -public class RemoveNewlinesFormatter implements Formatter { +public class RemoveNewlinesFormatter extends AbstractFormatter { private static final Pattern LINEBREAKS = Pattern.compile("(\r?\n|\r)"); @Override diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/UnitsToLatexFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/UnitsToLatexFormatter.java index 357f6f4d480..98c9c83410c 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/UnitsToLatexFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/UnitsToLatexFormatter.java @@ -6,11 +6,11 @@ import java.util.List; import java.util.Objects; +import org.jabref.logic.formatter.AbstractFormatter; import org.jabref.logic.l10n.Localization; import org.jabref.logic.util.strings.StringLengthComparator; -import org.jabref.model.cleanup.Formatter; -public class UnitsToLatexFormatter implements Formatter { +public class UnitsToLatexFormatter extends AbstractFormatter { private static final List UNIT_LIST = Arrays.asList( "A", // Ampere diff --git a/src/main/java/org/jabref/logic/formatter/casechanger/CapitalizeFormatter.java b/src/main/java/org/jabref/logic/formatter/casechanger/CapitalizeFormatter.java index a5717038e5c..d341cd1bc60 100644 --- a/src/main/java/org/jabref/logic/formatter/casechanger/CapitalizeFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/casechanger/CapitalizeFormatter.java @@ -1,9 +1,9 @@ package org.jabref.logic.formatter.casechanger; +import org.jabref.logic.formatter.AbstractFormatter; import org.jabref.logic.l10n.Localization; -import org.jabref.model.cleanup.Formatter; -public class CapitalizeFormatter implements Formatter { +public class CapitalizeFormatter extends AbstractFormatter { @Override public String getName() { diff --git a/src/main/java/org/jabref/logic/formatter/casechanger/LowerCaseFormatter.java b/src/main/java/org/jabref/logic/formatter/casechanger/LowerCaseFormatter.java index b1b037b634c..bc9ad3fc449 100644 --- a/src/main/java/org/jabref/logic/formatter/casechanger/LowerCaseFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/casechanger/LowerCaseFormatter.java @@ -1,9 +1,9 @@ package org.jabref.logic.formatter.casechanger; +import org.jabref.logic.formatter.AbstractFormatter; import org.jabref.logic.l10n.Localization; -import org.jabref.model.cleanup.Formatter; -public class LowerCaseFormatter implements Formatter { +public class LowerCaseFormatter extends AbstractFormatter { @Override public String getName() { @@ -27,16 +27,6 @@ public String format(String input) { return title.toString(); } - @Override - public int hashCode() { - return defaultHashCode(); - } - - @Override - public boolean equals(Object obj) { - return defaultEquals(obj); - } - @Override public String getDescription() { return Localization.lang("Changes all letters to lower case."); diff --git a/src/main/java/org/jabref/logic/formatter/casechanger/ProtectTermsFormatter.java b/src/main/java/org/jabref/logic/formatter/casechanger/ProtectTermsFormatter.java index 60109ca321a..bd0cce99d76 100644 --- a/src/main/java/org/jabref/logic/formatter/casechanger/ProtectTermsFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/casechanger/ProtectTermsFormatter.java @@ -3,12 +3,12 @@ import java.util.List; import java.util.Objects; +import org.jabref.logic.formatter.AbstractFormatter; import org.jabref.logic.l10n.Localization; import org.jabref.logic.protectedterms.ProtectedTermsLoader; import org.jabref.logic.util.strings.StringLengthComparator; -import org.jabref.model.cleanup.Formatter; -public class ProtectTermsFormatter implements Formatter { +public class ProtectTermsFormatter extends AbstractFormatter { private final ProtectedTermsLoader protectedTermsLoader; diff --git a/src/main/java/org/jabref/logic/formatter/casechanger/SentenceCaseFormatter.java b/src/main/java/org/jabref/logic/formatter/casechanger/SentenceCaseFormatter.java index 87342d63b3d..57a8c36cbb6 100644 --- a/src/main/java/org/jabref/logic/formatter/casechanger/SentenceCaseFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/casechanger/SentenceCaseFormatter.java @@ -1,9 +1,9 @@ package org.jabref.logic.formatter.casechanger; +import org.jabref.logic.formatter.AbstractFormatter; import org.jabref.logic.l10n.Localization; -import org.jabref.model.cleanup.Formatter; -public class SentenceCaseFormatter implements Formatter { +public class SentenceCaseFormatter extends AbstractFormatter { @Override public String getName() { diff --git a/src/main/java/org/jabref/logic/formatter/casechanger/TitleCaseFormatter.java b/src/main/java/org/jabref/logic/formatter/casechanger/TitleCaseFormatter.java index 16920a96dcf..5f1429cbee5 100644 --- a/src/main/java/org/jabref/logic/formatter/casechanger/TitleCaseFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/casechanger/TitleCaseFormatter.java @@ -1,9 +1,9 @@ package org.jabref.logic.formatter.casechanger; +import org.jabref.logic.formatter.AbstractFormatter; import org.jabref.logic.l10n.Localization; -import org.jabref.model.cleanup.Formatter; -public class TitleCaseFormatter implements Formatter { +public class TitleCaseFormatter extends AbstractFormatter { @Override public String getName() { diff --git a/src/main/java/org/jabref/logic/formatter/casechanger/UpperCaseFormatter.java b/src/main/java/org/jabref/logic/formatter/casechanger/UpperCaseFormatter.java index 0d88f2a8e78..c71329dfe49 100644 --- a/src/main/java/org/jabref/logic/formatter/casechanger/UpperCaseFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/casechanger/UpperCaseFormatter.java @@ -1,9 +1,9 @@ package org.jabref.logic.formatter.casechanger; +import org.jabref.logic.formatter.AbstractFormatter; import org.jabref.logic.l10n.Localization; -import org.jabref.model.cleanup.Formatter; -public class UpperCaseFormatter implements Formatter { +public class UpperCaseFormatter extends AbstractFormatter { @Override public String getName() { diff --git a/src/main/java/org/jabref/logic/formatter/minifier/MinifyNameListFormatter.java b/src/main/java/org/jabref/logic/formatter/minifier/MinifyNameListFormatter.java index 850be1050f2..86ef535904d 100644 --- a/src/main/java/org/jabref/logic/formatter/minifier/MinifyNameListFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/minifier/MinifyNameListFormatter.java @@ -2,13 +2,13 @@ import java.util.Objects; +import org.jabref.logic.formatter.AbstractFormatter; import org.jabref.logic.l10n.Localization; -import org.jabref.model.cleanup.Formatter; /** * Replaces three or more authors with and others */ -public class MinifyNameListFormatter implements Formatter { +public class MinifyNameListFormatter extends AbstractFormatter { @Override public String getName() { return Localization.lang("Minify list of person names"); From 97abcb97a5fec2ec36a7b0cd10c2f758bd9f78fc Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Tue, 22 May 2018 10:36:33 +0200 Subject: [PATCH 12/33] Add missing translation for "HTML to Unicode" (#4046) --- .../logic/formatter/bibtexfields/HtmlToUnicodeFormatter.java | 2 +- src/main/resources/l10n/JabRef_en.properties | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/HtmlToUnicodeFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/HtmlToUnicodeFormatter.java index c598966e7c9..d7b47671154 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/HtmlToUnicodeFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/HtmlToUnicodeFormatter.java @@ -12,7 +12,7 @@ public class HtmlToUnicodeFormatter implements LayoutFormatter, Formatter { @Override public String getName() { - return "HTML to Unicode"; + return Localization.lang("HTML to Unicode"); } @Override diff --git a/src/main/resources/l10n/JabRef_en.properties b/src/main/resources/l10n/JabRef_en.properties index a374292660b..62cac0e26f6 100644 --- a/src/main/resources/l10n/JabRef_en.properties +++ b/src/main/resources/l10n/JabRef_en.properties @@ -1945,6 +1945,7 @@ Changes\ all\ letters\ to\ upper\ case.=Changes all letters to upper case. Changes\ the\ first\ letter\ of\ all\ words\ to\ capital\ case\ and\ the\ remaining\ letters\ to\ lower\ case.=Changes the first letter of all words to capital case and the remaining letters to lower case. Cleans\ up\ LaTeX\ code.=Cleans up LaTeX code. Converts\ HTML\ code\ to\ LaTeX\ code.=Converts HTML code to LaTeX code. +HTML\ to\ Unicode=HTML to Unicode Converts\ HTML\ code\ to\ Unicode.=Converts HTML code to Unicode. Converts\ LaTeX\ encoding\ to\ Unicode\ characters.=Converts LaTeX encoding to Unicode characters. Converts\ Unicode\ characters\ to\ LaTeX\ encoding.=Converts Unicode characters to LaTeX encoding. From 08dff5d0ba967713f87910af72c4f1bc8eb875a5 Mon Sep 17 00:00:00 2001 From: Christoph Date: Tue, 22 May 2018 11:22:05 +0200 Subject: [PATCH 13/33] update gradle to 4.7 (#4049) update Azure 2.1.0 -> 2.1.1 update archunit 0.5.0 -> 0.8.0 --- build.gradle | 6 +++--- gradle/wrapper/gradle-wrapper.jar | Bin 54333 -> 54329 bytes gradle/wrapper/gradle-wrapper.properties | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index b2005e93365..ccd34f0c82a 100644 --- a/build.gradle +++ b/build.gradle @@ -147,8 +147,8 @@ dependencies { compile 'com.github.tomtung:latex2unicode_2.12:0.2.2' - compile group: 'com.microsoft.azure', name: 'applicationinsights-core', version: '2.1.0' - compile group: 'com.microsoft.azure', name: 'applicationinsights-logging-log4j2', version: '2.1.0' + compile group: 'com.microsoft.azure', name: 'applicationinsights-core', version: '2.1.1' + compile group: 'com.microsoft.azure', name: 'applicationinsights-logging-log4j2', version: '2.1.1' testImplementation 'org.junit.jupiter:junit-jupiter-api:5.2.0' testCompile 'org.junit.jupiter:junit-jupiter-params:5.2.0' @@ -163,7 +163,7 @@ dependencies { testCompile 'org.reflections:reflections:0.9.11' testCompile 'org.xmlunit:xmlunit-core:2.6.0' testCompile 'org.xmlunit:xmlunit-matchers:2.6.0' - testCompile 'com.tngtech.archunit:archunit-junit:0.5.0' + testCompile 'com.tngtech.archunit:archunit-junit:0.8.0' testCompile "org.testfx:testfx-core:4.0.+" testCompile "org.testfx:testfx-junit:4.0.+" diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index c44b679acd3f794ddbb3aa5e919244914911014a..f6b961fd5a86aa5fbfe90f707c3138408be7c718 100644 GIT binary patch delta 757 zcmY+CUr3Wt7{+&AW7C-VS!CNcr4&o~L{lkNk~%LkW0;eMX_UJtQ_yA@6BN7{7(@fv zcr37JCEXarC;}s-BKOa2&dpgDb!E_vP@r@Z1<~oSzVg7~Jiq6C&dcHDyqe2-IhW%# z=T){xzBg+$8oSS8*KUn$jWCT@em4K>?d}|n&8o}YXqx`Eht~`FMoX|5pBJnCU4kKa zmfgiru#UZkKX{BbH1I|C;%iW$VkTqZw7eqDyDQ&yYg* z^0L-0tK8#zZM)uL{zF5q1h z($xq&6Fp9*qeA+lW}0Xd@@bo%H<6ILB$H$n)`O*d*sKQhE-56pXRStRwF^0BFM$+O z=unTqo*o&49O;6yq78mu+V3OW1t*?xP*#?Ovxd*oyBk@ zTG%DbCb}p%j8DUryqAQJE=kYlon3L4NN$emaBaDc=0~$wiuGlMtm9eK<4Dp>mI*cN zO`fDlw~9ZK9dvL~MdwN@IXo&p^q6pKMZ%7hOc$qA+dsvhm{O?Ir&@uOh5Dye^iOFK zm@ecg2@PqPF5lT!^3G^+BV9|UXSUhvX$vbu>8gW`!M!>}FJ`l4Egpr7P?3@8_H%d^ z%FvgorK<~E)`-!(&&cdLHZ%R~6uQ^0@Xz&Tt={ziFE#v~n>Yude^;dqE&hSu9GWc- delta 705 zcmYL{-%Ha`7{+(rjm?$j*GjXaTd)e{D~3xfrA01^mTOixDlKYW%oMDZpcjQmAYF7} zlSc~EjINT1VkqRYY;&8=`Ey%dMEwKRMHJLc5FJmp&dvEe&-1=7oWmO&)xH_k`u7`q zHjI_nH5$#C{#tj|=k4D+zI8B-p9jW&hx1k|b(&L7Lzb!?I-4(QwjexR_rC*MBModA ztr05=;X$ODeZh5o0X{`kGBbpu`EW6grwIk_D5rCJVVU9A8_+nbz+q4}ijnKbhETMb z9vVf73AM3`wNbH)>;qO}9(D)TnI^JY9IHGZm|eR$6X{y|)@K&nf1U)-PW+ObaS4bPBl>?F&|#=#u!Oi{qn6TsNdFTeQ*PZizkJMIuq~a*@;R zThjWuc#=wb1s=lNq=I`(oHZk`)JB*3WbW_R%JAv zT5x*BL(aiW*f+RVuYi)Ab`4A0o;*M|MckdvyQ`(p@ Date: Tue, 22 May 2018 12:10:51 +0200 Subject: [PATCH 14/33] New Crowdin translations (#4048) * New translations JabRef_en.properties (Spanish) * New translations JabRef_en.properties (Persian) * New translations JabRef_en.properties (Portuguese, Brazilian) * New translations JabRef_en.properties (Russian) * New translations JabRef_en.properties (Norwegian) * New translations JabRef_en.properties (Swedish) * New translations JabRef_en.properties (Tagalog) * New translations JabRef_en.properties (Turkish) * New translations JabRef_en.properties (Chinese Simplified) * New translations JabRef_en.properties (Danish) * New translations JabRef_en.properties (Dutch) * New translations JabRef_en.properties (German) * New translations JabRef_en.properties (Japanese) * New translations JabRef_en.properties (Greek) * New translations JabRef_en.properties (Indonesian) * New translations JabRef_en.properties (Italian) --- src/main/resources/l10n/JabRef_da.properties | 1 + src/main/resources/l10n/JabRef_de.properties | 1 + src/main/resources/l10n/JabRef_el.properties | 1 + src/main/resources/l10n/JabRef_es.properties | 1 + src/main/resources/l10n/JabRef_fa.properties | 1 + src/main/resources/l10n/JabRef_in.properties | 1 + src/main/resources/l10n/JabRef_it.properties | 1 + src/main/resources/l10n/JabRef_ja.properties | 1 + src/main/resources/l10n/JabRef_nl.properties | 1 + src/main/resources/l10n/JabRef_no.properties | 1 + src/main/resources/l10n/JabRef_pt_BR.properties | 1 + src/main/resources/l10n/JabRef_ru.properties | 1 + src/main/resources/l10n/JabRef_sv.properties | 1 + src/main/resources/l10n/JabRef_tl.properties | 1 + src/main/resources/l10n/JabRef_tr.properties | 1 + src/main/resources/l10n/JabRef_zh.properties | 1 + 16 files changed, 16 insertions(+) diff --git a/src/main/resources/l10n/JabRef_da.properties b/src/main/resources/l10n/JabRef_da.properties index 06b03c9d74c..76ffddacd25 100644 --- a/src/main/resources/l10n/JabRef_da.properties +++ b/src/main/resources/l10n/JabRef_da.properties @@ -436,6 +436,7 @@ Export\ properties=Egenskaber for eksportfilter Export\ to\ clipboard=Eksporter til udklipsholder + Exporting=Eksporterer Extension=Efternavn diff --git a/src/main/resources/l10n/JabRef_de.properties b/src/main/resources/l10n/JabRef_de.properties index 9f32fd7b8ea..2bf99a26419 100644 --- a/src/main/resources/l10n/JabRef_de.properties +++ b/src/main/resources/l10n/JabRef_de.properties @@ -448,6 +448,7 @@ Export\ properties=Eigenschaften für Exportfilter Export\ to\ clipboard=In die Zwischenablage kopieren + Exporting=Exportiere Extension=Erweiterung diff --git a/src/main/resources/l10n/JabRef_el.properties b/src/main/resources/l10n/JabRef_el.properties index 39ef44f2185..f820ae6111c 100644 --- a/src/main/resources/l10n/JabRef_el.properties +++ b/src/main/resources/l10n/JabRef_el.properties @@ -382,6 +382,7 @@ Export=Εξαγωγή + Full\ name=Πλήρες όνομα diff --git a/src/main/resources/l10n/JabRef_es.properties b/src/main/resources/l10n/JabRef_es.properties index f76e6a89319..15b6fd795bd 100644 --- a/src/main/resources/l10n/JabRef_es.properties +++ b/src/main/resources/l10n/JabRef_es.properties @@ -446,6 +446,7 @@ Export\ properties=Exportar propiedades Export\ to\ clipboard=Exportar al portapapeles + Exporting=Exportando Extension=Extensión diff --git a/src/main/resources/l10n/JabRef_fa.properties b/src/main/resources/l10n/JabRef_fa.properties index 983cb004005..33676498c2d 100644 --- a/src/main/resources/l10n/JabRef_fa.properties +++ b/src/main/resources/l10n/JabRef_fa.properties @@ -320,6 +320,7 @@ Donate\ to\ JabRef=هدیه دادن به JabRef + Manage\ external\ file\ types=مدیریت نوع پرونده‌های خارجی diff --git a/src/main/resources/l10n/JabRef_in.properties b/src/main/resources/l10n/JabRef_in.properties index 1aca67669b7..6d2a2a6b766 100644 --- a/src/main/resources/l10n/JabRef_in.properties +++ b/src/main/resources/l10n/JabRef_in.properties @@ -445,6 +445,7 @@ Export\ properties=Ekspor properti Export\ to\ clipboard=Ekspor ke papan klip + Exporting=Proses mengekspor Extension=Ekstensi diff --git a/src/main/resources/l10n/JabRef_it.properties b/src/main/resources/l10n/JabRef_it.properties index 04e124f2ed3..4930004462b 100644 --- a/src/main/resources/l10n/JabRef_it.properties +++ b/src/main/resources/l10n/JabRef_it.properties @@ -446,6 +446,7 @@ Export\ properties=Esporta proprietà Export\ to\ clipboard=Esporta negli appunti + Exporting=Esportazione in corso Extension=Estensione diff --git a/src/main/resources/l10n/JabRef_ja.properties b/src/main/resources/l10n/JabRef_ja.properties index e32b5ce4e75..7fa1a9680d5 100644 --- a/src/main/resources/l10n/JabRef_ja.properties +++ b/src/main/resources/l10n/JabRef_ja.properties @@ -448,6 +448,7 @@ Export\ properties=特性を書き出す Export\ to\ clipboard=クリップボードに書き出す + Exporting=書き出し中 Extension=拡張子 diff --git a/src/main/resources/l10n/JabRef_nl.properties b/src/main/resources/l10n/JabRef_nl.properties index fccc9a8b3da..d8cdb878fef 100644 --- a/src/main/resources/l10n/JabRef_nl.properties +++ b/src/main/resources/l10n/JabRef_nl.properties @@ -403,6 +403,7 @@ Export\ properties=Eigenschappen exporteren Export\ to\ clipboard=Exporteer naar klembord + Exporting=Exporteren... External\ changes=Externe wijzigingen diff --git a/src/main/resources/l10n/JabRef_no.properties b/src/main/resources/l10n/JabRef_no.properties index 78f1c6910b1..2e331f509b7 100644 --- a/src/main/resources/l10n/JabRef_no.properties +++ b/src/main/resources/l10n/JabRef_no.properties @@ -433,6 +433,7 @@ Export\ properties=Egenskaper for eksportfilter Export\ to\ clipboard=Eksporter til utklippstavle + Exporting=Eksporterer Extension=Etternavn diff --git a/src/main/resources/l10n/JabRef_pt_BR.properties b/src/main/resources/l10n/JabRef_pt_BR.properties index b076bf11292..2c89c578847 100644 --- a/src/main/resources/l10n/JabRef_pt_BR.properties +++ b/src/main/resources/l10n/JabRef_pt_BR.properties @@ -439,6 +439,7 @@ Export\ properties=Propriedades de exportação Export\ to\ clipboard=Exportar para a área de transferência + Exporting=Exportando Extension=Extensão diff --git a/src/main/resources/l10n/JabRef_ru.properties b/src/main/resources/l10n/JabRef_ru.properties index 60ddda56ba2..160eee78776 100644 --- a/src/main/resources/l10n/JabRef_ru.properties +++ b/src/main/resources/l10n/JabRef_ru.properties @@ -440,6 +440,7 @@ Export\ properties=Экспорт свойств Export\ to\ clipboard=Экспорт в буфер обмена + Exporting=Выполняется экспорт Extension=Расширение diff --git a/src/main/resources/l10n/JabRef_sv.properties b/src/main/resources/l10n/JabRef_sv.properties index 585b2f0a79a..1e5ed156737 100644 --- a/src/main/resources/l10n/JabRef_sv.properties +++ b/src/main/resources/l10n/JabRef_sv.properties @@ -429,6 +429,7 @@ Export\ properties=Exportera egenskaper Export\ to\ clipboard=Exportera till utklipp + Exporting=Exporterar Extension=Filändelse diff --git a/src/main/resources/l10n/JabRef_tl.properties b/src/main/resources/l10n/JabRef_tl.properties index 339f1200e98..9fe70bd6b6d 100644 --- a/src/main/resources/l10n/JabRef_tl.properties +++ b/src/main/resources/l10n/JabRef_tl.properties @@ -446,6 +446,7 @@ Export\ properties=Pagpapalabas ng mga katangian Export\ to\ clipboard=Pagpapalabas sa clipboard + Exporting=Ang pagpapalabas Extension=Ekstenyon diff --git a/src/main/resources/l10n/JabRef_tr.properties b/src/main/resources/l10n/JabRef_tr.properties index b0f4bfc6c0d..04da7a81fcb 100644 --- a/src/main/resources/l10n/JabRef_tr.properties +++ b/src/main/resources/l10n/JabRef_tr.properties @@ -446,6 +446,7 @@ Export\ properties=Özellikleri dışa aktar Export\ to\ clipboard=Panoya aktar + Exporting=Dışa aktarılıyor Extension=Uzantı diff --git a/src/main/resources/l10n/JabRef_zh.properties b/src/main/resources/l10n/JabRef_zh.properties index e959a85e92e..6763251641a 100644 --- a/src/main/resources/l10n/JabRef_zh.properties +++ b/src/main/resources/l10n/JabRef_zh.properties @@ -446,6 +446,7 @@ Export\ properties=导出属性 Export\ to\ clipboard=导出到剪贴板 + Exporting=正在导出 Extension=扩展名 From c09e472070854f51eeaf600dd7aa8760abf582ae Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Tue, 22 May 2018 13:29:00 +0200 Subject: [PATCH 15/33] Make Formatter an abstract class (and remove AbstractFormatter) --- .../logic/formatter/AbstractFormatter.java | 18 --------------- .../logic/formatter/IdentityFormatter.java | 3 ++- .../bibtexfields/AddBracesFormatter.java | 4 ++-- .../bibtexfields/ClearFormatter.java | 4 ++-- .../EscapeUnderscoresFormatter.java | 4 ++-- .../bibtexfields/HtmlToLatexFormatter.java | 2 +- .../bibtexfields/HtmlToUnicodeFormatter.java | 2 +- .../bibtexfields/LatexCleanupFormatter.java | 4 ++-- .../bibtexfields/NormalizeDateFormatter.java | 4 ++-- .../bibtexfields/NormalizeMonthFormatter.java | 4 ++-- .../bibtexfields/NormalizeNamesFormatter.java | 4 ++-- .../bibtexfields/NormalizePagesFormatter.java | 4 ++-- .../OrdinalsToSuperscriptFormatter.java | 4 ++-- .../bibtexfields/RegexFormatter.java | 4 ++-- .../bibtexfields/RemoveBracesFormatter.java | 4 ++-- .../RemoveHyphenatedNewlinesFormatter.java | 4 ++-- .../bibtexfields/RemoveNewlinesFormatter.java | 4 ++-- .../bibtexfields/UnicodeToLatexFormatter.java | 2 +- .../bibtexfields/UnitsToLatexFormatter.java | 4 ++-- .../casechanger/CapitalizeFormatter.java | 4 ++-- .../casechanger/LowerCaseFormatter.java | 4 ++-- .../casechanger/ProtectTermsFormatter.java | 4 ++-- .../casechanger/SentenceCaseFormatter.java | 4 ++-- .../casechanger/TitleCaseFormatter.java | 4 ++-- .../casechanger/UpperCaseFormatter.java | 4 ++-- .../minifier/MinifyNameListFormatter.java | 4 ++-- .../format/LatexToUnicodeFormatter.java | 2 +- .../ReplaceUnicodeLigaturesFormatter.java | 2 +- .../org/jabref/model/cleanup/Formatter.java | 23 +++++++++++-------- 29 files changed, 62 insertions(+), 76 deletions(-) delete mode 100644 src/main/java/org/jabref/logic/formatter/AbstractFormatter.java diff --git a/src/main/java/org/jabref/logic/formatter/AbstractFormatter.java b/src/main/java/org/jabref/logic/formatter/AbstractFormatter.java deleted file mode 100644 index 28f6bf9ba15..00000000000 --- a/src/main/java/org/jabref/logic/formatter/AbstractFormatter.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.jabref.logic.formatter; - -import org.jabref.model.cleanup.Formatter; - -/** - * All formatters should implement hashcode and equals in the way the interface {@link Formatter} provides. This superclass ensures this. - */ -public abstract class AbstractFormatter implements Formatter { - @Override - public int hashCode() { - return defaultHashCode(); - } - - @Override - public boolean equals(Object obj) { - return defaultEquals(obj); - } -} diff --git a/src/main/java/org/jabref/logic/formatter/IdentityFormatter.java b/src/main/java/org/jabref/logic/formatter/IdentityFormatter.java index f633ed5fe5d..23cf683c283 100644 --- a/src/main/java/org/jabref/logic/formatter/IdentityFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/IdentityFormatter.java @@ -3,11 +3,12 @@ import java.util.Objects; import org.jabref.logic.l10n.Localization; +import org.jabref.model.cleanup.Formatter; /** * It may seem useless, but is needed as a fallback option */ -public class IdentityFormatter extends AbstractFormatter { +public class IdentityFormatter extends Formatter { @Override public String getName() { diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/AddBracesFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/AddBracesFormatter.java index fd54d3afb9e..3308ecc8000 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/AddBracesFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/AddBracesFormatter.java @@ -2,10 +2,10 @@ import java.util.Objects; -import org.jabref.logic.formatter.AbstractFormatter; +import org.jabref.model.cleanup.Formatter; import org.jabref.logic.l10n.Localization; -public class AddBracesFormatter extends AbstractFormatter { +public class AddBracesFormatter extends Formatter { @Override public String getName() { diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/ClearFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/ClearFormatter.java index b318a3d648e..6a549cea35f 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/ClearFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/ClearFormatter.java @@ -2,10 +2,10 @@ import java.util.Objects; -import org.jabref.logic.formatter.AbstractFormatter; +import org.jabref.model.cleanup.Formatter; import org.jabref.logic.l10n.Localization; -public class ClearFormatter extends AbstractFormatter { +public class ClearFormatter extends Formatter { @Override public String getName() { diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/EscapeUnderscoresFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/EscapeUnderscoresFormatter.java index 33c49ea0388..2de9214c2a9 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/EscapeUnderscoresFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/EscapeUnderscoresFormatter.java @@ -3,10 +3,10 @@ import java.util.Objects; import java.util.regex.Pattern; -import org.jabref.logic.formatter.AbstractFormatter; +import org.jabref.model.cleanup.Formatter; import org.jabref.logic.l10n.Localization; -public class EscapeUnderscoresFormatter extends AbstractFormatter { +public class EscapeUnderscoresFormatter extends Formatter { private static final Pattern UNDERSCORES = Pattern.compile("_"); diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/HtmlToLatexFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/HtmlToLatexFormatter.java index ba73bde75e3..060c1ee5b48 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/HtmlToLatexFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/HtmlToLatexFormatter.java @@ -13,7 +13,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class HtmlToLatexFormatter implements LayoutFormatter, Formatter { +public class HtmlToLatexFormatter extends Formatter implements LayoutFormatter { private static final Logger LOGGER = LoggerFactory.getLogger(HtmlToLatexFormatter.class); diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/HtmlToUnicodeFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/HtmlToUnicodeFormatter.java index c598966e7c9..cd7075b0971 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/HtmlToUnicodeFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/HtmlToUnicodeFormatter.java @@ -8,7 +8,7 @@ import org.apache.commons.lang3.StringEscapeUtils; @ApacheCommonsLang3Allowed("There is no equivalent in Google's Guava") -public class HtmlToUnicodeFormatter implements LayoutFormatter, Formatter { +public class HtmlToUnicodeFormatter extends Formatter implements LayoutFormatter { @Override public String getName() { diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/LatexCleanupFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/LatexCleanupFormatter.java index 0c9598c28ee..efc5e9d2ebb 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/LatexCleanupFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/LatexCleanupFormatter.java @@ -2,10 +2,10 @@ import java.util.regex.Pattern; -import org.jabref.logic.formatter.AbstractFormatter; +import org.jabref.model.cleanup.Formatter; import org.jabref.logic.l10n.Localization; -public class LatexCleanupFormatter extends AbstractFormatter { +public class LatexCleanupFormatter extends Formatter { private static final Pattern REMOVE_REDUNDANT = Pattern .compile("(?(\\d+:)?\\d+)(?:-{1,2}(?(\\d+:)?\\d+))?\\Z"); diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/OrdinalsToSuperscriptFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/OrdinalsToSuperscriptFormatter.java index 5619961ee5d..c443b8b7791 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/OrdinalsToSuperscriptFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/OrdinalsToSuperscriptFormatter.java @@ -4,13 +4,13 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.jabref.logic.formatter.AbstractFormatter; +import org.jabref.model.cleanup.Formatter; import org.jabref.logic.l10n.Localization; /** * This class transforms ordinal numbers into LaTex superscripts. */ -public class OrdinalsToSuperscriptFormatter extends AbstractFormatter { +public class OrdinalsToSuperscriptFormatter extends Formatter { // find possible superscripts on word boundaries private static final Pattern SUPERSCRIPT_DETECT_PATTERN = Pattern.compile("\\b(\\d+)(st|nd|rd|th)\\b", diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/RegexFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/RegexFormatter.java index 602a188fad3..0c653f3718d 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/RegexFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/RegexFormatter.java @@ -6,10 +6,10 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.jabref.logic.formatter.AbstractFormatter; +import org.jabref.model.cleanup.Formatter; import org.jabref.logic.l10n.Localization; -public class RegexFormatter extends AbstractFormatter { +public class RegexFormatter extends Formatter { private static final Pattern PATTERN_ESCAPED_OPENING_CURLY_BRACE = Pattern.compile("\\\\\\{"); diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveBracesFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveBracesFormatter.java index 9a0bb09ff89..98656936264 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveBracesFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveBracesFormatter.java @@ -2,10 +2,10 @@ import java.util.Objects; -import org.jabref.logic.formatter.AbstractFormatter; +import org.jabref.model.cleanup.Formatter; import org.jabref.logic.l10n.Localization; -public class RemoveBracesFormatter extends AbstractFormatter { +public class RemoveBracesFormatter extends Formatter { @Override public String getName() { diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveHyphenatedNewlinesFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveHyphenatedNewlinesFormatter.java index 6663a0d603c..985718533de 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveHyphenatedNewlinesFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveHyphenatedNewlinesFormatter.java @@ -3,13 +3,13 @@ import java.util.Objects; import java.util.regex.Pattern; -import org.jabref.logic.formatter.AbstractFormatter; +import org.jabref.model.cleanup.Formatter; import org.jabref.logic.l10n.Localization; /** * Removes all hyphenated line breaks in the string. */ -public class RemoveHyphenatedNewlinesFormatter extends AbstractFormatter { +public class RemoveHyphenatedNewlinesFormatter extends Formatter { private static final Pattern HYPHENATED_WORDS = Pattern.compile("(-\r\n|-\n|-\r)"); @Override diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveNewlinesFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveNewlinesFormatter.java index e28f9f3efe5..142e09e5aa8 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveNewlinesFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveNewlinesFormatter.java @@ -3,13 +3,13 @@ import java.util.Objects; import java.util.regex.Pattern; -import org.jabref.logic.formatter.AbstractFormatter; +import org.jabref.model.cleanup.Formatter; import org.jabref.logic.l10n.Localization; /** * Removes all line breaks in the string. */ -public class RemoveNewlinesFormatter extends AbstractFormatter { +public class RemoveNewlinesFormatter extends Formatter { private static final Pattern LINEBREAKS = Pattern.compile("(\r?\n|\r)"); @Override diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/UnicodeToLatexFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/UnicodeToLatexFormatter.java index d6bb7aff5cd..41147892971 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/UnicodeToLatexFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/UnicodeToLatexFormatter.java @@ -11,7 +11,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class UnicodeToLatexFormatter implements LayoutFormatter, Formatter { +public class UnicodeToLatexFormatter extends Formatter implements LayoutFormatter { private static final Logger LOGGER = LoggerFactory.getLogger(UnicodeToLatexFormatter.class); diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/UnitsToLatexFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/UnitsToLatexFormatter.java index 98c9c83410c..d5394756ba9 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/UnitsToLatexFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/UnitsToLatexFormatter.java @@ -6,11 +6,11 @@ import java.util.List; import java.util.Objects; -import org.jabref.logic.formatter.AbstractFormatter; +import org.jabref.model.cleanup.Formatter; import org.jabref.logic.l10n.Localization; import org.jabref.logic.util.strings.StringLengthComparator; -public class UnitsToLatexFormatter extends AbstractFormatter { +public class UnitsToLatexFormatter extends Formatter { private static final List UNIT_LIST = Arrays.asList( "A", // Ampere diff --git a/src/main/java/org/jabref/logic/formatter/casechanger/CapitalizeFormatter.java b/src/main/java/org/jabref/logic/formatter/casechanger/CapitalizeFormatter.java index d341cd1bc60..091715e5307 100644 --- a/src/main/java/org/jabref/logic/formatter/casechanger/CapitalizeFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/casechanger/CapitalizeFormatter.java @@ -1,9 +1,9 @@ package org.jabref.logic.formatter.casechanger; -import org.jabref.logic.formatter.AbstractFormatter; +import org.jabref.model.cleanup.Formatter; import org.jabref.logic.l10n.Localization; -public class CapitalizeFormatter extends AbstractFormatter { +public class CapitalizeFormatter extends Formatter { @Override public String getName() { diff --git a/src/main/java/org/jabref/logic/formatter/casechanger/LowerCaseFormatter.java b/src/main/java/org/jabref/logic/formatter/casechanger/LowerCaseFormatter.java index bc9ad3fc449..08ba0851d84 100644 --- a/src/main/java/org/jabref/logic/formatter/casechanger/LowerCaseFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/casechanger/LowerCaseFormatter.java @@ -1,9 +1,9 @@ package org.jabref.logic.formatter.casechanger; -import org.jabref.logic.formatter.AbstractFormatter; +import org.jabref.model.cleanup.Formatter; import org.jabref.logic.l10n.Localization; -public class LowerCaseFormatter extends AbstractFormatter { +public class LowerCaseFormatter extends Formatter { @Override public String getName() { diff --git a/src/main/java/org/jabref/logic/formatter/casechanger/ProtectTermsFormatter.java b/src/main/java/org/jabref/logic/formatter/casechanger/ProtectTermsFormatter.java index bd0cce99d76..eadfae7fd47 100644 --- a/src/main/java/org/jabref/logic/formatter/casechanger/ProtectTermsFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/casechanger/ProtectTermsFormatter.java @@ -3,12 +3,12 @@ import java.util.List; import java.util.Objects; -import org.jabref.logic.formatter.AbstractFormatter; +import org.jabref.model.cleanup.Formatter; import org.jabref.logic.l10n.Localization; import org.jabref.logic.protectedterms.ProtectedTermsLoader; import org.jabref.logic.util.strings.StringLengthComparator; -public class ProtectTermsFormatter extends AbstractFormatter { +public class ProtectTermsFormatter extends Formatter { private final ProtectedTermsLoader protectedTermsLoader; diff --git a/src/main/java/org/jabref/logic/formatter/casechanger/SentenceCaseFormatter.java b/src/main/java/org/jabref/logic/formatter/casechanger/SentenceCaseFormatter.java index 57a8c36cbb6..89565ae2dcb 100644 --- a/src/main/java/org/jabref/logic/formatter/casechanger/SentenceCaseFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/casechanger/SentenceCaseFormatter.java @@ -1,9 +1,9 @@ package org.jabref.logic.formatter.casechanger; -import org.jabref.logic.formatter.AbstractFormatter; +import org.jabref.model.cleanup.Formatter; import org.jabref.logic.l10n.Localization; -public class SentenceCaseFormatter extends AbstractFormatter { +public class SentenceCaseFormatter extends Formatter { @Override public String getName() { diff --git a/src/main/java/org/jabref/logic/formatter/casechanger/TitleCaseFormatter.java b/src/main/java/org/jabref/logic/formatter/casechanger/TitleCaseFormatter.java index 5f1429cbee5..c1e8c3c85eb 100644 --- a/src/main/java/org/jabref/logic/formatter/casechanger/TitleCaseFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/casechanger/TitleCaseFormatter.java @@ -1,9 +1,9 @@ package org.jabref.logic.formatter.casechanger; -import org.jabref.logic.formatter.AbstractFormatter; +import org.jabref.model.cleanup.Formatter; import org.jabref.logic.l10n.Localization; -public class TitleCaseFormatter extends AbstractFormatter { +public class TitleCaseFormatter extends Formatter { @Override public String getName() { diff --git a/src/main/java/org/jabref/logic/formatter/casechanger/UpperCaseFormatter.java b/src/main/java/org/jabref/logic/formatter/casechanger/UpperCaseFormatter.java index c71329dfe49..37015284be0 100644 --- a/src/main/java/org/jabref/logic/formatter/casechanger/UpperCaseFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/casechanger/UpperCaseFormatter.java @@ -1,9 +1,9 @@ package org.jabref.logic.formatter.casechanger; -import org.jabref.logic.formatter.AbstractFormatter; +import org.jabref.model.cleanup.Formatter; import org.jabref.logic.l10n.Localization; -public class UpperCaseFormatter extends AbstractFormatter { +public class UpperCaseFormatter extends Formatter { @Override public String getName() { diff --git a/src/main/java/org/jabref/logic/formatter/minifier/MinifyNameListFormatter.java b/src/main/java/org/jabref/logic/formatter/minifier/MinifyNameListFormatter.java index 86ef535904d..0f5476c78de 100644 --- a/src/main/java/org/jabref/logic/formatter/minifier/MinifyNameListFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/minifier/MinifyNameListFormatter.java @@ -2,13 +2,13 @@ import java.util.Objects; -import org.jabref.logic.formatter.AbstractFormatter; +import org.jabref.model.cleanup.Formatter; import org.jabref.logic.l10n.Localization; /** * Replaces three or more authors with and others */ -public class MinifyNameListFormatter extends AbstractFormatter { +public class MinifyNameListFormatter extends Formatter { @Override public String getName() { return Localization.lang("Minify list of person names"); diff --git a/src/main/java/org/jabref/logic/layout/format/LatexToUnicodeFormatter.java b/src/main/java/org/jabref/logic/layout/format/LatexToUnicodeFormatter.java index 4f3ced5f3c1..f16a5dd4c54 100644 --- a/src/main/java/org/jabref/logic/layout/format/LatexToUnicodeFormatter.java +++ b/src/main/java/org/jabref/logic/layout/format/LatexToUnicodeFormatter.java @@ -9,7 +9,7 @@ * This formatter converts LaTeX character sequences their equivalent unicode characters, * and removes other LaTeX commands without handling them. */ -public class LatexToUnicodeFormatter implements LayoutFormatter, Formatter { +public class LatexToUnicodeFormatter extends Formatter implements LayoutFormatter { @Override public String getName() { diff --git a/src/main/java/org/jabref/logic/layout/format/ReplaceUnicodeLigaturesFormatter.java b/src/main/java/org/jabref/logic/layout/format/ReplaceUnicodeLigaturesFormatter.java index f51c2e7b084..cce05eb57dc 100644 --- a/src/main/java/org/jabref/logic/layout/format/ReplaceUnicodeLigaturesFormatter.java +++ b/src/main/java/org/jabref/logic/layout/format/ReplaceUnicodeLigaturesFormatter.java @@ -9,7 +9,7 @@ import org.jabref.logic.util.strings.UnicodeLigaturesMap; import org.jabref.model.cleanup.Formatter; -public class ReplaceUnicodeLigaturesFormatter implements LayoutFormatter, Formatter { +public class ReplaceUnicodeLigaturesFormatter extends Formatter implements LayoutFormatter { private Map ligaturesMap; diff --git a/src/main/java/org/jabref/model/cleanup/Formatter.java b/src/main/java/org/jabref/model/cleanup/Formatter.java index 5b5dcd5673f..7fa32dacd94 100644 --- a/src/main/java/org/jabref/model/cleanup/Formatter.java +++ b/src/main/java/org/jabref/model/cleanup/Formatter.java @@ -1,28 +1,29 @@ package org.jabref.model.cleanup; /** - * The Formatter is used for a Filter design-pattern. Implementing classes have to accept a String and returned a - * formatted version of it. + * The Formatter is used for a Filter design-pattern. Extending classes have to accept a String and returned a + * formatted version of it. Implementations have to reside in the logic package. * * Example: * * "John von Neumann" => "von Neumann, John" * */ -public interface Formatter { +public abstract class Formatter { + /** * Returns a human readable name of the formatter usable for e.g. in the GUI * * @return the name of the formatter, always not null */ - String getName(); + public abstract String getName(); /** * Returns a unique key for the formatter that can be used for its identification * @return the key of the formatter, always not null */ - String getKey(); + public abstract String getKey(); /** * Formats a field value by with a particular formatter transformation. @@ -32,14 +33,14 @@ public interface Formatter { * @param value the input String * @return the formatted output String */ - String format(String value); + public abstract String format(String value); /** * Returns a description of the formatter. * * @return the description string, always non empty */ - String getDescription(); + public abstract String getDescription(); /** * Returns an example input string of the formatter. @@ -47,14 +48,15 @@ public interface Formatter { * * @return the example input string, always non empty */ - String getExampleInput(); + public abstract String getExampleInput(); /** * Returns a default hashcode of the formatter based on its key. * * @return the hash of the key of the formatter */ - default int defaultHashCode() { + @Override + public int hashCode() { return getKey().hashCode(); } @@ -64,7 +66,8 @@ default int defaultHashCode() { * @param obj the object to compare the formatter to * @return true if the object is a formatter with the same key */ - default boolean defaultEquals(Object obj) { + @Override + public boolean equals(Object obj) { if (obj instanceof Formatter) { return getKey().equals(((Formatter)obj).getKey()); } else { From b1ff3bd01c79029b6d4221d79e06508cdd4d79bd Mon Sep 17 00:00:00 2001 From: Christoph Date: Wed, 23 May 2018 09:01:25 +0200 Subject: [PATCH 16/33] New translations JabRef_en.properties (Vietnamese) (#4050) --- src/main/resources/l10n/JabRef_vi.properties | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/resources/l10n/JabRef_vi.properties b/src/main/resources/l10n/JabRef_vi.properties index 323dd8d3d1b..34106b26aa8 100644 --- a/src/main/resources/l10n/JabRef_vi.properties +++ b/src/main/resources/l10n/JabRef_vi.properties @@ -149,6 +149,7 @@ Broken\ link=Liên kết bị đứt Browse=Duyệt by=theo +The\ conflicting\ fields\ of\ these\ entries\ will\ be\ merged\ into\ the\ 'Comment'\ field.=Các trường xung đột của các mục này sẽ được sáp nhập vào trường 'Nhận xét'. Cancel=Hủy @@ -211,6 +212,7 @@ Color\ for\ marking\ incomplete\ entries=Màu để đánh dấu các mục chư Column\ width=Chiều rộng cột Command\ line\ id=Chỉ số (id) của dòng lệnh +Comments=Nhận xét Contained\ in=Chứa trong From d989d0b1863f1c3538b5fa65c5017f30f60eb57e Mon Sep 17 00:00:00 2001 From: Christoph Date: Wed, 23 May 2018 12:14:04 +0200 Subject: [PATCH 17/33] New translations JabRef_en.properties (French) (#4051) --- src/main/resources/l10n/JabRef_fr.properties | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/resources/l10n/JabRef_fr.properties b/src/main/resources/l10n/JabRef_fr.properties index 2dbfab36e87..729df89d87c 100644 --- a/src/main/resources/l10n/JabRef_fr.properties +++ b/src/main/resources/l10n/JabRef_fr.properties @@ -1946,6 +1946,7 @@ Changes\ all\ letters\ to\ upper\ case.=Convertit toutes les lettres en majuscul Changes\ the\ first\ letter\ of\ all\ words\ to\ capital\ case\ and\ the\ remaining\ letters\ to\ lower\ case.=Convertit en majuscules la première lettre de tous les mots, et les autres lettres en minuscules. Cleans\ up\ LaTeX\ code.=Nettoyer le code LaTeX. Converts\ HTML\ code\ to\ LaTeX\ code.=Convertit le code HTML en code LaTeX. +HTML\ to\ Unicode=HTML vers Unicode Converts\ HTML\ code\ to\ Unicode.=Convertit du code HTML en Unicode. Converts\ LaTeX\ encoding\ to\ Unicode\ characters.=Convertit l'encodage LaTeX en caractères Unicode. Converts\ Unicode\ characters\ to\ LaTeX\ encoding.=Convertit les caractères Unicode en encodage LaTeX. From ea5376cd33a96952865c6b87a9abe6c94055e59d Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Thu, 24 May 2018 07:31:33 +0200 Subject: [PATCH 18/33] Make test more informative in the failing case --- .../org/jabref/logic/formatter/FormatterTest.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/test/java/org/jabref/logic/formatter/FormatterTest.java b/src/test/java/org/jabref/logic/formatter/FormatterTest.java index 0006fbdfbbc..b662ccef1cf 100644 --- a/src/test/java/org/jabref/logic/formatter/FormatterTest.java +++ b/src/test/java/org/jabref/logic/formatter/FormatterTest.java @@ -1,6 +1,7 @@ package org.jabref.logic.formatter; import java.util.Collections; +import java.util.Map; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -37,10 +38,14 @@ public static void setUp() { @Test public void allFormatterKeysAreUnique() { // idea for uniqueness checking by https://stackoverflow.com/a/44032568/873282 - assertFalse(getFormatters().collect(Collectors.groupingBy( - formatter -> formatter.getKey(), - Collectors.counting() - )).entrySet().stream().anyMatch(e -> e.getValue() > 1)); + assertEquals(Collections.emptyList(), + getFormatters().collect(Collectors.groupingBy( + formatter -> formatter.getKey(), + Collectors.counting())) + .entrySet().stream() + .filter(e -> e.getValue() > 1) + .map(Map.Entry::getKey) + .collect(Collectors.toList())); } @ParameterizedTest From 8aab893fc3b089972c41afe859584ea0ebf3a8a5 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Thu, 24 May 2018 08:42:02 +0200 Subject: [PATCH 19/33] Fix checkstyle --- .../logic/formatter/bibtexfields/AddBracesFormatter.java | 3 +-- .../jabref/logic/formatter/bibtexfields/ClearFormatter.java | 2 +- .../formatter/bibtexfields/EscapeUnderscoresFormatter.java | 2 +- .../logic/formatter/bibtexfields/LatexCleanupFormatter.java | 3 +-- .../logic/formatter/bibtexfields/NormalizeDateFormatter.java | 2 +- .../formatter/bibtexfields/NormalizeMonthFormatter.java | 3 +-- .../formatter/bibtexfields/NormalizeNamesFormatter.java | 3 +-- .../formatter/bibtexfields/NormalizePagesFormatter.java | 4 ++-- .../bibtexfields/OrdinalsToSuperscriptFormatter.java | 3 +-- .../jabref/logic/formatter/bibtexfields/RegexFormatter.java | 3 +-- .../logic/formatter/bibtexfields/RemoveBracesFormatter.java | 2 +- .../bibtexfields/RemoveHyphenatedNewlinesFormatter.java | 2 +- .../formatter/bibtexfields/RemoveNewlinesFormatter.java | 2 +- .../logic/formatter/bibtexfields/UnitsToLatexFormatter.java | 5 +---- .../logic/formatter/casechanger/CapitalizeFormatter.java | 3 +-- .../logic/formatter/casechanger/LowerCaseFormatter.java | 3 +-- .../logic/formatter/casechanger/ProtectTermsFormatter.java | 3 +-- .../logic/formatter/casechanger/SentenceCaseFormatter.java | 3 +-- .../logic/formatter/casechanger/TitleCaseFormatter.java | 3 +-- .../logic/formatter/casechanger/UpperCaseFormatter.java | 3 +-- .../logic/formatter/minifier/MinifyNameListFormatter.java | 2 +- 21 files changed, 22 insertions(+), 37 deletions(-) diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/AddBracesFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/AddBracesFormatter.java index 3308ecc8000..7c1e03c2215 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/AddBracesFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/AddBracesFormatter.java @@ -2,8 +2,8 @@ import java.util.Objects; -import org.jabref.model.cleanup.Formatter; import org.jabref.logic.l10n.Localization; +import org.jabref.model.cleanup.Formatter; public class AddBracesFormatter extends Formatter { @@ -38,5 +38,4 @@ public String getDescription() { public String getExampleInput() { return "In CDMA"; } - } diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/ClearFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/ClearFormatter.java index 6a549cea35f..3aa516c7fe8 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/ClearFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/ClearFormatter.java @@ -2,8 +2,8 @@ import java.util.Objects; -import org.jabref.model.cleanup.Formatter; import org.jabref.logic.l10n.Localization; +import org.jabref.model.cleanup.Formatter; public class ClearFormatter extends Formatter { diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/EscapeUnderscoresFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/EscapeUnderscoresFormatter.java index 2de9214c2a9..a0dbd78195b 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/EscapeUnderscoresFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/EscapeUnderscoresFormatter.java @@ -3,8 +3,8 @@ import java.util.Objects; import java.util.regex.Pattern; -import org.jabref.model.cleanup.Formatter; import org.jabref.logic.l10n.Localization; +import org.jabref.model.cleanup.Formatter; public class EscapeUnderscoresFormatter extends Formatter { diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/LatexCleanupFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/LatexCleanupFormatter.java index efc5e9d2ebb..032914146b6 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/LatexCleanupFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/LatexCleanupFormatter.java @@ -2,8 +2,8 @@ import java.util.regex.Pattern; -import org.jabref.model.cleanup.Formatter; import org.jabref.logic.l10n.Localization; +import org.jabref.model.cleanup.Formatter; public class LatexCleanupFormatter extends Formatter { @@ -62,5 +62,4 @@ public String getDescription() { public String getExampleInput() { return "{VLSI} {DSP}"; } - } diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/NormalizeDateFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/NormalizeDateFormatter.java index c8d3d682c27..2ef6cb3dab3 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/NormalizeDateFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/NormalizeDateFormatter.java @@ -2,8 +2,8 @@ import java.util.Optional; -import org.jabref.model.cleanup.Formatter; import org.jabref.logic.l10n.Localization; +import org.jabref.model.cleanup.Formatter; import org.jabref.model.entry.Date; /** diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/NormalizeMonthFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/NormalizeMonthFormatter.java index 2b8e8c05b4a..2e71be8ea24 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/NormalizeMonthFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/NormalizeMonthFormatter.java @@ -3,8 +3,8 @@ import java.util.Objects; import java.util.Optional; -import org.jabref.model.cleanup.Formatter; import org.jabref.logic.l10n.Localization; +import org.jabref.model.cleanup.Formatter; import org.jabref.model.entry.Month; public class NormalizeMonthFormatter extends Formatter { @@ -35,5 +35,4 @@ public String getDescription() { public String getExampleInput() { return "December"; } - } diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/NormalizeNamesFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/NormalizeNamesFormatter.java index 2f5d82f8686..8ef592833fa 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/NormalizeNamesFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/NormalizeNamesFormatter.java @@ -2,8 +2,8 @@ import java.util.Objects; -import org.jabref.model.cleanup.Formatter; import org.jabref.logic.l10n.Localization; +import org.jabref.model.cleanup.Formatter; import org.jabref.model.entry.AuthorList; /** @@ -37,5 +37,4 @@ public String getDescription() { public String getExampleInput() { return "Albert Einstein and Alan Turing"; } - } diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/NormalizePagesFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/NormalizePagesFormatter.java index e43b5393d39..7829a0c928b 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/NormalizePagesFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/NormalizePagesFormatter.java @@ -4,8 +4,8 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.jabref.model.cleanup.Formatter; import org.jabref.logic.l10n.Localization; +import org.jabref.model.cleanup.Formatter; import com.google.common.base.Strings; @@ -61,7 +61,7 @@ public String format(String value) { } // Remove pages prefix - String cleanValue = value.replace("pp.", "").replace("p.",""); + String cleanValue = value.replace("pp.", "").replace("p.", ""); // remove unwanted literals incl. whitespace cleanValue = cleanValue.replaceAll("\u2013|\u2014", "-").replaceAll(REJECT_LITERALS, ""); // try to find pages pattern diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/OrdinalsToSuperscriptFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/OrdinalsToSuperscriptFormatter.java index c443b8b7791..d12871a8ca8 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/OrdinalsToSuperscriptFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/OrdinalsToSuperscriptFormatter.java @@ -4,8 +4,8 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.jabref.model.cleanup.Formatter; import org.jabref.logic.l10n.Localization; +import org.jabref.model.cleanup.Formatter; /** * This class transforms ordinal numbers into LaTex superscripts. @@ -61,5 +61,4 @@ public String getDescription() { public String getExampleInput() { return "11th"; } - } diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/RegexFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/RegexFormatter.java index 0c653f3718d..3b4dd551781 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/RegexFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/RegexFormatter.java @@ -6,8 +6,8 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.jabref.model.cleanup.Formatter; import org.jabref.logic.l10n.Localization; +import org.jabref.model.cleanup.Formatter; public class RegexFormatter extends Formatter { @@ -101,5 +101,4 @@ public static void setRegex(String rex) { String[] parts = rexToSet.split("\",\""); regex = parts; } - } diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveBracesFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveBracesFormatter.java index 98656936264..11cf48722b1 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveBracesFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveBracesFormatter.java @@ -2,8 +2,8 @@ import java.util.Objects; -import org.jabref.model.cleanup.Formatter; import org.jabref.logic.l10n.Localization; +import org.jabref.model.cleanup.Formatter; public class RemoveBracesFormatter extends Formatter { diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveHyphenatedNewlinesFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveHyphenatedNewlinesFormatter.java index 985718533de..2356c02cab0 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveHyphenatedNewlinesFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveHyphenatedNewlinesFormatter.java @@ -3,8 +3,8 @@ import java.util.Objects; import java.util.regex.Pattern; -import org.jabref.model.cleanup.Formatter; import org.jabref.logic.l10n.Localization; +import org.jabref.model.cleanup.Formatter; /** * Removes all hyphenated line breaks in the string. diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveNewlinesFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveNewlinesFormatter.java index 142e09e5aa8..c6942bf51ea 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveNewlinesFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/RemoveNewlinesFormatter.java @@ -3,8 +3,8 @@ import java.util.Objects; import java.util.regex.Pattern; -import org.jabref.model.cleanup.Formatter; import org.jabref.logic.l10n.Localization; +import org.jabref.model.cleanup.Formatter; /** * Removes all line breaks in the string. diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/UnitsToLatexFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/UnitsToLatexFormatter.java index d5394756ba9..b32f14a1e11 100644 --- a/src/main/java/org/jabref/logic/formatter/bibtexfields/UnitsToLatexFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/UnitsToLatexFormatter.java @@ -6,9 +6,9 @@ import java.util.List; import java.util.Objects; -import org.jabref.model.cleanup.Formatter; import org.jabref.logic.l10n.Localization; import org.jabref.logic.util.strings.StringLengthComparator; +import org.jabref.model.cleanup.Formatter; public class UnitsToLatexFormatter extends Formatter { @@ -81,7 +81,6 @@ public class UnitsToLatexFormatter extends Formatter { private final List prefixUnitCombinations; - public UnitsToLatexFormatter() { prefixUnitCombinations = new ArrayList<>( UnitsToLatexFormatter.UNIT_LIST.size() * UnitsToLatexFormatter.UNIT_PREFIX_LIST.size()); @@ -112,7 +111,6 @@ public String format(String text) { result = result.replaceAll("([0-9])(" + listOfWord + ")", "$1\\{$2\\}"); // Only add brackets to keep case result = result.replaceAll("([0-9])-(" + listOfWord + ")", "$1\\\\mbox\\{-\\}\\{$2\\}"); // Replace hyphen with non-break hyphen result = result.replaceAll("([0-9]) (" + listOfWord + ")", "$1~\\{$2\\}"); // Replace space with a hard space - } return result; @@ -137,5 +135,4 @@ public String getName() { public String getKey() { return "units_to_latex"; } - } diff --git a/src/main/java/org/jabref/logic/formatter/casechanger/CapitalizeFormatter.java b/src/main/java/org/jabref/logic/formatter/casechanger/CapitalizeFormatter.java index 091715e5307..bf225dcf80d 100644 --- a/src/main/java/org/jabref/logic/formatter/casechanger/CapitalizeFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/casechanger/CapitalizeFormatter.java @@ -1,7 +1,7 @@ package org.jabref.logic.formatter.casechanger; -import org.jabref.model.cleanup.Formatter; import org.jabref.logic.l10n.Localization; +import org.jabref.model.cleanup.Formatter; public class CapitalizeFormatter extends Formatter { @@ -37,5 +37,4 @@ public String getDescription() { public String getExampleInput() { return "I have {a} DREAM"; } - } diff --git a/src/main/java/org/jabref/logic/formatter/casechanger/LowerCaseFormatter.java b/src/main/java/org/jabref/logic/formatter/casechanger/LowerCaseFormatter.java index 08ba0851d84..239b35f8712 100644 --- a/src/main/java/org/jabref/logic/formatter/casechanger/LowerCaseFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/casechanger/LowerCaseFormatter.java @@ -1,7 +1,7 @@ package org.jabref.logic.formatter.casechanger; -import org.jabref.model.cleanup.Formatter; import org.jabref.logic.l10n.Localization; +import org.jabref.model.cleanup.Formatter; public class LowerCaseFormatter extends Formatter { @@ -36,5 +36,4 @@ public String getDescription() { public String getExampleInput() { return "KDE {Amarok}"; } - } diff --git a/src/main/java/org/jabref/logic/formatter/casechanger/ProtectTermsFormatter.java b/src/main/java/org/jabref/logic/formatter/casechanger/ProtectTermsFormatter.java index eadfae7fd47..c0b7c81612e 100644 --- a/src/main/java/org/jabref/logic/formatter/casechanger/ProtectTermsFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/casechanger/ProtectTermsFormatter.java @@ -3,10 +3,10 @@ import java.util.List; import java.util.Objects; -import org.jabref.model.cleanup.Formatter; import org.jabref.logic.l10n.Localization; import org.jabref.logic.protectedterms.ProtectedTermsLoader; import org.jabref.logic.util.strings.StringLengthComparator; +import org.jabref.model.cleanup.Formatter; public class ProtectTermsFormatter extends Formatter { @@ -56,5 +56,4 @@ public String getName() { public String getKey() { return "protect_terms"; } - } diff --git a/src/main/java/org/jabref/logic/formatter/casechanger/SentenceCaseFormatter.java b/src/main/java/org/jabref/logic/formatter/casechanger/SentenceCaseFormatter.java index 89565ae2dcb..ab6098c44d2 100644 --- a/src/main/java/org/jabref/logic/formatter/casechanger/SentenceCaseFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/casechanger/SentenceCaseFormatter.java @@ -1,7 +1,7 @@ package org.jabref.logic.formatter.casechanger; -import org.jabref.model.cleanup.Formatter; import org.jabref.logic.l10n.Localization; +import org.jabref.model.cleanup.Formatter; public class SentenceCaseFormatter extends Formatter { @@ -37,5 +37,4 @@ public String getDescription() { public String getExampleInput() { return "i have {Aa} DREAM"; } - } diff --git a/src/main/java/org/jabref/logic/formatter/casechanger/TitleCaseFormatter.java b/src/main/java/org/jabref/logic/formatter/casechanger/TitleCaseFormatter.java index c1e8c3c85eb..3d0f8e0c819 100644 --- a/src/main/java/org/jabref/logic/formatter/casechanger/TitleCaseFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/casechanger/TitleCaseFormatter.java @@ -1,7 +1,7 @@ package org.jabref.logic.formatter.casechanger; -import org.jabref.model.cleanup.Formatter; import org.jabref.logic.l10n.Localization; +import org.jabref.model.cleanup.Formatter; public class TitleCaseFormatter extends Formatter { @@ -49,5 +49,4 @@ public String getDescription() { public String getExampleInput() { return "{BPMN} conformance In open source Engines"; } - } diff --git a/src/main/java/org/jabref/logic/formatter/casechanger/UpperCaseFormatter.java b/src/main/java/org/jabref/logic/formatter/casechanger/UpperCaseFormatter.java index 37015284be0..6b743d7acf7 100644 --- a/src/main/java/org/jabref/logic/formatter/casechanger/UpperCaseFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/casechanger/UpperCaseFormatter.java @@ -1,7 +1,7 @@ package org.jabref.logic.formatter.casechanger; -import org.jabref.model.cleanup.Formatter; import org.jabref.logic.l10n.Localization; +import org.jabref.model.cleanup.Formatter; public class UpperCaseFormatter extends Formatter { @@ -37,5 +37,4 @@ public String getDescription() { public String getExampleInput() { return "Kde {Amarok}"; } - } diff --git a/src/main/java/org/jabref/logic/formatter/minifier/MinifyNameListFormatter.java b/src/main/java/org/jabref/logic/formatter/minifier/MinifyNameListFormatter.java index 0f5476c78de..136f8a38a39 100644 --- a/src/main/java/org/jabref/logic/formatter/minifier/MinifyNameListFormatter.java +++ b/src/main/java/org/jabref/logic/formatter/minifier/MinifyNameListFormatter.java @@ -2,8 +2,8 @@ import java.util.Objects; -import org.jabref.model.cleanup.Formatter; import org.jabref.logic.l10n.Localization; +import org.jabref.model.cleanup.Formatter; /** * Replaces three or more authors with and others From ffa2779c02ce1e29eba7d6d293306da1407b4017 Mon Sep 17 00:00:00 2001 From: Stefan Kolb Date: Thu, 24 May 2018 10:58:06 +0200 Subject: [PATCH 20/33] Update CHANGELOG.md --- CHANGELOG.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 40193767400..d3334684a00 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,14 +18,14 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# - We streamlined the defaults for a [cleanup of entries](http://help.jabref.org/en/CleanupEntries) in the case of BibTeX. ### Fixed -We fixed an issue where the export to clipboard functionality could not be invoked. [#3994](https://github.com/JabRef/jabref/issues/3994) -We fixed an issue with the migration of invalid Look and Feels. [#3995, comment](https://github.com/JabRef/jabref/issues/3995#issuecomment-385649448) -We fixed an issue where JabRef would no longer start, when the option "Override default font settings" was activated. [#3986](https://github.com/JabRef/jabref/issues/3986) -We fixed an issue where JabRef removed whitespace from the Title-fetcher which resulting in no entries being found. [#4014](https://github.com/JabRef/jabref/issues/4014) -We fixed an issue where fetched entries from the ACM fetcher could not be imported. [#4018](https://github.com/JabRef/jabref/issues/4018) +- We fixed an issue where the export to clipboard functionality could not be invoked. [#3994](https://github.com/JabRef/jabref/issues/3994) +- We fixed an issue with the migration of invalid Look and Feels. [#3995, comment](https://github.com/JabRef/jabref/issues/3995#issuecomment-385649448) +- We fixed an issue where JabRef would no longer start, when the option "Override default font settings" was activated. [#3986](https://github.com/JabRef/jabref/issues/3986) +- We fixed an issue where JabRef removed whitespace from the Title-fetcher which resulting in no entries being found. [#4014](https://github.com/JabRef/jabref/issues/4014) +- We fixed an issue where fetched entries from the ACM fetcher could not be imported. [#4018](https://github.com/JabRef/jabref/issues/4018) ### Removed -We removed the GTK Look and Feel from the Options, as it leads to freezes in JabRef on MacOSX and Linux [#3995](https://github.com/JabRef/jabref/issues/3995) +- We removed the GTK Look and Feel from the Options, as it leads to freezes in JabRef on MacOSX and Linux [#3995](https://github.com/JabRef/jabref/issues/3995). The GTK Look and Feel is now replaced with the "Nimbus" style as default. From a1377fc9dde9c4f2436ac4c649f92fee11dd19cc Mon Sep 17 00:00:00 2001 From: Christoph Date: Thu, 24 May 2018 11:02:10 +0200 Subject: [PATCH 21/33] New translations JabRef_en.properties (French) (#4052) --- src/main/resources/l10n/JabRef_fr.properties | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/resources/l10n/JabRef_fr.properties b/src/main/resources/l10n/JabRef_fr.properties index 729df89d87c..e2891e720bb 100644 --- a/src/main/resources/l10n/JabRef_fr.properties +++ b/src/main/resources/l10n/JabRef_fr.properties @@ -1967,6 +1967,8 @@ Normalizes\ lists\ of\ persons\ to\ the\ BibTeX\ standard.=Harmonise les listes Normalizes\ the\ date\ to\ ISO\ date\ format.=Harmonise la date au format de date ISO. Ordinals\ to\ LaTeX\ superscript=Numéros ordinaux vers exposants LaTeX Protect\ terms=Protéger les termes +Add\ enclosing\ braces=Ajouter des accolades englobantes +Add\ braces\ encapsulating\ the\ complete\ field\ content.=Ajoute des accolades encapsulant l'ensemble du contenu du champ. Remove\ enclosing\ braces=Supprimer les paires d'accolades Removes\ braces\ encapsulating\ the\ complete\ field\ content.=Supprimer les accolades autour d'un contenu de champ entier. Sentence\ case=Casse de la phrase From 7671b80d972c2c30ece9e93c3db0c9fa98974a21 Mon Sep 17 00:00:00 2001 From: Johannes Manner Date: Thu, 24 May 2018 12:39:03 +0200 Subject: [PATCH 22/33] A first solution for the cli problem #4038 (#4047) * A first solution for the cli problem ExportFactory is not initialized at this execution point... * Changing the order of execution in the main method --- src/main/java/org/jabref/JabRefMain.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/jabref/JabRefMain.java b/src/main/java/org/jabref/JabRefMain.java index bd370dda02a..79291172919 100644 --- a/src/main/java/org/jabref/JabRefMain.java +++ b/src/main/java/org/jabref/JabRefMain.java @@ -108,9 +108,6 @@ private static void start(String[] args) { PreferencesMigrations.addCrossRefRelatedFieldsForAutoComplete(); PreferencesMigrations.upgradeObsoleteLookAndFeels(); - // Process arguments - ArgumentProcessor argumentProcessor = new ArgumentProcessor(args, ArgumentProcessor.Mode.INITIAL_START); - FallbackExceptionHandler.installExceptionHandler(); ensureCorrectJavaVersion(); @@ -141,6 +138,9 @@ private static void start(String[] args) { preferences.loadCustomEntryTypes(BibDatabaseMode.BIBLATEX)); Globals.exportFactory = Globals.prefs.getExporterFactory(Globals.journalAbbreviationLoader); + // Process arguments + ArgumentProcessor argumentProcessor = new ArgumentProcessor(args, ArgumentProcessor.Mode.INITIAL_START); + // Initialize protected terms loader Globals.protectedTermsLoader = new ProtectedTermsLoader(Globals.prefs.getProtectedTermsPreferences()); From 4e28ed58b4e29d31d23f6a83f1510ab47ad1a02e Mon Sep 17 00:00:00 2001 From: Stefan Kolb Date: Thu, 24 May 2018 13:21:47 +0200 Subject: [PATCH 23/33] Extract migrations --- src/main/java/org/jabref/JabRefMain.java | 47 +++++++++++++----------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/src/main/java/org/jabref/JabRefMain.java b/src/main/java/org/jabref/JabRefMain.java index 79291172919..1df0090fb76 100644 --- a/src/main/java/org/jabref/JabRefMain.java +++ b/src/main/java/org/jabref/JabRefMain.java @@ -36,16 +36,21 @@ * JabRef MainClass */ public class JabRefMain extends Application { - private static final Logger LOGGER = LoggerFactory.getLogger(JabRefMain.class); + private static String[] arguments; public static void main(String[] args) { arguments = args; - launch(arguments); } + @Override + public void start(Stage mainStage) throws Exception { + Platform.setImplicitExit(false); + SwingUtilities.invokeLater(() -> start(arguments)); + } + /** * Tests if we are running an acceptable Java and terminates JabRef when we are sure the version is not supported. * This test uses the requirements for the Java version as specified in gradle.build. It is possible to @@ -97,16 +102,7 @@ private static void start(String[] args) { JabRefPreferences preferences = JabRefPreferences.getInstance(); Globals.prefs = preferences; // Perform Migrations - // Perform checks and changes for users with a preference set from an older JabRef version. - PreferencesMigrations.upgradePrefsToOrgJabRef(); - PreferencesMigrations.upgradeSortOrder(); - PreferencesMigrations.upgradeFaultyEncodingStrings(); - PreferencesMigrations.upgradeLabelPatternToBibtexKeyPattern(); - PreferencesMigrations.upgradeImportFileAndDirePatterns(); - PreferencesMigrations.upgradeStoredCustomEntryTypes(); - PreferencesMigrations.upgradeKeyBindingsToJavaFX(); - PreferencesMigrations.addCrossRefRelatedFieldsForAutoComplete(); - PreferencesMigrations.upgradeObsoleteLookAndFeels(); + migratePreferences(); FallbackExceptionHandler.installExceptionHandler(); @@ -138,12 +134,12 @@ private static void start(String[] args) { preferences.loadCustomEntryTypes(BibDatabaseMode.BIBLATEX)); Globals.exportFactory = Globals.prefs.getExporterFactory(Globals.journalAbbreviationLoader); - // Process arguments - ArgumentProcessor argumentProcessor = new ArgumentProcessor(args, ArgumentProcessor.Mode.INITIAL_START); - // Initialize protected terms loader Globals.protectedTermsLoader = new ProtectedTermsLoader(Globals.prefs.getProtectedTermsPreferences()); + // Process arguments + ArgumentProcessor argumentProcessor = new ArgumentProcessor(args, ArgumentProcessor.Mode.INITIAL_START); + // Check for running JabRef RemotePreferences remotePreferences = Globals.prefs.getRemotePreferences(); if (remotePreferences.useRemoteServer()) { @@ -178,14 +174,21 @@ private static void start(String[] args) { // If not, start GUI SwingUtilities - .invokeLater(() -> new JabRefGUI(argumentProcessor.getParserResults(), - argumentProcessor.isBlank())); + .invokeLater(() -> new JabRefGUI(argumentProcessor.getParserResults(), argumentProcessor.isBlank())); } - @Override - public void start(Stage mainStage) throws Exception { - Platform.setImplicitExit(false); - SwingUtilities.invokeLater(() -> start(arguments) - ); + /** + * Perform checks and changes for users with a preference set from an older JabRef version. + */ + private static void migratePreferences() { + PreferencesMigrations.upgradePrefsToOrgJabRef(); + PreferencesMigrations.upgradeSortOrder(); + PreferencesMigrations.upgradeFaultyEncodingStrings(); + PreferencesMigrations.upgradeLabelPatternToBibtexKeyPattern(); + PreferencesMigrations.upgradeImportFileAndDirePatterns(); + PreferencesMigrations.upgradeStoredCustomEntryTypes(); + PreferencesMigrations.upgradeKeyBindingsToJavaFX(); + PreferencesMigrations.addCrossRefRelatedFieldsForAutoComplete(); + PreferencesMigrations.upgradeObsoleteLookAndFeels(); } } From 888aade35e69a5fa7e9cca87fdaa755f01183c4e Mon Sep 17 00:00:00 2001 From: Stefan Kolb Date: Thu, 24 May 2018 13:38:38 +0200 Subject: [PATCH 24/33] Structure startup --- src/main/java/org/jabref/JabRefMain.java | 95 ++++++++++++++---------- 1 file changed, 54 insertions(+), 41 deletions(-) diff --git a/src/main/java/org/jabref/JabRefMain.java b/src/main/java/org/jabref/JabRefMain.java index 1df0090fb76..2f3e152e8cc 100644 --- a/src/main/java/org/jabref/JabRefMain.java +++ b/src/main/java/org/jabref/JabRefMain.java @@ -98,49 +98,43 @@ private static void ensureCorrectJavaVersion() { } private static void start(String[] args) { + // Fail on unsupported Java versions + ensureCorrectJavaVersion(); + FallbackExceptionHandler.installExceptionHandler(); + // Init preferences - JabRefPreferences preferences = JabRefPreferences.getInstance(); + final JabRefPreferences preferences = JabRefPreferences.getInstance(); Globals.prefs = preferences; - // Perform Migrations + // Perform migrations migratePreferences(); - FallbackExceptionHandler.installExceptionHandler(); - - ensureCorrectJavaVersion(); - - ProxyPreferences proxyPreferences = preferences.getProxyPreferences(); - ProxyRegisterer.register(proxyPreferences); - if (proxyPreferences.isUseProxy() && proxyPreferences.isUseAuthentication()) { - Authenticator.setDefault(new ProxyAuthenticator()); - } + configureProxy(preferences.getProxyPreferences()); Globals.startBackgroundTasks(); - // Update handling of special fields based on preferences - InternalBibtexFields - .updateSpecialFields(Globals.prefs.getBoolean(JabRefPreferences.SERIALIZESPECIALFIELDS)); - // Update name of the time stamp field based on preferences - InternalBibtexFields.updateTimeStampField(Globals.prefs.getTimestampPreferences().getTimestampField()); - // Update which fields should be treated as numeric, based on preferences: - InternalBibtexFields.setNumericFields(Globals.prefs.getStringList(JabRefPreferences.NUMERIC_FIELDS)); - - // Read list(s) of journal names and abbreviations - Globals.journalAbbreviationLoader = new JournalAbbreviationLoader(); - - /* Build list of Import and Export formats */ - Globals.IMPORT_FORMAT_READER.resetImportFormats(Globals.prefs.getImportFormatPreferences(), - Globals.prefs.getXMPPreferences(), Globals.getFileUpdateMonitor()); - EntryTypes.loadCustomEntryTypes(preferences.loadCustomEntryTypes(BibDatabaseMode.BIBTEX), - preferences.loadCustomEntryTypes(BibDatabaseMode.BIBLATEX)); - Globals.exportFactory = Globals.prefs.getExporterFactory(Globals.journalAbbreviationLoader); - - // Initialize protected terms loader - Globals.protectedTermsLoader = new ProtectedTermsLoader(Globals.prefs.getProtectedTermsPreferences()); + applyPreferences(preferences); // Process arguments ArgumentProcessor argumentProcessor = new ArgumentProcessor(args, ArgumentProcessor.Mode.INITIAL_START); // Check for running JabRef + if (!allowMultipleAppInstances(args)) { + return; + } + + // See if we should shut down now + if (argumentProcessor.shouldShutDown()) { + Globals.shutdownThreadPools(); + Platform.exit(); + return; + } + + // If not, start GUI + SwingUtilities + .invokeLater(() -> new JabRefGUI(argumentProcessor.getParserResults(), argumentProcessor.isBlank())); + } + + private static boolean allowMultipleAppInstances(String[] args) { RemotePreferences remotePreferences = Globals.prefs.getRemotePreferences(); if (remotePreferences.useRemoteServer()) { Globals.REMOTE_LISTENER.open(new JabRefMessageHandler(), remotePreferences.getPort()); @@ -154,27 +148,46 @@ private static void start(String[] args) { Globals.shutdownThreadPools(); // needed to tell JavaFx to stop Platform.exit(); - return; + return false; } } // we are alone, we start the server Globals.REMOTE_LISTENER.start(); } + return true; + } + + private static void applyPreferences(JabRefPreferences preferences) { + // Update handling of special fields based on preferences + InternalBibtexFields.updateSpecialFields(Globals.prefs.getBoolean(JabRefPreferences.SERIALIZESPECIALFIELDS)); + // Update name of the time stamp field based on preferences + InternalBibtexFields.updateTimeStampField(Globals.prefs.getTimestampPreferences().getTimestampField()); + // Update which fields should be treated as numeric, based on preferences: + InternalBibtexFields.setNumericFields(Globals.prefs.getStringList(JabRefPreferences.NUMERIC_FIELDS)); + + // Read list(s) of journal names and abbreviations + Globals.journalAbbreviationLoader = new JournalAbbreviationLoader(); + + /* Build list of Import and Export formats */ + Globals.IMPORT_FORMAT_READER.resetImportFormats(Globals.prefs.getImportFormatPreferences(), + Globals.prefs.getXMPPreferences(), Globals.getFileUpdateMonitor()); + EntryTypes.loadCustomEntryTypes(preferences.loadCustomEntryTypes(BibDatabaseMode.BIBTEX), + preferences.loadCustomEntryTypes(BibDatabaseMode.BIBLATEX)); + Globals.exportFactory = Globals.prefs.getExporterFactory(Globals.journalAbbreviationLoader); + + // Initialize protected terms loader + Globals.protectedTermsLoader = new ProtectedTermsLoader(Globals.prefs.getProtectedTermsPreferences()); // override used newline character with the one stored in the preferences // The preferences return the system newline character sequence as default OS.NEWLINE = Globals.prefs.get(JabRefPreferences.NEWLINE); + } - // See if we should shut down now - if (argumentProcessor.shouldShutDown()) { - Globals.shutdownThreadPools(); - Platform.exit(); - return; + private static void configureProxy(ProxyPreferences proxyPreferences) { + ProxyRegisterer.register(proxyPreferences); + if (proxyPreferences.isUseProxy() && proxyPreferences.isUseAuthentication()) { + Authenticator.setDefault(new ProxyAuthenticator()); } - - // If not, start GUI - SwingUtilities - .invokeLater(() -> new JabRefGUI(argumentProcessor.getParserResults(), argumentProcessor.isBlank())); } /** From ad8d3f07bd6ff4fd6ee34f9669623e00c621a8e5 Mon Sep 17 00:00:00 2001 From: Stefan Kolb Date: Fri, 25 May 2018 09:28:02 +0200 Subject: [PATCH 25/33] Move migrations to PreferencesMigrations --- src/main/java/org/jabref/JabRefMain.java | 17 +-------- .../migrations/PreferencesMigrations.java | 38 ++++++++++++------- 2 files changed, 25 insertions(+), 30 deletions(-) diff --git a/src/main/java/org/jabref/JabRefMain.java b/src/main/java/org/jabref/JabRefMain.java index 2f3e152e8cc..8eeda32c3d4 100644 --- a/src/main/java/org/jabref/JabRefMain.java +++ b/src/main/java/org/jabref/JabRefMain.java @@ -106,7 +106,7 @@ private static void start(String[] args) { final JabRefPreferences preferences = JabRefPreferences.getInstance(); Globals.prefs = preferences; // Perform migrations - migratePreferences(); + PreferencesMigrations.runMigrations(); configureProxy(preferences.getProxyPreferences()); @@ -189,19 +189,4 @@ private static void configureProxy(ProxyPreferences proxyPreferences) { Authenticator.setDefault(new ProxyAuthenticator()); } } - - /** - * Perform checks and changes for users with a preference set from an older JabRef version. - */ - private static void migratePreferences() { - PreferencesMigrations.upgradePrefsToOrgJabRef(); - PreferencesMigrations.upgradeSortOrder(); - PreferencesMigrations.upgradeFaultyEncodingStrings(); - PreferencesMigrations.upgradeLabelPatternToBibtexKeyPattern(); - PreferencesMigrations.upgradeImportFileAndDirePatterns(); - PreferencesMigrations.upgradeStoredCustomEntryTypes(); - PreferencesMigrations.upgradeKeyBindingsToJavaFX(); - PreferencesMigrations.addCrossRefRelatedFieldsForAutoComplete(); - PreferencesMigrations.upgradeObsoleteLookAndFeels(); - } } diff --git a/src/main/java/org/jabref/migrations/PreferencesMigrations.java b/src/main/java/org/jabref/migrations/PreferencesMigrations.java index e21a0fab82a..c3768f51cdd 100644 --- a/src/main/java/org/jabref/migrations/PreferencesMigrations.java +++ b/src/main/java/org/jabref/migrations/PreferencesMigrations.java @@ -22,17 +22,30 @@ import org.slf4j.LoggerFactory; public class PreferencesMigrations { - private static final Logger LOGGER = LoggerFactory.getLogger(PreferencesMigrations.class); private PreferencesMigrations() { } /** - * Migrate all preferences from net/sf/jabref to org/jabref + * Perform checks and changes for users with a preference set from an older JabRef version. */ - public static void upgradePrefsToOrgJabRef() { + public static void runMigrations() { + upgradePrefsToOrgJabRef(); + upgradeSortOrder(); + upgradeFaultyEncodingStrings(); + upgradeLabelPatternToBibtexKeyPattern(); + upgradeImportFileAndDirePatterns(); + upgradeStoredCustomEntryTypes(); + upgradeKeyBindingsToJavaFX(); + addCrossRefRelatedFieldsForAutoComplete(); + upgradeObsoleteLookAndFeels(); + } + /** + * Migrate all preferences from net/sf/jabref to org/jabref + */ + private static void upgradePrefsToOrgJabRef() { JabRefPreferences prefs = Globals.prefs; Preferences mainPrefsNode = Preferences.userNodeForPackage(JabRefMain.class); try { @@ -69,7 +82,7 @@ private static void copyPrefsRecursively(Preferences from, Preferences to) throw /** * Added from Jabref 2.11 beta 4 onwards to fix wrong encoding names */ - public static void upgradeFaultyEncodingStrings() { + private static void upgradeFaultyEncodingStrings() { JabRefPreferences prefs = Globals.prefs; String defaultEncoding = prefs.get(JabRefPreferences.DEFAULT_ENCODING); if (defaultEncoding == null) { @@ -110,7 +123,7 @@ public static void upgradeFaultyEncodingStrings() { * these preferences, but it is only used when the new preference does not * exist */ - public static void upgradeSortOrder() { + private static void upgradeSortOrder() { JabRefPreferences prefs = Globals.prefs; if (prefs.get(JabRefPreferences.EXPORT_IN_SPECIFIED_ORDER, null) == null) { @@ -138,8 +151,7 @@ public static void upgradeSortOrder() { /** * Migrate all customized entry types from versions <=3.7 */ - public static void upgradeStoredCustomEntryTypes() { - + private static void upgradeStoredCustomEntryTypes() { JabRefPreferences prefs = Globals.prefs; Preferences mainPrefsNode = Preferences.userNodeForPackage(JabRefMain.class); @@ -159,8 +171,7 @@ public static void upgradeStoredCustomEntryTypes() { /** * Migrate LabelPattern configuration from versions <=3.5 to new BibtexKeyPatterns */ - public static void upgradeLabelPatternToBibtexKeyPattern() { - + private static void upgradeLabelPatternToBibtexKeyPattern() { JabRefPreferences prefs = Globals.prefs; try { @@ -223,7 +234,7 @@ private static void migrateFileImportPattern(String oldStylePattern, String newS } } - public static void upgradeImportFileAndDirePatterns() { + private static void upgradeImportFileAndDirePatterns() { JabRefPreferences prefs = Globals.prefs; Preferences mainPrefsNode = Preferences.userNodeForPackage(JabRefMain.class); @@ -244,7 +255,7 @@ public static void upgradeImportFileAndDirePatterns() { // the user defined old-style patterns, and the default pattern is "". } - public static void upgradeKeyBindingsToJavaFX() { + private static void upgradeKeyBindingsToJavaFX() { UnaryOperator replaceKeys = (str) -> { String result = str.replace("ctrl ", "ctrl+"); result = result.replace("shift ", "shift+"); @@ -261,7 +272,7 @@ public static void upgradeKeyBindingsToJavaFX() { } - public static void addCrossRefRelatedFieldsForAutoComplete() { + private static void addCrossRefRelatedFieldsForAutoComplete() { JabRefPreferences prefs = Globals.prefs; //LinkedHashSet because we want to retain the order and add new fields to the end Set keys = new LinkedHashSet<>(prefs.getStringList(JabRefPreferences.AUTOCOMPLETER_COMPLETE_FIELDS)); @@ -283,7 +294,7 @@ private static void migrateTypedKeyPrefs(JabRefPreferences prefs, Preferences ol prefs.putKeyPattern(keyPattern); } - public static void upgradeObsoleteLookAndFeels() { + private static void upgradeObsoleteLookAndFeels() { JabRefPreferences prefs = Globals.prefs; String currentLandF = prefs.get(JabRefPreferences.WIN_LOOK_AND_FEEL); @@ -304,5 +315,4 @@ public static void upgradeObsoleteLookAndFeels() { } }); } - } From 9181257291db13a9f53439d08f5a11446f3d35d8 Mon Sep 17 00:00:00 2001 From: Stefan Kolb Date: Fri, 25 May 2018 09:37:00 +0200 Subject: [PATCH 26/33] Shutdown duplicate code --- src/main/java/org/jabref/JabRefMain.java | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/jabref/JabRefMain.java b/src/main/java/org/jabref/JabRefMain.java index 8eeda32c3d4..4654655e860 100644 --- a/src/main/java/org/jabref/JabRefMain.java +++ b/src/main/java/org/jabref/JabRefMain.java @@ -118,14 +118,8 @@ private static void start(String[] args) { ArgumentProcessor argumentProcessor = new ArgumentProcessor(args, ArgumentProcessor.Mode.INITIAL_START); // Check for running JabRef - if (!allowMultipleAppInstances(args)) { - return; - } - - // See if we should shut down now - if (argumentProcessor.shouldShutDown()) { - Globals.shutdownThreadPools(); - Platform.exit(); + if (!handleMultipleAppInstances(args) || argumentProcessor.shouldShutDown()) { + shutdownCurrentInstance(); return; } @@ -134,7 +128,7 @@ private static void start(String[] args) { .invokeLater(() -> new JabRefGUI(argumentProcessor.getParserResults(), argumentProcessor.isBlank())); } - private static boolean allowMultipleAppInstances(String[] args) { + private static boolean handleMultipleAppInstances(String[] args) { RemotePreferences remotePreferences = Globals.prefs.getRemotePreferences(); if (remotePreferences.useRemoteServer()) { Globals.REMOTE_LISTENER.open(new JabRefMessageHandler(), remotePreferences.getPort()); @@ -145,9 +139,6 @@ private static boolean allowMultipleAppInstances(String[] args) { // We have successfully sent our command line options through the socket to another JabRef instance. // So we assume it's all taken care of, and quit. LOGGER.info(Localization.lang("Arguments passed on to running JabRef instance. Shutting down.")); - Globals.shutdownThreadPools(); - // needed to tell JavaFx to stop - Platform.exit(); return false; } } @@ -157,6 +148,12 @@ private static boolean allowMultipleAppInstances(String[] args) { return true; } + private static void shutdownCurrentInstance() { + Globals.shutdownThreadPools(); + // needed to tell JavaFx to stop + Platform.exit(); + } + private static void applyPreferences(JabRefPreferences preferences) { // Update handling of special fields based on preferences InternalBibtexFields.updateSpecialFields(Globals.prefs.getBoolean(JabRefPreferences.SERIALIZESPECIALFIELDS)); From 0776ac25d22297376932a758f4894be0f2aa3965 Mon Sep 17 00:00:00 2001 From: Stefan Kolb Date: Fri, 25 May 2018 09:41:15 +0200 Subject: [PATCH 27/33] Package private for tests --- src/main/java/org/jabref/migrations/PreferencesMigrations.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/jabref/migrations/PreferencesMigrations.java b/src/main/java/org/jabref/migrations/PreferencesMigrations.java index c3768f51cdd..736cde821ec 100644 --- a/src/main/java/org/jabref/migrations/PreferencesMigrations.java +++ b/src/main/java/org/jabref/migrations/PreferencesMigrations.java @@ -234,7 +234,7 @@ private static void migrateFileImportPattern(String oldStylePattern, String newS } } - private static void upgradeImportFileAndDirePatterns() { + static void upgradeImportFileAndDirePatterns() { JabRefPreferences prefs = Globals.prefs; Preferences mainPrefsNode = Preferences.userNodeForPackage(JabRefMain.class); From b029c720de291c948d6bf6a71a6cbdab04f5098f Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Fri, 25 May 2018 11:03:35 +0200 Subject: [PATCH 28/33] Add NormalizeEnDashesFormatter (#4045) * Add NormalizeEnDashesFormatter * Adapt to new Formatter hiearchy * Add missing localization keys --- CHANGELOG.md | 1 + .../jabref/logic/formatter/Formatters.java | 2 + .../NormalizeEnDashesFormatter.java | 32 +++++++++++ src/main/resources/l10n/JabRef_en.properties | 2 + .../NormalizeEnDashesFormatterTest.java | 54 +++++++++++++++++++ 5 files changed, 91 insertions(+) create mode 100644 src/main/java/org/jabref/logic/formatter/bibtexfields/NormalizeEnDashesFormatter.java create mode 100644 src/test/java/org/jabref/logic/formatter/bibtexfields/NormalizeEnDashesFormatterTest.java diff --git a/CHANGELOG.md b/CHANGELOG.md index d3334684a00..f0e79b3220b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# - We added a fetcher based on RFC-IDs. [#3971](https://github.com/JabRef/jabref/issues/3971) - We changed the implementation of the `[shorttitle]` key pattern. It now removes small words like `a`, `an`, `on`, `the` etc. Refer to the help page for a complete overview. [Feature request in the forum](http://discourse.jabref.org/t/jabref-differences-in-shorttitle-between-versions-3-8-1-and-4-not-discounting-the-a-an-of-in-titles/1147) - We added a formatter for adding braces around the `title` field. E.g., `title = {ExamPle}` becomes `title = {{ExamPle}}`, which prevents BibTeX to convert it to lower case. You can use it at the [cleanup entries](http://help.jabref.org/en/CleanupEntries) functionality. +- We added a formatter to ensure correct en dashes in the `title` field. E.g., `title = {Example - illustrative}` becomes `title = {Example -- illustrative}`. - We streamlined the defaults for a [cleanup of entries](http://help.jabref.org/en/CleanupEntries) in the case of BibTeX. ### Fixed diff --git a/src/main/java/org/jabref/logic/formatter/Formatters.java b/src/main/java/org/jabref/logic/formatter/Formatters.java index 2d9f8b615a1..918f5f77fa4 100644 --- a/src/main/java/org/jabref/logic/formatter/Formatters.java +++ b/src/main/java/org/jabref/logic/formatter/Formatters.java @@ -13,6 +13,7 @@ import org.jabref.logic.formatter.bibtexfields.HtmlToUnicodeFormatter; import org.jabref.logic.formatter.bibtexfields.LatexCleanupFormatter; import org.jabref.logic.formatter.bibtexfields.NormalizeDateFormatter; +import org.jabref.logic.formatter.bibtexfields.NormalizeEnDashesFormatter; import org.jabref.logic.formatter.bibtexfields.NormalizeMonthFormatter; import org.jabref.logic.formatter.bibtexfields.NormalizeNamesFormatter; import org.jabref.logic.formatter.bibtexfields.NormalizePagesFormatter; @@ -53,6 +54,7 @@ public class Formatters { new LatexCleanupFormatter(), new MinifyNameListFormatter(), new NormalizeDateFormatter(), + new NormalizeEnDashesFormatter(), new NormalizeMonthFormatter(), new NormalizeNamesFormatter(), new NormalizePagesFormatter(), diff --git a/src/main/java/org/jabref/logic/formatter/bibtexfields/NormalizeEnDashesFormatter.java b/src/main/java/org/jabref/logic/formatter/bibtexfields/NormalizeEnDashesFormatter.java new file mode 100644 index 00000000000..cb50cc6a10d --- /dev/null +++ b/src/main/java/org/jabref/logic/formatter/bibtexfields/NormalizeEnDashesFormatter.java @@ -0,0 +1,32 @@ +package org.jabref.logic.formatter.bibtexfields; + +import org.jabref.logic.l10n.Localization; +import org.jabref.model.cleanup.Formatter; + +public class NormalizeEnDashesFormatter extends Formatter { + + @Override + public String getName() { + return Localization.lang("Normalize en dashes"); + } + + @Override + public String getKey() { + return "normalize_en_dashes"; + } + + @Override + public String format(String value) { + return value.replaceAll(" - ", " -- "); + } + + @Override + public String getDescription() { + return Localization.lang("Normalizes the en dashes."); + } + + @Override + public String getExampleInput() { + return "Winery - A Modeling Tool for TOSCA-based Cloud Applications"; + } +} diff --git a/src/main/resources/l10n/JabRef_en.properties b/src/main/resources/l10n/JabRef_en.properties index e4500956deb..159f4f4a85b 100644 --- a/src/main/resources/l10n/JabRef_en.properties +++ b/src/main/resources/l10n/JabRef_en.properties @@ -1957,6 +1957,7 @@ LaTeX\ to\ Unicode=LaTeX to Unicode Lower\ case=Lower case Minify\ list\ of\ person\ names=Minify list of person names Normalize\ date=Normalize date +Normalize\ en\ dashes=Normalize en dashes Normalize\ month=Normalize month Normalize\ month\ to\ BibTeX\ standard\ abbreviation.=Normalize month to BibTeX standard abbreviation. Normalize\ names\ of\ persons=Normalize names of persons @@ -1964,6 +1965,7 @@ Normalize\ page\ numbers=Normalize page numbers Normalize\ pages\ to\ BibTeX\ standard.=Normalize pages to BibTeX standard. Normalizes\ lists\ of\ persons\ to\ the\ BibTeX\ standard.=Normalizes lists of persons to the BibTeX standard. Normalizes\ the\ date\ to\ ISO\ date\ format.=Normalizes the date to ISO date format. +Normalizes\ the\ en\ dashes.=Normalizes the en dashes. Ordinals\ to\ LaTeX\ superscript=Ordinals to LaTeX superscript Protect\ terms=Protect terms Add\ enclosing\ braces=Add enclosing braces diff --git a/src/test/java/org/jabref/logic/formatter/bibtexfields/NormalizeEnDashesFormatterTest.java b/src/test/java/org/jabref/logic/formatter/bibtexfields/NormalizeEnDashesFormatterTest.java new file mode 100644 index 00000000000..ace49c02398 --- /dev/null +++ b/src/test/java/org/jabref/logic/formatter/bibtexfields/NormalizeEnDashesFormatterTest.java @@ -0,0 +1,54 @@ +package org.jabref.logic.formatter.bibtexfields; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +/** + * Tests in addition to the general tests from {@link org.jabref.logic.formatter.FormatterTest} + */ +public class NormalizeEnDashesFormatterTest { + + private NormalizeEnDashesFormatter formatter; + + @BeforeEach + public void setUp() { + formatter = new NormalizeEnDashesFormatter(); + } + + @Test + public void formatExample() { + assertEquals("Winery -- A Modeling Tool for TOSCA-based Cloud Applications", formatter.format(formatter.getExampleInput())); + } + + @Test + public void formatExampleOfChangelog() { + assertEquals("Example -- illustrative", formatter.format("Example - illustrative")); + } + + @Test + public void dashesWithinWordsAreKept() { + assertEquals("Example-illustrative", formatter.format("Example-illustrative")); + } + + @Test + public void dashesPreceededByASpaceAreKept() { + assertEquals("Example -illustrative", formatter.format("Example -illustrative")); + } + + @Test + public void dashesFollowedByASpaceAreKept() { + assertEquals("Example- illustrative", formatter.format("Example- illustrative")); + } + + @Test + public void dashAtTheBeginningIsKept() { + assertEquals("- illustrative", formatter.format("- illustrative")); + } + + @Test + public void dashAtTheEndIsKept() { + assertEquals("Example-", formatter.format("Example-")); + } +} From 8022d0d413ff01f99288a40c1f44117d89a39c34 Mon Sep 17 00:00:00 2001 From: Patrick Scheibe Date: Fri, 25 May 2018 14:36:45 +0200 Subject: [PATCH 29/33] Fix #4041 to make Push to Application work again on OSX. (#4057) For unknown reasons, it seems no longer possible to give the command as one single string. I created a test class and not even simple commands can be executed. I'm not sure when this changed but giving the command as list of each argument works as expected. --- .../jabref/gui/push/AbstractPushToApplication.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/jabref/gui/push/AbstractPushToApplication.java b/src/main/java/org/jabref/gui/push/AbstractPushToApplication.java index b901293c849..affc05c410f 100644 --- a/src/main/java/org/jabref/gui/push/AbstractPushToApplication.java +++ b/src/main/java/org/jabref/gui/push/AbstractPushToApplication.java @@ -71,7 +71,19 @@ public void pushEntries(BibDatabase database, List entries, String key try { if (OS.OS_X) { String[] commands = getCommandLine(keyString); - ProcessBuilder processBuilder = new ProcessBuilder("open -a " + commands[0] + " -n --args " + commands[1] + " " + commands[2]); + if (commands.length < 3) { + LOGGER.error("Commandline does not contain enough parameters to \"push to application\""); + return; + } + ProcessBuilder processBuilder = new ProcessBuilder( + "open", + "-a", + commands[0], + "-n", + "--args", + commands[1], + commands[2] + ); processBuilder.start(); } else { ProcessBuilder processBuilder = new ProcessBuilder(getCommandLine(keyString)); From ccadfc1ba2ab81d2b5bcc46834f0664dba1a8583 Mon Sep 17 00:00:00 2001 From: Stefan Kolb Date: Fri, 25 May 2018 15:17:19 +0200 Subject: [PATCH 30/33] macOs push to application fix --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f0e79b3220b..d6bda1eb768 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# - We fixed an issue where JabRef would no longer start, when the option "Override default font settings" was activated. [#3986](https://github.com/JabRef/jabref/issues/3986) - We fixed an issue where JabRef removed whitespace from the Title-fetcher which resulting in no entries being found. [#4014](https://github.com/JabRef/jabref/issues/4014) - We fixed an issue where fetched entries from the ACM fetcher could not be imported. [#4018](https://github.com/JabRef/jabref/issues/4018) +- We fixed an issue to enable push to application on macOs again [#4041](https://github.com/JabRef/jabref/issues/4041) ### Removed - We removed the GTK Look and Feel from the Options, as it leads to freezes in JabRef on MacOSX and Linux [#3995](https://github.com/JabRef/jabref/issues/3995). From 5e629b2b4d65f7829397435ce0cb460ff9313334 Mon Sep 17 00:00:00 2001 From: Stefan Kolb Date: Fri, 25 May 2018 16:30:22 +0200 Subject: [PATCH 31/33] Enable tests --- .../logic/bibtexkeypattern/BibtexKeyGeneratorTest.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/test/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGeneratorTest.java b/src/test/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGeneratorTest.java index 9fe07661d70..17134b98dc8 100644 --- a/src/test/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGeneratorTest.java +++ b/src/test/java/org/jabref/logic/bibtexkeypattern/BibtexKeyGeneratorTest.java @@ -301,6 +301,7 @@ public void testFirstAuthor() { assertEquals("", BibtexKeyGenerator.firstAuthor("")); } + @Test public void testFirstAuthorNull() { assertThrows(NullPointerException.class, () -> BibtexKeyGenerator.firstAuthor(null)); } @@ -424,6 +425,7 @@ public void testAuthIniN() { assertEquals("Newton", BibtexKeyGenerator.authIniN(AUTHOR_STRING_FIRSTNAME_INITIAL_LASTNAME_FULL_COUNT_1, 7)); } + @Test public void testAuthIniNNull() { assertThrows(NullPointerException.class, () -> BibtexKeyGenerator.authIniN(null, 3)); } @@ -514,6 +516,7 @@ public void authNM() { assertEquals("", BibtexKeyGenerator.authNofMth("", 2, 4)); } + @Test public void authNMThrowsNPE() { assertThrows(NullPointerException.class, () -> BibtexKeyGenerator.authNofMth(null, 2, 4)); } @@ -709,6 +712,7 @@ public void testPagePrefix() { assertEquals("", BibtexKeyGenerator.pagePrefix("43+")); } + @Test public void testPagePrefixNull() { assertThrows(NullPointerException.class, () -> BibtexKeyGenerator.pagePrefix(null)); } @@ -725,6 +729,7 @@ public void testLastPage() { assertEquals("43", BibtexKeyGenerator.lastPage("43+")); } + @Test public void testLastPageNull() { assertThrows(NullPointerException.class, () -> BibtexKeyGenerator.lastPage(null)); } From 787902ca13e8b13caa0561f2592d8a8f00dc0347 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Sat, 26 May 2018 20:29:40 +0200 Subject: [PATCH 32/33] Add date checker (#4007) * Add date checker * Fix changelog * Add for more date fields * Add more tests for parsing dates * Update CHANGELOG.md --- CHANGELOG.md | 1 + .../jabref/logic/integrity/DateChecker.java | 24 +++++++++++++++ .../jabref/logic/integrity/FieldCheckers.java | 7 +++++ .../java/org/jabref/model/entry/Date.java | 12 ++++++-- .../logic/integrity/DateCheckerTest.java | 28 ++++++++++++++++++ .../java/org/jabref/model/entry/DateTest.java | 29 ++++++++++++++++--- 6 files changed, 95 insertions(+), 6 deletions(-) create mode 100644 src/main/java/org/jabref/logic/integrity/DateChecker.java create mode 100644 src/test/java/org/jabref/logic/integrity/DateCheckerTest.java diff --git a/CHANGELOG.md b/CHANGELOG.md index d6bda1eb768..4f51a43499f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# ## [Unreleased] ### Changed +- We added a validity check for dates in the `date` and `urldate` fields. - We added a text file export for 'Find Unlinked Files'. [#3341](https://github.com/JabRef/jabref/issues/3341) - We added a fetcher based on RFC-IDs. [#3971](https://github.com/JabRef/jabref/issues/3971) - We changed the implementation of the `[shorttitle]` key pattern. It now removes small words like `a`, `an`, `on`, `the` etc. Refer to the help page for a complete overview. [Feature request in the forum](http://discourse.jabref.org/t/jabref-differences-in-shorttitle-between-versions-3-8-1-and-4-not-discounting-the-a-an-of-in-titles/1147) diff --git a/src/main/java/org/jabref/logic/integrity/DateChecker.java b/src/main/java/org/jabref/logic/integrity/DateChecker.java new file mode 100644 index 00000000000..83f0077b8aa --- /dev/null +++ b/src/main/java/org/jabref/logic/integrity/DateChecker.java @@ -0,0 +1,24 @@ +package org.jabref.logic.integrity; + +import java.util.Optional; + +import org.jabref.logic.l10n.Localization; +import org.jabref.model.entry.Date; +import org.jabref.model.strings.StringUtil; + +public class DateChecker implements ValueChecker { + + @Override + public Optional checkValue(String value) { + if (StringUtil.isBlank(value)) { + return Optional.empty(); + } + + Optional parsedDate = Date.parse(value); + if (!parsedDate.isPresent()) { + return Optional.of(Localization.lang("incorrect format")); + } + + return Optional.empty(); + } +} diff --git a/src/main/java/org/jabref/logic/integrity/FieldCheckers.java b/src/main/java/org/jabref/logic/integrity/FieldCheckers.java index 4358d4729a5..79cca452b11 100644 --- a/src/main/java/org/jabref/logic/integrity/FieldCheckers.java +++ b/src/main/java/org/jabref/logic/integrity/FieldCheckers.java @@ -50,6 +50,13 @@ private static Multimap getAllMap(BibDatabaseContext datab fieldCheckers.put(FieldName.YEAR, new YearChecker()); fieldCheckers.put(FieldName.KEY, new ValidBibtexKeyChecker(enforceLegalKey)); + if (databaseContext.isBiblatexMode()) { + fieldCheckers.put(FieldName.DATE, new DateChecker()); + fieldCheckers.put(FieldName.URLDATE, new DateChecker()); + fieldCheckers.put(FieldName.EVENTDATE, new DateChecker()); + fieldCheckers.put(FieldName.ORIGDATE, new DateChecker()); + } + return fieldCheckers; } diff --git a/src/main/java/org/jabref/model/entry/Date.java b/src/main/java/org/jabref/model/entry/Date.java index fb558155984..b1655ad7c17 100644 --- a/src/main/java/org/jabref/model/entry/Date.java +++ b/src/main/java/org/jabref/model/entry/Date.java @@ -44,9 +44,17 @@ public Date(TemporalAccessor date) { */ public static Optional parse(String dateString) { Objects.requireNonNull(dateString); - List formatStrings = Arrays.asList("uuuu-M-d", "uuuu-M", "d-M-uuuu", "M/uu", "M/uuuu", "MMMM d, uuuu", + List formatStrings = Arrays.asList( + "uuuu-M-d", + "uuuu-M", + "d-M-uuuu", + "M-uuuu", + "M/uu", + "M/uuuu", + "MMMM d, uuuu", "MMMM, uuuu", - "d.M.uuuu", "uuuu.M.d", "uuuu"); + "d.M.uuuu", + "uuuu.M.d", "uuuu"); for (String formatString : formatStrings) { try { diff --git a/src/test/java/org/jabref/logic/integrity/DateCheckerTest.java b/src/test/java/org/jabref/logic/integrity/DateCheckerTest.java new file mode 100644 index 00000000000..21cf8306ef4 --- /dev/null +++ b/src/test/java/org/jabref/logic/integrity/DateCheckerTest.java @@ -0,0 +1,28 @@ +package org.jabref.logic.integrity; + +import java.util.Optional; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +class DateCheckerTest { + + private DateChecker checker; + + @BeforeEach + void setUp() { + checker = new DateChecker(); + } + + @Test + void complainsAboutInvalidIsoLikeDate() { + assertEquals(Optional.of("incorrect format"), checker.checkValue("2018-04-21TZ")); + } + + @Test + void acceptsValidIsoDate() { + assertEquals(Optional.empty(), checker.checkValue("2018-04-21")); + } +} diff --git a/src/test/java/org/jabref/model/entry/DateTest.java b/src/test/java/org/jabref/model/entry/DateTest.java index 3234ea84280..3e8ba6127e7 100644 --- a/src/test/java/org/jabref/model/entry/DateTest.java +++ b/src/test/java/org/jabref/model/entry/DateTest.java @@ -1,6 +1,8 @@ package org.jabref.model.entry; import java.time.LocalDate; +import java.time.Year; +import java.time.YearMonth; import java.util.Optional; import org.junit.jupiter.api.Test; @@ -8,15 +10,34 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; -public class DateTest { +class DateTest { @Test - public void parseCorrectlyDayMonthYearDate() throws Exception { + void parseCorrectlyDayMonthYearDate() throws Exception { Date expected = new Date(LocalDate.of(2014, 6, 19)); assertEquals(Optional.of(expected), Date.parse("19-06-2014")); } - public void parseDateNull() { - assertThrows(NullPointerException.class, () -> assertEquals(Optional.empty(), Date.parse(null))); + @Test + void parseCorrectlyMonthYearDate() throws Exception { + Date expected = new Date(YearMonth.of(2014, 6)); + assertEquals(Optional.of(expected), Date.parse("06-2014")); + } + + @Test + void parseCorrectlyYearMonthDate() throws Exception { + Date expected = new Date(YearMonth.of(2014, 6)); + assertEquals(Optional.of(expected), Date.parse("2014-06")); + } + + @Test + void parseCorrectlyYearDate() throws Exception { + Date expected = new Date(Year.of(2014)); + assertEquals(Optional.of(expected), Date.parse("2014")); + } + + @Test + void parseDateNull() { + assertThrows(NullPointerException.class, () -> Date.parse(null)); } } From d2ddf938092bfd226f73cb63a61494a1d2dccec6 Mon Sep 17 00:00:00 2001 From: Christoph Date: Sun, 27 May 2018 17:20:55 +0200 Subject: [PATCH 33/33] Import inspection uses now same font size setttings as maintable (#4062) * Set import inspection table row size to the same size as the maintable * add changelog --- CHANGELOG.md | 1 + .../org/jabref/gui/importer/ImportInspectionDialog.java | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f51a43499f..5d310d4abb2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `# - We added a formatter for adding braces around the `title` field. E.g., `title = {ExamPle}` becomes `title = {{ExamPle}}`, which prevents BibTeX to convert it to lower case. You can use it at the [cleanup entries](http://help.jabref.org/en/CleanupEntries) functionality. - We added a formatter to ensure correct en dashes in the `title` field. E.g., `title = {Example - illustrative}` becomes `title = {Example -- illustrative}`. - We streamlined the defaults for a [cleanup of entries](http://help.jabref.org/en/CleanupEntries) in the case of BibTeX. +- The import inspection window now uses the same font size setting as the maintable [Feature request in the forum](http://discourse.jabref.org/t/inspection-window-and-others-line-height-of-table-too-small-for-fonts/1168) ### Fixed - We fixed an issue where the export to clipboard functionality could not be invoked. [#3994](https://github.com/JabRef/jabref/issues/3994) diff --git a/src/main/java/org/jabref/gui/importer/ImportInspectionDialog.java b/src/main/java/org/jabref/gui/importer/ImportInspectionDialog.java index 882067c44c8..f6a289752c3 100644 --- a/src/main/java/org/jabref/gui/importer/ImportInspectionDialog.java +++ b/src/main/java/org/jabref/gui/importer/ImportInspectionDialog.java @@ -1358,6 +1358,12 @@ class EntryTable extends JTable { public EntryTable(TableModel model) { super(model); getTableHeader().setReorderingAllowed(false); + + setFont(GUIGlobals.currentFont); + int maxOfIconsAndFontSize = Math.max(GUIGlobals.currentFont.getSize(), Globals.prefs.getInt(JabRefPreferences.ICON_SIZE_SMALL)); + setRowHeight(Globals.prefs.getInt(JabRefPreferences.TABLE_ROW_PADDING) + maxOfIconsAndFontSize); + // Update Table header with new settings + this.getTableHeader().resizeAndRepaint(); } @Override