// (b) copy and paste entries between multiple instances of JabRef (since
// only the text representation seems to get as far as the X clipboard, at least on my system)
actions.put("paste", new BaseAction() {
public void action() {
// Get clipboard contents, and see if TransferableBibtexEntry is among the content flavors offered
Transferable content = Toolkit.getDefaultToolkit()
.getSystemClipboard().getContents(null);
if (content != null) {
BibtexEntry[] bes = null;
if (content.isDataFlavorSupported(TransferableBibtexEntry.entryFlavor)) {
// We have determined that the clipboard data is a set of entries.
try {
bes = (BibtexEntry[])(content.getTransferData(TransferableBibtexEntry.entryFlavor));
} catch (UnsupportedFlavorException ex) {
ex.printStackTrace();
} catch (IOException ex) {
ex.printStackTrace();
}
} else if (content.isDataFlavorSupported(DataFlavor.stringFlavor)) {
try {
BibtexParser bp = new BibtexParser
(new java.io.StringReader( (String) (content.getTransferData(
DataFlavor.stringFlavor))));
BibtexDatabase db = bp.parse().getDatabase();
Util.pr("Parsed " + db.getEntryCount() + " entries from clipboard text");
if(db.getEntryCount()>0) {
bes = db.getEntries().toArray(new BibtexEntry[db.getEntryCount()]);