Search in sources :

Example 1 with SpecialFieldMenuAction

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());
            }
        });
    }
}
Also used : SpecialFieldMenuAction(org.jabref.gui.specialfields.SpecialFieldMenuAction) SpecialFieldValueViewModel(org.jabref.gui.specialfields.SpecialFieldValueViewModel) SpecialFieldViewModel(org.jabref.gui.specialfields.SpecialFieldViewModel) JPopupMenu(javax.swing.JPopupMenu) SpecialFieldValue(org.jabref.model.entry.specialfields.SpecialFieldValue)

Example 2 with SpecialFieldMenuAction

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));
    }
}
Also used : SpecialFieldMenuAction(org.jabref.gui.specialfields.SpecialFieldMenuAction) SpecialFieldValueViewModel(org.jabref.gui.specialfields.SpecialFieldValueViewModel) SpecialFieldViewModel(org.jabref.gui.specialfields.SpecialFieldViewModel) SpecialFieldValue(org.jabref.model.entry.specialfields.SpecialFieldValue)

Aggregations

SpecialFieldMenuAction (org.jabref.gui.specialfields.SpecialFieldMenuAction)2 SpecialFieldValueViewModel (org.jabref.gui.specialfields.SpecialFieldValueViewModel)2 SpecialFieldViewModel (org.jabref.gui.specialfields.SpecialFieldViewModel)2 SpecialFieldValue (org.jabref.model.entry.specialfields.SpecialFieldValue)2 JPopupMenu (javax.swing.JPopupMenu)1