1
1
package org .jabref .gui .auximport ;
2
2
3
3
import java .nio .file .Path ;
4
+ import java .util .Optional ;
5
+
4
6
5
7
import javafx .fxml .FXML ;
6
8
import javafx .scene .control .Button ;
10
12
import javafx .scene .control .TextArea ;
11
13
import javafx .scene .control .TextField ;
12
14
15
+
13
16
import org .jabref .gui .DialogService ;
14
17
import org .jabref .gui .JabRefFrame ;
15
18
import org .jabref .gui .LibraryTab ;
16
- import org .jabref .gui .importer . ImportEntriesViewModel ;
19
+ import org .jabref .gui .StateManager ;
17
20
import org .jabref .gui .theme .ThemeManager ;
18
21
import org .jabref .gui .util .BaseDialog ;
19
22
import org .jabref .gui .util .FileDialogConfiguration ;
23
+ import org .jabref .gui .util .ViewModelListCellFactory ;
20
24
import org .jabref .logic .auxparser .AuxParser ;
21
25
import org .jabref .logic .auxparser .AuxParserResult ;
22
26
import org .jabref .logic .auxparser .DefaultAuxParser ;
23
27
import org .jabref .logic .l10n .Localization ;
28
+ import org .jabref .logic .shared .DatabaseLocation ;
24
29
import org .jabref .logic .util .StandardFileType ;
30
+ import org .jabref .logic .util .io .FileUtil ;
25
31
import org .jabref .model .database .BibDatabase ;
26
32
import org .jabref .model .database .BibDatabaseContext ;
27
- import org .jabref .model .entry .BibEntry ;
28
33
import org .jabref .preferences .PreferencesService ;
29
34
30
35
import com .airhacks .afterburner .views .ViewLoader ;
31
36
import jakarta .inject .Inject ;
32
- import org .controlsfx .control .CheckListView ;
37
+
38
+
33
39
34
40
/**
35
41
* A wizard dialog for generating a new sub database from existing TeX AUX file
36
42
*/
37
43
public class FromAuxDialog extends BaseDialog <Void > {
38
44
39
- public CheckListView <BibEntry > entriesListView ;
40
-
41
- private ImportEntriesViewModel viewModel ;
42
- public ComboBox <String > libraryListView ;
43
45
private final LibraryTab libraryTab ;
44
46
@ FXML private ButtonType generateButtonType ;
45
47
private final Button generateButton ;
@@ -51,15 +53,19 @@ public class FromAuxDialog extends BaseDialog<Void> {
51
53
@ Inject private PreferencesService preferences ;
52
54
@ Inject private DialogService dialogService ;
53
55
@ Inject private ThemeManager themeManager ;
56
+ public ComboBox <BibDatabaseContext > libraryListView ;
57
+ @ Inject private StateManager stateManager ;
58
+
59
+
60
+
61
+
54
62
55
63
public FromAuxDialog (JabRefFrame frame ) {
56
64
libraryTab = frame .getCurrentLibraryTab ();
57
65
this .setTitle (Localization .lang ("AUX file import" ));
58
-
59
66
ViewLoader .view (this )
60
67
.load ()
61
68
.setAsDialogPane (this );
62
-
63
69
generateButton = (Button ) this .getDialogPane ().lookupButton (generateButtonType );
64
70
generateButton .setDisable (true );
65
71
generateButton .defaultButtonProperty ().bind (generateButton .disableProperty ().not ());
@@ -70,10 +76,8 @@ public FromAuxDialog(JabRefFrame frame) {
70
76
}
71
77
return null ;
72
78
});
73
-
74
79
themeManager .updateFontStyle (getDialogPane ().getScene ());
75
80
}
76
-
77
81
@ FXML
78
82
private void parseActionPerformed () {
79
83
notFoundList .getItems ().clear ();
@@ -108,22 +112,28 @@ private void browseButtonClicked() {
108
112
dialogService .showFileOpenDialog (fileDialogConfiguration ).ifPresent (file -> auxFileField .setText (file .toAbsolutePath ().toString ()));
109
113
}
110
114
111
- public void unselectAll () {
112
- entriesListView .getCheckModel ().clearChecks ();
113
- }
114
-
115
- public void selectAllNewEntries () {
116
- unselectAll ();
117
- for (BibEntry entry : entriesListView .getItems ()) {
118
- if (!viewModel .hasDuplicate (entry )) {
119
- entriesListView .getCheckModel ().check (entry );
120
- }
121
- }
122
- }
123
-
124
- public void selectAllEntries () {
125
- unselectAll ();
126
- entriesListView .getCheckModel ().checkAll ();
115
+ @ FXML
116
+ private void initialize () {
117
+
118
+ libraryListView .setEditable (false );
119
+ libraryListView .getItems ().addAll (stateManager .getOpenDatabases ());
120
+ new ViewModelListCellFactory <BibDatabaseContext >()
121
+ .withText (database -> {
122
+ Optional <String > dbOpt = Optional .empty ();
123
+ if (database .getDatabasePath ().isPresent ()) {
124
+ dbOpt = FileUtil .getUniquePathFragment (stateManager .collectAllDatabasePaths (), database .getDatabasePath ().get ());
125
+ }
126
+ if (database .getLocation () == DatabaseLocation .SHARED ) {
127
+ return database .getDBMSSynchronizer ().getDBName () + " [" + Localization .lang ("shared" ) + "]" ;
128
+ }
129
+
130
+ if (dbOpt .isEmpty ()) {
131
+ return Localization .lang ("untitled" );
132
+ }
133
+
134
+ return dbOpt .get ();
135
+ })
136
+ .install (libraryListView );
127
137
}
128
138
129
139
}
0 commit comments