use of org.jabref.gui.specialfields.SpecialFieldMenuAction in project jabref by JabRef.
the class MainTableSelectionListener method handleSpecialFieldLeftClick.
/**
* Method to handle a single left click on one the special fields (e.g., ranking, quality, ...)
* Shows either a popup to select/clear a value or simply toggles the functionality to set/unset the special field
*
* @param e MouseEvent used to determine the position of the popups
* @param columnName the name of the specialfield column
*/
private void handleSpecialFieldLeftClick(MouseEvent e, String columnName) {
if ((e.getClickCount() == 1)) {
SpecialField.getSpecialFieldInstanceFromFieldName(columnName).ifPresent(field -> {
if (field.isSingleValueField()) {
new SpecialFieldViewModel(field).getSpecialFieldAction(field.getValues().get(0), panel.frame()).action();
} else {
JPopupMenu menu = new JPopupMenu();
for (SpecialFieldValue val : field.getValues()) {
menu.add(new SpecialFieldMenuAction(new SpecialFieldValueViewModel(val), panel.frame()));
}
menu.show(table, e.getX(), e.getY());
}
});
}
}
use of org.jabref.gui.specialfields.SpecialFieldMenuAction in project jabref by JabRef.
the class RightClickMenu method populateSpecialFieldMenu.
/**
* Remove all types from the menu.
* Then cycle through all available values, and add them.
*/
public static void populateSpecialFieldMenu(JMenu menu, SpecialField field, JabRefFrame frame) {
SpecialFieldViewModel viewModel = new SpecialFieldViewModel(field);
menu.setText(viewModel.getLocalization());
menu.setIcon(viewModel.getRepresentingIcon());
for (SpecialFieldValue val : field.getValues()) {
menu.add(new SpecialFieldMenuAction(new SpecialFieldValueViewModel(val), frame));
}
}
Aggregations