diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7ee65d748db..fb14f814d32 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -19,7 +19,7 @@ If fetched article is already in database the ImportInspectionDialog is started
- We fixed an issue where the fetcher for the Astrophysics Data System (ADS) added some non-bibtex data to the entry returned from the search [#3035](https://github.com/JabRef/jabref/issues/3035)
- We fixed an issue where assigning an entry via drag and drop to a group caused JabRef to stop/freeze completely [#3036](https://github.com/JabRef/jabref/issues/3036)
- We fixed an issue where the preferences could not be imported without a restart of JabRef [#3064](https://github.com/JabRef/jabref/issues/3064)
-
+- We fixed an issue where DEL, Ctrl+C, Ctrl+V and Ctrl+A in the search field triggered corresponding actions in the main table [#3067](https://github.com/JabRef/jabref/issues/3067)
### Removed
diff --git a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java
index 833d08e0902..d5ae811676b 100644
--- a/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java
+++ b/src/main/java/org/jabref/gui/entryeditor/EntryEditor.java
@@ -8,7 +8,7 @@
import java.awt.Insets;
import java.awt.RenderingHints;
import java.awt.event.ActionEvent;
-import java.awt.event.KeyListener;
+import java.awt.event.KeyAdapter;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.time.LocalDateTime;
@@ -157,18 +157,7 @@ public EntryEditor(JabRefFrame frame, BasePanel panel, BibEntry entry, String la
JFXPanel container = new JFXPanel();
- container.addKeyListener(new KeyListener() {
-
- @Override
- public void keyTyped(java.awt.event.KeyEvent e) {
- //empty
- }
-
- @Override
- public void keyReleased(java.awt.event.KeyEvent e) {
- // empty
-
- }
+ container.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(java.awt.event.KeyEvent e) {
diff --git a/src/main/java/org/jabref/gui/search/GlobalSearchBar.java b/src/main/java/org/jabref/gui/search/GlobalSearchBar.java
index 41151522c33..8323eb1ea00 100644
--- a/src/main/java/org/jabref/gui/search/GlobalSearchBar.java
+++ b/src/main/java/org/jabref/gui/search/GlobalSearchBar.java
@@ -5,9 +5,11 @@
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.event.ActionEvent;
+import java.awt.event.KeyAdapter;
import java.io.File;
import java.util.List;
import java.util.Objects;
+import java.util.Optional;
import java.util.stream.Collectors;
import javax.swing.AbstractAction;
@@ -61,7 +63,6 @@ public class GlobalSearchBar extends JPanel {
private static final PseudoClass CLASS_NO_RESULTS = PseudoClass.getPseudoClass("emptyResult");
private static final PseudoClass CLASS_RESULTS_FOUND = PseudoClass.getPseudoClass("emptyResult");
-
private final JabRefFrame frame;
private final TextField searchField = SearchTextField.create();
@@ -70,7 +71,7 @@ public class GlobalSearchBar extends JPanel {
private final JButton searchModeButton = new JButton();
private final JLabel currentResults = new JLabel("");
private final SearchQueryHighlightObservable searchQueryHighlightObservable = new SearchQueryHighlightObservable();
- private JButton openCurrentResultsInDialog = new JButton(IconTheme.JabRefIcon.OPEN_IN_NEW_WINDOW.getSmallIcon());
+ private final JButton openCurrentResultsInDialog = new JButton(IconTheme.JabRefIcon.OPEN_IN_NEW_WINDOW.getSmallIcon());
private SearchWorker searchWorker;
private GlobalSearchWorker globalSearchWorker;
@@ -83,7 +84,6 @@ public class GlobalSearchBar extends JPanel {
*/
private boolean dontSelectSearchBar;
-
public GlobalSearchBar(JabRefFrame frame) {
super();
this.frame = Objects.requireNonNull(frame);
@@ -99,6 +99,7 @@ public GlobalSearchBar(JabRefFrame frame) {
// default action to be performed for toggling globalSearch
AbstractAction globalSearchStandardAction = new AbstractAction() {
+
@Override
public void actionPerformed(ActionEvent e) {
searchPreferences.setGlobalSearch(globalSearch.isSelected());
@@ -108,6 +109,7 @@ public void actionPerformed(ActionEvent e) {
// additional action for global search shortcut
AbstractAction globalSearchShortCutAction = new AbstractAction() {
+
@Override
public void actionPerformed(ActionEvent e) {
globalSearch.setSelected(true);
@@ -115,6 +117,35 @@ public void actionPerformed(ActionEvent e) {
focus();
}
};
+ //TODO: These have to be somehow converted
+ /*
+ String endSearch = "endSearch";
+ searchField.getInputMap().put(Globals.getKeyPrefs().getKey(KeyBinding.CLEAR_SEARCH), endSearch);
+ searchField.getActionMap().put(endSearch, new AbstractAction() {
+ @Override
+ public void actionPerformed(ActionEvent event) {
+ if (autoCompleteSupport.isVisible()) {
+ autoCompleteSupport.setVisible(false);
+ } else {
+ endSearch();
+ }
+ }
+ });
+ */
+
+ /*
+ String acceptSearch = "acceptSearch";
+ searchField.getInputMap().put(Globals.getKeyPrefs().getKey(KeyBinding.ACCEPT), acceptSearch);
+ searchField.getActionMap().put(acceptSearch, new AbstractAction() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ autoCompleteSupport.setVisible(false);
+ BasePanel currentBasePanel = frame.getCurrentBasePanel();
+ Globals.getFocusListener().setFocused(currentBasePanel.getMainTable());
+ currentBasePanel.getMainTable().requestFocus();
+ }
+ });
+ */
String searchGlobalByKey = "searchGlobalByKey";
globalSearch.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(Globals.getKeyPrefs().getKey(KeyBinding.GLOBAL_SEARCH), searchGlobalByKey);
@@ -154,38 +185,31 @@ public void actionPerformed(ActionEvent e) {
EasyBind.subscribe(searchField.textProperty(), searchText -> performSearch());
- /*
- String endSearch = "endSearch";
- searchField.getInputMap().put(Globals.getKeyPrefs().getKey(KeyBinding.CLEAR_SEARCH), endSearch);
- searchField.getActionMap().put(endSearch, new AbstractAction() {
- @Override
- public void actionPerformed(ActionEvent event) {
- if (autoCompleteSupport.isVisible()) {
- autoCompleteSupport.setVisible(false);
- } else {
- endSearch();
- }
- }
- });
- */
-
- /*
- String acceptSearch = "acceptSearch";
- searchField.getInputMap().put(Globals.getKeyPrefs().getKey(KeyBinding.ACCEPT), acceptSearch);
- searchField.getActionMap().put(acceptSearch, new AbstractAction() {
- @Override
- public void actionPerformed(ActionEvent e) {
- autoCompleteSupport.setVisible(false);
- BasePanel currentBasePanel = frame.getCurrentBasePanel();
- Globals.getFocusListener().setFocused(currentBasePanel.getMainTable());
- currentBasePanel.getMainTable().requestFocus();
- }
- });
- */
-
JFXPanel container = new JFXPanel();
DefaultTaskExecutor.runInJavaFXThread(() -> {
container.setScene(new Scene(searchField));
+ container.addKeyListener(new KeyAdapter() {
+
+ @Override
+ public void keyPressed(java.awt.event.KeyEvent e) {
+ //We need to consume this event here to prevent the propgation of keybinding events back to the JFrame
+ Optional keyBinding = Globals.getKeyPrefs().mapToKeyBinding(e);
+ if (keyBinding.isPresent()) {
+ switch (keyBinding.get()) {
+ case CUT:
+ case COPY:
+ case PASTE:
+ case DELETE_ENTRY:
+ case SELECT_ALL:
+ e.consume();
+ break;
+ default:
+ //do nothing
+ }
+ }
+ }
+ });
+
});
setLayout(new FlowLayout(FlowLayout.RIGHT));
@@ -207,7 +231,7 @@ public void actionPerformed(ActionEvent e) {
public void performGlobalSearch() {
BasePanel currentBasePanel = frame.getCurrentBasePanel();
- if (currentBasePanel == null || validateSearchResultFrame(true)) {
+ if ((currentBasePanel == null) || validateSearchResultFrame(true)) {
return;
}
@@ -226,7 +250,7 @@ public void performGlobalSearch() {
private void openLocalFindingsInExternalPanel() {
BasePanel currentBasePanel = frame.getCurrentBasePanel();
- if (currentBasePanel == null || validateSearchResultFrame(false)) {
+ if ((currentBasePanel == null) || validateSearchResultFrame(false)) {
return;
}
@@ -237,7 +261,7 @@ private void openLocalFindingsInExternalPanel() {
SearchResultFrame searchDialog = new SearchResultFrame(currentBasePanel.frame(),
Localization.lang("Search results in library %0 for %1", currentBasePanel.getBibDatabaseContext()
- .getDatabaseFile().map(File::getName).orElse(GUIGlobals.UNTITLED_TITLE),
+ .getDatabaseFile().map(File::getName).orElse(GUIGlobals.UNTITLED_TITLE),
this.getSearchQuery().localize()),
getSearchQuery(), false);
List entries = currentBasePanel.getDatabase().getEntries().stream()
@@ -250,7 +274,7 @@ private void openLocalFindingsInExternalPanel() {
private boolean validateSearchResultFrame(boolean globalSearch) {
if (searchResultFrame != null) {
- if (searchResultFrame.isGlobalSearch() == globalSearch && isStillValidQuery(searchResultFrame.getSearchQuery())) {
+ if ((searchResultFrame.isGlobalSearch() == globalSearch) && isStillValidQuery(searchResultFrame.getSearchQuery())) {
searchResultFrame.focus();
return true;
} else {
@@ -358,6 +382,7 @@ public void setAutoCompleter(AutoCompleteSuggestionProvider searchComple
searchCompleter,
new PersonNameStringConverter(true, true, AutoCompleteFirstNameMode.BOTH),
new AppendPersonNamesStrategy());
+
}
public SearchQueryHighlightObservable getSearchQueryHighlightObservable() {
@@ -384,7 +409,7 @@ public void updateResults(int matched, String description, boolean grammarBasedS
currentResults.setText(Localization.lang("Found %0 results.", String.valueOf(matched)));
searchField.pseudoClassStateChanged(CLASS_RESULTS_FOUND, true);
}
- searchField.setTooltip(new Tooltip(description));
+ DefaultTaskExecutor.runInJavaFXThread(() -> searchField.setTooltip(new Tooltip(description)));
openCurrentResultsInDialog.setEnabled(true);
}