From b10f941e8c3108c101eb023b491ed81af7961ed5 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Fri, 11 May 2018 11:22:58 +0200 Subject: [PATCH 001/130] 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 002/130] 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 1c2a5fb288832fa032d805662952462b9463c667 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Fri, 11 May 2018 22:43:29 +0200 Subject: [PATCH 003/130] Fix formatting --- src/main/java/org/jabref/gui/PreambleEditor.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/jabref/gui/PreambleEditor.java b/src/main/java/org/jabref/gui/PreambleEditor.java index 821b46088dd..d28cb2c69c7 100644 --- a/src/main/java/org/jabref/gui/PreambleEditor.java +++ b/src/main/java/org/jabref/gui/PreambleEditor.java @@ -29,23 +29,23 @@ public void execute() { DialogPane pane = new DialogPane(); editor.setText(frame.getCurrentBasePanel() - .getDatabase() - .getPreamble() - .orElse("")); + .getDatabase() + .getPreamble() + .orElse("")); pane.setContent(editor); Optional pressedButton = frame.getDialogService().showCustomDialogAndWait(Localization.lang("Edit Preamble"), pane, ButtonType.APPLY, ButtonType.CANCEL); if (pressedButton.isPresent() && pressedButton.get().equals(ButtonType.APPLY)) { - String toSet = editor.getText(); + String newPreamble = editor.getText(); // We check if the field has changed, since we don't want to mark the // base as changed unless we have a real change. - if (!database.getPreamble().orElse("").equals(toSet)) { + if (!database.getPreamble().orElse("").equals(newPreamble)) { panel.getUndoManager().addEdit( - new UndoablePreambleChange(database, database.getPreamble().orElse(null), toSet)); - database.setPreamble(toSet); + new UndoablePreambleChange(database, database.getPreamble().orElse(null), newPreamble)); + database.setPreamble(newPreamble); panel.markBaseChanged(); } From fe5a3050bc61dda83f4d6a79bbbaa599c37c433a Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Fri, 11 May 2018 22:49:59 +0200 Subject: [PATCH 004/130] Fix formatting --- src/main/java/org/jabref/gui/PreviewPanel.java | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/jabref/gui/PreviewPanel.java b/src/main/java/org/jabref/gui/PreviewPanel.java index d2b1fd8c118..f83f023b011 100644 --- a/src/main/java/org/jabref/gui/PreviewPanel.java +++ b/src/main/java/org/jabref/gui/PreviewPanel.java @@ -69,8 +69,6 @@ public class PreviewPanel extends ScrollPane implements SearchQueryHighlightList /** * @param panel (may be null) Only set this if the preview is associated to the main window. * @param databaseContext (may be null) Used for resolving pdf directories for links. - * @param preferences - * @param dialogService */ public PreviewPanel(BasePanel panel, BibDatabaseContext databaseContext, KeyBindingRepository keyBindingRepository, PreviewPreferences preferences, DialogService dialogService) { this.databaseContext = Optional.ofNullable(databaseContext); @@ -106,7 +104,7 @@ public PreviewPanel(BasePanel panel, BibDatabaseContext databaseContext, KeyBind private void createKeyBindings() { addEventFilter(KeyEvent.KEY_PRESSED, event -> { - Optional keyBinding = Globals.getKeyPrefs().mapToKeyBinding(event); + Optional keyBinding = keyBindingRepository.mapToKeyBinding(event); if (keyBinding.isPresent()) { switch (keyBinding.get()) { case COPY_PREVIEW: @@ -168,10 +166,10 @@ public void updateLayout(PreviewPreferences previewPreferences) { if (basePanel.isPresent()) { layout = Optional.empty(); CitationStyle.createCitationStyleFromFile(style) - .ifPresent(citationStyle -> { - basePanel.get().getCitationStyleCache().setCitationStyle(citationStyle); - basePanel.get().output(Localization.lang("Preview style changed to: %0", citationStyle.getTitle())); - }); + .ifPresent(citationStyle -> { + basePanel.get().getCitationStyleCache().setCitationStyle(citationStyle); + basePanel.get().output(Localization.lang("Preview style changed to: %0", citationStyle.getTitle())); + }); } } else { updatePreviewLayout(previewPreferences.getPreviewStyle(), previewPreferences.getLayoutFormatterPreferences()); @@ -184,9 +182,7 @@ public void updateLayout(PreviewPreferences previewPreferences) { private void updatePreviewLayout(String layoutFile, LayoutFormatterPreferences layoutFormatterPreferences) { StringReader sr = new StringReader(layoutFile.replace("__NEWLINE__", "\n")); try { - layout = Optional.of( - new LayoutHelper(sr, layoutFormatterPreferences) - .getLayoutFromText()); + layout = Optional.of(new LayoutHelper(sr, layoutFormatterPreferences).getLayoutFromText()); } catch (IOException e) { layout = Optional.empty(); LOGGER.debug("no layout could be set", e); From 4f56b28d5e3287d0ee35c9507b0614016c6cffcc Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Fri, 11 May 2018 22:55:53 +0200 Subject: [PATCH 005/130] Fix case of constants --- .../java/org/jabref/gui/actions/Actions.java | 32 +++++++++---------- .../SpecialFieldValueViewModel.java | 32 +++++++++---------- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/src/main/java/org/jabref/gui/actions/Actions.java b/src/main/java/org/jabref/gui/actions/Actions.java index f4837351926..3f5522e095e 100644 --- a/src/main/java/org/jabref/gui/actions/Actions.java +++ b/src/main/java/org/jabref/gui/actions/Actions.java @@ -59,20 +59,20 @@ public enum Actions { UNDO, WRITE_XMP, PRINT_PREVIEW, - togglePrinted, - clearPriority, - setPriority1, - setPriority2, - setPriority3, - toggleQualityAssured, - clearRank, - setRank1, - setRank2, - setRank3, - setRank4, - setRank5, - clearReadStatus, - setReadStatusToRead, - setReadStatusToSkimmed, - toggleRelevance + TOGGLE_PRINTED, + CLEAR_PRIORITY, + SET_PRIORITY_1, + SET_PRIORITY_2, + SET_PRIORITY_3, + TOGGLE_QUALITY_ASSURED, + CLEAR_RANK, + SET_RANK_1, + SET_RANK_2, + SET_RANK_3, + SET_RANK_4, + SET_RANK_5, + CLEAR_READ_STATUS, + SET_READ_STATUS_TO_READ, + SET_READ_STATUS_TO_SKIMMED, + TOGGLE_RELEVANCE } diff --git a/src/main/java/org/jabref/gui/specialfields/SpecialFieldValueViewModel.java b/src/main/java/org/jabref/gui/specialfields/SpecialFieldValueViewModel.java index 956f0df4c92..3f1ad4f3e6e 100644 --- a/src/main/java/org/jabref/gui/specialfields/SpecialFieldValueViewModel.java +++ b/src/main/java/org/jabref/gui/specialfields/SpecialFieldValueViewModel.java @@ -87,37 +87,37 @@ public String getToolTipText() { public Actions getCommand() { switch (value) { case PRINTED: - return Actions.togglePrinted; + return Actions.TOGGLE_PRINTED; case CLEAR_PRIORITY: - return Actions.clearPriority; + return Actions.CLEAR_PRIORITY; case PRIORITY_HIGH: - return Actions.setPriority1; + return Actions.SET_PRIORITY_1; case PRIORITY_MEDIUM: - return Actions.setPriority2; + return Actions.SET_PRIORITY_2; case PRIORITY_LOW: - return Actions.setPriority3; + return Actions.SET_PRIORITY_3; case QUALITY_ASSURED: - return Actions.toggleQualityAssured; + return Actions.TOGGLE_QUALITY_ASSURED; case CLEAR_RANK: - return Actions.clearRank; + return Actions.CLEAR_RANK; case RANK_1: - return Actions.setRank1; + return Actions.SET_RANK_1; case RANK_2: - return Actions.setRank2; + return Actions.SET_RANK_2; case RANK_3: - return Actions.setRank3; + return Actions.SET_RANK_3; case RANK_4: - return Actions.setRank4; + return Actions.SET_RANK_4; case RANK_5: - return Actions.setRank5; + return Actions.SET_RANK_5; case CLEAR_READ_STATUS: - return Actions.clearReadStatus; + return Actions.CLEAR_READ_STATUS; case READ: - return Actions.setReadStatusToRead; + return Actions.SET_READ_STATUS_TO_READ; case SKIMMED: - return Actions.setReadStatusToSkimmed; + return Actions.SET_READ_STATUS_TO_SKIMMED; case RELEVANT: - return Actions.toggleRelevance; + return Actions.TOGGLE_RELEVANCE; default: throw new IllegalArgumentException("There is no action name for special field value " + value); } From 15c0a7828e2917af276c8621985fa23854af3e4d Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Fri, 11 May 2018 23:00:35 +0200 Subject: [PATCH 006/130] Do not cache bibtex key pattern dialog --- .../gui/actions/BibtexKeyPatternAction.java | 11 +-------- .../BibtexKeyPatternDialog.java | 23 +++++-------------- 2 files changed, 7 insertions(+), 27 deletions(-) diff --git a/src/main/java/org/jabref/gui/actions/BibtexKeyPatternAction.java b/src/main/java/org/jabref/gui/actions/BibtexKeyPatternAction.java index 67f44fdd6e3..71c125f9659 100644 --- a/src/main/java/org/jabref/gui/actions/BibtexKeyPatternAction.java +++ b/src/main/java/org/jabref/gui/actions/BibtexKeyPatternAction.java @@ -2,12 +2,10 @@ import org.jabref.gui.JabRefFrame; import org.jabref.gui.bibtexkeypattern.BibtexKeyPatternDialog; -import org.jabref.preferences.JabRefPreferences; public class BibtexKeyPatternAction extends SimpleCommand { private JabRefFrame frame; - private BibtexKeyPatternDialog bibtexKeyPatternDialog; public BibtexKeyPatternAction(JabRefFrame frame) { this.frame = frame; @@ -15,14 +13,7 @@ public BibtexKeyPatternAction(JabRefFrame frame) { @Override public void execute() { - JabRefPreferences.getInstance(); - if (bibtexKeyPatternDialog == null) { - // if no instance of BibtexKeyPatternDialog exists, create new one - bibtexKeyPatternDialog = new BibtexKeyPatternDialog(frame, frame.getCurrentBasePanel()); - } else { - // BibtexKeyPatternDialog allows for updating content based on currently selected panel - bibtexKeyPatternDialog.setPanel(frame.getCurrentBasePanel()); - } + BibtexKeyPatternDialog bibtexKeyPatternDialog = new BibtexKeyPatternDialog(frame.getCurrentBasePanel()); bibtexKeyPatternDialog.setLocationRelativeTo(null); bibtexKeyPatternDialog.setVisible(true); } diff --git a/src/main/java/org/jabref/gui/bibtexkeypattern/BibtexKeyPatternDialog.java b/src/main/java/org/jabref/gui/bibtexkeypattern/BibtexKeyPatternDialog.java index 21cf1a6eb48..3897f74042b 100644 --- a/src/main/java/org/jabref/gui/bibtexkeypattern/BibtexKeyPatternDialog.java +++ b/src/main/java/org/jabref/gui/bibtexkeypattern/BibtexKeyPatternDialog.java @@ -17,7 +17,6 @@ import org.jabref.Globals; import org.jabref.gui.BasePanel; import org.jabref.gui.JabRefDialog; -import org.jabref.gui.JabRefFrame; import org.jabref.gui.keyboard.KeyBinder; import org.jabref.logic.l10n.Localization; import org.jabref.model.bibtexkeypattern.AbstractBibtexKeyPattern; @@ -27,28 +26,18 @@ public class BibtexKeyPatternDialog extends JabRefDialog { - private MetaData metaData; - private BasePanel panel; + private final MetaData metaData; + private final BasePanel panel; private final BibtexKeyPatternPanel bibtexKeyPatternPanel; - - public BibtexKeyPatternDialog(JabRefFrame parent, BasePanel panel) { + public BibtexKeyPatternDialog(BasePanel panel) { super((JFrame) null, Localization.lang("BibTeX key patterns"), true, BibtexKeyPatternDialog.class); this.bibtexKeyPatternPanel = new BibtexKeyPatternPanel(panel); - setPanel(panel); - init(); - } - - /** - * Used for updating an existing Dialog - * - * @param panel the panel to read the data from - */ - public void setPanel(BasePanel panel) { this.panel = panel; this.metaData = panel.getBibDatabaseContext().getMetaData(); - AbstractBibtexKeyPattern keypatterns = metaData.getCiteKeyPattern(Globals.prefs.getKeyPattern()); - bibtexKeyPatternPanel.setValues(keypatterns); + AbstractBibtexKeyPattern keyPattern = metaData.getCiteKeyPattern(Globals.prefs.getKeyPattern()); + bibtexKeyPatternPanel.setValues(keyPattern); + init(); } private void init() { From 5b80bcd19e8223877c8ed611f80bea6bbc3e1971 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Fri, 11 May 2018 23:03:22 +0200 Subject: [PATCH 007/130] No global preferences in cleanup action --- .../org/jabref/gui/actions/CleanupAction.java | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/jabref/gui/actions/CleanupAction.java b/src/main/java/org/jabref/gui/actions/CleanupAction.java index 93629476756..71d8f6e24c7 100644 --- a/src/main/java/org/jabref/gui/actions/CleanupAction.java +++ b/src/main/java/org/jabref/gui/actions/CleanupAction.java @@ -6,7 +6,6 @@ import org.jabref.Globals; import org.jabref.gui.BasePanel; import org.jabref.gui.DialogService; -import org.jabref.gui.JabRefFrame; import org.jabref.gui.cleanup.CleanupDialog; import org.jabref.gui.undo.NamedCompound; import org.jabref.gui.undo.UndoableFieldChange; @@ -22,7 +21,6 @@ public class CleanupAction extends AbstractWorker { private final BasePanel panel; - private final JabRefFrame frame; private final DialogService dialogService; /** @@ -36,9 +34,8 @@ public class CleanupAction extends AbstractWorker { public CleanupAction(BasePanel panel, JabRefPreferences preferences) { this.panel = panel; - this.frame = panel.frame(); this.preferences = preferences; - this.dialogService = frame.getDialogService(); + this.dialogService = panel.frame().getDialogService(); } @Override @@ -60,7 +57,7 @@ public void run() { if (canceled) { return; } - CleanupDialog cleanupDialog = new CleanupDialog(panel.getBibDatabaseContext(), Globals.prefs.getCleanupPreset()); + CleanupDialog cleanupDialog = new CleanupDialog(panel.getBibDatabaseContext(), preferences.getCleanupPreset()); Optional chosenPreset = cleanupDialog.showAndWait(); if (!chosenPreset.isPresent()) { @@ -68,18 +65,18 @@ public void run() { return; } CleanupPreset cleanupPreset = chosenPreset.get(); - Globals.prefs.setCleanupPreset(cleanupPreset); + preferences.setCleanupPreset(cleanupPreset); - if (cleanupPreset.isRenamePDF() && Globals.prefs.getBoolean(JabRefPreferences.ASK_AUTO_NAMING_PDFS_AGAIN)) { + if (cleanupPreset.isRenamePDF() && preferences.getBoolean(JabRefPreferences.ASK_AUTO_NAMING_PDFS_AGAIN)) { - boolean autogeneratePressed = DefaultTaskExecutor.runInJavaFXThread(() -> dialogService.showConfirmationDialogWithOptOutAndWait(Localization.lang("Autogenerate PDF Names"), + boolean confirmed = DefaultTaskExecutor.runInJavaFXThread(() -> dialogService.showConfirmationDialogWithOptOutAndWait(Localization.lang("Autogenerate PDF Names"), Localization.lang("Auto-generating PDF-Names does not support undo. Continue?"), Localization.lang("Autogenerate PDF Names"), Localization.lang("Cancel"), Localization.lang("Disable this confirmation dialog"), optOut -> Globals.prefs.putBoolean(JabRefPreferences.ASK_AUTO_NAMING_PDFS_AGAIN, !optOut))); - if (!autogeneratePressed) { + if (!confirmed) { canceled = true; return; } From 88cbb40240e44e285fdb7b51c155408cb741982f Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Fri, 11 May 2018 23:05:22 +0200 Subject: [PATCH 008/130] No global clipboard manager in copy action --- src/main/java/org/jabref/gui/BasePanel.java | 2 +- .../jabref/gui/actions/CopyBibTeXKeyAndLinkAction.java | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/jabref/gui/BasePanel.java b/src/main/java/org/jabref/gui/BasePanel.java index aea1f9e9258..868e3573e27 100644 --- a/src/main/java/org/jabref/gui/BasePanel.java +++ b/src/main/java/org/jabref/gui/BasePanel.java @@ -464,7 +464,7 @@ public void update() { actions.put(Actions.COPY_CITATION_TEXT, (BaseAction) () -> copyCitationToClipboard(CitationStyleOutputFormat.TEXT)); // The action for copying the BibTeX keys as hyperlinks to the urls of the selected entries - actions.put(Actions.COPY_KEY_AND_LINK, new CopyBibTeXKeyAndLinkAction(mainTable)); + actions.put(Actions.COPY_KEY_AND_LINK, new CopyBibTeXKeyAndLinkAction(mainTable, Globals.clipboardManager)); actions.put(Actions.MERGE_DATABASE, new AppendDatabaseAction(frame, this)); diff --git a/src/main/java/org/jabref/gui/actions/CopyBibTeXKeyAndLinkAction.java b/src/main/java/org/jabref/gui/actions/CopyBibTeXKeyAndLinkAction.java index 948f2108c1e..831ac29ec93 100644 --- a/src/main/java/org/jabref/gui/actions/CopyBibTeXKeyAndLinkAction.java +++ b/src/main/java/org/jabref/gui/actions/CopyBibTeXKeyAndLinkAction.java @@ -3,8 +3,8 @@ import java.util.List; import java.util.stream.Collectors; -import org.jabref.Globals; import org.jabref.JabRefGUI; +import org.jabref.gui.ClipBoardManager; import org.jabref.gui.maintable.MainTable; import org.jabref.gui.util.DefaultTaskExecutor; import org.jabref.logic.l10n.Localization; @@ -20,9 +20,11 @@ public class CopyBibTeXKeyAndLinkAction implements BaseAction { private final MainTable mainTable; + private final ClipBoardManager clipboardManager; - public CopyBibTeXKeyAndLinkAction(MainTable mainTable) { + public CopyBibTeXKeyAndLinkAction(MainTable mainTable, ClipBoardManager clipboardManager) { this.mainTable = mainTable; + this.clipboardManager = clipboardManager; } @Override @@ -45,7 +47,7 @@ public void action() throws Exception { sb.append(OS.NEWLINE); } - DefaultTaskExecutor.runInJavaFXThread(() -> Globals.clipboardManager.setClipboardHtmlContent(sb.toString())); + DefaultTaskExecutor.runInJavaFXThread(() -> clipboardManager.setClipboardHtmlContent(sb.toString())); int copied = entriesWithKey.size(); int toCopy = entries.size(); From 8f927231c6dc5ce42f2dfa9bed77611e8f26984e Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Fri, 11 May 2018 23:07:08 +0200 Subject: [PATCH 009/130] Fix naming --- .../org/jabref/gui/actions/CustomizeEntryAction.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/jabref/gui/actions/CustomizeEntryAction.java b/src/main/java/org/jabref/gui/actions/CustomizeEntryAction.java index ce2747f4765..f6ef7b46080 100644 --- a/src/main/java/org/jabref/gui/actions/CustomizeEntryAction.java +++ b/src/main/java/org/jabref/gui/actions/CustomizeEntryAction.java @@ -7,16 +7,14 @@ public class CustomizeEntryAction extends SimpleCommand { - private final JabRefFrame jabRefFrame; + private final JabRefFrame frame; - public CustomizeEntryAction(JabRefFrame jabRefFrame) { - this.jabRefFrame = jabRefFrame; + public CustomizeEntryAction(JabRefFrame frame) { + this.frame = frame; } @Override public void execute() { - JDialog dl = new EntryCustomizationDialog(jabRefFrame); - dl.setVisible(true); - + JDialog dialog = new EntryCustomizationDialog(frame); + dialog.setVisible(true); } - } From 768398cee49416b8f51fe2494ecc229e08ad8512 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Fri, 11 May 2018 23:07:24 +0200 Subject: [PATCH 010/130] Fix formatting --- src/main/java/org/jabref/gui/actions/CustomizeEntryAction.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/org/jabref/gui/actions/CustomizeEntryAction.java b/src/main/java/org/jabref/gui/actions/CustomizeEntryAction.java index f6ef7b46080..aaee283cde1 100644 --- a/src/main/java/org/jabref/gui/actions/CustomizeEntryAction.java +++ b/src/main/java/org/jabref/gui/actions/CustomizeEntryAction.java @@ -12,6 +12,7 @@ public class CustomizeEntryAction extends SimpleCommand { public CustomizeEntryAction(JabRefFrame frame) { this.frame = frame; } + @Override public void execute() { JDialog dialog = new EntryCustomizationDialog(frame); From 8baece5aed2998c58ec078290b48bb53d8110551 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Fri, 11 May 2018 23:08:34 +0200 Subject: [PATCH 011/130] Do not cache external file type edit action --- .../org/jabref/gui/actions/EditExternalFileTypesAction.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/main/java/org/jabref/gui/actions/EditExternalFileTypesAction.java b/src/main/java/org/jabref/gui/actions/EditExternalFileTypesAction.java index 9b14c1cea45..82bbc9123ce 100644 --- a/src/main/java/org/jabref/gui/actions/EditExternalFileTypesAction.java +++ b/src/main/java/org/jabref/gui/actions/EditExternalFileTypesAction.java @@ -4,13 +4,9 @@ public class EditExternalFileTypesAction extends SimpleCommand { - private ExternalFileTypeEditor editor; - @Override public void execute() { - if (editor == null) { - editor = new ExternalFileTypeEditor(); - } + ExternalFileTypeEditor editor = new ExternalFileTypeEditor(); editor.show(); } } From cb41cf8a9f9c6ae94c38cb767eb1b03be50e25d6 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Fri, 11 May 2018 23:12:27 +0200 Subject: [PATCH 012/130] Do not cache database properties dialog --- src/main/java/org/jabref/gui/JabRefFrame.java | 4 +-- .../gui/actions/DatabasePropertiesAction.java | 21 +++++++++++++++ .../gui/actions/LibraryPropertiesAction.java | 27 ------------------- .../DatabasePropertiesDialog.java | 11 +++----- 4 files changed, 27 insertions(+), 36 deletions(-) create mode 100644 src/main/java/org/jabref/gui/actions/DatabasePropertiesAction.java delete mode 100644 src/main/java/org/jabref/gui/actions/LibraryPropertiesAction.java diff --git a/src/main/java/org/jabref/gui/JabRefFrame.java b/src/main/java/org/jabref/gui/JabRefFrame.java index 65f714b22f7..1e648c3bad2 100644 --- a/src/main/java/org/jabref/gui/JabRefFrame.java +++ b/src/main/java/org/jabref/gui/JabRefFrame.java @@ -63,11 +63,11 @@ import org.jabref.gui.actions.CopyFilesAction; import org.jabref.gui.actions.CustomizeEntryAction; import org.jabref.gui.actions.CustomizeKeyBindingAction; +import org.jabref.gui.actions.DatabasePropertiesAction; import org.jabref.gui.actions.EditExternalFileTypesAction; import org.jabref.gui.actions.ErrorConsoleAction; import org.jabref.gui.actions.FindUnlinkedFilesAction; import org.jabref.gui.actions.IntegrityCheckAction; -import org.jabref.gui.actions.LibraryPropertiesAction; import org.jabref.gui.actions.LookupIdentifierAction; import org.jabref.gui.actions.ManageCustomExportsAction; import org.jabref.gui.actions.ManageCustomImportsAction; @@ -833,7 +833,7 @@ private MenuBar createMenu() { new SeparatorMenuItem(), - factory.createMenuItem(StandardActions.LIBRARY_PROPERTIES, new LibraryPropertiesAction(this)), + factory.createMenuItem(StandardActions.LIBRARY_PROPERTIES, new DatabasePropertiesAction(this)), factory.createMenuItem(StandardActions.EDIT_PREAMBLE, new PreambleEditor(this)), factory.createMenuItem(StandardActions.EDIT_STRINGS, new OldDatabaseCommandWrapper(Actions.EDIT_STRINGS, this, Globals.stateManager)) diff --git a/src/main/java/org/jabref/gui/actions/DatabasePropertiesAction.java b/src/main/java/org/jabref/gui/actions/DatabasePropertiesAction.java new file mode 100644 index 00000000000..d7b3ffe35bf --- /dev/null +++ b/src/main/java/org/jabref/gui/actions/DatabasePropertiesAction.java @@ -0,0 +1,21 @@ +package org.jabref.gui.actions; + +import org.jabref.gui.JabRefFrame; +import org.jabref.gui.dbproperties.DatabasePropertiesDialog; + +public class DatabasePropertiesAction extends SimpleCommand { + + private final JabRefFrame frame; + + public DatabasePropertiesAction(JabRefFrame frame) { + this.frame = frame; + } + + @Override + public void execute() { + DatabasePropertiesDialog propertiesDialog = new DatabasePropertiesDialog(null, frame.getCurrentBasePanel()); + propertiesDialog.updateEnableStatus(); + propertiesDialog.setVisible(true); + } + +} diff --git a/src/main/java/org/jabref/gui/actions/LibraryPropertiesAction.java b/src/main/java/org/jabref/gui/actions/LibraryPropertiesAction.java deleted file mode 100644 index 34b7fd3f270..00000000000 --- a/src/main/java/org/jabref/gui/actions/LibraryPropertiesAction.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.jabref.gui.actions; - -import org.jabref.gui.JabRefFrame; -import org.jabref.gui.dbproperties.DatabasePropertiesDialog; - -public class LibraryPropertiesAction extends SimpleCommand { - - private final JabRefFrame frame; - private DatabasePropertiesDialog propertiesDialog; - - public LibraryPropertiesAction(JabRefFrame frame) { - this.frame = frame; - } - - @Override - public void execute() { - if (propertiesDialog == null) { - propertiesDialog = new DatabasePropertiesDialog(null); - } - - propertiesDialog.setPanel(frame.getCurrentBasePanel()); - propertiesDialog.updateEnableStatus(); - propertiesDialog.setLocationRelativeTo(null); - propertiesDialog.setVisible(true); - } - -} diff --git a/src/main/java/org/jabref/gui/dbproperties/DatabasePropertiesDialog.java b/src/main/java/org/jabref/gui/dbproperties/DatabasePropertiesDialog.java index c51d1626a6f..8667f8cf49e 100644 --- a/src/main/java/org/jabref/gui/dbproperties/DatabasePropertiesDialog.java +++ b/src/main/java/org/jabref/gui/dbproperties/DatabasePropertiesDialog.java @@ -46,8 +46,8 @@ public class DatabasePropertiesDialog extends JabRefDialog { - private MetaData metaData; - private BasePanel panel; + private final MetaData metaData; + private final BasePanel panel; private final JComboBox encoding; private final JButton ok; private final JButton cancel; @@ -69,18 +69,15 @@ public class DatabasePropertiesDialog extends JabRefDialog { private FieldFormatterCleanupsPanel fieldFormatterCleanupsPanel; - public DatabasePropertiesDialog(JFrame parent) { + public DatabasePropertiesDialog(JFrame parent, BasePanel panel) { super(parent, Localization.lang("Library properties"), true, DatabasePropertiesDialog.class); encoding = new JComboBox<>(); encoding.setModel(new DefaultComboBoxModel<>(Encodings.ENCODINGS)); ok = new JButton(Localization.lang("OK")); cancel = new JButton(Localization.lang("Cancel")); - init(); - } - - public void setPanel(BasePanel panel) { this.panel = panel; this.metaData = panel.getBibDatabaseContext().getMetaData(); + init(); } public void updateEnableStatus() { From c80c5a98db266b789b75e46c49f656e1fc65439a Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Fri, 11 May 2018 23:14:36 +0200 Subject: [PATCH 013/130] Remove unused class --- .../actions/ManageContentSelectorAction.java | 26 ------------------- 1 file changed, 26 deletions(-) delete mode 100644 src/main/java/org/jabref/gui/actions/ManageContentSelectorAction.java diff --git a/src/main/java/org/jabref/gui/actions/ManageContentSelectorAction.java b/src/main/java/org/jabref/gui/actions/ManageContentSelectorAction.java deleted file mode 100644 index 6a552dca717..00000000000 --- a/src/main/java/org/jabref/gui/actions/ManageContentSelectorAction.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.jabref.gui.actions; - -import org.jabref.gui.BasePanel; -import org.jabref.gui.JabRefFrame; -import org.jabref.gui.contentselector.ContentSelectorDialog; - -//TODO: Throws an NPE If BasePanel is null -public class ManageContentSelectorAction extends SimpleCommand { - - private final BasePanel basePanel; - private final JabRefFrame frame; - - public ManageContentSelectorAction(BasePanel basePanel, JabRefFrame frame) - { - this.basePanel = basePanel; - this.frame = frame; - } - - @Override - public void execute() { - ContentSelectorDialog csd = new ContentSelectorDialog(null, frame, basePanel, false, null); - csd.setVisible(true); - - } - -} From 4c9dbc33395fffde3cd4ddb7d68425840f1e63bb Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Fri, 11 May 2018 23:16:18 +0200 Subject: [PATCH 014/130] Fix formatting --- .../gui/actions/MassSetFieldAction.java | 318 +++++++++--------- 1 file changed, 159 insertions(+), 159 deletions(-) diff --git a/src/main/java/org/jabref/gui/actions/MassSetFieldAction.java b/src/main/java/org/jabref/gui/actions/MassSetFieldAction.java index 953d420d024..a93aaebe2b8 100644 --- a/src/main/java/org/jabref/gui/actions/MassSetFieldAction.java +++ b/src/main/java/org/jabref/gui/actions/MassSetFieldAction.java @@ -66,131 +66,37 @@ public MassSetFieldAction(JabRefFrame frame) { this.frame = frame; } - private void createDialog() { - diag = new JDialog((JFrame) null, Localization.lang("Set/clear/append/rename fields"), true); - - field = new JComboBox<>(); - field.setEditable(true); - textFieldSet = new JTextField(); - textFieldSet.setEnabled(false); - textFieldAppend = new JTextField(); - textFieldAppend.setEnabled(false); - textFieldRename = new JTextField(); - textFieldRename.setEnabled(false); - - JButton ok = new JButton(Localization.lang("OK")); - JButton cancel = new JButton(Localization.lang("Cancel")); - - all = new JRadioButton(Localization.lang("All entries")); - selected = new JRadioButton(Localization.lang("Selected entries")); - clear = new JRadioButton(Localization.lang("Clear fields")); - set = new JRadioButton(Localization.lang("Set fields")); - append = new JRadioButton(Localization.lang("Append to fields")); - rename = new JRadioButton(Localization.lang("Rename field to") + ":"); - rename.setToolTipText(Localization.lang("Move contents of a field into a field with a different name")); - - Set allFields = frame.getCurrentBasePanel().getDatabase().getAllVisibleFields(); - - for (String f : allFields) { - field.addItem(f); - } - - set.addChangeListener(e -> - // Entering a setText is only relevant if we are setting, not clearing: - textFieldSet.setEnabled(set.isSelected())); - - append.addChangeListener(e -> { - // Text to append is only required if we are appending: - textFieldAppend.setEnabled(append.isSelected()); - // Overwrite protection makes no sense if we are appending to a field: - overwrite.setEnabled(!clear.isSelected() && !append.isSelected()); - }); - - clear.addChangeListener(e -> - // Overwrite protection makes no sense if we are clearing the field: - overwrite.setEnabled(!clear.isSelected() && !append.isSelected())); - - rename.addChangeListener(e -> - // Entering a setText is only relevant if we are renaming - textFieldRename.setEnabled(rename.isSelected())); - - overwrite = new JCheckBox(Localization.lang("Overwrite existing field values"), true); - ButtonGroup bg = new ButtonGroup(); - bg.add(all); - bg.add(selected); - bg = new ButtonGroup(); - bg.add(clear); - bg.add(set); - bg.add(append); - bg.add(rename); - FormBuilder builder = FormBuilder.create().layout(new FormLayout( - "left:pref, 4dlu, fill:100dlu:grow", "pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref")); - builder.addSeparator(Localization.lang("Field name")).xyw(1, 1, 3); - builder.add(Localization.lang("Field name")).xy(1, 3); - builder.add(field).xy(3, 3); - builder.addSeparator(Localization.lang("Include entries")).xyw(1, 5, 3); - builder.add(all).xyw(1, 7, 3); - builder.add(selected).xyw(1, 9, 3); - builder.addSeparator(Localization.lang("New field value")).xyw(1, 11, 3); - builder.add(set).xy(1, 13); - builder.add(textFieldSet).xy(3, 13); - builder.add(clear).xyw(1, 15, 3); - builder.add(append).xy(1, 17); - builder.add(textFieldAppend).xy(3, 17); - builder.add(rename).xy(1, 19); - builder.add(textFieldRename).xy(3, 19); - builder.add(overwrite).xyw(1, 21, 3); - - ButtonBarBuilder bb = new ButtonBarBuilder(); - bb.addGlue(); - bb.addButton(ok); - bb.addButton(cancel); - bb.addGlue(); - builder.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); - bb.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); - diag.getContentPane().add(builder.getPanel(), BorderLayout.CENTER); - diag.getContentPane().add(bb.getPanel(), BorderLayout.SOUTH); - diag.pack(); - - ok.addActionListener(e -> { - // Check that any field name is set - String fieldText = (String) field.getSelectedItem(); - if ((fieldText == null) || fieldText.trim().isEmpty()) { - - frame.getDialogService().showErrorDialogAndWait(Localization.lang("You must enter at least one field name")); - - return; // Do not close the dialog. - } - - // Check if the user tries to rename multiple fields: - if (rename.isSelected()) { - String[] fields = getFieldNames(fieldText); - if (fields.length > 1) { - - frame.getDialogService().showErrorDialogAndWait(Localization.lang("You can only rename one field at a time")); + /** + * Set a given field to a given value for all entries in a Collection. This method DOES NOT update any UndoManager, + * but returns a relevant CompoundEdit that should be registered by the caller. + * + * @param entries The entries to set the field for. + * @param field The name of the field to set. + * @param textToSet The value to set. This value can be null, indicating that the field should be cleared. + * @param overwriteValues Indicate whether the value should be set even if an entry already has the field set. + * @return A CompoundEdit for the entire operation. + */ + private static UndoableEdit massSetField(Collection entries, String field, String textToSet, + boolean overwriteValues) { - return; // Do not close the dialog. - } + NamedCompound compoundEdit = new NamedCompound(Localization.lang("Set field")); + for (BibEntry entry : entries) { + Optional oldValue = entry.getField(field); + // If we are not allowed to overwrite values, check if there is a + // nonempty + // value already for this entry: + if (!overwriteValues && (oldValue.isPresent()) && !oldValue.get().isEmpty()) { + continue; } - canceled = false; - diag.dispose(); - }); - - Action cancelAction = new AbstractAction() { - - @Override - public void actionPerformed(ActionEvent e) { - canceled = true; - diag.dispose(); + if (textToSet == null) { + entry.clearField(field); + } else { + entry.setField(field, textToSet); } - }; - cancel.addActionListener(cancelAction); - - // Key bindings: - ActionMap am = builder.getPanel().getActionMap(); - InputMap im = builder.getPanel().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); - im.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE), "close"); - am.put("close", cancelAction); + compoundEdit.addEdit(new UndoableFieldChange(entry, field, oldValue.orElse(null), textToSet)); + } + compoundEdit.end(); + return compoundEdit; } private void prepareDialog(boolean selection) { @@ -265,46 +171,13 @@ public void execute() { bp.markBaseChanged(); } - /** - * Set a given field to a given value for all entries in a Collection. This method DOES NOT update any UndoManager, - * but returns a relevant CompoundEdit that should be registered by the caller. - * - * @param entries The entries to set the field for. - * @param field The name of the field to set. - * @param textToSet The value to set. This value can be null, indicating that the field should be cleared. - * @param overwriteValues Indicate whether the value should be set even if an entry already has the field set. - * @return A CompoundEdit for the entire operation. - */ - private static UndoableEdit massSetField(Collection entries, String field, String textToSet, - boolean overwriteValues) { - - NamedCompound compoundEdit = new NamedCompound(Localization.lang("Set field")); - for (BibEntry entry : entries) { - Optional oldValue = entry.getField(field); - // If we are not allowed to overwrite values, check if there is a - // nonempty - // value already for this entry: - if (!overwriteValues && (oldValue.isPresent()) && !oldValue.get().isEmpty()) { - continue; - } - if (textToSet == null) { - entry.clearField(field); - } else { - entry.setField(field, textToSet); - } - compoundEdit.addEdit(new UndoableFieldChange(entry, field, oldValue.orElse(null), textToSet)); - } - compoundEdit.end(); - return compoundEdit; - } - /** * Append a given value to a given field for all entries in a Collection. This method DOES NOT update any UndoManager, * but returns a relevant CompoundEdit that should be registered by the caller. * - * @param entries The entries to process the operation for. - * @param field The name of the field to append to. - * @param textToAppend The value to set. A null in this case will simply preserve the current field state. + * @param entries The entries to process the operation for. + * @param field The name of the field to append to. + * @param textToAppend The value to set. A null in this case will simply preserve the current field state. * @return A CompoundEdit for the entire operation. */ private static UndoableEdit massAppendField(Collection entries, String field, String textToAppend) { @@ -336,7 +209,7 @@ private static UndoableEdit massAppendField(Collection entries, String * @return A CompoundEdit for the entire operation. */ private static UndoableEdit massRenameField(Collection entries, String field, String newField, - boolean overwriteValues) { + boolean overwriteValues) { NamedCompound compoundEdit = new NamedCompound(Localization.lang("Rename field")); for (BibEntry entry : entries) { Optional valToMove = entry.getField(field); @@ -360,6 +233,133 @@ private static UndoableEdit massRenameField(Collection entries, String return compoundEdit; } + private void createDialog() { + diag = new JDialog((JFrame) null, Localization.lang("Set/clear/append/rename fields"), true); + + field = new JComboBox<>(); + field.setEditable(true); + textFieldSet = new JTextField(); + textFieldSet.setEnabled(false); + textFieldAppend = new JTextField(); + textFieldAppend.setEnabled(false); + textFieldRename = new JTextField(); + textFieldRename.setEnabled(false); + + JButton ok = new JButton(Localization.lang("OK")); + JButton cancel = new JButton(Localization.lang("Cancel")); + + all = new JRadioButton(Localization.lang("All entries")); + selected = new JRadioButton(Localization.lang("Selected entries")); + clear = new JRadioButton(Localization.lang("Clear fields")); + set = new JRadioButton(Localization.lang("Set fields")); + append = new JRadioButton(Localization.lang("Append to fields")); + rename = new JRadioButton(Localization.lang("Rename field to") + ":"); + rename.setToolTipText(Localization.lang("Move contents of a field into a field with a different name")); + + Set allFields = frame.getCurrentBasePanel().getDatabase().getAllVisibleFields(); + + for (String f : allFields) { + field.addItem(f); + } + + set.addChangeListener(e -> + // Entering a setText is only relevant if we are setting, not clearing: + textFieldSet.setEnabled(set.isSelected())); + + append.addChangeListener(e -> { + // Text to append is only required if we are appending: + textFieldAppend.setEnabled(append.isSelected()); + // Overwrite protection makes no sense if we are appending to a field: + overwrite.setEnabled(!clear.isSelected() && !append.isSelected()); + }); + + clear.addChangeListener(e -> + // Overwrite protection makes no sense if we are clearing the field: + overwrite.setEnabled(!clear.isSelected() && !append.isSelected())); + + rename.addChangeListener(e -> + // Entering a setText is only relevant if we are renaming + textFieldRename.setEnabled(rename.isSelected())); + + overwrite = new JCheckBox(Localization.lang("Overwrite existing field values"), true); + ButtonGroup bg = new ButtonGroup(); + bg.add(all); + bg.add(selected); + bg = new ButtonGroup(); + bg.add(clear); + bg.add(set); + bg.add(append); + bg.add(rename); + FormBuilder builder = FormBuilder.create().layout(new FormLayout( + "left:pref, 4dlu, fill:100dlu:grow", "pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref, 2dlu, pref")); + builder.addSeparator(Localization.lang("Field name")).xyw(1, 1, 3); + builder.add(Localization.lang("Field name")).xy(1, 3); + builder.add(field).xy(3, 3); + builder.addSeparator(Localization.lang("Include entries")).xyw(1, 5, 3); + builder.add(all).xyw(1, 7, 3); + builder.add(selected).xyw(1, 9, 3); + builder.addSeparator(Localization.lang("New field value")).xyw(1, 11, 3); + builder.add(set).xy(1, 13); + builder.add(textFieldSet).xy(3, 13); + builder.add(clear).xyw(1, 15, 3); + builder.add(append).xy(1, 17); + builder.add(textFieldAppend).xy(3, 17); + builder.add(rename).xy(1, 19); + builder.add(textFieldRename).xy(3, 19); + builder.add(overwrite).xyw(1, 21, 3); + + ButtonBarBuilder bb = new ButtonBarBuilder(); + bb.addGlue(); + bb.addButton(ok); + bb.addButton(cancel); + bb.addGlue(); + builder.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); + bb.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); + diag.getContentPane().add(builder.getPanel(), BorderLayout.CENTER); + diag.getContentPane().add(bb.getPanel(), BorderLayout.SOUTH); + diag.pack(); + + ok.addActionListener(e -> { + // Check that any field name is set + String fieldText = (String) field.getSelectedItem(); + if ((fieldText == null) || fieldText.trim().isEmpty()) { + + frame.getDialogService().showErrorDialogAndWait(Localization.lang("You must enter at least one field name")); + + return; // Do not close the dialog. + } + + // Check if the user tries to rename multiple fields: + if (rename.isSelected()) { + String[] fields = getFieldNames(fieldText); + if (fields.length > 1) { + + frame.getDialogService().showErrorDialogAndWait(Localization.lang("You can only rename one field at a time")); + + return; // Do not close the dialog. + } + } + canceled = false; + diag.dispose(); + }); + + Action cancelAction = new AbstractAction() { + + @Override + public void actionPerformed(ActionEvent e) { + canceled = true; + diag.dispose(); + } + }; + cancel.addActionListener(cancelAction); + + // Key bindings: + ActionMap am = builder.getPanel().getActionMap(); + InputMap im = builder.getPanel().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); + im.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE), "close"); + am.put("close", cancelAction); + } + private static String[] getFieldNames(String s) { return s.split("[\\s;,]"); } From b11d9cc821639f94551daf4351e5009d16ae0edf Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Fri, 11 May 2018 23:19:21 +0200 Subject: [PATCH 015/130] Remove unused class --- .../org/jabref/gui/actions/NormalSearchAction.java | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 src/main/java/org/jabref/gui/actions/NormalSearchAction.java diff --git a/src/main/java/org/jabref/gui/actions/NormalSearchAction.java b/src/main/java/org/jabref/gui/actions/NormalSearchAction.java deleted file mode 100644 index aec0b9be3f4..00000000000 --- a/src/main/java/org/jabref/gui/actions/NormalSearchAction.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.jabref.gui.actions; - -public class NormalSearchAction extends SimpleCommand { - - @Override - public void execute() { - // TODO Auto-generated method stub - - } - -} From c4286b8bfc0555a53a5a7085376ace21b722d207 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Fri, 11 May 2018 23:25:33 +0200 Subject: [PATCH 016/130] Fix formatting --- .../java/org/jabref/gui/customentrytypes/EntryTypeList.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/jabref/gui/customentrytypes/EntryTypeList.java b/src/main/java/org/jabref/gui/customentrytypes/EntryTypeList.java index dacabb87021..2b6e9c7dc7d 100644 --- a/src/main/java/org/jabref/gui/customentrytypes/EntryTypeList.java +++ b/src/main/java/org/jabref/gui/customentrytypes/EntryTypeList.java @@ -30,8 +30,9 @@ public class EntryTypeList extends FieldSetComponent implements ListSelectionLis private final BibDatabaseMode mode; private final DialogService dialogService; - /** Creates a new instance of EntryTypeList - * @param frame */ + /** + * Creates a new instance of EntryTypeList + */ public EntryTypeList(DialogService dialogService, List fields, BibDatabaseMode mode) { super(Localization.lang("Entry types"), fields, fields, false, true); this.mode = mode; From e352f1118dff63f1e3d90c220609e20d4c23681b Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Fri, 11 May 2018 23:28:59 +0200 Subject: [PATCH 017/130] Remove commented-out code --- src/main/java/org/jabref/gui/entryeditor/EntryEditor.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java index 44f972469d2..cacdb605d01 100644 --- a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java +++ b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java @@ -88,7 +88,6 @@ public EntryEditor(BasePanel panel, EntryEditorPreferences preferences, FileUpda .root(this) .load(); - //getStylesheets().add(EntryEditor.class.getResource("EntryEditor.css").toExternalForm()); if (GUIGlobals.currentFont != null) { setStyle( "text-area-background: " + convertToHex(GUIGlobals.validFieldBackgroundColor) + ";" From 4606e6e3d284685ec59730967c0a061d888e4dab Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Fri, 11 May 2018 23:34:06 +0200 Subject: [PATCH 018/130] Preferences as parameter to export command --- src/main/java/org/jabref/gui/JabRefFrame.java | 4 ++-- .../org/jabref/gui/exporter/ExportCommand.java | 16 +++++++--------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/jabref/gui/JabRefFrame.java b/src/main/java/org/jabref/gui/JabRefFrame.java index 1e648c3bad2..4b5a02507c1 100644 --- a/src/main/java/org/jabref/gui/JabRefFrame.java +++ b/src/main/java/org/jabref/gui/JabRefFrame.java @@ -729,8 +729,8 @@ private MenuBar createMenu() { factory.createMenuItem(StandardActions.MERGE_DATABASE, new OldDatabaseCommandWrapper(Actions.MERGE_DATABASE, this, Globals.stateManager)), // TODO: merge with import factory.createMenuItem(StandardActions.IMPORT_INTO_CURRENT_LIBRARY, new ImportCommand(this, true)), factory.createMenuItem(StandardActions.IMPORT_INTO_NEW_LIBRARY, new ImportCommand(this, false)), - factory.createMenuItem(StandardActions.EXPORT_ALL, new ExportCommand(this, false)), - factory.createMenuItem(StandardActions.EXPORT_SELECTED, new ExportCommand(this, true)), + factory.createMenuItem(StandardActions.EXPORT_ALL, new ExportCommand(this, false, Globals.prefs)), + factory.createMenuItem(StandardActions.EXPORT_SELECTED, new ExportCommand(this, true, Globals.prefs)), factory.createMenuItem(StandardActions.SAVE_SELECTED_AS_PLAIN_BIBTEX, new OldDatabaseCommandWrapper(Actions.SAVE_SELECTED_AS_PLAIN, this, Globals.stateManager)) ), diff --git a/src/main/java/org/jabref/gui/exporter/ExportCommand.java b/src/main/java/org/jabref/gui/exporter/ExportCommand.java index d203d573fcc..21bd5051feb 100644 --- a/src/main/java/org/jabref/gui/exporter/ExportCommand.java +++ b/src/main/java/org/jabref/gui/exporter/ExportCommand.java @@ -38,25 +38,23 @@ public class ExportCommand extends SimpleCommand { private static final Logger LOGGER = LoggerFactory.getLogger(ExportCommand.class); private final JabRefFrame frame; private final boolean selectedOnly; + private final JabRefPreferences preferences; /** * @param selectedOnly true if only the selected entries should be exported, otherwise all entries are exported */ - public ExportCommand(JabRefFrame frame, boolean selectedOnly) { + public ExportCommand(JabRefFrame frame, boolean selectedOnly, JabRefPreferences preferences) { this.frame = frame; this.selectedOnly = selectedOnly; - + this.preferences = preferences; } @Override public void execute() { - - JabRefPreferences prefs = Globals.prefs; //TODO: Pass as param? - - Map customExporters = prefs.customExports.getCustomExportFormats(prefs, Globals.journalAbbreviationLoader); - LayoutFormatterPreferences layoutPreferences = prefs.getLayoutFormatterPreferences(Globals.journalAbbreviationLoader); - SavePreferences savePreferences = prefs.loadForExportFromPreferences(); - XmpPreferences xmpPreferences = prefs.getXMPPreferences(); + Map customExporters = preferences.customExports.getCustomExportFormats(preferences, Globals.journalAbbreviationLoader); + LayoutFormatterPreferences layoutPreferences = preferences.getLayoutFormatterPreferences(Globals.journalAbbreviationLoader); + SavePreferences savePreferences = preferences.loadForExportFromPreferences(); + XmpPreferences xmpPreferences = preferences.getXMPPreferences(); Globals.exportFactory = ExporterFactory.create(customExporters, layoutPreferences, savePreferences, xmpPreferences); FileDialogConfiguration fileDialogConfiguration = createExportFileChooser(Globals.exportFactory, Globals.prefs.get(JabRefPreferences.EXPORT_WORKING_DIRECTORY)); DialogService dialogService = frame.getDialogService(); From a4697646ba6e8e6b1e2dd04339f4f38f9ed7663b Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Sat, 12 May 2018 21:22:19 +0200 Subject: [PATCH 019/130] call System.exit after Platform.exit, as the latter one did not shutdown all running threads --- .../org/jabref/JabRefExecutorService.java | 2 +- src/main/java/org/jabref/JabRefMain.java | 31 +++++++++++++------ 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/jabref/JabRefExecutorService.java b/src/main/java/org/jabref/JabRefExecutorService.java index 3f5aa22badc..df127df89f6 100644 --- a/src/main/java/org/jabref/JabRefExecutorService.java +++ b/src/main/java/org/jabref/JabRefExecutorService.java @@ -140,7 +140,7 @@ public void shutdownEverything() { this.lowPriorityExecutorService.shutdownNow(); // kill the remote thread stopRemoteThread(); - // timer doesn't need to be canceled as it is run in daemon mode, which ensures that it is stopped if the application is shut down + timer.cancel(); } private class NamedRunnable implements Runnable { diff --git a/src/main/java/org/jabref/JabRefMain.java b/src/main/java/org/jabref/JabRefMain.java index fc2a8993209..bdc30d67a1c 100644 --- a/src/main/java/org/jabref/JabRefMain.java +++ b/src/main/java/org/jabref/JabRefMain.java @@ -66,11 +66,9 @@ private static void ensureCorrectJavaVersion() { if (java9Fail || versionFail) { StringBuilder versionError = new StringBuilder( - Localization.lang("Your current Java version (%0) is not supported. Please install version %1 or higher.", - checker.getJavaVersion(), - buildInfo.getMinRequiredJavaVersion() - ) - ); + Localization.lang("Your current Java version (%0) is not supported. Please install version %1 or higher.", + checker.getJavaVersion(), + buildInfo.getMinRequiredJavaVersion())); versionError.append("\n"); versionError.append(Localization.lang("Your Java Runtime Environment is located at %0.", checker.getJavaInstallationDirectory())); @@ -93,7 +91,11 @@ private static void ensureCorrectJavaVersion() { @Override public void start(Stage mainStage) throws Exception { FallbackExceptionHandler.installExceptionHandler(); - + + + + //Platform.setImplicitExit(true); + ensureCorrectJavaVersion(); // Init preferences @@ -121,7 +123,7 @@ public void start(Stage mainStage) throws Exception { // Update handling of special fields based on preferences InternalBibtexFields - .updateSpecialFields(Globals.prefs.getBoolean(JabRefPreferences.SERIALIZESPECIALFIELDS)); + .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: @@ -132,9 +134,9 @@ public void start(Stage mainStage) throws Exception { /* Build list of Import and Export formats */ Globals.IMPORT_FORMAT_READER.resetImportFormats(Globals.prefs.getImportFormatPreferences(), - Globals.prefs.getXMPPreferences(), Globals.getFileUpdateMonitor()); + Globals.prefs.getXMPPreferences(), Globals.getFileUpdateMonitor()); EntryTypes.loadCustomEntryTypes(preferences.loadCustomEntryTypes(BibDatabaseMode.BIBTEX), - preferences.loadCustomEntryTypes(BibDatabaseMode.BIBLATEX)); + preferences.loadCustomEntryTypes(BibDatabaseMode.BIBLATEX)); Globals.exportFactory = Globals.prefs.getExporterFactory(Globals.journalAbbreviationLoader); // Initialize protected terms loader @@ -151,9 +153,11 @@ public void start(Stage mainStage) throws Exception { // 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.stopBackgroundTasks(); Globals.shutdownThreadPools(); // needed to tell JavaFx to stop Platform.exit(); + System.exit(0); return; } } @@ -170,12 +174,21 @@ public void start(Stage mainStage) throws Exception { // See if we should shut down now if (argumentProcessor.shouldShutDown()) { + Globals.stopBackgroundTasks(); Globals.shutdownThreadPools(); Platform.exit(); + System.exit(0); return; } // If not, start GUI new JabRefGUI(mainStage, argumentProcessor.getParserResults(), argumentProcessor.isBlank()); } + + @Override + public void stop() { + System.out.println("stop"); + Platform.exit(); + System.exit(0); + } } From 0700051b370b1a87ddb5f895391754f61f0b0a5b Mon Sep 17 00:00:00 2001 From: Siedlerchr Date: Sat, 12 May 2018 21:43:22 +0200 Subject: [PATCH 020/130] fix checkstyle --- src/main/java/org/jabref/JabRefMain.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/main/java/org/jabref/JabRefMain.java b/src/main/java/org/jabref/JabRefMain.java index bdc30d67a1c..f4b61f6c8b9 100644 --- a/src/main/java/org/jabref/JabRefMain.java +++ b/src/main/java/org/jabref/JabRefMain.java @@ -92,10 +92,6 @@ private static void ensureCorrectJavaVersion() { public void start(Stage mainStage) throws Exception { FallbackExceptionHandler.installExceptionHandler(); - - - //Platform.setImplicitExit(true); - ensureCorrectJavaVersion(); // Init preferences @@ -187,7 +183,6 @@ public void start(Stage mainStage) throws Exception { @Override public void stop() { - System.out.println("stop"); Platform.exit(); System.exit(0); } From 899d267bb8f1a4e56873896f4fa85ac7d2fd6c6c Mon Sep 17 00:00:00 2001 From: Christoph Date: Sat, 12 May 2018 23:46:26 +0200 Subject: [PATCH 021/130] 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 f95229cfc6e053914ff2612296901955e89ba3b8 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Sun, 13 May 2018 17:00:01 +0200 Subject: [PATCH 022/130] Fix spelling --- .../gui/externalfiles/FindFullTextAction.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/jabref/gui/externalfiles/FindFullTextAction.java b/src/main/java/org/jabref/gui/externalfiles/FindFullTextAction.java index af390209343..b5470da1d3e 100644 --- a/src/main/java/org/jabref/gui/externalfiles/FindFullTextAction.java +++ b/src/main/java/org/jabref/gui/externalfiles/FindFullTextAction.java @@ -54,16 +54,18 @@ public void init() throws Exception { @Override public void run() { if (basePanel.getSelectedEntries().size() >= WARNING_LIMIT) { - - boolean getFullTextForAllCliecked = dialogService.showConfirmationDialogAndWait(Localization.lang("Look up full text documents"), Localization.lang( - "You are about to look up full text documents for %0 entries.", - String.valueOf(basePanel.getSelectedEntries().size())) + "\n" - + Localization.lang("JabRef will send at least one request per entry to a publisher.") - + "\n" - + Localization.lang("Do you still want to continue?"), Localization.lang("Look up full text documents"), + boolean confirmDownload = dialogService.showConfirmationDialogAndWait( + Localization.lang("Look up full text documents"), + Localization.lang( + "You are about to look up full text documents for %0 entries.", + String.valueOf(basePanel.getSelectedEntries().size())) + "\n" + + Localization.lang("JabRef will send at least one request per entry to a publisher.") + + "\n" + + Localization.lang("Do you still want to continue?"), + Localization.lang("Look up full text documents"), Localization.lang("Cancel")); - if (!getFullTextForAllCliecked) { + if (!confirmDownload) { basePanel.output(Localization.lang("Operation canceled.")); return; } From bbff88dbe8fccdce489e5bc4ad30ac8c2c949dbc Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Sun, 13 May 2018 17:10:01 +0200 Subject: [PATCH 023/130] Remove unused argument --- .../java/org/jabref/gui/fieldeditors/JournalEditor.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/jabref/gui/fieldeditors/JournalEditor.java b/src/main/java/org/jabref/gui/fieldeditors/JournalEditor.java index 84767243df7..af338ef26fa 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/JournalEditor.java +++ b/src/main/java/org/jabref/gui/fieldeditors/JournalEditor.java @@ -1,6 +1,5 @@ package org.jabref.gui.fieldeditors; -import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.Parent; import javafx.scene.layout.HBox; @@ -17,10 +16,8 @@ public class JournalEditor extends HBox implements FieldEditorFX { - @FXML - private JournalEditorViewModel viewModel; - @FXML - private EditorTextArea textArea; + @FXML private JournalEditorViewModel viewModel; + @FXML private EditorTextArea textArea; public JournalEditor(String fieldName, JournalAbbreviationLoader journalAbbreviationLoader, JabRefPreferences preferences, AutoCompleteSuggestionProvider suggestionProvider, FieldCheckers fieldCheckers) { this.viewModel = new JournalEditorViewModel(fieldName, suggestionProvider, journalAbbreviationLoader, preferences.getJournalAbbreviationPreferences(), fieldCheckers); @@ -52,7 +49,7 @@ public Parent getNode() { } @FXML - private void toggleAbbreviation(ActionEvent unused) { + private void toggleAbbreviation() { viewModel.toggleAbbreviation(); } } From 2909b7e0fc8a5002c77a1ddc84abca6b9d103ebb Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Sun, 13 May 2018 17:16:25 +0200 Subject: [PATCH 024/130] Fix formatting --- .../jabref/gui/filelist/AttachFileAction.java | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/jabref/gui/filelist/AttachFileAction.java b/src/main/java/org/jabref/gui/filelist/AttachFileAction.java index 70285312836..eac832389f7 100644 --- a/src/main/java/org/jabref/gui/filelist/AttachFileAction.java +++ b/src/main/java/org/jabref/gui/filelist/AttachFileAction.java @@ -32,24 +32,23 @@ public void execute() { } BibEntry entry = panel.getSelectedEntries().get(0); FileDialogConfiguration fileDialogConfiguration = new FileDialogConfiguration.Builder() - .withInitialDirectory(Globals.prefs.get(JabRefPreferences.WORKING_DIRECTORY)) - .build(); + .withInitialDirectory(Globals.prefs.get(JabRefPreferences.WORKING_DIRECTORY)) + .build(); dialogService.showFileOpenDialog(fileDialogConfiguration).ifPresent(newFile -> { LinkedFile newLinkedFile = new LinkedFile("", newFile.toString(), ""); LinkedFileEditDialogView dialog = new LinkedFileEditDialogView(newLinkedFile); - Optional editedLinkeDfile = dialog.showAndWait(); - editedLinkeDfile.ifPresent(file -> { - - Optional fieldChange = entry.addFile(file); - fieldChange.ifPresent(change -> { - UndoableFieldChange ce = new UndoableFieldChange(change); - panel.getUndoManager().addEdit(ce); - panel.markBaseChanged(); - }); - }); + dialog.showAndWait() + .ifPresent(editedLinkedFile -> { + Optional fieldChange = entry.addFile(editedLinkedFile); + fieldChange.ifPresent(change -> { + UndoableFieldChange ce = new UndoableFieldChange(change); + panel.getUndoManager().addEdit(ce); + panel.markBaseChanged(); + }); + }); }); } } From 75621724c7331d357c1af6ef0315bfdeb1e3a569 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Sun, 13 May 2018 17:17:17 +0200 Subject: [PATCH 025/130] Fix formatting --- src/main/java/org/jabref/gui/filelist/FileListEntryEditor.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/java/org/jabref/gui/filelist/FileListEntryEditor.java b/src/main/java/org/jabref/gui/filelist/FileListEntryEditor.java index d63e6e6f964..31c046720f0 100644 --- a/src/main/java/org/jabref/gui/filelist/FileListEntryEditor.java +++ b/src/main/java/org/jabref/gui/filelist/FileListEntryEditor.java @@ -84,9 +84,6 @@ public class FileListEntryEditor { //Do not make this variable final, as then the lambda action listener will fail on compiöe private BibDatabaseContext databaseContext; private final ActionListener browsePressed = e -> { - - - String fileText = link.getText().trim(); Optional file = FileHelper.expandFilename(this.databaseContext, fileText, Globals.prefs.getFileDirectoryPreferences()); From c56ebaf7b8458b50d748355d2c0a6543399d04a2 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Sun, 13 May 2018 17:23:03 +0200 Subject: [PATCH 026/130] Convert static methods to instance members (and fix spelling) --- .../org/jabref/gui/SidePaneComponent.java | 4 +-- .../jabref/gui/groups/GroupModeViewModel.java | 30 ++++++++++--------- .../org/jabref/gui/groups/GroupSidePane.java | 23 +++++++------- 3 files changed, 29 insertions(+), 28 deletions(-) diff --git a/src/main/java/org/jabref/gui/SidePaneComponent.java b/src/main/java/org/jabref/gui/SidePaneComponent.java index 0c2ced683a5..603a1bb1407 100644 --- a/src/main/java/org/jabref/gui/SidePaneComponent.java +++ b/src/main/java/org/jabref/gui/SidePaneComponent.java @@ -109,7 +109,7 @@ public final Node getHeader() { final HBox buttonContainer = new HBox(); buttonContainer.getChildren().addAll(up, down); - buttonContainer.getChildren().addAll(getAddtionalHeaderButtons()); + buttonContainer.getChildren().addAll(getAdditionalHeaderButtons()); buttonContainer.getChildren().add(close); BorderPane graphic = new BorderPane(); @@ -124,7 +124,7 @@ public final Node getHeader() { return container; } - protected List getAddtionalHeaderButtons() { + protected List getAdditionalHeaderButtons() { return Collections.emptyList(); } diff --git a/src/main/java/org/jabref/gui/groups/GroupModeViewModel.java b/src/main/java/org/jabref/gui/groups/GroupModeViewModel.java index fa513a7cb00..d88565f82ba 100644 --- a/src/main/java/org/jabref/gui/groups/GroupModeViewModel.java +++ b/src/main/java/org/jabref/gui/groups/GroupModeViewModel.java @@ -8,27 +8,29 @@ public class GroupModeViewModel { - public static Tooltip getUnionIntersectionTooltip(GroupViewMode mode) { - if (mode == GroupViewMode.UNION) { - return new Tooltip(Localization.lang("Toogle intersection")); - } - if (mode == GroupViewMode.INTERSECTION) { - return new Tooltip(Localization.lang("Toogle union")); - } - return new Tooltip(); + private GroupViewMode mode; + public GroupModeViewModel(GroupViewMode mode) { + this.mode = mode; } - public static Node getUnionIntersectionGraphic(GroupViewMode mode) { - + public Node getUnionIntersectionGraphic() { if (mode == GroupViewMode.UNION) { return JabRefIcons.GROUP_UNION.getGraphicNode(); - } - if (mode == GroupViewMode.INTERSECTION) { + } else if (mode == GroupViewMode.INTERSECTION) { return JabRefIcons.GROUP_INTERSECTION.getGraphicNode(); } - //as there is no concept like an empty node/icon, we return simply the other icon + + // As there is no concept like an empty node/icon, we return simply the other icon return JabRefIcons.GROUP_INTERSECTION.getGraphicNode(); + } + public Tooltip getUnionIntersectionTooltip() { + if (mode == GroupViewMode.UNION) { + return new Tooltip(Localization.lang("Toogle intersection")); + } else if (mode == GroupViewMode.INTERSECTION) { + return new Tooltip(Localization.lang("Toogle union")); + } + return new Tooltip(); } -} \ No newline at end of file +} diff --git a/src/main/java/org/jabref/gui/groups/GroupSidePane.java b/src/main/java/org/jabref/gui/groups/GroupSidePane.java index 3b93c145e44..9fedb7901e4 100644 --- a/src/main/java/org/jabref/gui/groups/GroupSidePane.java +++ b/src/main/java/org/jabref/gui/groups/GroupSidePane.java @@ -1,6 +1,6 @@ package org.jabref.gui.groups; -import java.util.Arrays; +import java.util.Collections; import java.util.List; import javafx.scene.Node; @@ -35,15 +35,15 @@ public GroupSidePane(SidePaneManager manager, JabRefPreferences preferences, Dia } @Override - protected List getAddtionalHeaderButtons() { + protected List getAdditionalHeaderButtons() { intersectionUnionToggle.setOnAction(event -> toggleUnionIntersection()); - return Arrays.asList(intersectionUnionToggle); + return Collections.singletonList(intersectionUnionToggle); } @Override public void afterOpening() { preferences.putBoolean(JabRefPreferences.GROUP_SIDEPANE_VISIBLE, Boolean.TRUE); - setGraphicsAndTooltipforButton(preferences.getGroupViewMode()); + setGraphicsAndTooltipForButton(preferences.getGroupViewMode()); } @Override @@ -67,19 +67,18 @@ private void toggleUnionIntersection() { if (mode == GroupViewMode.UNION) { preferences.setGroupViewMode(GroupViewMode.INTERSECTION); dialogService.notify(Localization.lang("Group view mode set to intersection")); - } - - if (mode == GroupViewMode.INTERSECTION) { + } else if (mode == GroupViewMode.INTERSECTION) { preferences.setGroupViewMode(GroupViewMode.UNION); - dialogService.notify(Localization.lang("Group view mode set to union")); } - setGraphicsAndTooltipforButton(mode); + + setGraphicsAndTooltipForButton(mode); } - private void setGraphicsAndTooltipforButton(GroupViewMode mode) { - intersectionUnionToggle.setGraphic(GroupModeViewModel.getUnionIntersectionGraphic(mode)); - intersectionUnionToggle.setTooltip(GroupModeViewModel.getUnionIntersectionTooltip(mode)); + private void setGraphicsAndTooltipForButton(GroupViewMode mode) { + GroupModeViewModel modeViewModel = new GroupModeViewModel(mode); + intersectionUnionToggle.setGraphic(modeViewModel.getUnionIntersectionGraphic()); + intersectionUnionToggle.setTooltip(modeViewModel.getUnionIntersectionTooltip()); } @Override From f610b6d682d8602aef82bdeba01673ea339cc66d Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Sun, 13 May 2018 17:36:04 +0200 Subject: [PATCH 027/130] Remove commented-out code --- .../java/org/jabref/gui/importer/fetcher/GeneralFetcher.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/org/jabref/gui/importer/fetcher/GeneralFetcher.java b/src/main/java/org/jabref/gui/importer/fetcher/GeneralFetcher.java index 142dd682016..487794ab9bb 100644 --- a/src/main/java/org/jabref/gui/importer/fetcher/GeneralFetcher.java +++ b/src/main/java/org/jabref/gui/importer/fetcher/GeneralFetcher.java @@ -71,7 +71,6 @@ protected Node createContentPane() { List fetchers = new EntryFetchers(Globals.journalAbbreviationLoader).getEntryFetchers(); EntryFetcher[] fetcherArray = fetchers.toArray(new EntryFetcher[fetchers.size()]); Arrays.sort(fetcherArray, new EntryFetcherComparator()); - //JLabel[] choices = new JLabel[fetchers.size()]; String[] choices = new String[fetcherArray.length]; for (int i = 0; i < fetcherArray.length; i++) { choices[i] = fetcherArray[i].getTitle(); @@ -158,7 +157,6 @@ protected Node createContentPane() { main.add(optPanel); main.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1)); - //add(main, BorderLayout.CENTER); go.addActionListener(this); tf.addActionListener(this); From d6bc06f18e4a7f675bf47356bd27bad70070f825 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Sun, 13 May 2018 17:55:11 +0200 Subject: [PATCH 028/130] Show tooltip for icon-based columns --- .../java/org/jabref/gui/maintable/MainTable.java | 16 +--------------- .../gui/maintable/MainTableColumnFactory.java | 13 ++++++++++--- src/main/resources/l10n/JabRef_en.properties | 1 + 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/src/main/java/org/jabref/gui/maintable/MainTable.java b/src/main/java/org/jabref/gui/maintable/MainTable.java index ec049c3b9c8..d704560cf49 100644 --- a/src/main/java/org/jabref/gui/maintable/MainTable.java +++ b/src/main/java/org/jabref/gui/maintable/MainTable.java @@ -78,9 +78,6 @@ public MainTable(MainTableDataModel model, JabRefFrame frame, // Enable sorting model.bindComparator(this.comparatorProperty()); - // TODO: Cannot add focus listener as it is expecting an swing component - //addFocusListener(Globals.getFocusListener()); - this.panel = panel; pane = new ScrollPane(this); @@ -88,18 +85,7 @@ public MainTable(MainTableDataModel model, JabRefFrame frame, pane.setFitToWidth(true); this.pane.getStylesheets().add(MainTable.class.getResource("MainTable.css").toExternalForm()); - - // TODO: Tooltip for column header - /* - @Override - public String getToolTipText(MouseEvent event) { - int index = columnModel.getColumnIndexAtX(event.getX()); - int realIndex = columnModel.getColumn(index).getModelIndex(); - MainTableColumn column = tableFormat.getTableColumn(realIndex); - return column.getDisplayName(); - } - */ - + // Store visual state new PersistenceVisualStateTable(this, Globals.prefs); diff --git a/src/main/java/org/jabref/gui/maintable/MainTableColumnFactory.java b/src/main/java/org/jabref/gui/maintable/MainTableColumnFactory.java index 51f563095b6..fa771bc9a3b 100644 --- a/src/main/java/org/jabref/gui/maintable/MainTableColumnFactory.java +++ b/src/main/java/org/jabref/gui/maintable/MainTableColumnFactory.java @@ -43,6 +43,7 @@ import org.jabref.model.entry.specialfields.SpecialField; import org.jabref.model.entry.specialfields.SpecialFieldValue; import org.jabref.model.groups.AbstractGroup; +import org.jabref.model.strings.StringUtil; import org.jabref.model.util.OptionalUtil; import org.controlsfx.control.Rating; @@ -164,7 +165,9 @@ private Node createGroupColorRegion(BibEntryTableViewModel entry, List> createSpecialFieldColumn(SpecialField specialField) { TableColumn> column = new TableColumn<>(); SpecialFieldViewModel specialFieldViewModel = new SpecialFieldViewModel(specialField, undoManager); - column.setGraphic(specialFieldViewModel.getIcon().getGraphicNode()); + Node headerGraphic = specialFieldViewModel.getIcon().getGraphicNode(); + Tooltip.install(headerGraphic, new Tooltip(specialFieldViewModel.getLocalization())); + column.setGraphic(headerGraphic); column.getStyleClass().add(ICON_COLUMN); if (specialField == SpecialField.RANKING) { setExactWidth(column, GUIGlobals.WIDTH_ICON_COL_RANKING); @@ -239,7 +242,9 @@ private void setExactWidth(TableColumn column, int width) { private TableColumn> createFileColumn() { TableColumn> column = new TableColumn<>(); - column.setGraphic(IconTheme.JabRefIcons.FILE.getGraphicNode()); + Node headerGraphic = IconTheme.JabRefIcons.FILE.getGraphicNode(); + Tooltip.install(headerGraphic, new Tooltip(Localization.lang("Linked files"))); + column.setGraphic(headerGraphic); column.getStyleClass().add(ICON_COLUMN); setExactWidth(column, GUIGlobals.WIDTH_ICON_COL); column.setCellValueFactory(cellData -> cellData.getValue().getLinkedFiles()); @@ -289,7 +294,9 @@ private ContextMenu createFileMenu(BibEntryTableViewModel entry, List createUrlOrDoiColumn(JabRefIcon icon, String firstField, String secondField) { TableColumn column = new TableColumn<>(); - column.setGraphic(icon.getGraphicNode()); + Node headerGraphic = icon.getGraphicNode(); + Tooltip.install(headerGraphic, new Tooltip(StringUtil.capitalizeFirst(firstField) + " / " + StringUtil.capitalizeFirst(secondField))); + column.setGraphic(headerGraphic); column.getStyleClass().add(ICON_COLUMN); setExactWidth(column, GUIGlobals.WIDTH_ICON_COL); // icon is chosen based on field name in cell, so map fields to its names diff --git a/src/main/resources/l10n/JabRef_en.properties b/src/main/resources/l10n/JabRef_en.properties index ce86c338a3c..23791f8795b 100644 --- a/src/main/resources/l10n/JabRef_en.properties +++ b/src/main/resources/l10n/JabRef_en.properties @@ -2377,3 +2377,4 @@ Toggle\ union=Toggle union Hide\ panel=Hide panel Move\ panel\ up=Move panel up Move\ panel\ down=Move panel down +Linked\ files=Linked files From 7b0cedf2d8f1c4383de182b56053e90208c61a55 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Sun, 13 May 2018 18:00:49 +0200 Subject: [PATCH 029/130] Remove unused class --- .../maintable/MainTableSelectionListener.java | 466 ------------------ 1 file changed, 466 deletions(-) delete mode 100644 src/main/java/org/jabref/gui/maintable/MainTableSelectionListener.java diff --git a/src/main/java/org/jabref/gui/maintable/MainTableSelectionListener.java b/src/main/java/org/jabref/gui/maintable/MainTableSelectionListener.java deleted file mode 100644 index 0bb70a885b8..00000000000 --- a/src/main/java/org/jabref/gui/maintable/MainTableSelectionListener.java +++ /dev/null @@ -1,466 +0,0 @@ -package org.jabref.gui.maintable; - -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; - -import javax.swing.JPopupMenu; -import javax.swing.Timer; - -import org.jabref.gui.BasePanel; -import org.jabref.gui.BasePanelMode; -import org.jabref.gui.PreviewPanel; -import org.jabref.gui.entryeditor.EntryEditor; -import org.jabref.model.entry.BibEntry; - -import ca.odell.glazedlists.BasicEventList; -import ca.odell.glazedlists.EventList; -import ca.odell.glazedlists.event.ListEvent; -import ca.odell.glazedlists.event.ListEventListener; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * List event, mouse, key and focus listener for the main table that makes up the - * most part of the BasePanel for a single BIB database. - */ -public class MainTableSelectionListener implements ListEventListener, MouseListener, KeyListener, FocusListener { - private static final Logger LOGGER = LoggerFactory.getLogger(MainTableSelectionListener.class); - - private final MainTable table; - private final BasePanel panel; - - private final EventList tableRows; - // Register the last character pressed to quick jump in the table. Together - // with storing the last row number jumped to, this is used to let multiple - // key strokes cycle between all entries starting with the same letter: - private final int[] lastPressed = new int[20]; - private PreviewPanel preview; - private boolean workingOnPreview; - private boolean enabled = true; - private int lastPressedCount; - - private long lastPressedTime; - - public MainTableSelectionListener(BasePanel panel, MainTable table) { - this.table = table; - this.panel = panel; - this.tableRows = new BasicEventList<>(); - preview = panel.getPreviewPanel(); - } - - public void setEnabled(boolean enabled) { - this.enabled = enabled; - } - - @Override - public void listChanged(ListEvent e) { - if (!enabled) { - return; - } - - EventList selected = e.getSourceList(); - if (selected.isEmpty()) { - return; - } - - final BibEntry newSelected = selected.get(0); - if ((panel.getMode() == BasePanelMode.SHOWING_EDITOR || panel.getMode() == BasePanelMode.WILL_SHOW_EDITOR) - && panel.getEntryEditor() != null && newSelected == panel.getEntryEditor().getEntry()) { - // entry already selected and currently editing it, do not steal the focus from the selected textfield - return; - } - - if (newSelected != null) { - // TODO: Update entry editor / preview on selection change - /* - final BasePanelMode mode = panel.getMode(); // What is the panel already showing? - if ((mode == BasePanelMode.WILL_SHOW_EDITOR) || (mode == BasePanelMode.SHOWING_EDITOR)) { - panel.showAndEdit(newSelected); - SwingUtilities.invokeLater(() -> table.ensureVisible(table.getSelectedRow())); - } else if (panel.getMode() == BasePanelMode.SHOWING_NOTHING || panel.getMode() == BasePanelMode.SHOWING_PREVIEW) { - // Either nothing or a preview was shown. Update the preview. - updatePreview(newSelected); - } - */ - } - } - - private void updatePreview(final BibEntry toShow) { - updatePreview(toShow, 0); - } - - private void updatePreview(final BibEntry toShow, int repeats) { - if (workingOnPreview) { - if (repeats > 0) { - return; // We've already waited once. Give up on this selection. - } - Timer t = new Timer(50, actionEvent -> updatePreview(toShow, 1)); - t.setRepeats(false); - t.start(); - return; - } - /* - EventList list = table.getSelected(); - // Check if the entry to preview is still selected: - if ((list.size() != 1) || (list.get(0) != toShow)) { - return; - } - workingOnPreview = true; - SwingUtilities.invokeLater(() -> { - panel.showPreview(toShow); - workingOnPreview = false; - }); - */ - } - - @Override - public void mouseReleased(MouseEvent e) { - // TODO: Right-click menu for special columns - /* - // Check if the user has right-clicked. If so, open the right-click menu. - if (e.isPopupTrigger() || (e.getButton() == MouseEvent.BUTTON3)) { - if ((modelColumn == null) || !modelColumn.isIconColumn()) { - // show normal right click menu - processPopupTrigger(e, row); - } else { - // show right click menu for icon columns - showIconRightClickMenu(e, row, modelColumn); - } - } - */ - } - - @Override - public void mousePressed(MouseEvent e) { - // all handling is done in "mouseReleased" - } - - @Override - public void mouseClicked(MouseEvent e) { - /* - // First find the column on which the user has clicked. - final int row = table.rowAtPoint(e.getPoint()); - - // A double click on an entry should open the entry's editor. - if (e.getClickCount() == 2) { - BibEntry toShow = tableRows.get(row); - panel.showAndEdit(toShow); - return; - } - - final int col = table.columnAtPoint(e.getPoint()); - // get the MainTableColumn which is currently visible at col - int modelIndex = table.getColumnModel().getColumn(col).getModelIndex(); - MainTableColumn modelColumn = table.getMainTableColumn(modelIndex); - - // Workaround for Windows. Right-click is not popup trigger on mousePressed, but - // on mouseReleased. Therefore we need to avoid taking action at this point, because - // action will be taken when the button is released: - if (OS.WINDOWS && (modelColumn.isIconColumn()) && (e.getButton() != MouseEvent.BUTTON1)) { - return; - } - - // Check if the clicked colum is a specialfield column - if (modelColumn.isIconColumn() && (SpecialField.isSpecialField(modelColumn.getColumnName()))) { - // handle specialfield - handleSpecialFieldLeftClick(e, modelColumn.getColumnName()); - } else if (modelColumn.isIconColumn()) { // left click on icon field - - Object value = table.getValueAt(row, col); - if (value == null) { - return; // No icon here, so we do nothing. - } - - final BibEntry entry = tableRows.get(row); - - final List fieldNames = modelColumn.getBibtexFields(); - - // Open it now. We do this in a thread, so the program won't freeze during the wait. - JabRefExecutorService.INSTANCE.execute(() -> { - panel.output(Localization.lang("External viewer called") + '.'); - // check for all field names whether a link is present - // (is relevant for combinations such as "url/doi") - for (String fieldName : fieldNames) { - // Check if field is present, if not skip this field - if (entry.hasField(fieldName)) { - String link = entry.getField(fieldName).get(); - - // See if this is a simple file link field, or if it is a file-list - // field that can specify a list of links: - if (fieldName.equals(FieldName.FILE)) { - - // We use a FileListTableModel to parse the field content: - FileListTableModel fileList = new FileListTableModel(); - fileList.setContent(link); - - FileListEntry flEntry = null; - // If there are one or more links of the correct type, open the first one: - if (modelColumn.isFileFilter()) { - for (int i = 0; i < fileList.getRowCount(); i++) { - if (fileList.getEntry(i).getType().toString().equals(modelColumn.getColumnName())) { - flEntry = fileList.getEntry(i); - break; - } - } - } else if (fileList.getRowCount() > 0) { - //If there are no file types specified open the first file - flEntry = fileList.getEntry(0); - } - if (flEntry != null) { - ExternalFileMenuItem item = new ExternalFileMenuItem(panel.frame(), entry, "", - flEntry.getLink(), flEntry.getType().map(ExternalFileType::getIcon).orElse(null), - panel.getBibDatabaseContext(), flEntry.getType()); - item.doClick(); - } - } else { - try { - JabRefDesktop.openExternalViewer(panel.getBibDatabaseContext(), link, fieldName); - } catch (IOException ex) { - panel.output(Localization.lang("Unable to open link.")); - LOGGER.info("Unable to open link", ex); - } - } - break; // only open the first link - } - } - }); - } else if (modelColumn.getBibtexFields().contains(FieldName.CROSSREF)) { // Clicking on crossref column - tableRows.get(row).getField(FieldName.CROSSREF) - .ifPresent(crossref -> panel.getDatabase().getEntryByKey(crossref).ifPresent(entry -> panel.highlightEntry(entry))); - } - panel.frame().updateEnabledState(); - */ - } - - /** - * Method to handle a single left click on one the special fields (e.g., ranking, quality, ...) - * Shows either a popup to select/clear a value or simply toggles the functionality to set/unset the special field - * - * @param e MouseEvent used to determine the position of the popups - * @param columnName the name of the specialfield column - */ - private void handleSpecialFieldLeftClick(MouseEvent e, String columnName) { - /* - if ((e.getClickCount() == 1)) { - SpecialField.getSpecialFieldInstanceFromFieldName(columnName).ifPresent(field -> { - // special field found - if (field.isSingleValueField()) { - // directly execute toggle action instead of showing a menu with one action - new SpecialFieldViewModel(field).getSpecialFieldAction(field.getValues().get(0), panel.frame()).action(); - } else { - JPopupMenu menu = new JPopupMenu(); - for (SpecialFieldValue val : field.getValues()) { - menu.add(new SpecialFieldMenuAction(new SpecialFieldValueViewModel(val), panel.frame())); - } - menu.show(table, e.getX(), e.getY()); - } - }); - } - */ - } - - /** - * Process general right-click events on the table. Show the table context menu at - * the position where the user right-clicked. - * @param e The mouse event defining the popup trigger. - * @param row The row where the event occurred. - */ - private void processPopupTrigger(MouseEvent e, int row) { - /* - int selRow = table.getSelectedRow(); - if ((selRow == -1) || !table.isRowSelected(table.rowAtPoint(e.getPoint()))) { - table.setRowSelectionInterval(row, row); - } - RightClickMenu rightClickMenu = new RightClickMenu(JabRefGUI.getMainFrame(), panel); - rightClickMenu.show(table, e.getX(), e.getY()); - */ - } - - /** - * Process popup trigger events occurring on an icon cell in the table. Show a menu where the user can choose which - * external resource to open for the entry. If no relevant external resources exist, let the normal popup trigger - * handler do its thing instead. - * - * @param e The mouse event defining this popup trigger. - * @param row The row where the event occurred. - * @param column the MainTableColumn associated with this table cell. - */ - private void showIconRightClickMenu(MouseEvent e, int row, MainTableColumn column) { - BibEntry entry = tableRows.get(row); - JPopupMenu menu = new JPopupMenu(); - boolean showDefaultPopup = true; - - /* - // See if this is a simple file link field, or if it is a file-list - // field that can specify a list of links: - if (!column.getBibtexFields().isEmpty()) { - for (String field : column.getBibtexFields()) { - if (FieldName.FILE.equals(field)) { - // We use a FileListTableModel to parse the field content: - FileListTableModel fileList = new FileListTableModel(); - entry.getField(field).ifPresent(fileList::setContent); - for (int i = 0; i < fileList.getRowCount(); i++) { - FileListEntry flEntry = fileList.getEntry(i); - if (column.isFileFilter() - && (!flEntry.getType().get().getName().equalsIgnoreCase(column.getColumnName()))) { - continue; - } - String description = flEntry.getDescription(); - if ((description == null) || (description.trim().isEmpty())) { - description = flEntry.getLink(); - } - - Optional fileType = flEntry.getType(); - - // file type might be unknown - if (!fileType.isPresent()) { - String fileExtension = FileUtil.getFileExtension(flEntry.getLink()).orElse(""); - fileType = Optional.of(new UnknownExternalFileType(fileExtension.toUpperCase(), fileExtension)); - } - menu.add(new ExternalFileMenuItem(panel.frame(), entry, description, flEntry.getLink(), - fileType.get().getIcon(), panel.getBibDatabaseContext(), fileType)); - showDefaultPopup = false; - } - } else { - if (SpecialField.isSpecialField(column.getColumnName())) { - // full pop should be shown as left click already shows short popup - showDefaultPopup = true; - } else { - Optional content = entry.getField(field); - if (content.isPresent()) { - Icon icon; - JLabel iconLabel = GUIGlobals.getTableIcon(field); - if (iconLabel == null) { - icon = IconTheme.JabRefIcon.FILE.getIcon(); - } else { - icon = iconLabel.getIcon(); - } - menu.add(new ExternalFileMenuItem(panel.frame(), entry, content.get(), content.get(), icon, - panel.getBibDatabaseContext(), field)); - if (field.equals(FieldName.DOI)) { - menu.add(new CopyDoiUrlAction(content.get())); - } - showDefaultPopup = false; - } - } - } - } - if (showDefaultPopup) { - processPopupTrigger(e, row); - } else { - menu.show(table, e.getX(), e.getY()); - } - } - */ - } - - public void entryEditorClosing(EntryEditor editor) { - /* - if (Globals.prefs.getPreviewPreferences().isPreviewPanelEnabled()) { - panel.showPreview(editor.getEntry()); - } else { - panel.hideBottomComponent(); - panel.adjustSplitter(); - } - table.requestFocus(); - */ - } - - @Override - public void mouseEntered(MouseEvent e) { - // Do nothing - } - - @Override - public void mouseExited(MouseEvent e) { - // Do nothing - } - - /** - * Receive key event on the main table. If the key is a letter or a digit, - * we should select the first entry in the table which starts with the given - * letter in the column by which the table is sorted. - * @param e The KeyEvent - */ - @Override - public void keyTyped(KeyEvent e) { - /* - if ((!e.isActionKey()) && Character.isLetterOrDigit(e.getKeyChar()) - && (e.getModifiers() == 0)) { - long time = System.currentTimeMillis(); - final long QUICK_JUMP_TIMEOUT = 2000; - if ((time - lastPressedTime) > QUICK_JUMP_TIMEOUT) { - lastPressedCount = 0; // Reset last pressed character - } - // Update timestamp: - lastPressedTime = time; - // Add the new char to the search array: - int c = e.getKeyChar(); - if (lastPressedCount < lastPressed.length) { - lastPressed[lastPressedCount] = c; - lastPressedCount++; - } - - int sortingColumn = table.getSortingColumn(0); - if (sortingColumn == -1) { - return; // No sorting? TODO: look up by author, etc.? - } - // TODO: the following lookup should be done by a faster algorithm, - // such as binary search. But the table may not be sorted properly, - // due to marked entries, search etc., which rules out the binary search. - - for (int i = 0; i < table.getRowCount(); i++) { - Object o = table.getValueAt(i, sortingColumn); - if (o == null) { - continue; - } - String s = o.toString().toLowerCase(Locale.ROOT); - if (s.length() >= lastPressedCount) { - for (int j = 0; j < lastPressedCount; j++) { - if (s.charAt(j) != lastPressed[j]) { - break; // Escape the loop immediately when we find a mismatch - } else if (j == (lastPressedCount - 1)) { - // We found a match: - table.setRowSelectionInterval(i, i); - table.ensureVisible(i); - return; - } - } - } - } - - } else if (e.getKeyChar() == KeyEvent.VK_ESCAPE) { - lastPressedCount = 0; - } - panel.frame().updateEnabledState(); - */ - } - - @Override - public void keyReleased(KeyEvent e) { - // Do nothing - } - - @Override - public void keyPressed(KeyEvent e) { - // Do nothing - } - - @Override - public void focusGained(FocusEvent e) { - // Do nothing - } - - @Override - public void focusLost(FocusEvent e) { - lastPressedCount = 0; // Reset quick jump when focus is lost. - } - - public PreviewPanel getPreview() { - return preview; - } -} From 591992cea530841482f778d3bb774b402b9de42e Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Sun, 13 May 2018 18:06:06 +0200 Subject: [PATCH 030/130] Extract dialog service to field --- .../gui/openoffice/OpenOfficePanel.java | 40 ++++++++++--------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java b/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java index 5362f5fab4e..eca428640e3 100644 --- a/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java +++ b/src/main/java/org/jabref/gui/openoffice/OpenOfficePanel.java @@ -79,6 +79,7 @@ public class OpenOfficePanel extends AbstractWorker { private static final Logger LOGGER = LoggerFactory.getLogger(OpenOfficePanel.class); + private final DialogService dialogService; private JPanel content; @@ -130,6 +131,7 @@ public OpenOfficePanel(JabRefFrame jabRefFrame) { this.frame = jabRefFrame; initPanel(); + dialogService = frame.getDialogService(); } public JPanel getContent() { @@ -151,7 +153,7 @@ private void initPanel() { } catch (UnknownPropertyException | WrappedTargetException | IndexOutOfBoundsException | NoSuchElementException | NoDocumentException ex) { LOGGER.warn("Problem connecting", ex); - frame.getDialogService().showErrorDialogAndWait(ex); + dialogService.showErrorDialogAndWait(ex); } }); @@ -202,7 +204,7 @@ public void actionPerformed(ActionEvent e) { List unresolvedKeys = ooBase.refreshCiteMarkers(databases, style); ooBase.rebuildBibTextSection(databases, style); if (!unresolvedKeys.isEmpty()) { - frame.getDialogService().showErrorDialogAndWait(Localization.lang("Unable to synchronize bibliography"), + dialogService.showErrorDialogAndWait(Localization.lang("Unable to synchronize bibliography"), Localization.lang("Your OpenOffice/LibreOffice document references the BibTeX key '%0', which could not be found in your current library.", unresolvedKeys.get(0))); @@ -215,12 +217,12 @@ public void actionPerformed(ActionEvent e) { showConnectionLostErrorMessage(); } catch (IOException ex) { LOGGER.warn("Problem with style file", ex); - frame.getDialogService().showErrorDialogAndWait(Localization.lang("No valid style file defined"), + dialogService.showErrorDialogAndWait(Localization.lang("No valid style file defined"), Localization.lang("You must select either a valid style file, or use one of the default styles.")); } catch (BibEntryNotFoundException ex) { LOGGER.debug("BibEntry not found", ex); - frame.getDialogService().showErrorDialogAndWait(Localization.lang("Unable to synchronize bibliography"), Localization.lang( + dialogService.showErrorDialogAndWait(Localization.lang("Unable to synchronize bibliography"), Localization.lang( "Your OpenOffice/LibreOffice document references the BibTeX key '%0', which could not be found in your current library.", ex.getBibtexKey())); @@ -248,7 +250,7 @@ public void actionPerformed(ActionEvent e) { settingsB.addActionListener(e -> showSettingsPopup()); manageCitations.addActionListener(e -> { try { - CitationManager cm = new CitationManager(ooBase, frame.getDialogService()); + CitationManager cm = new CitationManager(ooBase, dialogService); cm.showDialog(); } catch (NoSuchElementException | WrappedTargetException | UnknownPropertyException ex) { LOGGER.warn("Problem showing citation manager", ex); @@ -318,7 +320,7 @@ private void exportEntries() { BibDatabase newDatabase = ooBase.generateDatabase(databases); if (!unresolvedKeys.isEmpty()) { - frame.getDialogService().showErrorDialogAndWait(Localization.lang("Unable to generate new library"), + dialogService.showErrorDialogAndWait(Localization.lang("Unable to generate new library"), Localization.lang("Your OpenOffice/LibreOffice document references the BibTeX key '%0', which could not be found in your current library.", unresolvedKeys.get(0))); @@ -331,7 +333,7 @@ private void exportEntries() { } catch (BibEntryNotFoundException ex) { LOGGER.debug("BibEntry not found", ex); - frame.getDialogService().showErrorDialogAndWait(Localization.lang("Unable to synchronize bibliography"), + dialogService.showErrorDialogAndWait(Localization.lang("Unable to synchronize bibliography"), Localization.lang("Your OpenOffice/LibreOffice document references the BibTeX key '%0', which could not be found in your current library.", ex.getBibtexKey())); @@ -358,10 +360,10 @@ private List getBaseList() { private void connect(boolean autoDetect) { if (autoDetect) { - DetectOpenOfficeInstallation officeInstallation = new DetectOpenOfficeInstallation(diag, preferences, frame.getDialogService()); + DetectOpenOfficeInstallation officeInstallation = new DetectOpenOfficeInstallation(diag, preferences, dialogService); if (!officeInstallation.isInstalled()) { - frame.getDialogService().showErrorDialogAndWait(Localization.lang("Autodetection failed"), Localization.lang("Autodetection failed")); + dialogService.showErrorDialogAndWait(Localization.lang("Autodetection failed"), Localization.lang("Autodetection failed")); return; } diag.dispose(); @@ -379,7 +381,7 @@ private void connect(boolean autoDetect) { loadOpenOfficeJars(Paths.get(preferences.getInstallationPath())); // Show progress dialog: - progressDialog = new DetectOpenOfficeInstallation(diag, preferences, frame.getDialogService()) + progressDialog = new DetectOpenOfficeInstallation(diag, preferences, dialogService) .showProgressDialog(diag, Localization.lang("Connecting"), Localization.lang("Please wait...")); getWorker().run(); // Do the actual connection, using Spin to get off the EDT. progressDialog.dispose(); @@ -406,13 +408,13 @@ private void connect(boolean autoDetect) { } catch (UnsatisfiedLinkError e) { LOGGER.warn("Could not connect to running OpenOffice/LibreOffice", e); - frame.getDialogService().showErrorDialogAndWait(Localization.lang("Unable to connect. One possible reason is that JabRef " + dialogService.showErrorDialogAndWait(Localization.lang("Unable to connect. One possible reason is that JabRef " + "and OpenOffice/LibreOffice are not both running in either 32 bit mode or 64 bit mode.")); } catch (IOException e) { LOGGER.warn("Could not connect to running OpenOffice/LibreOffice", e); - frame.getDialogService().showErrorDialogAndWait(Localization.lang("Could not connect to running OpenOffice/LibreOffice."), + dialogService.showErrorDialogAndWait(Localization.lang("Could not connect to running OpenOffice/LibreOffice."), Localization.lang("Could not connect to running OpenOffice/LibreOffice.") + "\n" + Localization.lang("Make sure you have installed OpenOffice/LibreOffice with Java support.") + "\n" + Localization.lang("If connecting manually, please verify program and library paths.") @@ -475,7 +477,7 @@ private void showManualConnectionDialog() { final JDialog cDiag = new JDialog((JFrame) null, Localization.lang("Set connection parameters"), true); final NativeDesktop nativeDesktop = JabRefDesktop.getNativeDesktop(); - final DialogService dialogService = frame.getDialogService(); + final DialogService dialogService = this.dialogService; DirectoryDialogConfiguration dirDialogConfiguration = new DirectoryDialogConfiguration.Builder() .withInitialDirectory(nativeDesktop.getApplicationDirectory()) .build(); @@ -556,7 +558,7 @@ private void showManualConnectionDialog() { private void pushEntries(boolean inParenthesisIn, boolean withText, boolean addPageInfo) { if (!ooBase.isConnectedToDocument()) { - DefaultTaskExecutor.runInJavaFXThread(() -> frame.getDialogService().showErrorDialogAndWait( + DefaultTaskExecutor.runInJavaFXThread(() -> dialogService.showErrorDialogAndWait( Localization.lang("Error pushing entries"), Localization.lang("Not connected to any Writer document. Please" + " make sure a document is open, and use the 'Select Writer document' button to connect to it."))); @@ -592,7 +594,7 @@ private void pushEntries(boolean inParenthesisIn, boolean withText, boolean addP preferences.getSyncWhenCiting()); } catch (FileNotFoundException ex) { - DefaultTaskExecutor.runInJavaFXThread(() -> frame.getDialogService().showErrorDialogAndWait( + DefaultTaskExecutor.runInJavaFXThread(() -> dialogService.showErrorDialogAndWait( Localization.lang("No valid style file defined"), Localization.lang("You must select either a valid style file, or use one of the default styles."))); @@ -638,7 +640,7 @@ private boolean checkThatEntriesHaveKeys(List entries) { } // Ask if keys should be generated - boolean citePressed = frame.getDialogService().showConfirmationDialogAndWait(Localization.lang("Cite"), + boolean citePressed = dialogService.showConfirmationDialogAndWait(Localization.lang("Cite"), Localization.lang("Cannot cite entries without BibTeX keys. Generate keys now?"), Localization.lang("Generate keys"), Localization.lang("Cancel")); @@ -668,14 +670,14 @@ private boolean checkThatEntriesHaveKeys(List entries) { } private void showConnectionLostErrorMessage() { - DefaultTaskExecutor.runInJavaFXThread(() -> frame.getDialogService().showErrorDialogAndWait(Localization.lang("Connection lost"), + DefaultTaskExecutor.runInJavaFXThread(() -> dialogService.showErrorDialogAndWait(Localization.lang("Connection lost"), Localization.lang("Connection to OpenOffice/LibreOffice has been lost. " + "Please make sure OpenOffice/LibreOffice is running, and try to reconnect."))); } private void reportUndefinedParagraphFormat(UndefinedParagraphFormatException ex) { - DefaultTaskExecutor.runInJavaFXThread(() -> frame.getDialogService().showErrorDialogAndWait(Localization.lang("Undefined paragraph format"), + DefaultTaskExecutor.runInJavaFXThread(() -> dialogService.showErrorDialogAndWait(Localization.lang("Undefined paragraph format"), Localization.lang("Your style file specifies the paragraph format '%0', " + "which is undefined in your current OpenOffice/LibreOffice document.", ex.getFormatName()) @@ -685,7 +687,7 @@ private void reportUndefinedParagraphFormat(UndefinedParagraphFormatException ex } private void reportUndefinedCharacterFormat(UndefinedCharacterFormatException ex) { - DefaultTaskExecutor.runInJavaFXThread(() -> frame.getDialogService().showErrorDialogAndWait(Localization.lang("Undefined character format"), + DefaultTaskExecutor.runInJavaFXThread(() -> dialogService.showErrorDialogAndWait(Localization.lang("Undefined character format"), Localization.lang( "Your style file specifies the character format '%0', " + "which is undefined in your current OpenOffice/LibreOffice document.", From c62070bf1421dc0c19140c27d3ce836655d71292 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Sun, 13 May 2018 18:08:19 +0200 Subject: [PATCH 031/130] Extract dialog service to field --- .../org/jabref/gui/openoffice/StyleSelectDialog.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/jabref/gui/openoffice/StyleSelectDialog.java b/src/main/java/org/jabref/gui/openoffice/StyleSelectDialog.java index 826523d6858..901e2afd0da 100644 --- a/src/main/java/org/jabref/gui/openoffice/StyleSelectDialog.java +++ b/src/main/java/org/jabref/gui/openoffice/StyleSelectDialog.java @@ -34,6 +34,7 @@ import javafx.scene.Scene; import org.jabref.Globals; +import org.jabref.gui.DialogService; import org.jabref.gui.JabRefDialog; import org.jabref.gui.JabRefFrame; import org.jabref.gui.PreviewPanel; @@ -78,6 +79,7 @@ class StyleSelectDialog { private static final Logger LOGGER = LoggerFactory.getLogger(StyleSelectDialog.class); private final JabRefFrame frame; + private final DialogService dialogService; private EventList styles; private JDialog diag; private JTable table; @@ -107,6 +109,7 @@ public StyleSelectDialog(JabRefFrame frame, OpenOfficePreferences preferences, S this.loader = Objects.requireNonNull(loader); prevEntry = TestEntry.getTestEntry(); init(); + dialogService = frame.getDialogService(); } private void init() { @@ -131,7 +134,7 @@ private void init() { // Create a preview panel for previewing styles // Must be done before creating the table to avoid NPEs DefaultTaskExecutor.runInJavaFXThread(() -> { - preview = new PreviewPanel(null, null, Globals.getKeyPrefs(), Globals.prefs.getPreviewPreferences(), frame.getDialogService()); + preview = new PreviewPanel(null, null, Globals.getKeyPrefs(), Globals.prefs.getPreviewPreferences(), dialogService); // Use the test entry from the Preview settings tab in Preferences: preview.setEntry(prevEntry); }); @@ -162,7 +165,7 @@ private void init() { @Override public void actionPerformed(ActionEvent event) { if ((table.getRowCount() == 0) || (table.getSelectedRowCount() == 0)) { - frame.getDialogService().showErrorDialogAndWait(Localization.lang("Style selection"), + dialogService.showErrorDialogAndWait(Localization.lang("Style selection"), Localization.lang("You must select a valid style file.")); return; } @@ -265,7 +268,7 @@ private void setupPopupMenu() { // Create action listener for removing a style, also used for the remove button removeAction = actionEvent -> getSelectedStyle().ifPresent(style -> { - if (!style.isFromResource() && frame.getDialogService().showConfirmationDialogAndWait(Localization.lang("Remove style"), + if (!style.isFromResource() && dialogService.showConfirmationDialogAndWait(Localization.lang("Remove style"), Localization.lang("Are you sure you want to remove the style?"), Localization.lang("Remove style"), Localization.lang("Cancel"))) { @@ -473,7 +476,7 @@ public AddFileDialog() { browse.addActionListener(e -> { Optional file = DefaultTaskExecutor - .runInJavaFXThread(() -> frame.getDialogService().showFileOpenDialog(fileDialogConfiguration)); + .runInJavaFXThread(() -> dialogService.showFileOpenDialog(fileDialogConfiguration)); file.ifPresent(f -> newFile.setText(f.toAbsolutePath().toString())); }); From 287a21b48796b2640a3816f77fdbcd9c3381e288 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Sun, 13 May 2018 18:17:55 +0200 Subject: [PATCH 032/130] Move color related method --- .../java/org/jabref/gui/entryeditor/EntryEditor.java | 11 ++++------- src/main/java/org/jabref/gui/util/ColorUtil.java | 4 ++++ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java index cacdb605d01..61ed4e04c5a 100644 --- a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java +++ b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java @@ -29,6 +29,7 @@ import org.jabref.gui.mergeentries.EntryFetchAndMergeWorker; import org.jabref.gui.undo.CountingUndoManager; import org.jabref.gui.undo.UndoableKeyChange; +import org.jabref.gui.util.ColorUtil; import org.jabref.gui.util.DefaultTaskExecutor; import org.jabref.logic.TypedBibEntry; import org.jabref.logic.bibtexkeypattern.BibtexKeyGenerator; @@ -90,9 +91,9 @@ public EntryEditor(BasePanel panel, EntryEditorPreferences preferences, FileUpda if (GUIGlobals.currentFont != null) { setStyle( - "text-area-background: " + convertToHex(GUIGlobals.validFieldBackgroundColor) + ";" - + "text-area-foreground: " + convertToHex(GUIGlobals.editorTextColor) + ";" - + "text-area-highlight: " + convertToHex(GUIGlobals.activeBackgroundColor) + ";"); + "text-area-background: " + ColorUtil.toHex(GUIGlobals.validFieldBackgroundColor) + ";" + + "text-area-foreground: " + ColorUtil.toHex(GUIGlobals.editorTextColor) + ";" + + "text-area-highlight: " + ColorUtil.toHex(GUIGlobals.activeBackgroundColor) + ";"); } EasyBind.subscribe(tabbed.getSelectionModel().selectedItemProperty(), tab -> { @@ -303,8 +304,4 @@ public void setFocusToField(String fieldName) { } }); } - - private String convertToHex(java.awt.Color color) { - return String.format("#%02x%02x%02x", color.getRed(), color.getGreen(), color.getBlue()); - } } diff --git a/src/main/java/org/jabref/gui/util/ColorUtil.java b/src/main/java/org/jabref/gui/util/ColorUtil.java index 3b713ded83c..90284d24250 100644 --- a/src/main/java/org/jabref/gui/util/ColorUtil.java +++ b/src/main/java/org/jabref/gui/util/ColorUtil.java @@ -25,4 +25,8 @@ public static String toRGBCode(Color color) { (int) (color.getGreen() * 255), (int) (color.getBlue() * 255)); } + + public static String toHex(java.awt.Color color) { + return String.format("#%02x%02x%02x", color.getRed(), color.getGreen(), color.getBlue()); + } } From e5fa39a7531e2c0dc795a0f683cfcd06e5670002 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Sun, 13 May 2018 18:20:58 +0200 Subject: [PATCH 033/130] Inline comment --- src/main/java/org/jabref/logic/citationstyle/CSLAdapter.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/org/jabref/logic/citationstyle/CSLAdapter.java b/src/main/java/org/jabref/logic/citationstyle/CSLAdapter.java index 0dd93135dc3..7ce1e57e6f6 100644 --- a/src/main/java/org/jabref/logic/citationstyle/CSLAdapter.java +++ b/src/main/java/org/jabref/logic/citationstyle/CSLAdapter.java @@ -84,9 +84,6 @@ private static class JabRefItemDataProvider implements ItemDataProvider { /** * Converts the {@link BibEntry} into {@link CSLItemData}. - * - * Change month field from JabRefFormat #mon# to ShortName mon - * because CSL does not support JabRefFormat. */ private static CSLItemData bibEntryToCSLItemData(BibEntry bibEntry) { String citeKey = bibEntry.getCiteKeyOptional().orElse(""); @@ -101,6 +98,7 @@ private static CSLItemData bibEntryToCSLItemData(BibEntry bibEntry) { .map(latexToHtmlConverter::format) .ifPresent(value -> { if (FieldName.MONTH.equals(key)) { + // Change month from #mon# to mon because CSL does not support the former format value = bibEntry.getMonth().map(Month::getShortName).orElse(value); } bibTeXEntry.addField(new Key(key), new DigitStringValue(value)); From 468cce92eb2717d86e7bf60acd799b9fa5b32739 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Sun, 13 May 2018 23:25:16 +0200 Subject: [PATCH 034/130] Fix initial freeze when downloading files --- .../gui/externalfiles/FileDownloadTask.java | 6 ++-- .../gui/fieldeditors/LinkedFileViewModel.java | 33 ++++++++++--------- .../org/jabref/gui/util/BackgroundTask.java | 27 +++++++++++++-- 3 files changed, 46 insertions(+), 20 deletions(-) diff --git a/src/main/java/org/jabref/gui/externalfiles/FileDownloadTask.java b/src/main/java/org/jabref/gui/externalfiles/FileDownloadTask.java index 890cd232f16..6880d8b7c0a 100644 --- a/src/main/java/org/jabref/gui/externalfiles/FileDownloadTask.java +++ b/src/main/java/org/jabref/gui/externalfiles/FileDownloadTask.java @@ -11,7 +11,7 @@ import org.fxmisc.easybind.EasyBind; -public class FileDownloadTask extends BackgroundTask { +public class FileDownloadTask extends BackgroundTask { private final URL source; private final Path destination; @@ -22,7 +22,7 @@ public FileDownloadTask(URL source, Path destination) { } @Override - protected Void call() throws Exception { + protected Path call() throws Exception { URLDownload download = new URLDownload(source); try (ProgressInputStream inputStream = download.asInputStream()) { EasyBind.subscribe( @@ -35,6 +35,6 @@ protected Void call() throws Exception { Files.copy(inputStream, destination, StandardCopyOption.REPLACE_EXISTING); } - return null; + return destination; } } diff --git a/src/main/java/org/jabref/gui/fieldeditors/LinkedFileViewModel.java b/src/main/java/org/jabref/gui/fieldeditors/LinkedFileViewModel.java index 2307caf04d1..e1480c08688 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/LinkedFileViewModel.java +++ b/src/main/java/org/jabref/gui/fieldeditors/LinkedFileViewModel.java @@ -356,26 +356,30 @@ public void download() { } try { - URLDownload urlDownload = new URLDownload(linkedFile.getLink()); - Optional suggestedType = inferFileType(urlDownload); - String suggestedTypeName = suggestedType.map(ExternalFileType::getName).orElse(""); - linkedFile.setFileType(suggestedTypeName); - Optional targetDirectory = databaseContext.getFirstExistingFileDir(fileDirectoryPreferences); if (!targetDirectory.isPresent()) { dialogService.showErrorDialogAndWait(Localization.lang("Download file"), Localization.lang("File directory is not set or does not exist!")); return; } - String suffix = suggestedType.map(ExternalFileType::getExtension).orElse(""); - String suggestedName = getSuggestedFileName(suffix); - Path destination = targetDirectory.get().resolve(suggestedName); - BackgroundTask downloadTask = new FileDownloadTask(urlDownload.getSource(), destination) - .onSuccess(event -> { - LinkedFile newLinkedFile = LinkedFilesEditorViewModel.fromFile(destination, databaseContext.getFileDirectoriesAsPaths(fileDirectoryPreferences)); - linkedFile.setLink(newLinkedFile.getLink()); - linkedFile.setFileType(newLinkedFile.getFileType()); - }).onFailure(ex -> dialogService.showErrorDialogAndWait("Download failed", ex)); + URLDownload urlDownload = new URLDownload(linkedFile.getLink()); + BackgroundTask downloadTask = BackgroundTask + .wrap(() -> { + Optional suggestedType = inferFileType(urlDownload); + String suggestedTypeName = suggestedType.map(ExternalFileType::getName).orElse(""); + linkedFile.setFileType(suggestedTypeName); + + String suffix = suggestedType.map(ExternalFileType::getExtension).orElse(""); + String suggestedName = getSuggestedFileName(suffix); + return targetDirectory.get().resolve(suggestedName); + }) + .then(destination -> new FileDownloadTask(urlDownload.getSource(), destination)) + .onSuccess(destination -> { + LinkedFile newLinkedFile = LinkedFilesEditorViewModel.fromFile(destination, databaseContext.getFileDirectoriesAsPaths(fileDirectoryPreferences)); + linkedFile.setLink(newLinkedFile.getLink()); + linkedFile.setFileType(newLinkedFile.getFileType()); + }) + .onFailure(exception -> dialogService.showErrorDialogAndWait("Download failed", exception)); downloadProgress.bind(downloadTask.workDonePercentageProperty()); taskExecutor.execute(downloadTask); @@ -395,7 +399,6 @@ private Optional inferFileType(URLDownload urlDownload) { } private Optional inferFileTypeFromMimeType(URLDownload urlDownload) { - // TODO: what if this takes long time? String mimeType = urlDownload.getMimeType(); if (mimeType != null) { diff --git a/src/main/java/org/jabref/gui/util/BackgroundTask.java b/src/main/java/org/jabref/gui/util/BackgroundTask.java index a0ba66966b4..d420881b049 100644 --- a/src/main/java/org/jabref/gui/util/BackgroundTask.java +++ b/src/main/java/org/jabref/gui/util/BackgroundTask.java @@ -3,6 +3,7 @@ import java.util.concurrent.Callable; import java.util.concurrent.Future; import java.util.function.Consumer; +import java.util.function.Function; import javafx.beans.property.DoubleProperty; import javafx.beans.property.ObjectProperty; @@ -120,11 +121,33 @@ public BackgroundTask onFinished(Runnable onFinished) { return this; } + /** + * Creates a {@link BackgroundTask} that first runs this task and based on the result runs a second task. + * + * @param nextTaskFactory the function that creates the new task + * @param type of the return value of the second task + */ + public BackgroundTask then(Function> nextTaskFactory) { + return new BackgroundTask() { + @Override + protected T call() throws Exception { + V result = BackgroundTask.this.call(); + BackgroundTask nextTask = nextTaskFactory.apply(result); + EasyBind.subscribe(nextTask.progressProperty(), this::updateProgress); + return nextTask.call(); + } + }; + } + + protected void updateProgress(BackgroundProgress newProgress) { + progress.setValue(newProgress); + } + protected void updateProgress(double workDone, double max) { - progress.setValue(new BackgroundProgress(workDone, max)); + updateProgress(new BackgroundProgress(workDone, max)); } - public class BackgroundProgress { + class BackgroundProgress { private final double workDone; private final double max; From 3a0474d8448342671f8397986613cbf50920213d Mon Sep 17 00:00:00 2001 From: Florian Beetz <8899552+florian-beetz@users.noreply.github.com> Date: Tue, 15 May 2018 21:49:02 +0200 Subject: [PATCH 035/130] Remove reflection hack to set WM_CLASS (#4034) --- src/main/java/org/jabref/gui/GUIGlobals.java | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/main/java/org/jabref/gui/GUIGlobals.java b/src/main/java/org/jabref/gui/GUIGlobals.java index 8c1e6696abc..cbfeb8dc34d 100644 --- a/src/main/java/org/jabref/gui/GUIGlobals.java +++ b/src/main/java/org/jabref/gui/GUIGlobals.java @@ -2,12 +2,10 @@ import java.awt.Color; import java.awt.Font; -import java.awt.Toolkit; import org.jabref.Globals; import org.jabref.gui.keyboard.EmacsKeyBindings; import org.jabref.logic.l10n.Localization; -import org.jabref.logic.util.OS; import org.jabref.preferences.JabRefPreferences; import org.slf4j.Logger; @@ -61,19 +59,6 @@ public static void init() { GUIGlobals.currentFont = new Font(Globals.prefs.get(JabRefPreferences.FONT_FAMILY), Globals.prefs.getInt(JabRefPreferences.FONT_STYLE), Globals.prefs.getInt(JabRefPreferences.FONT_SIZE)); - - // Set WM_CLASS using reflection for certain Un*x window managers - if (!OS.WINDOWS && !OS.OS_X) { - try { - Toolkit xToolkit = Toolkit.getDefaultToolkit(); - java.lang.reflect.Field awtAppClassNameField = xToolkit.getClass().getDeclaredField("awtAppClassName"); - awtAppClassNameField.setAccessible(true); - awtAppClassNameField.set(xToolkit, "org-jabref-JabRefMain"); - } catch (Exception e) { - // ignore any error since this code only works for certain toolkits - } - } - } public static void setFont(int size) { From c560e00204f9c90168953cbe0bbbe95ded1a7dcb Mon Sep 17 00:00:00 2001 From: Florian Beetz <8899552+florian-beetz@users.noreply.github.com> Date: Tue, 15 May 2018 21:51:13 +0200 Subject: [PATCH 036/130] Use JavaFX-native SVGPath for logo in About dialog (#4035) * Remove usage of transitive dependency on Apache Commons (cherry picked from commit 6608b2b) * Use JavaFX-native SVGPath for logo in About dialog --- build.gradle | 5 +- .../java/org/jabref/gui/help/AboutDialog.css | 10 ++- .../java/org/jabref/gui/help/AboutDialog.fxml | 90 ++++++++++--------- .../org/jabref/gui/help/AboutDialogView.java | 7 -- .../org/jabref/logic/util/io/FileUtil.java | 3 +- 5 files changed, 62 insertions(+), 53 deletions(-) diff --git a/build.gradle b/build.gradle index f415e479c0a..b737695ffe2 100644 --- a/build.gradle +++ b/build.gradle @@ -120,7 +120,6 @@ dependencies { compile 'com.google.guava:guava:25.0-jre' // JavaFX stuff - compile 'de.codecentric.centerdevice:javafxsvg:1.3.0' compile 'de.jensd:fontawesomefx-materialdesignfont:1.7.22-4' compile 'de.saxsys:mvvmfx-validation:1.7.0' compile 'de.saxsys:mvvmfx:1.7.0' @@ -314,7 +313,7 @@ test { useJUnitPlatform { excludeTags 'DatabaseTest', 'FetcherTest', 'GUITest', 'org.jabref.testutils.category.FetcherTest', 'org.jabref.testutils.category.GUITest' } - + testLogging { // set options for log level LIFECYCLE events "failed" @@ -375,7 +374,7 @@ checkstyle { // do not use other packages for checkstyle, excluding gen(erated) sources checkstyleMain.source = "src/main/java" toolVersion = '8.5' - + // do not perform checkstyle checks by default sourceSets = [] } diff --git a/src/main/java/org/jabref/gui/help/AboutDialog.css b/src/main/java/org/jabref/gui/help/AboutDialog.css index b24df8f687f..836e89c4eb7 100644 --- a/src/main/java/org/jabref/gui/help/AboutDialog.css +++ b/src/main/java/org/jabref/gui/help/AboutDialog.css @@ -43,4 +43,12 @@ .dialog-pane *.button-bar { -fx-max-height: 0; -fx-pref-height: 0; -} \ No newline at end of file +} + +.logo-pane { + fx-fill: transparent; +} + +.logo-pane SVGPath { + -fx-fill: #4f5f8f; +} diff --git a/src/main/java/org/jabref/gui/help/AboutDialog.fxml b/src/main/java/org/jabref/gui/help/AboutDialog.fxml index 9ffe83aee39..87a73866520 100644 --- a/src/main/java/org/jabref/gui/help/AboutDialog.fxml +++ b/src/main/java/org/jabref/gui/help/AboutDialog.fxml @@ -1,5 +1,6 @@ + @@ -7,62 +8,74 @@ - - + + - + + + -
- + + + + + + + + + + + + + + + + + + + + + + - + - + - +
@@ -70,22 +83,19 @@
-