use of org.jabref.gui.FXDialogService in project jabref by JabRef.
the class OpenDatabaseAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
List<Path> filesToOpen = new ArrayList<>();
if (showDialog) {
DialogService ds = new FXDialogService();
FileDialogConfiguration fileDialogConfiguration = new FileDialogConfiguration.Builder().addExtensionFilter(FileExtensions.BIBTEX_DB).withDefaultExtension(FileExtensions.BIBTEX_DB).withInitialDirectory(Paths.get(Globals.prefs.get(JabRefPreferences.WORKING_DIRECTORY))).build();
List<Path> chosenFiles = DefaultTaskExecutor.runInJavaFXThread(() -> ds.showFileOpenDialogAndGetMultipleFiles(fileDialogConfiguration));
filesToOpen.addAll(chosenFiles);
} else {
LOGGER.info(Action.NAME + " " + e.getActionCommand());
filesToOpen.add(Paths.get(StringUtil.getCorrectFileName(e.getActionCommand(), "bib")));
}
openFiles(filesToOpen, true);
}
use of org.jabref.gui.FXDialogService in project jabref by JabRef.
the class AppendDatabaseAction method action.
@Override
public void action() {
filesToOpen.clear();
final MergeDialog dialog = new MergeDialog(frame, Localization.lang("Append library"), true);
dialog.setLocationRelativeTo(panel);
dialog.setVisible(true);
if (dialog.isOkPressed()) {
FileDialogConfiguration fileDialogConfiguration = new FileDialogConfiguration.Builder().withDefaultExtension(FileExtensions.BIBTEX_DB).withInitialDirectory(Globals.prefs.get(JabRefPreferences.WORKING_DIRECTORY)).build();
DialogService dialogService = new FXDialogService();
List<Path> chosen = DefaultTaskExecutor.runInJavaFXThread(() -> dialogService.showFileOpenDialogAndGetMultipleFiles(fileDialogConfiguration));
if (chosen.isEmpty()) {
return;
}
filesToOpen.addAll(chosen);
// Run the actual open in a thread to prevent the program
// locking until the file is loaded.
JabRefExecutorService.INSTANCE.execute(() -> openIt(dialog.importEntries(), dialog.importStrings(), dialog.importGroups(), dialog.importSelectorWords()));
}
}
use of org.jabref.gui.FXDialogService in project jabref by JabRef.
the class ConnectToSharedDatabaseDialog method showFileChooser.
private void showFileChooser() {
FileDialogConfiguration fileDialogConfiguration = new FileDialogConfiguration.Builder().addExtensionFilter(FileExtensions.BIBTEX_DB).withDefaultExtension(FileExtensions.BIBTEX_DB).withInitialDirectory(Globals.prefs.get(JabRefPreferences.WORKING_DIRECTORY)).build();
DialogService ds = new FXDialogService();
Optional<Path> path = DefaultTaskExecutor.runInJavaFXThread(() -> ds.showFileOpenDialog(fileDialogConfiguration));
path.ifPresent(p -> fileLocationField.setText(p.toString()));
}
Aggregations