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);
}
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);
}
Aggregations