1 | public void actionPerformed(ActionEvent event) { | | 1 | public void insertUsingBST() { |
2 | ArrayList<BibtexEntry> entries = new ArrayList<BibtexEntry>(); | | 2 | try { |
3 | for (BibtexEntry e: JabRef.jrf.basePanel().getSelectedEntries()) { | | 3 | BasePanel panel =frame.basePanel(); |
4 | entries.add(e); | | 4 | final BibtexDatabase database = panel.database(); |
5 | } | | 5 | if (panel != null) { |
6 | if (entries.isEmpty()) { | | 6 | BibtexEntry[] entries = panel.getSelectedEntries(); |
7 | JabRef.jrf.basePanel().output(Globals.lang("No entries selected.")); | | 7 | ArrayList<BibtexEntry> el = new ArrayList<BibtexEntry>(); |
8 | return; | | 8 | for (int i = 0; i < entries.length; i++) { |
9 | } | | 9 | el.add(entries[i]); |
10 | JDialog diag = new JDialog(JabRef.jrf, true); | | 10 | } |
11 | final NamedCompound nc = new NamedCompound(Globals.lang("Automatically set file links")); | | 11 | |
12 | Util.autoSetLinks(entries, nc, null, null, JabRef.jrf.basePanel().metaData(), new ActionListener() { | | 12 | BstWrapper wrapper = new BstWrapper(); |
13 | public void actionPerformed(ActionEvent e) { | | 13 | //wrapper.loadBstFile(new File("/home/usr/share/texmf-tetex/bibtex/bst/base/plain.bst")); |
14 | if (e.getID() > 0) { | | 14 | wrapper.loadBstFile(new File("/home/usr/share/texmf-tetex/bibtex/bst/ams/amsalpha.bst")); |
15 | // entry has been updated in Util.autoSetLinks, only treat nc and status message | | 15 | Map<String,String> result = wrapper.processEntries(el, database); |
16 | if (nc.hasEdits()) { | | 16 | for (String key : result.keySet()) { |
17 | nc.end(); | | 17 | System.out.println("Key: "+key); |
18 | JabRef.jrf.basePanel().undoManager.addEdit(nc); | | 18 | System.out.println("Entry: "+result.get(key)); |
19 | JabRef.jrf.basePanel().markBaseChanged(); | | 19 | ooBase.insertMarkedUpTextAtViewCursor(result.get(key), "Default"); |
20 | } | | 20 | } |
21 | JabRef.jrf.output(Globals.lang("Finished autosetting external links.")); | | 21 | //System.out.println(result); |
22 | } | | 22 | } |
23 | else JabRef.jrf.output(Globals.lang("Finished autosetting external links.") | | 23 | } catch (Exception ex) { |
24 | +" "+Globals.lang("No files found.")); | | 24 | ex.printStackTrace(); |
25 | } | | 25 | } |
26 | }, diag); | | 26 | } |
27 | } | | | |