-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Post change notifications on JavaFX (#4871)
* Post change notifications on JavaFX Fixes #4817. The problem is that changes in other threads produce a "Not on FX application thread" exception. This is fixed by adding a wrapper around the list of entries. The wrapper only posts changes in the correct thread, without making a copy of the underlying list - so performance shouldn't be affected. * fix compile error * fix checkstyle
- Loading branch information
1 parent
504c0d3
commit 793fa88
Showing
5 changed files
with
66 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package org.jabref.gui.util; | ||
|
||
import javafx.application.Platform; | ||
import javafx.collections.ListChangeListener; | ||
import javafx.collections.ObservableList; | ||
import javafx.collections.transformation.TransformationList; | ||
|
||
class UiThreadList<T> extends TransformationList<T, T> { | ||
public UiThreadList(ObservableList<? extends T> source) { | ||
super(source); | ||
} | ||
|
||
@Override | ||
protected void sourceChanged(ListChangeListener.Change<? extends T> change) { | ||
Platform.runLater(() -> fireChange(change)); | ||
} | ||
|
||
@Override | ||
public int getSourceIndex(int index) { | ||
return index; | ||
} | ||
|
||
@Override | ||
public T get(int index) { | ||
return getSource().get(index); | ||
} | ||
|
||
@Override | ||
public int size() { | ||
return getSource().size(); | ||
} | ||
} |