Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new menu entry to remove braces from selection, aka unprotect it. #9968

2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -22,10 +22,12 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We enabled scrolling in the groups list when dragging a group on another group. [#2869](https://github.com/JabRef/jabref/pull/2869)
- We added the option to automatically download online files when a new entry is created from an existing ID (e.g., DOI). The option can be disabled in the preferences under "Import and Export". [#9756](https://github.com/JabRef/jabref/issues/9756)
- We added a new Integrity check for unscaped ampersands. [koppor#585](https://github.com/koppor/jabref/issues/585)
- We added the possibility to automatically fetch entries when an IBSN is pasted on the main table. [#9864](https://github.com/JabRef/jabref/issues/9864)
- We added support for parsing `$\backslash$` in file paths (as exported by Mendeley). [forum#3470](https://discourse.jabref.org/t/mendeley-bib-import-with-linked-files/3470)
- 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)
Original file line number Diff line number Diff line change
@@ -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,16 @@ public void execute() {
}
}

private class UnprotectSelectionAction extends SimpleCommand {

@Override
public void execute() {
String selectedText = textInputControl.getSelectedText();
BeeJay28 marked this conversation as resolved.
Show resolved Hide resolved
String formattedString = new UnprotectTermsFormatter().format(selectedText);
textInputControl.replaceSelection(formattedString);
}
}

private class FormatFieldAction extends SimpleCommand {
FormatFieldAction() {
this.executable.bind(textInputControl.textProperty().isNotEmpty());
@@ -88,7 +111,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() {
2 changes: 2 additions & 0 deletions src/main/resources/l10n/JabRef_en.properties
Original file line number Diff line number Diff line change
@@ -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