public void actionPerformed(ActionEvent e) {
BibtexEntry[] bes = entryTable.getSelectedEntries();
// Entries are copied if only the first or multiple
// columns are selected.
if ((bes != null) && (bes.length > 0)) {
TransferableBibtexEntry trbe = new TransferableBibtexEntry(bes);
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(trbe, parent);
output("Copied "+(bes.length >1 ? bes.length+" entries." : "1 entry."));
} else {
// The user maybe selected a single cell.
int[] rows = entryTable.getSelectedRows(),
cols = entryTable.getSelectedColumns();
if ((cols.length == 1) && (rows.length == 1)) {
// Copy single value.
Object o = tableModel.getValueAt(rows[0], cols[0]);
if (o != null) {
StringSelection ss = new StringSelection(o.toString());
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, parent);
output("Copied cell contents.");
}
} /*else
output("Copy multiple cell values: not yet supported.");*/
}
}
|