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

Double click on citation should open the LaTeX editor at the respective place #11996

Closed
koppor opened this issue Oct 16, 2024 · 10 comments · Fixed by #12044
Closed

Double click on citation should open the LaTeX editor at the respective place #11996

koppor opened this issue Oct 16, 2024 · 10 comments · Fixed by #12044
Assignees
Labels
📍 Assigned Assigned by assign-issue-action (or manually assigned) FirstTimeCodeContribution Triggers GitHub Greeter Workflow good first issue An issue intended for project-newcomers. Varies in difficulty.

Comments

@koppor
Copy link
Member

koppor commented Oct 16, 2024

We have the push-to-application functionality. We also have the "LaTeX citations" functionality. It would be nice if I as user could navigate to the listed TeX file in the LaTeX editor by a double click.


The resulting code will add a method jumpToLine(Path fileName, int line, int column) to org.jabref.gui.push.PushToApplication.

Add default empty implementation, to avoid compile errors at the beginning.

Hints

  1. Leave out configuration of each tool; reuse org.jabref.gui.push.PushToApplicationPreferences and hard-code the parameters to jump to a line
  2. Implement for TeXstudio. texstudio --line "$lineno" "$file"
  3. The commandPath contains the path tot he executable.
  4. Optionally: implement for more applications (e.g., emacsclient +4:3 FILE)
  5. Optionally: Add VSCode as new push target

Note: The push to applications functionality is described at https://docs.jabref.org/cite/pushtoapplications.


Example:

  1. Open src\test\resources\pdfs\IEEE\ieee-paper.tex
  2. Double click on "Kopp et al."
  3. Select tab "LaTeX ciations" in entry editor
  4. Double click on the first entry in the table:
    Image
  5. See that nothing happens

Instead of 5, TeXstudio should be opened with ieee.tex opened and jumping to line 26.

@koppor koppor added the good first issue An issue intended for project-newcomers. Varies in difficulty. label Oct 16, 2024
@github-project-automation github-project-automation bot moved this to Free to take in Good First Issues Oct 16, 2024
@u7465990
Copy link
Contributor

I’m currently working on a university assignment focused on contributing to open source projects. Could I take this issue? I would be happy to work on it and contribute to the project.

Thank you !

@koppor koppor added FirstTimeCodeContribution Triggers GitHub Greeter Workflow 📍 Assigned Assigned by assign-issue-action (or manually assigned) labels Oct 17, 2024
Copy link
Contributor

Welcome to the vibrant world of open-source development with JabRef!

Newcomers, we're excited to have you on board. Start by exploring our Contributing guidelines, and don't forget to check out our workspace setup guidelines to get started smoothly.

In case you encounter failing tests during development, please check our developer FAQs!

Having any questions or issues? Feel free to ask here on GitHub. Need help setting up your local workspace? Join the conversation on JabRef's Gitter chat. And don't hesitate to open a (draft) pull request early on to show the direction it is heading towards. This way, you will receive valuable feedback.

⚠ Note that this issue will become unassigned if it isn't closed within 30 days.

🔧 A maintainer can also add the Pinned label to prevent it from being unassigned automatically.

Happy coding! 🚀

@u7465990
Copy link
Contributor

Could I know what function is called after clicking the push to external file?
This entry is called LatexCitationsTab. This tab is a java class that us javafx to set the preferences. But I don't what happened after the user double click it. How could I found the tex file path in this latex citations tab ?
I think this issue is about open the external tex editor. This is to run the command. The commandPath is setted in the Preference. The path and the line number is setted in the latex citations.

@koppor
Copy link
Member Author

koppor commented Oct 19, 2024

Could I know what function is called after clicking the push to external file?

What do you mean? The "push to applications" functionality? It is not directly related to this wish - you can only learn how things are implemented for a different use case.

You did not provide any context or test application - thus it makes difficult to point you to concrete classes.

Start reading code at org.jabref.gui.push.AbstractPushToApplication#pushEntries(org.jabref.model.database.BibDatabaseContext, java.util.List<org.jabref.model.entry.BibEntry>, java.lang.String, java.lang.ProcessBuilder). You can use Ctrl+click on a method to see where it is defined or where it is called.

This entry is called LatexCitationsTab. This tab is a java class that us javafx to set the preferences. But I don't what happened after the user double click it.

Curerntly nothing. It is your task to add this functionality. See step 5 in the issue description (the part at "Example:")

How could I found the tex file path in this latex citations tab ?

org.jabref.model.texparser.Citation is the object holding the Path. It is used at org.jabref.gui.texparser.CitationsDisplay. CitationsDisplay displays the citation.

I think this issue is about open the external tex editor.

Not quite. It is to instruct the opened editor to JUMP to a lline.

It seems you never used LaTeX and BibTeX.

Here two slides, maybe, they help to understand the goal:

Image

Image

Imagine now that someone writes a book and has several .tex files. That person uses JabRef for editing the .bib file. Now, they want to have the text edtor jump to the .tex file where the current citation is used.

The commandPath is setted in the Preference.

Retrieve it similarly to preferences.getPushToApplicationPreferences().

The path and the line number is setted in the latex citations.

It is available in org.jabref.model.texparser.Citation.

@u7465990
Copy link
Contributor

Sorry. I didn't provided the example. I read the pushEntry function and try to understand what happened.

I did some test cases. I open the 'ieee-paper.bib' in 'src\test\resources\pdfs\IEEE'. I select the first article and press the push the button 'Push entry to external application'. Then the 'pushEntries' is called and then the command 'texstudio --insert-cite \cite{Alver2007a}' is runned by terminal.

And in this issue, the pushEntries will run 'texstudio --line "$lineno" "$file"' after double clicking the the first entry in the table. But currently after clicking the entry, the pushEntry is not runned. How could I improved it?

@koppor
Copy link
Member Author

koppor commented Oct 19, 2024

And in this issue, the pushEntries will run 'texstudio --line "$lineno" "$file"' after double clicking the the first entry in the table. But currently after clicking the entry, the pushEntry is not runned. How could I improved it?

It is exactly the task of this issue to implement running texstudio --line "$lineno" "$file" on double click of a citation.

@u7465990
Copy link
Contributor

How to catch the doulble click? Should I use the javaFx event listener in the LatexCitationTabs?

@koppor
Copy link
Member Author

koppor commented Oct 19, 2024

How to catch the doulble click? Should I use the javaFx event listener in the LatexCitationTabs?

I do not know. I would need to try out, too.

Searching for "double click" reveals

    private void handleItemMouseClick(LinkedFileViewModel linkedFile, MouseEvent event) {
        if (event.getButton() == MouseButton.PRIMARY && (event.getClickCount() == 2)) {
            // Double click -> open
            linkedFile.open();
        }
    }

You need to handle it in CitationsDisplay. Maybe StackOverflow can help you https://stackoverflow.com/q/9722418/873282 ?

@u7465990
Copy link
Contributor

I found the problem. The 'LatexCitationTab' use 'GidPane' to divided schema. Those citations are actually one list in a 'VBox' of 'GridPane'. I found that list works as a 'ReadOnlyListWrapper' but it should works like the table of entries for articles, do nothing while click once and do some actions while double click. But I didn't found the class of 'DoubleClickOnlyListWrapper'. How should I fix it?

@u7465990
Copy link
Contributor

Thanks for merge my contribution to the main branch.

This was referenced Oct 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📍 Assigned Assigned by assign-issue-action (or manually assigned) FirstTimeCodeContribution Triggers GitHub Greeter Workflow good first issue An issue intended for project-newcomers. Varies in difficulty.
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants