Search in sources :

Example 11 with DialogService

use of org.jabref.gui.DialogService 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);
}
Also used : Path(java.nio.file.Path) FXDialogService(org.jabref.gui.FXDialogService) DialogService(org.jabref.gui.DialogService) FXDialogService(org.jabref.gui.FXDialogService) ArrayList(java.util.ArrayList) FileDialogConfiguration(org.jabref.gui.util.FileDialogConfiguration)

Example 12 with DialogService

use of org.jabref.gui.DialogService 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()));
    }
}
Also used : FXDialogService(org.jabref.gui.FXDialogService) Path(java.nio.file.Path) DialogService(org.jabref.gui.DialogService) FXDialogService(org.jabref.gui.FXDialogService) FileDialogConfiguration(org.jabref.gui.util.FileDialogConfiguration) MergeDialog(org.jabref.gui.MergeDialog)

Example 13 with DialogService

use of org.jabref.gui.DialogService 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()));
}
Also used : FXDialogService(org.jabref.gui.FXDialogService) Path(java.nio.file.Path) FXDialogService(org.jabref.gui.FXDialogService) DialogService(org.jabref.gui.DialogService) FileDialogConfiguration(org.jabref.gui.util.FileDialogConfiguration)

Example 14 with DialogService

use of org.jabref.gui.DialogService in project jabref by JabRef.

the class ManageJournalAbbreviationsViewModelTest method setUpViewModel.

@Before
public void setUpViewModel() throws Exception {
    abbreviationPreferences = mock(JournalAbbreviationPreferences.class);
    PreferencesService preferences = mock(PreferencesService.class);
    when(preferences.getJournalAbbreviationPreferences()).thenReturn(abbreviationPreferences);
    dialogService = mock(DialogService.class);
    TaskExecutor taskExecutor = new CurrentThreadTaskExecutor();
    JournalAbbreviationLoader journalAbbreviationLoader = mock(JournalAbbreviationLoader.class);
    viewModel = new ManageJournalAbbreviationsViewModel(preferences, dialogService, taskExecutor, journalAbbreviationLoader);
    emptyTestFile = createTemporaryTestFile("emptyTestFile.txt", "");
    testFile1Entries = createTemporaryTestFile("testFile1Entries.txt", "Test Entry = TE" + NEWLINE + "");
    testFile3Entries = createTemporaryTestFile("testFile3Entries.txt", "Abbreviations = Abb" + NEWLINE + "Test Entry = TE" + NEWLINE + "MoreEntries = ME" + NEWLINE + "");
    testFile4Entries = createTemporaryTestFile("testFile4Entries.txt", "Abbreviations = Abb" + NEWLINE + "Test Entry = TE" + NEWLINE + "MoreEntries = ME" + NEWLINE + "Entry = E" + NEWLINE + "");
    testFile5EntriesWithDuplicate = createTemporaryTestFile("testFile5Entries.txt", "Abbreviations = Abb" + NEWLINE + "Test Entry = TE" + NEWLINE + "Test Entry = TE" + NEWLINE + "MoreEntries = ME" + NEWLINE + "EntryEntry = EE" + NEWLINE + "");
}
Also used : DialogService(org.jabref.gui.DialogService) CurrentThreadTaskExecutor(org.jabref.gui.util.CurrentThreadTaskExecutor) TaskExecutor(org.jabref.gui.util.TaskExecutor) CurrentThreadTaskExecutor(org.jabref.gui.util.CurrentThreadTaskExecutor) JournalAbbreviationPreferences(org.jabref.logic.journals.JournalAbbreviationPreferences) JournalAbbreviationLoader(org.jabref.logic.journals.JournalAbbreviationLoader) PreferencesService(org.jabref.preferences.PreferencesService) Before(org.junit.Before)

Aggregations

DialogService (org.jabref.gui.DialogService)14 FXDialogService (org.jabref.gui.FXDialogService)12 FileDialogConfiguration (org.jabref.gui.util.FileDialogConfiguration)10 Path (java.nio.file.Path)9 FormBuilder (com.jgoodies.forms.builder.FormBuilder)7 FormLayout (com.jgoodies.forms.layout.FormLayout)6 JButton (javax.swing.JButton)5 ButtonBarBuilder (com.jgoodies.forms.builder.ButtonBarBuilder)4 ActionEvent (java.awt.event.ActionEvent)4 JTextField (javax.swing.JTextField)4 Localization (org.jabref.logic.l10n.Localization)4 List (java.util.List)3 JPanel (javax.swing.JPanel)3 BorderLayout (java.awt.BorderLayout)2 IOException (java.io.IOException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 Optional (java.util.Optional)2 AbstractAction (javax.swing.AbstractAction)2 Action (javax.swing.Action)2 Log (org.apache.commons.logging.Log)2