JabRef / jabref

Graphical Java application for managing BibTeX and biblatex (.bib) databases
https://devdocs.jabref.org
MIT License
3.59k stars 2.52k forks source link

Context menu of linked file not updated after downloading #5777

Closed tobiasdiez closed 3 years ago

tobiasdiez commented 4 years ago
JabRef version on

Steps to reproduce the behavior:

  1. Add online link to a pdf to some entry
  2. Right-click pdf > Download
  3. Wait until downloaded.
  4. Right-click pdf again. Most of the options are still grayed-out, probably because JabRef still thinks that this is an online pdf and not a local pdf.

Relevant code: context menu: https://github.com/JabRef/jabref/blob/fc4201d6dffe16d2d3a820bd1200c4256c9c3e02/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditor.java#L215-L267 download: https://github.com/JabRef/jabref/blob/fc4201d6dffe16d2d3a820bd1200c4256c9c3e02/src/main/java/org/jabref/gui/fieldeditors/LinkedFileViewModel.java#L407-L410

Log File ``` Paste an excerpt of your log file here ```
kevone123 commented 4 years ago

Mac OS X 10.14.4 Java 13.0.1

I can’t recreate this bug.

1) I clicked general and added the link http://www.africau.edu/images/default/sample.pdf to URL 2) Then I right-clicked “Open URL or DOI”(I did this because Open File was grayed-out despite adding the URL 3) I downloaded the pdf but Open File was still grayed - out.

Screen Shot 2019-12-31 at 12 24 04 AM

Then I tried to download from URL. I didn't get the same grayed out the issue.

Screen Shot 2019-12-31 at 12 26 52 AM

What am I missing to recreate this bug?

tobiasdiez commented 4 years ago

@kevone123 Thanks for your interest! The entry context menu of the main table is working fine, but the context menu of the file is the problem (right click on "PDF" in your last screenshot). Sorry for being imprecise.

kevone123 commented 4 years ago

@tobiasdiez I'm still unable to recreate this bug.

1) Added the link to an entry

Screen Shot 2020-01-06 at 1 04 42 PM

2) Downloaded the pdf

Screen Shot 2020-01-06 at 12 49 20 PM

3) When I right-clicked the pdf it isn't grayed out.

Screen Shot 2020-01-06 at 12 50 53 PM

However it is greyed out when I clicked the empty grayed line after it.

Screen Shot 2020-01-06 at 12 51 09 PM

Thank you for your response.

tobiasdiez commented 4 years ago

This is very strange. For me, the context menu looks like the one on your last screenshot. Only after I switch between entries, the context menu is updated correctly.

Xuanxuan-Zou commented 4 years ago

Hi, we are a team of 5 students, and we are interested in working on this issue.

Firstly, we had reproduced this bug. Thanks for your tips, we understand the reason. In our opinion, we find that only after downloading completed, LinkedFile object’s link attributes will update, and content menu will consequently update, making some options not grayed out.

We guess that it can’t immediately update for it not renews content menu, and can only reinitialize after switch between entries.

We consider whether it is possible to renew the content menu immediately after downloading complete, that is after onSuccess function. But we are a little confused about the onSuccess function, it seems like a blocking, which can make the program continue to do other things. And we have no ideas on where to add operation after this function. Therefore, we are stucking at this.

We would sincerely appreciate it if you could give us some hints or suggestions.

https://github.com/JabRef/jabref/blob/7cb7ea60324932723db22fcd1964e26f73f7d9b4/src/main/java/org/jabref/gui/fieldeditors/LinkedFileViewModel.java#L415-L420

tobiasdiez commented 4 years ago

Thanks for your interest!

Updating the context menu manually would be one option. However, the "proper" JavaFX way would be to listen to the changes in the linked files. However, this automatic update should work in principle - but it doesn't for some reason. I would start investigating this issue by debugging how often/ when https://github.com/JabRef/jabref/blob/7cb7ea60324932723db22fcd1964e26f73f7d9b4/src/main/java/org/jabref/gui/fieldeditors/LinkedFilesEditor.java#L217 is called. Then go up the chain and check when these methods are called: https://github.com/JabRef/jabref/blob/7cb7ea60324932723db22fcd1964e26f73f7d9b4/src/main/java/org/jabref/gui/util/ViewModelListCellFactory.java#L190 https://github.com/JabRef/jabref/blob/7cb7ea60324932723db22fcd1964e26f73f7d9b4/src/main/java/org/jabref/gui/util/ViewModelListCellFactory.java#L161

Xuanxuan-Zou commented 4 years ago

Many thanks for your guidance, we understand this issue better.

After re-syncing today, we find this bug seems to be solved due to issue # 6381. After downloading completed, the context menu will update immediately. And a new entry will be added but not overwrite. Sorry for not syncing this project in time.

Please point out if there is any misunderstanding. Thanks a lot!

Siedlerchr commented 4 years ago

I think @btut still noticed some issues in his comment https://github.com/JabRef/jabref/pull/6381#discussion_r420556932 Maybe you can work together on the remaining issues?

Xuanxuan-Zou commented 4 years ago

We will try to work on the remaining issues. Thanks.

btut commented 4 years ago

I'd be happy to! The issue that I am having is that it would be nice to somehow let the user know that the file is still being downloaded. Otherwise people may wonder why the file entry is missing while actually the file is not downloaded yet. @Xuanxuan-Zou feel free to join the discussion in #6381

calixtus commented 4 years ago

I noticed that the ContextMenu for the FileEditor is not using the factory methods, we normally use for JabRef menus. Take a look at gui/maintable/RightClickMenu.java for an example. Maybe this is worth some programming time. 😉

Xuanxuan-Zou commented 4 years ago

Thanks for your reminder!We will try to. 😃

github-actions[bot] commented 3 years ago

This issue has been inactive for half a year. Since JabRef is constantly evolving this issue may not be relevant any longer and it will be closed in two weeks if no further activity occurs.

As part of an effort to ensure that the JabRef team is focusing on important and valid issues, we would like to ask if you could update the issue if it still persists. This could be in the following form:

Thank you for your contribution!