-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Shared database synchronized by FocusChangedEvent #6771
Conversation
…lled. Focus is changed in EntryEditor. CoarseChangeFilter with no special function -> does not work with shared databases.
* @param event {@link FocusChangedEvent} object | ||
*/ | ||
@Subscribe | ||
public void listen(FocusChangedEvent event) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the problem is that you are listening to an Event from the EventBus which is nowhere fired
|
||
if (fieldChange.getDelta() > 1 || isEditOnNewField) { | ||
if (isEditOnNewField) { | ||
lastFieldChanged = fieldChange.getField(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the eventBus.post method, the eventBus post method is reposinsible for firing the event.
I tried firing the event via the Perhaps the second commit is a bit irritating, it is only uncommenting something in |
It's a bit complicated with all those listenes. jabref/src/main/java/org/jabref/model/database/BibDatabaseContext.java Lines 196 to 202 in 3709924
And the CoraseChangeFilter register itself here: jabref/src/main/java/org/jabref/model/database/event/CoarseChangeFilter.java Lines 19 to 23 in 4b39b78
it registers itselt as a listener on BibDAtabase. jabref/src/main/java/org/jabref/model/database/BibDatabase.java Lines 198 to 206 in 9d17101
So you need to listen for the FocusChangedEvent and relay that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for investigating this issue.
You already made a good analysis of the underlying problem in #6663. Your solution using a new variable tracking the focused field in the BibEntry, has sadly the disadvantage that the data object (the BibEntry) is tightly coupled to the UI state (focused field). That's something we try to avoid as much as possible. So we need to look for a solution that doesn't couple the model and gui. In the end, the problem comes from the fact that this if statement
jabref/src/main/java/org/jabref/model/database/event/CoarseChangeFilter.java
Lines 35 to 38 in 22b1700
if (fieldChange.getDelta() > 1 || isEditOnNewField) { | |
lastFieldChanged = fieldChange.getField(); | |
eventBus.post(event); | |
} |
Can you try to implement something along these lines? That would be great!
Introduced DelayTaskThrottler on CoarseChangeFilter.
Thank you for your help. Finally, I deleted all
I found out that a throttled task will not interrupt any input. That means if a Can you reproduce this problems? In general, it works as intended. Another idea: What about throttling all |
Side note: We have an internal discussion ongoing, why not using JavaFX Observables everywhere - instead of the event bus. Not fully checked all aspects until now. Will (hopefully) be done at JabCon. Do you have a "feeling" on that? |
I have not much experience with JavaFX Observables but it seems like they are directly bound to GUI elements. |
Thanks a lot @m-mauersberger! I've fixed a few very minor things that I noticed and will merge now. Looking forward to your next PR. |
This PR is related to #6663 and partly #4461.
Shared database synchronization event in
DBMSSynchronizer
is triggered by aFocusChangedEvent
. This is added similar toFieldChangedEvent
but has to be initiated fromEntryEditor
(?).I have manually tested the new code - and it does not work. Maybe we can discuss changes through this pull request.
Thank you for your help.