11package org .jabref .gui .auximport ;
22
33import java .nio .file .Path ;
4+ import java .util .Optional ;
5+
46
57import javafx .fxml .FXML ;
68import javafx .scene .control .Button ;
1012import javafx .scene .control .TextArea ;
1113import javafx .scene .control .TextField ;
1214
15+
1316import org .jabref .gui .DialogService ;
1417import org .jabref .gui .JabRefFrame ;
1518import org .jabref .gui .LibraryTab ;
16- import org .jabref .gui .importer . ImportEntriesViewModel ;
19+ import org .jabref .gui .StateManager ;
1720import org .jabref .gui .theme .ThemeManager ;
1821import org .jabref .gui .util .BaseDialog ;
1922import org .jabref .gui .util .FileDialogConfiguration ;
23+ import org .jabref .gui .util .ViewModelListCellFactory ;
2024import org .jabref .logic .auxparser .AuxParser ;
2125import org .jabref .logic .auxparser .AuxParserResult ;
2226import org .jabref .logic .auxparser .DefaultAuxParser ;
2327import org .jabref .logic .l10n .Localization ;
28+ import org .jabref .logic .shared .DatabaseLocation ;
2429import org .jabref .logic .util .StandardFileType ;
30+ import org .jabref .logic .util .io .FileUtil ;
2531import org .jabref .model .database .BibDatabase ;
2632import org .jabref .model .database .BibDatabaseContext ;
27- import org .jabref .model .entry .BibEntry ;
2833import org .jabref .preferences .PreferencesService ;
2934
3035import com .airhacks .afterburner .views .ViewLoader ;
3136import jakarta .inject .Inject ;
32- import org .controlsfx .control .CheckListView ;
37+
38+
3339
3440/**
3541 * A wizard dialog for generating a new sub database from existing TeX AUX file
3642 */
3743public class FromAuxDialog extends BaseDialog <Void > {
3844
39- public CheckListView <BibEntry > entriesListView ;
40-
41- private ImportEntriesViewModel viewModel ;
42- public ComboBox <String > libraryListView ;
4345 private final LibraryTab libraryTab ;
4446 @ FXML private ButtonType generateButtonType ;
4547 private final Button generateButton ;
@@ -51,15 +53,19 @@ public class FromAuxDialog extends BaseDialog<Void> {
5153 @ Inject private PreferencesService preferences ;
5254 @ Inject private DialogService dialogService ;
5355 @ Inject private ThemeManager themeManager ;
56+ public ComboBox <BibDatabaseContext > libraryListView ;
57+ @ Inject private StateManager stateManager ;
58+
59+
60+
61+
5462
5563 public FromAuxDialog (JabRefFrame frame ) {
5664 libraryTab = frame .getCurrentLibraryTab ();
5765 this .setTitle (Localization .lang ("AUX file import" ));
58-
5966 ViewLoader .view (this )
6067 .load ()
6168 .setAsDialogPane (this );
62-
6369 generateButton = (Button ) this .getDialogPane ().lookupButton (generateButtonType );
6470 generateButton .setDisable (true );
6571 generateButton .defaultButtonProperty ().bind (generateButton .disableProperty ().not ());
@@ -70,10 +76,8 @@ public FromAuxDialog(JabRefFrame frame) {
7076 }
7177 return null ;
7278 });
73-
7479 themeManager .updateFontStyle (getDialogPane ().getScene ());
7580 }
76-
7781 @ FXML
7882 private void parseActionPerformed () {
7983 notFoundList .getItems ().clear ();
@@ -108,22 +112,28 @@ private void browseButtonClicked() {
108112 dialogService .showFileOpenDialog (fileDialogConfiguration ).ifPresent (file -> auxFileField .setText (file .toAbsolutePath ().toString ()));
109113 }
110114
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 );
127137 }
128138
129139}
0 commit comments