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

Fix delete entry keybindings bug #2

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ private Optional<KeyBinding> getKeyBinding(String key) {
}

private Optional<KeyBinding> getKeyBinding(KeyBinding key) {
return Arrays.stream(KeyBinding.values()).filter(b -> b.equals(key)).findFirst();
return Arrays.stream(KeyBinding.values()).filter(b -> b.getLocalization().equals(key)).findFirst();
}

public void resetToDefault(String key) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
public class KeyBindingsListener extends KeyAdapter {

private final KeyBindingTable table;
boolean isDeleteKey = false;

public KeyBindingsListener(KeyBindingTable table) {
this.table = table;
}

@Override
public void keyPressed(KeyEvent evt) {
// first check if anything is selected if not the return
// first check if anything is selected if not then return
final int selRow = table.getSelectedRow();
boolean isAnyRowSelected = selRow >= 0;
if (!isAnyRowSelected) {
Expand All @@ -31,13 +32,13 @@ public void keyPressed(KeyEvent evt) {
int kc = evt.getKeyCode();
boolean isFunctionKey = (kc >= KeyEvent.VK_F1) && (kc <= KeyEvent.VK_F12);
boolean isEscapeKey = kc == KeyEvent.VK_ESCAPE;
boolean isDeleteKey = kc == KeyEvent.VK_DELETE;
isDeleteKey = kc == KeyEvent.VK_DELETE;
if (!(isFunctionKey || isEscapeKey || isDeleteKey)) {
return; // need a modifier except for function, escape and delete keys
}
}

final String code = KeyEvent.getKeyText(evt.getKeyCode());
String code = KeyEvent.getKeyText(evt.getKeyCode());
// second key cannot be a modifiers
if ("Tab".equals(code)
|| "Backspace".equals(code)
Expand All @@ -51,6 +52,9 @@ public void keyPressed(KeyEvent evt) {

// COMPUTE new key binding
String newKey;
if (isDeleteKey) {
code = KeyBinding.DELETE_ENTRY.getLocalization();
}
if ("".equals(modifier)) {
newKey = code;
} else {
Expand Down
6 changes: 4 additions & 2 deletions src/test/resources/testbib/testjabref_292.bib
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
% This file was created with JabRef 2.9.2.
% Encoding: UTF8
% Encoding: UTF-8

@String{qwdasd = {asdda}}

@ARTICLE{Aziz2009256-ChannelNeuralRecordingandDeltaCompressionMicrosystemWith3DElectrodesIEEEJOURNALOFSOLID-STATECIRCUITS,
author = {Aziz, Joseph N. Y. and Abdelhalim, Karim and Shulyzki, Ruslana and
Expand Down Expand Up @@ -299,3 +300,4 @@ @siumed.edu
url = {http://dx.doi.org/10.1016/j.jneumeth.2008.01.009}
}

@Comment{jabref-meta: databaseType:bibtex;}