/** * Handle a List containing File objects for a set of files to import. * * @param files A List containing File instances pointing to files. * @param dropRow @param dropRow The row in the table where the files were dragged. * @return success status for the operation */ private boolean handleDraggedFiles(List<File> files, final int dropRow) { final String[] fileNames = new String[files.size()]; int i = 0; for (File file : files) { fileNames[i] = file.getAbsolutePath(); i++; } // Try to load bib files normally, and import the rest into the current // database. // This process must be spun off into a background thread: JabRefExecutorService.INSTANCE.execute( new Runnable() { @Override public void run() { final ImportPdfFilesResult importRes = new PdfImporter(frame, panel, entryTable, dropRow).importPdfFiles(fileNames, frame); if (importRes.noPdfFiles.length > 0) { loadOrImportFiles(importRes.noPdfFiles, dropRow); } } }); return true; }
@Override public void actionPerformed(ActionEvent arg0) { // Background this, as it takes a while. JabRefExecutorService.INSTANCE.execute( () -> { try { PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet(); pras.add(new JobName(entry.map(BibEntry::getCiteKey).orElse("NO ENTRY"), null)); previewPane.print(null, null, true, null, pras, false); } catch (PrinterException e) { // Inform the user... we don't know what to do. JOptionPane.showMessageDialog( PreviewPanel.this, Localization.lang("Could not print preview") + ".\n" + e.getMessage(), Localization.lang("Print entry preview"), JOptionPane.ERROR_MESSAGE); LOGGER.info("Could not print preview", e); } }); }
@Override public void actionPerformed(ActionEvent e) { panel = frame.getCurrentBasePanel(); // Check if a BasePanel exists: if (panel == null) { return; } // Check if any entries are selected: entries = panel.getSelectedEntries(); if (entries.length == 0) { JOptionPane.showMessageDialog( frame, Localization.lang("This operation requires one or more entries to be selected."), (String) getValue(Action.NAME), JOptionPane.ERROR_MESSAGE); return; } // If required, check that all entries have BibTeX keys defined: if (operation.requiresBibtexKeys()) { for (BibEntry entry : entries) { if ((entry.getCiteKey() == null) || entry.getCiteKey().trim().isEmpty()) { JOptionPane.showMessageDialog( frame, Localization.lang( "This operation requires all selected entries to have BibTex keys defined."), (String) getValue(Action.NAME), JOptionPane.ERROR_MESSAGE); return; } } } // All set, call the operation in a new thread: JabRefExecutorService.INSTANCE.execute(this); }