use of org.jabref.gui.actions.CopyDoiUrlAction in project jabref by JabRef.
the class EditorMenus method getDOIMenu.
public static List<MenuItem> getDOIMenu(TextArea textArea) {
AbstractAction copyDoiUrlAction = new CopyDoiUrlAction(textArea);
MenuItem copyDoiUrlMenuItem = new MenuItem((String) copyDoiUrlAction.getValue(Action.NAME));
copyDoiUrlMenuItem.setOnAction(event -> copyDoiUrlAction.actionPerformed(null));
List<MenuItem> menuItems = new ArrayList<>();
menuItems.add(copyDoiUrlMenuItem);
menuItems.add(new SeparatorMenuItem());
return menuItems;
}
use of org.jabref.gui.actions.CopyDoiUrlAction in project jabref by JabRef.
the class MainTableSelectionListener method showIconRightClickMenu.
/**
* Process popup trigger events occurring on an icon cell in the table. Show a menu where the user can choose which
* external resource to open for the entry. If no relevant external resources exist, let the normal popup trigger
* handler do its thing instead.
*
* @param e The mouse event defining this popup trigger.
* @param row The row where the event occurred.
* @param column the MainTableColumn associated with this table cell.
*/
private void showIconRightClickMenu(MouseEvent e, int row, MainTableColumn column) {
BibEntry entry = tableRows.get(row);
JPopupMenu menu = new JPopupMenu();
boolean showDefaultPopup = true;
// field that can specify a list of links:
if (!column.getBibtexFields().isEmpty()) {
for (String field : column.getBibtexFields()) {
if (FieldName.FILE.equals(field)) {
// We use a FileListTableModel to parse the field content:
FileListTableModel fileList = new FileListTableModel();
entry.getField(field).ifPresent(fileList::setContent);
for (int i = 0; i < fileList.getRowCount(); i++) {
FileListEntry flEntry = fileList.getEntry(i);
if (column.isFileFilter() && (!flEntry.getType().get().getName().equalsIgnoreCase(column.getColumnName()))) {
continue;
}
String description = flEntry.getDescription();
if ((description == null) || (description.trim().isEmpty())) {
description = flEntry.getLink();
}
menu.add(new ExternalFileMenuItem(panel.frame(), entry, description, flEntry.getLink(), flEntry.getType().get().getIcon(), panel.getBibDatabaseContext(), flEntry.getType()));
showDefaultPopup = false;
}
} else {
if (SpecialField.isSpecialField(column.getColumnName())) {
// full pop should be shown as left click already shows short popup
showDefaultPopup = true;
} else {
Optional<String> content = entry.getField(field);
if (content.isPresent()) {
Icon icon;
JLabel iconLabel = GUIGlobals.getTableIcon(field);
if (iconLabel == null) {
icon = IconTheme.JabRefIcon.FILE.getIcon();
} else {
icon = iconLabel.getIcon();
}
menu.add(new ExternalFileMenuItem(panel.frame(), entry, content.get(), content.get(), icon, panel.getBibDatabaseContext(), field));
if (field.equals(FieldName.DOI)) {
menu.add(new CopyDoiUrlAction(content.get()));
}
showDefaultPopup = false;
}
}
}
}
if (showDefaultPopup) {
processPopupTrigger(e, row);
} else {
menu.show(table, e.getX(), e.getY());
}
}
}
Aggregations