8
8
import java .util .Objects ;
9
9
import java .util .Optional ;
10
10
11
+ import javafx .beans .Observable ;
12
+ import javafx .beans .property .BooleanProperty ;
13
+ import javafx .beans .property .DoubleProperty ;
14
+ import javafx .beans .property .SimpleBooleanProperty ;
15
+ import javafx .beans .property .SimpleDoubleProperty ;
16
+ import javafx .beans .property .SimpleStringProperty ;
17
+ import javafx .beans .property .StringProperty ;
18
+
11
19
import org .jabref .model .database .BibDatabaseContext ;
12
20
import org .jabref .model .metadata .FileDirectoryPreferences ;
13
21
import org .jabref .model .util .FileHelper ;
19
27
public class LinkedFile implements Serializable {
20
28
21
29
private static final LinkedFile NULL_OBJECT = new LinkedFile ("" , "" , "" );
22
- private String description ;
23
- private String link ;
24
- private String fileType ;
30
+ private final StringProperty description = new SimpleStringProperty ();
31
+ private final StringProperty link = new SimpleStringProperty ();
32
+ private final StringProperty fileType = new SimpleStringProperty ();
33
+ private final DoubleProperty downloadProgress = new SimpleDoubleProperty (-1 );
34
+ private final BooleanProperty isAutomaticallyFound = new SimpleBooleanProperty (false );
25
35
26
36
public LinkedFile (String description , String link , String fileType ) {
27
- this .description = Objects .requireNonNull (description );
28
- this .link = Objects .requireNonNull (link );
29
- this .fileType = Objects .requireNonNull (fileType );
37
+ this .description . setValue ( Objects .requireNonNull (description ) );
38
+ this .link . setValue ( Objects .requireNonNull (link ) );
39
+ this .fileType . setValue ( Objects .requireNonNull (fileType ) );
30
40
}
31
41
32
42
public LinkedFile (String description , URL link , String fileType ) {
33
43
this (description , Objects .requireNonNull (link ).toString (), fileType );
34
44
}
35
45
36
46
public String getFileType () {
37
- return fileType ;
47
+ return fileType . get () ;
38
48
}
39
49
40
50
public void setFileType (String fileType ) {
41
- this .fileType = fileType ;
51
+ this .fileType . setValue ( fileType ) ;
42
52
}
43
53
44
54
public String getDescription () {
45
- return description ;
55
+ return description . get () ;
46
56
}
47
57
48
58
public void setDescription (String description ) {
49
- this .description = description ;
59
+ this .description .setValue (description );
60
+
50
61
}
51
62
52
63
public String getLink () {
53
- return link ;
64
+ return link . get () ;
54
65
}
55
66
56
67
public void setLink (String link ) {
57
- this .link = link ;
68
+ this .link .setValue (link );
69
+ }
70
+
71
+ public Observable [] getObservables () {
72
+ return new Observable [] {this .downloadProgress , this .isAutomaticallyFound };
58
73
}
59
74
60
75
@ Override
@@ -96,7 +111,7 @@ public boolean isEmpty() {
96
111
}
97
112
98
113
public boolean isOnlineLink () {
99
- return link .startsWith ("http://" ) || link .startsWith ("https://" ) || link .contains ("www." );
114
+ return link .get (). startsWith ("http://" ) || link .get (). startsWith ("https://" ) || link . get () .contains ("www." );
100
115
}
101
116
102
117
public Optional <Path > findIn (BibDatabaseContext databaseContext , FileDirectoryPreferences fileDirectoryPreferences ) {
@@ -105,11 +120,11 @@ public Optional<Path> findIn(BibDatabaseContext databaseContext, FileDirectoryPr
105
120
}
106
121
107
122
public Optional <Path > findIn (List <Path > directories ) {
108
- Path file = Paths .get (link );
123
+ Path file = Paths .get (link . get () );
109
124
if (file .isAbsolute () || directories .isEmpty ()) {
110
125
return Optional .of (file );
111
126
} else {
112
- return FileHelper .expandFilenameAsPath (link , directories );
127
+ return FileHelper .expandFilenameAsPath (link . get () , directories );
113
128
}
114
129
}
115
130
}
0 commit comments