Skip to content

Commit

Permalink
Fix issue with actions on empty space of menu items (#10093)
Browse files Browse the repository at this point in the history
This change fixes #8388 by removing CustomMenuItem from several context menus. This also removes the corresponding tooltips.
  • Loading branch information
Clunphumb committed Jul 18, 2023
1 parent 2f2deb5 commit 34ac6d1
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We fixed an issue where fetching an ISBN could lead to application freezing when the fetcher did not return any results. [#9979](https://github.com/JabRef/jabref/issues/9979)
- We fixed an issue where closing a library containing groups and entries caused an exception [#9997](https://github.com/JabRef/jabref/issues/9997)
- We fixed a bug where the editor for strings in a bibliography file did not sort the entries by their keys [#10083](https://github.com/JabRef/jabref/pull/10083)
- We fixed an issues where clicking on the empty space of specific context menu entries would not trigger the associated action. [#8388](https://github.com/JabRef/jabref/issues/8388)

### Removed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@
import java.util.Objects;
import java.util.function.Supplier;

import javafx.scene.control.CustomMenuItem;
import javafx.scene.control.Label;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuItem;
import javafx.scene.control.SeparatorMenuItem;
import javafx.scene.control.TextInputControl;
import javafx.scene.control.Tooltip;

import org.jabref.logic.cleanup.Formatter;
import org.jabref.logic.formatter.Formatters;
Expand Down Expand Up @@ -47,9 +44,7 @@ private static Menu getCaseChangeMenu(TextInputControl textInputControl) {
Menu submenu = new Menu(Localization.lang("Change case"));

for (final Formatter caseChanger : Formatters.getCaseChangers()) {
CustomMenuItem menuItem = new CustomMenuItem(new Label(caseChanger.getName()));
Tooltip toolTip = new Tooltip(caseChanger.getDescription());
Tooltip.install(menuItem.getContent(), toolTip);
MenuItem menuItem = new MenuItem(caseChanger.getName());
EasyBind.subscribe(textInputControl.textProperty(), value -> menuItem.setDisable(StringUtil.isNullOrEmpty(value)));
menuItem.setOnAction(event ->
textInputControl.textProperty().set(caseChanger.format(textInputControl.textProperty().get())));
Expand All @@ -63,9 +58,7 @@ private static Menu getConversionMenu(TextInputControl textInputControl) {
Menu submenu = new Menu(Localization.lang("Convert"));

for (Formatter converter : Formatters.getConverters()) {
CustomMenuItem menuItem = new CustomMenuItem(new Label(converter.getName()));
Tooltip toolTip = new Tooltip(converter.getDescription());
Tooltip.install(menuItem.getContent(), toolTip);
MenuItem menuItem = new MenuItem(converter.getName());
EasyBind.subscribe(textInputControl.textProperty(), value -> menuItem.setDisable(StringUtil.isNullOrEmpty(value)));
menuItem.setOnAction(event ->
textInputControl.textProperty().set(converter.format(textInputControl.textProperty().get())));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@
import java.util.List;
import java.util.function.Supplier;

import javafx.scene.control.CustomMenuItem;
import javafx.scene.control.Label;
import javafx.scene.control.MenuItem;
import javafx.scene.control.SeparatorMenuItem;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextInputControl;
import javafx.scene.control.Tooltip;

import org.jabref.gui.Globals;
import org.jabref.gui.actions.ActionFactory;
Expand Down Expand Up @@ -39,11 +36,9 @@ public class EditorMenus {
*/
public static Supplier<List<MenuItem>> getNameMenu(final TextInputControl textInput) {
return () -> {
CustomMenuItem normalizeNames = new CustomMenuItem(new Label(Localization.lang("Normalize to BibTeX name format")));
MenuItem normalizeNames = new MenuItem(Localization.lang("Normalize to BibTeX name format"));
EasyBind.subscribe(textInput.textProperty(), value -> normalizeNames.setDisable(StringUtil.isNullOrEmpty(value)));
normalizeNames.setOnAction(event -> textInput.setText(new NormalizeNamesFormatter().format(textInput.getText())));
Tooltip toolTip = new Tooltip(Localization.lang("If possible, normalize this list of names to conform to standard BibTeX name formatting"));
Tooltip.install(normalizeNames.getContent(), toolTip);
List<MenuItem> menuItems = new ArrayList<>(6);
menuItems.add(normalizeNames);
menuItems.addAll(new DefaultMenu(textInput).get());
Expand Down Expand Up @@ -79,7 +74,7 @@ public static Supplier<List<MenuItem>> getDOIMenu(TextArea textArea) {
*/
public static Supplier<List<MenuItem>> getCleanupUrlMenu(TextArea textArea) {
return () -> {
CustomMenuItem cleanupURL = new CustomMenuItem(new Label(Localization.lang("Cleanup URL link")));
MenuItem cleanupURL = new MenuItem(Localization.lang("Cleanup URL link"));
cleanupURL.setDisable(textArea.textProperty().isEmpty().get());
cleanupURL.setOnAction(event -> textArea.setText(new CleanupUrlFormatter().format(textArea.getText())));
List<MenuItem> menuItems = new ArrayList<>();
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/l10n/JabRef_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,6 @@ Please\ choose\ which\ one\ to\ connect\ to\:=Please choose which one to connect
Choose\ OpenOffice/LibreOffice\ executable=Choose OpenOffice/LibreOffice executable
Select\ document=Select document
HTML\ list=HTML list
If\ possible,\ normalize\ this\ list\ of\ names\ to\ conform\ to\ standard\ BibTeX\ name\ formatting=If possible, normalize this list of names to conform to standard BibTeX name formatting
Could\ not\ open\ %0=Could not open %0
Unknown\ import\ format=Unknown import format
Style\ selection=Style selection
Expand Down

0 comments on commit 34ac6d1

Please sign in to comment.