Search in sources :

Example 1 with ProtectedTermsList

use of org.jabref.logic.protectedterms.ProtectedTermsList 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)

Example 2 with ProtectedTermsList

use of org.jabref.logic.protectedterms.ProtectedTermsList in project jabref by JabRef.

the class JabRefPreferences method setProtectedTermsPreferences.

public void setProtectedTermsPreferences(ProtectedTermsLoader loader) {
    List<String> enabledExternalList = new ArrayList<>();
    List<String> disabledExternalList = new ArrayList<>();
    List<String> enabledInternalList = new ArrayList<>();
    List<String> disabledInternalList = new ArrayList<>();
    for (ProtectedTermsList list : loader.getProtectedTermsLists()) {
        if (list.isInternalList()) {
            if (list.isEnabled()) {
                enabledInternalList.add(list.getLocation());
            } else {
                disabledInternalList.add(list.getLocation());
            }
        } else {
            if (list.isEnabled()) {
                enabledExternalList.add(list.getLocation());
            } else {
                disabledExternalList.add(list.getLocation());
            }
        }
    }
    putStringList(PROTECTED_TERMS_ENABLED_EXTERNAL, enabledExternalList);
    putStringList(PROTECTED_TERMS_DISABLED_EXTERNAL, disabledExternalList);
    putStringList(PROTECTED_TERMS_ENABLED_INTERNAL, enabledInternalList);
    putStringList(PROTECTED_TERMS_DISABLED_INTERNAL, disabledInternalList);
}
Also used : ProtectedTermsList(org.jabref.logic.protectedterms.ProtectedTermsList) ArrayList(java.util.ArrayList)

Aggregations

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