Search in sources :

Example 1 with ImportInspectionDialog

use of org.jabref.gui.importer.ImportInspectionDialog in project jabref by JabRef.

the class JabRefFrame method addImportedEntries.

/**
     * This method does the job of adding imported entries into the active
     * database, or into a new one. It shows the ImportInspectionDialog if
     * preferences indicate it should be used. Otherwise it imports directly.
     *
     * @param panel     The BasePanel to add to.
     * @param entries   The entries to add.
     * @param openInNew Should the entries be imported into a new database?
     */
private void addImportedEntries(final BasePanel panel, final List<BibEntry> entries, final boolean openInNew) {
    SwingUtilities.invokeLater(() -> {
        ImportInspectionDialog diag = new ImportInspectionDialog(JabRefFrame.this, panel, Localization.lang("Import"), openInNew);
        diag.addEntries(entries);
        diag.entryListComplete();
        diag.setLocationRelativeTo(JabRefFrame.this);
        diag.setVisible(true);
        diag.toFront();
    });
}
Also used : ImportInspectionDialog(org.jabref.gui.importer.ImportInspectionDialog)

Example 2 with ImportInspectionDialog

use of org.jabref.gui.importer.ImportInspectionDialog in project jabref by JabRef.

the class GeneralFetcher method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    if (tf.getText().trim().isEmpty()) {
        frame.output(Localization.lang("Please enter a search string"));
        return;
    }
    if (frame.getCurrentBasePanel() == null) {
        frame.output(Localization.lang("Please open or start a new library before searching"));
        return;
    }
    // user which ones to download:
    if (activeFetcher instanceof PreviewEntryFetcher) {
        frame.output(Localization.lang("Searching..."));
        frame.setProgressBarIndeterminate(true);
        frame.setProgressBarVisible(true);
        final PreviewEntryFetcher pFetcher = (PreviewEntryFetcher) activeFetcher;
        final FetcherPreviewDialog dialog = new FetcherPreviewDialog(frame, pFetcher.getWarningLimit(), pFetcher.getPreferredPreviewHeight());
        JabRefExecutorService.INSTANCE.execute(() -> {
            final boolean result = pFetcher.processQueryGetPreview(tf.getText().trim(), dialog, dialog);
            SwingUtilities.invokeLater(() -> {
                frame.setProgressBarVisible(false);
                frame.output("");
                if (result) {
                    dialog.setLocationRelativeTo(frame);
                    dialog.setVisible(true);
                    if (dialog.isOkPressed()) {
                        final ImportInspectionDialog d2 = new ImportInspectionDialog(frame, frame.getCurrentBasePanel(), activeFetcher.getTitle(), false);
                        d2.addCallBack(activeFetcher);
                        d2.setLocationRelativeTo(frame);
                        d2.setVisible(true);
                        JabRefExecutorService.INSTANCE.execute(() -> {
                            pFetcher.getEntries(dialog.getSelection(), d2);
                            d2.entryListComplete();
                        });
                    }
                }
            });
        });
    } else // The other category downloads the entries first, then asks the user which ones to keep:
    {
        final ImportInspectionDialog dialog = new ImportInspectionDialog(frame, frame.getCurrentBasePanel(), activeFetcher.getTitle(), false);
        dialog.addCallBack(activeFetcher);
        dialog.setLocationRelativeTo(frame);
        dialog.setVisible(true);
        JabRefExecutorService.INSTANCE.execute(() -> {
            if (activeFetcher.processQuery(tf.getText().trim(), dialog, dialog)) {
                dialog.entryListComplete();
            } else {
                dialog.dispose();
            }
        });
    }
}
Also used : ImportInspectionDialog(org.jabref.gui.importer.ImportInspectionDialog) FetcherPreviewDialog(org.jabref.gui.importer.FetcherPreviewDialog)

Aggregations

ImportInspectionDialog (org.jabref.gui.importer.ImportInspectionDialog)2 FetcherPreviewDialog (org.jabref.gui.importer.FetcherPreviewDialog)1