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

Added preset for new entry keybindings and reintroduced defaults #7705

Merged
merged 16 commits into from
May 10, 2021
Merged
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)

### 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),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these defaults really necessary? They were removed in a recent PR on purpose (because they are not often used). Users can still set keybindings themselves, right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Carl and me discussed this in length yesterday, too.

I like convention over configuration. If I start a tool, I want to have it behaving "well". It should require configuration only for certain special cases.

In the concrete case, the key bindings are NOT used for some other cases (except the pull from shared database). Thus, I have a strong vote to add the non-conflicting key bindings back as default.

The other option is that I write a lengthy manual on key bindings and explain each (power) user why they have to configure key bindings. - IMHO JabRef should not require much documentation. Only for the hard cases.

See also #7439 and #7346. Thus, there are multiple users used to the key bindings.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are too many entry types, especially if you use biblatex, to have keybindings for all types. Thus you need to make a cutoff somewhere, and in my opinion it should be sufficient to have bindings for the 5 most commonly used types. This would also be consistent with the "new entry" dialog where the following types are treated specially:

public static final List<BibEntryType> RECOMMENDED = Arrays.asList(ARTICLE, BOOK, INPROCEEDINGS, REPORT, MISC);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "most commonly used types" are for me the ones where keybindings existed for more than a decade. IMHO there is no need to remove functionality in this case.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From this perspective, we shouldn't have changed the new entry dialog as well...

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,38 @@
package org.jabref.gui.preferences.keybindings.presets;

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

import org.jabref.gui.keyboard.KeyBinding;

public class NewEntryBindingPreset implements KeyBindingPreset {

@Override
public String getName() {
return "New Entries";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find "new entries" a bit confusing, maybe something longer that better explains the purpose? Should be localized as well.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make a suggestion. We did not come up with something better yet.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New Entry types ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like "Bindings for creating all entry types"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remember this is just shown in the small menubutton below the the keybindings table
image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A long text would just repeat information the user already has and would be imho extremely annoying.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I couldn't find a nice formulation that doesn't include "Bindings". But with "New entries" or "New entry types" it's really not clear what this is doing.

}

@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;
}
}
3 changes: 1 addition & 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