30
30
/**
31
31
* Try to download fulltext PDF for selected entry(ies) by following URL or DOI link.
32
32
*/
33
- public class FindFullTextAction extends SimpleCommand {
33
+ public class DownloadFullTextAction extends SimpleCommand {
34
34
35
- private static final Logger LOGGER = LoggerFactory .getLogger (FindFullTextAction .class );
35
+ private static final Logger LOGGER = LoggerFactory .getLogger (DownloadFullTextAction .class );
36
36
// The minimum number of selected entries to ask the user for confirmation
37
37
private static final int WARNING_LIMIT = 5 ;
38
38
39
39
private final BasePanel basePanel ;
40
40
private final DialogService dialogService ;
41
41
42
- public FindFullTextAction (BasePanel basePanel ) {
42
+ public DownloadFullTextAction (BasePanel basePanel ) {
43
43
this .basePanel = basePanel ;
44
44
this .dialogService = basePanel .frame ().getDialogService ();
45
45
}
@@ -54,14 +54,14 @@ public void execute() {
54
54
55
55
if (basePanel .getSelectedEntries ().size () >= WARNING_LIMIT ) {
56
56
boolean confirmDownload = dialogService .showConfirmationDialogAndWait (
57
- Localization .lang ("Look up full text documents" ),
57
+ Localization .lang ("Download full text documents" ),
58
58
Localization .lang (
59
- "You are about to look up full text documents for %0 entries." ,
59
+ "You are about to download full text documents for %0 entries." ,
60
60
String .valueOf (basePanel .getSelectedEntries ().size ())) + "\n "
61
61
+ Localization .lang ("JabRef will send at least one request per entry to a publisher." )
62
62
+ "\n "
63
63
+ Localization .lang ("Do you still want to continue?" ),
64
- Localization .lang ("Look up full text documents" ),
64
+ Localization .lang ("Download full text documents" ),
65
65
Localization .lang ("Cancel" ));
66
66
67
67
if (!confirmDownload ) {
@@ -87,7 +87,7 @@ protected Map<BibEntry, Optional<URL>> call() {
87
87
findFullTextsTask .setOnSucceeded (value -> downloadFullTexts (findFullTextsTask .getValue ()));
88
88
89
89
dialogService .showProgressDialogAndWait (
90
- Localization .lang ("Look up full text documents" ),
90
+ Localization .lang ("Download full text documents" ),
91
91
Localization .lang ("Looking for full text document..." ),
92
92
findFullTextsTask );
93
93
@@ -100,17 +100,15 @@ private void downloadFullTexts(Map<BibEntry, Optional<URL>> downloads) {
100
100
Optional <URL > result = download .getValue ();
101
101
if (result .isPresent ()) {
102
102
Optional <Path > dir = basePanel .getBibDatabaseContext ().getFirstExistingFileDir (Globals .prefs .getFilePreferences ());
103
-
104
- if (!dir .isPresent ()) {
105
-
103
+ if (dir .isEmpty ()) {
106
104
dialogService .showErrorDialogAndWait (Localization .lang ("Directory not found" ),
107
105
Localization .lang ("Main file directory not set!" ) + " " + Localization .lang ("Preferences" )
108
106
+ " -> " + Localization .lang ("File" ));
109
107
return ;
110
108
}
111
- //Download and link full text
112
- addLinkedFileFromURL (result .get (), entry , dir .get ());
113
109
110
+ // Download and link full text
111
+ addLinkedFileFromURL (result .get (), entry , dir .get ());
114
112
} else {
115
113
dialogService .notify (Localization .lang ("No full text document found for entry %0." ,
116
114
entry .getCiteKeyOptional ().orElse (Localization .lang ("undefined" ))));
@@ -130,15 +128,14 @@ private void addLinkedFileFromURL(URL url, BibEntry entry, Path targetDirectory)
130
128
LinkedFile newLinkedFile = new LinkedFile (url , "" );
131
129
132
130
if (!entry .getFiles ().contains (newLinkedFile )) {
133
-
134
131
LinkedFileViewModel onlineFile = new LinkedFileViewModel (
135
132
newLinkedFile ,
136
133
entry ,
137
134
basePanel .getBibDatabaseContext (),
138
135
Globals .TASK_EXECUTOR ,
139
136
dialogService ,
140
137
JabRefPreferences .getInstance ().getXMPPreferences (),
141
- JabRefPreferences .getInstance ().getFilePreferences (),
138
+ JabRefPreferences .getInstance ().getFilePreferences (),
142
139
ExternalFileTypes .getInstance ());
143
140
144
141
try {
0 commit comments