From 7f2b602ed4d723f05f94cb7a3936c2d10bbe2f0c Mon Sep 17 00:00:00 2001 From: Gpax971 <34959806+Gpax971@users.noreply.github.com> Date: Tue, 25 Oct 2022 21:03:14 +1100 Subject: [PATCH] Download from URL now automatically fills with URL in clipboard (#9282) Autofills URL in clipboard when downloading from URL Fixes koppor#535 --- CHANGELOG.md | 1 + .../gui/fieldeditors/LinkedFilesEditorViewModel.java | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ed74a68e2c..08d2266ecb1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - We fixed an issue where a message about changed metadata would occur on saving although nothing changed. [#9159](https://github.com/JabRef/jabref/issues/9159) - When adding or editing a subgroup it is placed w.r.t. to alphabetical ordering rather than at the end. [koppor#577](https://github.com/koppor/jabref/issues/577) - We modified the Directory of Open Access Books (DOAB) fetcher so that it will now also fetch the ISBN when possible. [#8708](https://github.com/JabRef/jabref/issues/8708) +- Download from URL now automatically fills with URL from clipboard. [koppor#535](https://github.com/koppor/jabref/issues/535) ### Fixed diff --git a/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditorViewModel.java b/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditorViewModel.java index 44a3f15d538..94e292babd6 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditorViewModel.java +++ b/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditorViewModel.java @@ -16,6 +16,7 @@ import javafx.collections.FXCollections; import javafx.collections.ObservableList; +import org.jabref.gui.ClipBoardManager; import org.jabref.gui.DialogService; import org.jabref.gui.autocompleter.SuggestionProvider; import org.jabref.gui.externalfiles.AutoSetFileLinksUtil; @@ -214,8 +215,15 @@ public void fetchFulltext() { } public void addFromURL() { - Optional urlText = dialogService.showInputDialogAndWait( - Localization.lang("Download file"), Localization.lang("Enter URL to download")); + String clipText = ClipBoardManager.getContents(); + Optional urlText; + if (clipText.startsWith("http://") || clipText.startsWith("https://") || clipText.startsWith("ftp://")) { + urlText = dialogService.showInputDialogWithDefaultAndWait( + Localization.lang("Download file"), Localization.lang("Enter URL to download"), clipText); + } else { + urlText = dialogService.showInputDialogAndWait( + Localization.lang("Download file"), Localization.lang("Enter URL to download")); + } if (urlText.isPresent()) { try { URL url = new URL(urlText.get());