From 288747ae3762f1f2c27a667a17989a65f3a81c8c Mon Sep 17 00:00:00 2001 From: braincident <569120128@qq.com> Date: Thu, 7 May 2020 15:12:37 +0800 Subject: [PATCH 1/3] Update EditAction.java Fix the bug #6421 --- .../java/org/jabref/gui/edit/EditAction.java | 105 +++++++++--------- 1 file changed, 54 insertions(+), 51 deletions(-) diff --git a/src/main/java/org/jabref/gui/edit/EditAction.java b/src/main/java/org/jabref/gui/edit/EditAction.java index 36794f64ab7..1b40c0d621e 100644 --- a/src/main/java/org/jabref/gui/edit/EditAction.java +++ b/src/main/java/org/jabref/gui/edit/EditAction.java @@ -14,63 +14,66 @@ */ public class EditAction extends SimpleCommand { - private final JabRefFrame frame; - private final StandardActions action; - private final StateManager stateManager; + private final JabRefFrame frame; + private final StandardActions action; + private final StateManager stateManager; - public EditAction(StandardActions action, JabRefFrame frame, StateManager stateManager) { - this.action = action; - this.frame = frame; - this.stateManager = stateManager; + public EditAction(StandardActions action, JabRefFrame frame, StateManager stateManager) { + this.action = action; + this.frame = frame; + this.stateManager = stateManager; - this.executable.bind(ActionHelper.needsEntriesSelected(stateManager)); - } + this.executable.bind(ActionHelper.needsEntriesSelected(stateManager)); + } - @Override - public String toString() { - return this.action.toString(); - } + @Override + public String toString() { + return this.action.toString(); + } - @Override - public void execute() { - stateManager.getFocusOwner().ifPresent(focusOwner -> { - if (focusOwner instanceof TextInputControl) { - // Focus is on text field -> copy/paste/cut selected text - TextInputControl textInput = (TextInputControl) focusOwner; - switch (action) { - case COPY: - textInput.copy(); - break; - case CUT: - textInput.cut(); - break; - case PASTE: - // handled by FX in TextInputControl#paste - break; - default: - throw new IllegalStateException("Only cut/copy/paste supported in TextInputControl but got " + action); - } - } else { - // Not sure what is selected -> copy/paste/cut selected entries + @Override + public void execute() { + stateManager.getFocusOwner().ifPresent(focusOwner -> { + if (focusOwner instanceof TextInputControl) { + // Focus is on text field -> copy/paste/cut selected text + TextInputControl textInput = (TextInputControl) focusOwner; + switch (action) { + case COPY: + textInput.copy(); + break; + case CUT: + textInput.cut(); + break; + case PASTE: + // handled by FX in TextInputControl#paste + break; + case DELETE_ENTRY: + // DELETE_ENTRY in text field should do forward delete + textInput.deleteNextChar(); + default: + throw new IllegalStateException("Only cut/copy/paste supported in TextInputControl but got " + action); + } + } else { + // Not sure what is selected -> copy/paste/cut selected entries - // ToDo: Should be handled by BibDatabaseContext instead of BasePanel - switch (action) { - case COPY: - frame.getCurrentBasePanel().copy(); - break; - case CUT: - frame.getCurrentBasePanel().cut(); - break; - case PASTE: - frame.getCurrentBasePanel().paste(); - break; - case DELETE_ENTRY: - frame.getCurrentBasePanel().delete(false); - break; - default: - throw new IllegalStateException("Only cut/copy/paste supported but got " + action); - } + // ToDo: Should be handled by BibDatabaseContext instead of BasePanel + switch (action) { + case COPY: + frame.getCurrentBasePanel().copy(); + break; + case CUT: + frame.getCurrentBasePanel().cut(); + break; + case PASTE: + frame.getCurrentBasePanel().paste(); + break; + case DELETE_ENTRY: + frame.getCurrentBasePanel().delete(false); + break; + default: + throw new IllegalStateException("Only cut/copy/paste supported but got " + action); } + } }); } } From abff7d694f3792cbd5192846bc10aa0d625cbf14 Mon Sep 17 00:00:00 2001 From: braincident <569120128@qq.com> Date: Thu, 7 May 2020 15:27:02 +0800 Subject: [PATCH 2/3] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f5f4e34895c..762f841e60d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - We now show the number of items found and selected to import in the online search dialog. [#6248](https://github.com/JabRef/jabref/pull/6248) - We created a new install screen for macOS. [#5759](https://github.com/JabRef/jabref/issues/5759) - We implemented an option to download fulltext files while importing. [#6381](https://github.com/JabRef/jabref/pull/6381) +- We fixed the bug when strike the delete key in the text field. [#6421](https://github.com/JabRef/jabref/issues/6421) ### Changed From 225874b9b06d439ec6cf306e53941510f4b1c44c Mon Sep 17 00:00:00 2001 From: braincident <569120128@qq.com> Date: Thu, 7 May 2020 18:44:21 +0800 Subject: [PATCH 3/3] Update EditAction.java --- src/main/java/org/jabref/gui/edit/EditAction.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/org/jabref/gui/edit/EditAction.java b/src/main/java/org/jabref/gui/edit/EditAction.java index 1b40c0d621e..22a7ee38d13 100644 --- a/src/main/java/org/jabref/gui/edit/EditAction.java +++ b/src/main/java/org/jabref/gui/edit/EditAction.java @@ -50,6 +50,7 @@ public void execute() { case DELETE_ENTRY: // DELETE_ENTRY in text field should do forward delete textInput.deleteNextChar(); + break; default: throw new IllegalStateException("Only cut/copy/paste supported in TextInputControl but got " + action); }