From 840431246d928d76f6d58dab65d49235c65fdf25 Mon Sep 17 00:00:00 2001 From: juliusalberto <57690582+juliusalberto@users.noreply.github.com> Date: Sun, 13 Oct 2024 15:45:53 +1100 Subject: [PATCH] Convert some fields to TextArea (#11886) * Add custom paste behavior to EditorTextField * Changed TextArea to TextField for CleanupUrlMenu * Changed TextArea to TextField in UrlEditor * Changed DOI menu to accept textfield instead of textarea * Changed TextArea into TextField in the IdentifierEditor * Changed TextArea into TextField in the ISSN editor * Changed TextArea into TextField in the OwnerEditor * Added fix CHANGELOG.md * Modified the name to additionalPasteActionHandler and removed comments * Update src/main/java/org/jabref/gui/fieldeditors/contextmenu/EditorMenus.java * Add kbd around Tab * Changed the interface to Runnable and removed the unused PasteActionHandler interface --------- Co-authored-by: Oliver Kopp --- CHANGELOG.md | 1 + .../org/jabref/gui/edit/CopyDoiUrlAction.java | 6 +++--- .../gui/fieldeditors/EditorTextArea.java | 14 +++---------- .../gui/fieldeditors/EditorTextField.java | 15 ++++++++++++++ .../jabref/gui/fieldeditors/ISSNEditor.fxml | 4 ++-- .../jabref/gui/fieldeditors/ISSNEditor.java | 10 +++++----- .../jabref/gui/fieldeditors/OwnerEditor.fxml | 4 ++-- .../jabref/gui/fieldeditors/OwnerEditor.java | 8 ++++---- .../jabref/gui/fieldeditors/UrlEditor.fxml | 4 ++-- .../jabref/gui/fieldeditors/UrlEditor.java | 12 +++++------ .../fieldeditors/contextmenu/EditorMenus.java | 20 +++++++++---------- .../identifier/IdentifierEditor.fxml | 4 ++-- .../identifier/IdentifierEditor.java | 12 +++++------ 13 files changed, 61 insertions(+), 53 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f23a80be7c8..5c84f5424c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -88,6 +88,7 @@ Note that this project **does not** adhere to [Semantic Versioning](https://semv - We fixed an issue where the Undo/Redo buttons were active even when all libraries are closed. [#11837](https://github.com/JabRef/jabref/issues/11837) - We fixed an issue where recently opened files were not displayed in the main menu properly. [#9042](https://github.com/JabRef/jabref/issues/9042) - We fixed an issue where the DOI lookup would show an error when a DOI was found for an entry. [#11850](https://github.com/JabRef/jabref/issues/11850) +- We fixed an issue where Tab cannot be used to jump to next field in some single-line fields. [#11785](https://github.com/JabRef/jabref/issues/11785) ### Removed diff --git a/src/main/java/org/jabref/gui/edit/CopyDoiUrlAction.java b/src/main/java/org/jabref/gui/edit/CopyDoiUrlAction.java index 7dec0abeae1..f8d7f173acd 100644 --- a/src/main/java/org/jabref/gui/edit/CopyDoiUrlAction.java +++ b/src/main/java/org/jabref/gui/edit/CopyDoiUrlAction.java @@ -2,7 +2,7 @@ import java.util.Optional; -import javafx.scene.control.TextArea; +import javafx.scene.control.TextField; import org.jabref.gui.ClipBoardManager; import org.jabref.gui.DialogService; @@ -16,12 +16,12 @@ */ public class CopyDoiUrlAction extends SimpleCommand { - private final TextArea component; + private final TextField component; private final StandardActions action; private final DialogService dialogService; private final ClipBoardManager clipBoardManager; - public CopyDoiUrlAction(TextArea component, StandardActions action, DialogService dialogService, ClipBoardManager clipBoardManager) { + public CopyDoiUrlAction(TextField component, StandardActions action, DialogService dialogService, ClipBoardManager clipBoardManager) { this.component = component; this.action = action; this.dialogService = dialogService; diff --git a/src/main/java/org/jabref/gui/fieldeditors/EditorTextArea.java b/src/main/java/org/jabref/gui/fieldeditors/EditorTextArea.java index 7b478f94695..fc18e591103 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/EditorTextArea.java +++ b/src/main/java/org/jabref/gui/fieldeditors/EditorTextArea.java @@ -21,7 +21,7 @@ public class EditorTextArea extends TextArea implements Initializable, ContextMe /** * Variable that contains user-defined behavior for paste action. */ - private PasteActionHandler pasteActionHandler = () -> { + private Runnable pasteActionHandler = () -> { // Set empty paste behavior by default }; @@ -57,7 +57,7 @@ public void initialize(URL location, ResourceBundle resources) { * * @param handler an instance of PasteActionHandler that describes paste behavior */ - public void setPasteActionHandler(PasteActionHandler handler) { + public void setPasteActionHandler(Runnable handler) { Objects.requireNonNull(handler); this.pasteActionHandler = handler; } @@ -68,14 +68,6 @@ public void setPasteActionHandler(PasteActionHandler handler) { @Override public void paste() { super.paste(); - pasteActionHandler.handle(); - } - - /** - * Interface presents user-described paste behaviour applying to paste method - */ - @FunctionalInterface - public interface PasteActionHandler { - void handle(); + pasteActionHandler.run(); } } diff --git a/src/main/java/org/jabref/gui/fieldeditors/EditorTextField.java b/src/main/java/org/jabref/gui/fieldeditors/EditorTextField.java index 34fd2be09f4..08cd9dde886 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/EditorTextField.java +++ b/src/main/java/org/jabref/gui/fieldeditors/EditorTextField.java @@ -2,6 +2,7 @@ import java.net.URL; import java.util.List; +import java.util.Objects; import java.util.ResourceBundle; import java.util.function.Supplier; @@ -19,6 +20,9 @@ public class EditorTextField extends TextField implements Initializable, ContextMenuAddable { private final ContextMenu contextMenu = new ContextMenu(); + private Runnable additionalPasteActionHandler = () -> { + // No additional paste behavior + }; public EditorTextField() { this(""); @@ -47,4 +51,15 @@ public void initContextMenu(final Supplier> items, KeyBindingRepo public void initialize(URL location, ResourceBundle resources) { // not needed } + + public void setAdditionalPasteActionHandler(Runnable handler) { + Objects.requireNonNull(handler); + this.additionalPasteActionHandler = handler; + } + + @Override + public void paste() { + super.paste(); + additionalPasteActionHandler.run(); + } } diff --git a/src/main/java/org/jabref/gui/fieldeditors/ISSNEditor.fxml b/src/main/java/org/jabref/gui/fieldeditors/ISSNEditor.fxml index 44d70fb78c4..7358de4c2b1 100644 --- a/src/main/java/org/jabref/gui/fieldeditors/ISSNEditor.fxml +++ b/src/main/java/org/jabref/gui/fieldeditors/ISSNEditor.fxml @@ -3,11 +3,11 @@ - + - +