Skip to content

Commit

Permalink
Download from URL now automatically fills with URL in clipboard (JabR…
Browse files Browse the repository at this point in the history
…ef#9282)

Autofills URL in clipboard when downloading from URL
Fixes koppor#535
  • Loading branch information
Gpax971 committed 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.