Search in sources :

Example 1 with NewProtectedTermsFileDialog

use of org.jabref.gui.protectedterms.NewProtectedTermsFileDialog in project jabref by JabRef.

the class ProtectedTermsMenu method updateFiles.

private void updateFiles() {
    externalFiles.getItems().clear();
    for (ProtectedTermsList list : Globals.protectedTermsLoader.getProtectedTermsLists()) {
        if (!list.isInternalList()) {
            MenuItem fileItem = new MenuItem(list.getDescription());
            fileItem.setOnAction(event -> {
                String selectedText = opener.getSelectedText();
                if ((selectedText != null) && !selectedText.isEmpty()) {
                    list.addProtectedTerm(selectedText);
                }
            });
            externalFiles.getItems().add(fileItem);
        }
    }
    externalFiles.getItems().add(new SeparatorMenuItem());
    MenuItem addToNewFileItem = new MenuItem(Localization.lang("New") + "...");
    addToNewFileItem.setOnAction(event -> {
        NewProtectedTermsFileDialog dialog = new NewProtectedTermsFileDialog(JabRefGUI.getMainFrame(), Globals.protectedTermsLoader);
        dialog.setVisible(true);
        if (dialog.isOKPressed()) {
            Globals.prefs.setProtectedTermsPreferences(Globals.protectedTermsLoader);
        }
    });
    externalFiles.getItems().add(addToNewFileItem);
}
Also used : ProtectedTermsList(org.jabref.logic.protectedterms.ProtectedTermsList) NewProtectedTermsFileDialog(org.jabref.gui.protectedterms.NewProtectedTermsFileDialog) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem) MenuItem(javafx.scene.control.MenuItem) SeparatorMenuItem(javafx.scene.control.SeparatorMenuItem)

Aggregations

MenuItem (javafx.scene.control.MenuItem)1 SeparatorMenuItem (javafx.scene.control.SeparatorMenuItem)1 NewProtectedTermsFileDialog (org.jabref.gui.protectedterms.NewProtectedTermsFileDialog)1 ProtectedTermsList (org.jabref.logic.protectedterms.ProtectedTermsList)1