diff --git a/CHANGELOG.md b/CHANGELOG.md index a0e849d73ef..0ff91909069 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - We added the possibility to automatically fetch entries when an ISBN is pasted on the main table. [#9864](https://github.com/JabRef/jabref/issues/9864) - We added the option to disable the automatic linking of files in the entry editor [#5105](https://github.com/JabRef/jabref/issues/5105) - We added the link icon for ISBNs in linked identifiers column. [#9819](https://github.com/JabRef/jabref/issues/9819) +- We added the option to unprotect a text selection, which strips all pairs of curly braces away. [#9950](https://github.com/JabRef/jabref/issues/9950) - We added drag and drop events for field 'Groups' in entry editor panel. [#569](https://github.com/koppor/jabref/issues/569) - We added support for parsing MathML in the Medline importer. [#4273](https://github.com/JabRef/jabref/issues/4273) - We added the ability to search for a DOI directly from 'Web Search'. [#9674](https://github.com/JabRef/jabref/issues/9674) diff --git a/src/main/java/org/jabref/gui/fieldeditors/contextmenu/ProtectedTermsMenu.java b/src/main/java/org/jabref/gui/fieldeditors/contextmenu/ProtectedTermsMenu.java index e085eb981bd..d66eb82a777 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/contextmenu/ProtectedTermsMenu.java +++ b/src/main/java/org/jabref/gui/fieldeditors/contextmenu/ProtectedTermsMenu.java @@ -16,6 +16,7 @@ import org.jabref.gui.icon.JabRefIcon; import org.jabref.logic.cleanup.Formatter; import org.jabref.logic.formatter.casechanger.ProtectTermsFormatter; +import org.jabref.logic.formatter.casechanger.UnprotectTermsFormatter; import org.jabref.logic.l10n.Localization; import org.jabref.logic.protectedterms.ProtectedTermsList; @@ -42,6 +43,18 @@ public String getDescription() { } }; + private final Action unprotectSelectionActionInformation = new Action() { + @Override + public String getText() { + return Localization.lang("Unprotect selection"); + } + + @Override + public String getDescription() { + return Localization.lang("Remove all {} in selected text"); + } + }; + private class ProtectSelectionAction extends SimpleCommand { ProtectSelectionAction() { this.executable.bind(textInputControl.selectedTextProperty().isNotEmpty()); @@ -54,6 +67,20 @@ public void execute() { } } + private class UnprotectSelectionAction extends SimpleCommand { + + public UnprotectSelectionAction() { + this.executable.bind(textInputControl.selectedTextProperty().isNotEmpty()); + } + + @Override + public void execute() { + String selectedText = textInputControl.getSelectedText(); + String formattedString = new UnprotectTermsFormatter().format(selectedText); + textInputControl.replaceSelection(formattedString); + } + } + private class FormatFieldAction extends SimpleCommand { FormatFieldAction() { this.executable.bind(textInputControl.textProperty().isNotEmpty()); @@ -88,7 +115,8 @@ public ProtectedTermsMenu(final TextInputControl textInputControl) { getItems().addAll(factory.createMenuItem(protectSelectionActionInformation, new ProtectSelectionAction()), getExternalFilesMenu(), new SeparatorMenuItem(), - factory.createMenuItem(() -> Localization.lang("Format field"), new FormatFieldAction())); + factory.createMenuItem(() -> Localization.lang("Format field"), new FormatFieldAction()), + factory.createMenuItem(unprotectSelectionActionInformation, new UnprotectSelectionAction())); } private Menu getExternalFilesMenu() { diff --git a/src/main/resources/l10n/JabRef_en.properties b/src/main/resources/l10n/JabRef_en.properties index 306597d3313..02dbc0da732 100644 --- a/src/main/resources/l10n/JabRef_en.properties +++ b/src/main/resources/l10n/JabRef_en.properties @@ -1634,6 +1634,7 @@ Are\ you\ sure\ you\ want\ to\ remove\ the\ protected\ terms\ file?=Are you sure Remove\ protected\ terms\ file=Remove protected terms file Add\ selected\ text\ to\ list=Add selected text to list Add\ {}\ around\ selected\ text=Add {} around selected text +Remove\ all\ {}\ in\ selected\ text=Remove all {} in selected text Format\ field=Format field New\ protected\ terms\ file=New protected terms file change\ field\ %0\ of\ entry\ %1\ from\ %2\ to\ %3=change field %0 of entry %1 from %2 to %3 @@ -2290,6 +2291,7 @@ Custom\ import\ formats=Custom import formats No\ list\ enabled=No list enabled Protect\ selection=Protect selection +Unprotect\ selection=Unprotect selection Customized\ preview\ style=Customized preview style Next\ preview\ style=Next preview style