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

Corrected shortcut #6960

Merged
merged 10 commits into from
Oct 18, 2020
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,16 @@ inserting new citations in a OpenOffic/LibreOffice document. [#6957](https://git
- We fixed the failure to Copy citation key and link. [#5835](https://github.com/JabRef/jabref/issues/5835)
- We fixed an issue where the sort order of the entry table was reset after a restart of JabRef. [#6898](https://github.com/JabRef/jabref/pull/6898)
- We fixed an issue where no longer a warning was displayed when inserting references into LibreOffice with an invalid "ReferenceParagraphFormat". [#6907](https://github.com/JabRef/jabref/pull/60907).
- We fixed an issue where a selected field was not removed after the first click in the custom entry types dialog [#6934](https://github.com/JabRef/jabref/issues/6934)
- We fixed an issue where a remove icon was shown for standard entry types in the custom entry types dialog [6906](https://github.com/JabRef/jabref/issues/6906)
- We fixed an issue, when pulling changes from shared database via shortcut caused creation a new new tech report [6867](https://github.com/JabRef/jabref/issues/6867)
calixtus marked this conversation as resolved.
Show resolved Hide resolved
- We fixed an issue where a selected field was not removed after the first click in the custom entry types dialog. [#6934](https://github.com/JabRef/jabref/issues/6934)
- We fixed an issue where a remove icon was shown for standard entry types in the custom entry types dialog. [#6906](https://github.com/JabRef/jabref/issues/6906)
- We fixed an issue where it was impossible to connect to OpenOffice/LibreOffice on Mac OSX. [#6970](https://github.com/JabRef/jabref/pull/6970)
- We fixed an issue with the python script used by browser plugins that failed to locate JabRef if not installed in its default location. [#6963](https://github.com/JabRef/jabref/pull/6963/files)
- We fixed an issue where identity column header had incorrect foreground color in the Dark theme. [#6796](https://github.com/JabRef/jabref/issues/6796)
- We fixed an issue where clicking on Collapse All button in the Search for Unlinked Local Files expanded the directory structure erroneously [#6848](https://github.com/JabRef/jabref/issues/6848)

- We fixed an issue, when pulling changes from shared database via shortcut caused creation a new new tech report [6867](https://github.com/JabRef/jabref/issues/6867)
### Removed

## [5.1] – 2020-08-30
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/org/jabref/gui/JabRefFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,9 @@ private void initKeyBindings() {
case NEW_UNPUBLISHED:
new NewEntryAction(this, StandardEntryType.Unpublished, dialogService, prefs, stateManager).execute();
break;
case NEW_INPROCEEDINGS:
new NewEntryAction(this, StandardEntryType.InProceedings, dialogService, prefs, stateManager).execute();
break;
case PASTE:
if (OS.OS_X) { // Workaround for a jdk issue that executes paste twice when using cmd+v in a TextField
// Extra workaround for CodeArea, which does not inherit from TextInputControl
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/gui/actions/JabRefAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public JabRefAction(Action action, KeyBindingRepository keyBindingRepository) {
action.getIcon()
.ifPresent(icon -> setGraphic(icon.getGraphicNode()));
action.getKeyBinding()
.ifPresent(keyBinding -> setAccelerator(keyBindingRepository.getKeyCombination(keyBinding)));
.ifPresent(keyBinding -> keyBindingRepository.getKeyCombination(keyBinding).ifPresent(combination -> setAccelerator(combination)));

setLongText(action.getDescription());
}
Expand Down
13 changes: 7 additions & 6 deletions src/main/java/org/jabref/gui/keyboard/KeyBinding.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,13 @@ public enum KeyBinding {
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"), "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"), "ctrl+shift+R", 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_TECHREPORT("New technical report", Localization.lang("New technical report"), "", KeyBindingCategory.BIBTEX),
NEW_INPROCEEDINGS("New inproceesings", Localization.lang("New inproceedings"), "", KeyBindingCategory.BIBTEX),
calixtus marked this conversation as resolved.
Show resolved Hide resolved
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
17 changes: 11 additions & 6 deletions src/main/java/org/jabref/gui/keyboard/KeyBindingRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,21 +112,23 @@ public int size() {
}

public Optional<KeyBinding> mapToKeyBinding(KeyEvent keyEvent) {
for (KeyBinding binding : KeyBinding.values()) {
for (KeyBinding binding : KeyBinding.values()){
calixtus marked this conversation as resolved.
Show resolved Hide resolved
if (checkKeyCombinationEquality(binding, keyEvent)) {
return Optional.of(binding);
}
}
return Optional.empty();
}

public KeyCombination getKeyCombination(KeyBinding bindName) {
public Optional<KeyCombination> getKeyCombination(KeyBinding bindName) {
String binding = get(bindName.getConstant());
if (binding.isEmpty()){
return Optional.empty();
}
if (OS.OS_X) {
binding = binding.replace("ctrl", "meta");
}

return KeyCombination.valueOf(binding);
return Optional.of(KeyCombination.valueOf(binding));
}

/**
Expand All @@ -137,8 +139,11 @@ public KeyCombination getKeyCombination(KeyBinding bindName) {
* @return true if matching, else false
*/
public boolean checkKeyCombinationEquality(KeyBinding binding, KeyEvent keyEvent) {
KeyCombination keyCombination = getKeyCombination(binding);
return checkKeyCombinationEquality(keyCombination, keyEvent);
Optional<KeyCombination> keyCombination = getKeyCombination(binding);
if (!keyCombination.isPresent()){
calixtus marked this conversation as resolved.
Show resolved Hide resolved
return false;
}
return checkKeyCombinationEquality(keyCombination.get(), keyEvent);
}

public List<String> getBindNames() {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/jabref/gui/preview/PreviewPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,15 @@ private void createKeyBindings() {

private ContextMenu createPopupMenu() {
MenuItem copyPreview = new MenuItem(Localization.lang("Copy preview"), IconTheme.JabRefIcons.COPY.getGraphicNode());
copyPreview.setAccelerator(keyBindingRepository.getKeyCombination(KeyBinding.COPY_PREVIEW));
keyBindingRepository.getKeyCombination(KeyBinding.COPY_PREVIEW).ifPresent(keyCombination -> copyPreview.setAccelerator(keyCombination));
copyPreview.setOnAction(event -> previewView.copyPreviewToClipBoard());
MenuItem printEntryPreview = new MenuItem(Localization.lang("Print entry preview"), IconTheme.JabRefIcons.PRINTED.getGraphicNode());
printEntryPreview.setOnAction(event -> previewView.print());
MenuItem previousPreviewLayout = new MenuItem(Localization.lang("Previous preview layout"));
previousPreviewLayout.setAccelerator(keyBindingRepository.getKeyCombination(KeyBinding.PREVIOUS_PREVIEW_LAYOUT));
keyBindingRepository.getKeyCombination(KeyBinding.PREVIOUS_PREVIEW_LAYOUT).ifPresent(keyCombination -> previousPreviewLayout.setAccelerator(keyCombination));
previousPreviewLayout.setOnAction(event -> this.previousPreviewStyle());
MenuItem nextPreviewLayout = new MenuItem(Localization.lang("Next preview layout"));
nextPreviewLayout.setAccelerator(keyBindingRepository.getKeyCombination(KeyBinding.NEXT_PREVIEW_LAYOUT));
keyBindingRepository.getKeyCombination(KeyBinding.NEXT_PREVIEW_LAYOUT).ifPresent(keyCombination -> nextPreviewLayout.setAccelerator(keyCombination));
nextPreviewLayout.setOnAction(event -> this.nextPreviewStyle());

ContextMenu menu = new ContextMenu();
Expand Down