1 | @Override | | 1 | public void actionPerformed(ActionEvent event) { |
2 | public void action() throws Throwable { | | 2 | ArrayList<BibtexEntry> entries = new ArrayList<BibtexEntry>(); |
3 | | | 3 | for (BibtexEntry e: JabRef.jrf.basePanel().getSelectedEntries()) { |
4 | ArrayList<BibtexEntry> entries = new ArrayList<BibtexEntry>(); | | 4 | entries.add(e); |
5 | BibtexEntry[] sel = panel.getSelectedEntries(); | | 5 | } |
6 | for (int i = 0; i < sel.length; i++) { | | 6 | if (entries.isEmpty()) { |
7 | BibtexEntry bibtexEntry = sel[i]; | | 7 | JabRef.jrf.basePanel().output(Globals.lang("No entries selected.")); |
8 | entries.add(bibtexEntry); | | 8 | return; |
9 | } | | 9 | } |
10 | final List<FileListEntry> links = | | 10 | JDialog diag = new JDialog(JabRef.jrf, true); |
11 | AccessLinksForEntries.getExternalLinksForEntries(entries); | | 11 | final NamedCompound nc = new NamedCompound(Globals.lang("Automatically set file links")); |
12 | for (Iterator<FileListEntry> iterator = links.iterator(); iterator.hasNext();) { | | 12 | Util.autoSetLinks(entries, nc, null, null, JabRef.jrf.basePanel().metaData(), new ActionListener() { |
13 | FileListEntry entry = iterator.next(); | | 13 | public void actionPerformed(ActionEvent e) { |
14 | System.out.println("Link: " + entry.getLink()); | | 14 | if (e.getID() > 0) { |
15 | } | | 15 | // entry has been updated in Util.autoSetLinks, only treat nc and status message |
16 | | | 16 | if (nc.hasEdits()) { |
17 | final JProgressBar prog = new JProgressBar(); | | 17 | nc.end(); |
18 | prog.setIndeterminate(true); | | 18 | JabRef.jrf.basePanel().undoManager.addEdit(nc); |
19 | final JDialog diag = new JDialog(panel.frame(), false); | | 19 | JabRef.jrf.basePanel().markBaseChanged(); |
20 | diag.getContentPane().add(prog, BorderLayout.CENTER); | | 20 | } |
21 | diag.pack(); | | 21 | JabRef.jrf.output(Globals.lang("Finished autosetting external links.")); |
22 | diag.setLocationRelativeTo(panel.frame()); | | 22 | } |
23 | diag.setVisible(true); | | 23 | else JabRef.jrf.output(Globals.lang("Finished autosetting external links.") |
24 | Thread t = new Thread(new Runnable() { | | 24 | +" "+Globals.lang("No files found.")); |
25 | public void run() { | | 25 | } |
26 | AccessLinksForEntries.copyExternalLinksToDirectory(links, | | 26 | }, diag); |
27 | new File("/home/alver/tmp"), panel.metaData(), prog, false, | | 27 | } |
28 | new ActionListener() { | | | |
29 | public void actionPerformed(ActionEvent actionEvent) { | | | |
30 | diag.dispose(); | | | |
31 | } | | | |
32 | }); | | | |
33 | } | | | |
34 | }); | | | |
35 | t.start(); | | | |
36 | | | | |
37 | | | | |
38 | } | | | |