Skip to content

Commit

Permalink
Added preset for new entry keybindings and reintroduced defaults (#7705)
Browse files Browse the repository at this point in the history
  • Loading branch information
calixtus authored May 10, 2021
1 parent edae432 commit 7242baa
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 34 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We added a feature that allows the user to copy highlighted text in the preview window. [#6962](https://github.com/JabRef/jabref/issues/6962)
- We added a feature that allows you to create new BibEntry via paste arxivId [#2292](https://github.com/JabRef/jabref/issues/2292)
- We added a feature that allows the user to choose whether to trust the target site when unable to find a valid certification path from the file download site. [#7616](https://github.com/JabRef/jabref/issues/7616)
- We added a keybinding preset for new entries. [#7705](https://github.com/JabRef/jabref/issues/7705)

### Changed

Expand All @@ -36,6 +37,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- Automatically found pdf files now have the linking button to the far left and uses a link icon with a plus instead of a briefcase. The file name also has lowered opacity(70%) until added. [#3607](https://github.com/JabRef/jabref/issues/3607)
- We simplified the select entry type form by splitting it into two parts ("Recommended" and "Others") based on internal usage data. [#6730](https://github.com/JabRef/jabref/issues/6730)
- The export to MS Office XML now uses the month name for the field `Month` instead of the two digit number [forum#2685](https://discourse.jabref.org/t/export-month-as-text-not-number/2685)
- We reintroduced missing default keybindings for new entries. [#7346](https://github.com/JabRef/jabref/issues/7346) [#7439](https://github.com/JabRef/jabref/issues/7439)
- Lists of available fields are now sorted alphabetically. [#7716](https://github.com/JabRef/jabref/issues/7716)

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/gui/entryeditor/EntryEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ private void setupKeyBindings() {
event.consume();
break;
case CLOSE:
case CLOSE_ENTRY:
case EDIT_ENTRY:
close();
event.consume();
break;
Expand Down
15 changes: 8 additions & 7 deletions src/main/java/org/jabref/gui/keyboard/KeyBinding.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public enum KeyBinding {
CHECK_INTEGRITY("Check integrity", Localization.lang("Check integrity"), "ctrl+F8", KeyBindingCategory.QUALITY),
CLEANUP("Cleanup", Localization.lang("Cleanup entries"), "alt+F8", KeyBindingCategory.QUALITY),
CLOSE_DATABASE("Close library", Localization.lang("Close library"), "ctrl+W", KeyBindingCategory.FILE),
CLOSE_ENTRY("Close entry", Localization.lang("Close entry"), "ctrl+E", KeyBindingCategory.VIEW),
CLOSE("Close dialog", Localization.lang("Close dialog"), "Esc", KeyBindingCategory.VIEW),
COPY("Copy", Localization.lang("Copy"), "ctrl+C", KeyBindingCategory.EDIT),
COPY_TITLE("Copy title", Localization.lang("Copy title"), "ctrl+shift+alt+T", KeyBindingCategory.EDIT),
Expand All @@ -44,7 +43,7 @@ public enum KeyBinding {
DELETE_ENTRY("Delete entry", Localization.lang("Delete entry"), "DELETE", KeyBindingCategory.BIBTEX),
DEFAULT_DIALOG_ACTION("Execute default action in dialog", Localization.lang("Execute default action in dialog"), "ctrl+ENTER", KeyBindingCategory.VIEW),
DOWNLOAD_FULL_TEXT("Download full text documents", Localization.lang("Download full text documents"), "alt+F7", KeyBindingCategory.QUALITY),
EDIT_ENTRY("Edit entry", Localization.lang("Edit entry"), "ctrl+E", KeyBindingCategory.BIBTEX),
EDIT_ENTRY("Open / close entry editor", Localization.lang("Open / close entry editor"), "ctrl+E", KeyBindingCategory.VIEW),
EXPORT("Export", Localization.lang("Export"), "ctrl+alt+e", KeyBindingCategory.FILE),
EXPORT_SELECTED("Export Selected", Localization.lang("Export selected entries"), "ctrl+shift+e", KeyBindingCategory.FILE),
EDIT_STRINGS("Edit strings", Localization.lang("Edit strings"), "ctrl+T", KeyBindingCategory.BIBTEX),
Expand All @@ -61,17 +60,19 @@ public enum KeyBinding {
IMPORT_INTO_CURRENT_DATABASE("Import into current library", Localization.lang("Import into current library"), "ctrl+I", KeyBindingCategory.FILE),
IMPORT_INTO_NEW_DATABASE("Import into new library", Localization.lang("Import into new library"), "ctrl+alt+I", KeyBindingCategory.FILE),
MERGE_ENTRIES("Merge entries", Localization.lang("Merge entries"), "ctrl+M", KeyBindingCategory.TOOLS),

NEW_ARTICLE("New article", Localization.lang("New article"), "ctrl+shift+A", KeyBindingCategory.BIBTEX),
NEW_BOOK("New book", Localization.lang("New book"), "ctrl+shift+B", KeyBindingCategory.BIBTEX),
NEW_ENTRY("New entry", Localization.lang("New entry"), "ctrl+N", KeyBindingCategory.BIBTEX),
NEW_ENTRY_FROM_PLAIN_TEXT("New entry from plain text", Localization.lang("New entry from plain text"), "ctrl+shift+N", KeyBindingCategory.BIBTEX),
NEW_INBOOK("New inbook", Localization.lang("New inbook"), "", KeyBindingCategory.BIBTEX),
NEW_MASTERSTHESIS("New mastersthesis", Localization.lang("New mastersthesis"), "", KeyBindingCategory.BIBTEX),
NEW_PHDTHESIS("New phdthesis", Localization.lang("New phdthesis"), "", KeyBindingCategory.BIBTEX),
NEW_PROCEEDINGS("New proceedings", Localization.lang("New proceedings"), "", KeyBindingCategory.BIBTEX),
NEW_UNPUBLISHED("New unpublished", Localization.lang("New unpublished"), "", KeyBindingCategory.BIBTEX),
NEW_INBOOK("New inbook", Localization.lang("New inbook"), "ctrl+shift+I", KeyBindingCategory.BIBTEX),
NEW_MASTERSTHESIS("New mastersthesis", Localization.lang("New mastersthesis"), "ctrl+shift+M", KeyBindingCategory.BIBTEX),
NEW_PHDTHESIS("New phdthesis", Localization.lang("New phdthesis"), "ctrl+shift+T", KeyBindingCategory.BIBTEX),
NEW_PROCEEDINGS("New proceedings", Localization.lang("New proceedings"), "ctrl+shift+P", KeyBindingCategory.BIBTEX),
NEW_UNPUBLISHED("New unpublished", Localization.lang("New unpublished"), "ctrl+shift+U", KeyBindingCategory.BIBTEX),
NEW_TECHREPORT("New technical report", Localization.lang("New technical report"), "", KeyBindingCategory.BIBTEX),
NEW_INPROCEEDINGS("New inproceesings", Localization.lang("New inproceedings"), "", KeyBindingCategory.BIBTEX),

NEXT_PREVIEW_LAYOUT("Next preview layout", Localization.lang("Next preview layout"), "F9", KeyBindingCategory.VIEW),
NEXT_LIBRARY("Next library", Localization.lang("Next library"), "ctrl+PAGE_DOWN", KeyBindingCategory.VIEW),
OPEN_CONSOLE("Open terminal here", Localization.lang("Open terminal here"), "ctrl+shift+L", KeyBindingCategory.TOOLS),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.jabref.gui.preferences.PreferenceTabViewModel;
import org.jabref.gui.preferences.keybindings.presets.BashKeyBindingPreset;
import org.jabref.gui.preferences.keybindings.presets.KeyBindingPreset;
import org.jabref.gui.preferences.keybindings.presets.NewEntryBindingPreset;
import org.jabref.gui.util.OptionalObjectProperty;
import org.jabref.logic.l10n.Localization;
import org.jabref.preferences.PreferencesService;
Expand All @@ -45,6 +46,7 @@ public KeyBindingsTabViewModel(KeyBindingRepository keyBindingRepository, Dialog
this.preferences = Objects.requireNonNull(preferences);

keyBindingPresets.add(new BashKeyBindingPreset());
keyBindingPresets.add(new NewEntryBindingPreset());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,34 @@

public class BashKeyBindingPreset implements KeyBindingPreset {

private static final Map<KeyBinding, String> KEY_BINDINGS = new HashMap<>();

static {
KEY_BINDINGS.put(KeyBinding.EDITOR_DELETE, "ctrl+D");
// DELETE BACKWARDS = Rubout
KEY_BINDINGS.put(KeyBinding.EDITOR_BACKWARD, "ctrl+B");
KEY_BINDINGS.put(KeyBinding.EDITOR_FORWARD, "ctrl+F");
KEY_BINDINGS.put(KeyBinding.EDITOR_WORD_BACKWARD, "alt+B");
KEY_BINDINGS.put(KeyBinding.EDITOR_WORD_FORWARD, "alt+F");
KEY_BINDINGS.put(KeyBinding.EDITOR_BEGINNING, "ctrl+A");
KEY_BINDINGS.put(KeyBinding.EDITOR_END, "ctrl+E");
KEY_BINDINGS.put(KeyBinding.EDITOR_BEGINNING_DOC, "alt+LESS");
KEY_BINDINGS.put(KeyBinding.EDITOR_END_DOC, "alt+shift+LESS");
KEY_BINDINGS.put(KeyBinding.EDITOR_UP, "ctrl+P");
KEY_BINDINGS.put(KeyBinding.EDITOR_DOWN, "ctrl+N");
KEY_BINDINGS.put(KeyBinding.EDITOR_CAPITALIZE, "alt+C");
KEY_BINDINGS.put(KeyBinding.EDITOR_LOWERCASE, "alt+L");
KEY_BINDINGS.put(KeyBinding.EDITOR_UPPERCASE, "alt+U");
KEY_BINDINGS.put(KeyBinding.EDITOR_KILL_LINE, "ctrl+K");
KEY_BINDINGS.put(KeyBinding.EDITOR_KILL_WORD, "alt+D");
KEY_BINDINGS.put(KeyBinding.EDITOR_KILL_WORD_BACKWARD, "alt+DELETE");
}

@Override
public String getName() {
return "Bash";
}

@Override
public Map<KeyBinding, String> getKeyBindings() {
return KEY_BINDINGS;
final Map<KeyBinding, String> keyBindings = new HashMap<>();

keyBindings.put(KeyBinding.EDITOR_DELETE, "ctrl+D");
// DELETE BACKWARDS = Rubout
keyBindings.put(KeyBinding.EDITOR_BACKWARD, "ctrl+B");
keyBindings.put(KeyBinding.EDITOR_FORWARD, "ctrl+F");
keyBindings.put(KeyBinding.EDITOR_WORD_BACKWARD, "alt+B");
keyBindings.put(KeyBinding.EDITOR_WORD_FORWARD, "alt+F");
keyBindings.put(KeyBinding.EDITOR_BEGINNING, "ctrl+A");
keyBindings.put(KeyBinding.EDITOR_END, "ctrl+E");
keyBindings.put(KeyBinding.EDITOR_BEGINNING_DOC, "alt+LESS");
keyBindings.put(KeyBinding.EDITOR_END_DOC, "alt+shift+LESS");
keyBindings.put(KeyBinding.EDITOR_UP, "ctrl+P");
keyBindings.put(KeyBinding.EDITOR_DOWN, "ctrl+N");
keyBindings.put(KeyBinding.EDITOR_CAPITALIZE, "alt+C");
keyBindings.put(KeyBinding.EDITOR_LOWERCASE, "alt+L");
keyBindings.put(KeyBinding.EDITOR_UPPERCASE, "alt+U");
keyBindings.put(KeyBinding.EDITOR_KILL_LINE, "ctrl+K");
keyBindings.put(KeyBinding.EDITOR_KILL_WORD, "alt+D");
keyBindings.put(KeyBinding.EDITOR_KILL_WORD_BACKWARD, "alt+DELETE");

return keyBindings;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package org.jabref.gui.preferences.keybindings.presets;

import java.util.HashMap;
import java.util.Map;

import org.jabref.gui.keyboard.KeyBinding;
import org.jabref.logic.l10n.Localization;

public class NewEntryBindingPreset implements KeyBindingPreset {

@Override
public String getName() {
return Localization.lang("New entry by type");
}

@Override
public Map<KeyBinding, String> getKeyBindings() {
final Map<KeyBinding, String> keyBindings = new HashMap<>();

// Clear conflicting default presets
keyBindings.put(KeyBinding.PULL_CHANGES_FROM_SHARED_DATABASE, "");
keyBindings.put(KeyBinding.COPY_PREVIEW, "");

// Add new entry presets
keyBindings.put(KeyBinding.NEW_ARTICLE, "ctrl+shift+A");
keyBindings.put(KeyBinding.NEW_BOOK, "ctrl+shift+B");
keyBindings.put(KeyBinding.NEW_ENTRY, "ctrl+N");
keyBindings.put(KeyBinding.NEW_ENTRY_FROM_PLAIN_TEXT, "ctrl+shift+N");
keyBindings.put(KeyBinding.NEW_INBOOK, "ctrl+shift+I");
keyBindings.put(KeyBinding.NEW_INPROCEEDINGS, "ctrl+shift+C");
keyBindings.put(KeyBinding.NEW_MASTERSTHESIS, "ctrl+shift+M");
keyBindings.put(KeyBinding.NEW_PHDTHESIS, "ctrl+shift+T");
keyBindings.put(KeyBinding.NEW_PROCEEDINGS, "ctrl+shift+P");
keyBindings.put(KeyBinding.NEW_TECHREPORT, "ctrl+shift+R");
keyBindings.put(KeyBinding.NEW_UNPUBLISHED, "ctrl+shift+U");

return keyBindings;
}
}
4 changes: 2 additions & 2 deletions src/main/resources/l10n/JabRef_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ Clear=Clear

Clear\ fields=Clear fields

Close\ entry=Close entry
Open\ /\ close\ entry\ editor=Open / close entry editor

Close\ dialog=Close dialog

Expand Down Expand Up @@ -269,7 +269,6 @@ Each\ line\ must\ be\ of\ the\ following\ form\:\ \'tab\:field1;field2;...;field

Edit=Edit

Edit\ entry=Edit entry
Edit\ file\ type=Edit file type

Edit\ group=Edit group
Expand Down Expand Up @@ -2300,3 +2299,4 @@ Download\ operation\ canceled.=Download operation canceled.
Convert\ timestamp\ field\ to\ field\ 'creationdate'=Convert timestamp field to field 'creationdate'
Convert\ timestamp\ field\ to\ field\ 'modificationdate'=Convert timestamp field to field 'modificationdate'
New\ entry\ by\ type=New entry by type

0 comments on commit 7242baa

Please sign in to comment.