Skip to content

Commit

Permalink
Download from URL now automatically fills with URL in clipboard (#9282)
Browse files Browse the repository at this point in the history
Autofills URL in clipboard when downloading from URL
Fixes koppor#535
  • Loading branch information
Gpax971 authored Oct 25, 2022
1 parent 3759561 commit 7f2b602
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -214,8 +215,15 @@ public void fetchFulltext() {
}

public void addFromURL() {
Optional<String> urlText = dialogService.showInputDialogAndWait(
Localization.lang("Download file"), Localization.lang("Enter URL to download"));
String clipText = ClipBoardManager.getContents();
Optional<String> 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());
Expand Down

0 comments on commit 7f2b602

Please sign in to comment.