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

11802: add new KeyBinding for bibliographic data shortcut #11842

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

HeroxHeruxum
Copy link

@HeroxHeruxum HeroxHeruxum commented Sep 27, 2024

Fixes #11802
Resolves https://discourse.jabref.org/t/shortcuts-for-get-bibliographic-data-from-doi-and-look-up-doi/4468
Resolves https://discourse.jabref.org/t/how-to-assign-a-keyboard-shortcut-to-search-document-identifier-online-doi/5244

Mandatory checks

  • Change in CHANGELOG.md described in a way that is understandable for the average user (if applicable)
  • Tests created for changes (if applicable)
  • Manually tested changed features in running JabRef (always required)
  • Screenshots added in PR description (for UI changes)
  • Checked developer's documentation: Is the information available and up to date? If not, I outlined it in this pull request.
  • Checked documentation: Is the information available and up to date? If not, I created an issue at https://github.com/JabRef/user-documentation/issues or, even better, I submitted a pull request to the documentation repository.

@HeroxHeruxum
Copy link
Author

NO real changes made yet, just a hull for now, to see if my config works

@ThiloteE
Copy link
Member

To ease organizational workflows I have linked the pull-request to the issue with syntax as described in https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue

Linking a pull request to an issue using a keyword

You can link a pull request to an issue by using a supported keyword in the pull request's description or in a commit message. The pull request must be on the default branch.

  • close
  • closes
  • closed
  • fix
  • fixes
  • fixed
  • resolve
  • resolves
  • resolved

If you use a keyword to reference a pull request comment in another pull request, the pull requests will be linked. Merging the referencing pull request also closes the referenced pull request.

The syntax for closing keywords depends on whether the issue is in the same repository as the pull request.

Example:

  • Fix #xyz links pull-request to issue. Merging the PR will close the Issue.
  • Fix https://github.com/JabRef/jabref/issues/xyz links pull-request to issue. Merging the PR will close the Issue.
  • Fix https://github.com/Koppor/jabref/issues/xyz links pull-request to issue. Merging the PR will close the Issue.
  • Fix [#xyz](https://github.com/JabRef/jabref/issues/xyz) links pull-request to issue. Merging the PR will NOT close the Issue.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Your code currently does not meet JabRef's code guidelines.
We use Checkstyle to identify issues.
The tool reviewdog already placed comments on GitHub to indicate the places. See the tab "Files" in you PR.
Please carefully follow the setup guide for the codestyle.
Afterwards, please run checkstyle locally and fix the issues.

You can check review dog's comments at the tab "Files changed" of your pull request.

@HeroxHeruxum
Copy link
Author

I added a standard action and copied the initKeybindings method (kinda) from JabRefFrame.java into IdentifierEditor.java,
as a sort of first try.
I tried working with org.jabref.gui.actions.ActionFactory#configureIconButton , but it did not seem to actually listen to me key Inputs.

The issue with the current state is, that eventhough it works, you would need to focus the editor. In my oppinion, an open General-Tab should suffice.

Is there a way how i can implement that with initKeybindings? Or is org.jabref.gui.actions.ActionFactory#configureIconButton the only correct way.
If so could someone give me an ellaborate explanation on how to properly use it? I couldnt find any in https://devdocs.jabref.org/

Comment on lines +35 to +53
@FXML
private BaseIdentifierEditorViewModel<?> viewModel;
@FXML
private EditorTextArea textArea;
@FXML
private Button fetchInformationByIdentifierButton;
@FXML
private Button lookupIdentifierButton;

@Inject
private DialogService dialogService;
@Inject
private TaskExecutor taskExecutor;
@Inject
private GuiPreferences preferences;
@Inject
private UndoManager undoManager;
@Inject
private StateManager stateManager;
Copy link
Member

Choose a reason for hiding this comment

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

Please do not reformat the code. All JabRef code should be consistently formatted. Check our guidelines for setting up a workspace. With that configuration, this should not happen.

Comment on lines +103 to +108
addEventFilter(KeyEvent.KEY_PRESSED, event -> {
Optional<KeyBinding> keyBinding = preferences.getKeyBindingRepository().mapToKeyBinding(event);
if (keyBinding.isPresent() && keyBinding.get() == KeyBinding.GET_BIBLIOGRAPHIC_DATA) {
this.fetchInformationByIdentifier();
}
});
Copy link
Member

Choose a reason for hiding this comment

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

This feels wrong. All other keybindings work differently. You already correctly added it into KeyBinding. - And you say, you need this peace of code here to get if fully working?

Copy link
Author

Choose a reason for hiding this comment

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

@koppor Just because I couldnt get it to work with org.jabref.gui.actions.ActionFactory#configureIconButton (locally).
And debugging it, didnt help either, i tried to understand it by using org.jabref.gui.groups.GroupDialogView#GroupDialogView (it configures a HelpAction) as a reference.
But also this doesnt seem to work for me locally.

When i have following modal open:
grafik

and press F1, nothing happens.

Then i stumpled upon org.jabref.gui.frame.JabRefFrame#initKeyBindings
which was the only occurence where I could observe a keybinding to be actually caught.

And then I copied that code and at least i now i have the wanted behavior.

Copy link
Member

Choose a reason for hiding this comment

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

It sounds like the keyevent is consumed before reaching the Dialog... Maybe you can try to follow the keyevent?

Copy link
Author

@HeroxHeruxum HeroxHeruxum Oct 8, 2024

Choose a reason for hiding this comment

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

The event doesnt Seem to be Consumed.
I also debugged a bit further, it seems like this issue affects all Buttons that are in some sort of a dialog.
Buttons that did not work:
autosaveLocalLibrariesHelp in org.jabref.gui.preferences.general.GeneralTab
remoteHelp in org.jabref.gui.preferences.general.GeneralTab

But there are also buttons that work that way, like:
generateCitationKeyButton in org.jabref.gui.fieldeditors.CitationKeyEditor

I Suspect that it matters where The Button is mounted.

But this for sure seems like a bug (in JabRef) to me, could some try to reproduced it to verify?

Copy link
Member

Choose a reason for hiding this comment

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

I have a mac and there the KeyEvent is always going through the top menu, so F1 always triggers the "online help" menu item and thus opens the default help page.
So I cannot help here

Copy link
Author

Choose a reason for hiding this comment

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

I'll reset the branch and, try again.

Copy link
Member

Choose a reason for hiding this comment

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

The only hint I currently have is that one should try with a minimal JavaFX app. Maybe https://github.com/Siedlerchr/javafxreproducer?

Comment on lines -74 to +84
.root(this)
.load();
.root(this)
.load();
Copy link
Member

Choose a reason for hiding this comment

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

Please no code reformatting

Comment on lines +66 to +67


Copy link
Member

Choose a reason for hiding this comment

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

No double empty lines.

@@ -113,7 +113,7 @@ public enum StandardActions implements Action {
ABBREVIATE_DOTLESS(Localization.lang("dotless"), Localization.lang("Abbreviate journal names of the selected entries (DOTLESS abbreviation)")),
ABBREVIATE_SHORTEST_UNIQUE(Localization.lang("shortest unique"), Localization.lang("Abbreviate journal names of the selected entries (SHORTEST UNIQUE abbreviation)")),
UNABBREVIATE(Localization.lang("Unabbreviate journal names"), Localization.lang("Unabbreviate journal names of the selected entries"), KeyBinding.UNABBREVIATE),

GET_BIBLIOGRAPHIC_DATA(Localization.lang("Get bibliographic data"), IconTheme.JabRefIcons.SEARCH,KeyBinding.GET_BIBLIOGRAPHIC_DATA),
Copy link
Member

Choose a reason for hiding this comment

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

Please fix checkstyle: space messing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add keyboard shortcuts for "Get bibliographic data from DOI" and "Look up DOI"
5 participants