37 lines
1.0 KiB
Java
37 lines
1.0 KiB
Java
package envoy.client.ui;
|
|
|
|
import javafx.scene.control.ListCell;
|
|
import javafx.scene.control.ListView;
|
|
|
|
/**
|
|
* This is a utility class that provides access to a refreshing mechanism for
|
|
* elements that were added without notifying the underlying {@link ListView}.
|
|
* <p>
|
|
* Project: <strong>envoy-client</strong><br>
|
|
* File: <strong>ListViewRefresh.java</strong><br>
|
|
* Created: <strong>16.07.2020</strong><br>
|
|
*
|
|
* @author Leon Hofmeister
|
|
* @since Envoy Client v0.1-beta
|
|
*/
|
|
public final class ListViewRefresh {
|
|
|
|
private ListViewRefresh() {}
|
|
|
|
/**
|
|
* Deeply refreshes a {@code listview}, meaning it recomputes every single of
|
|
* its {@link ListCell}s.
|
|
* <p>
|
|
* While it does work, it is <b>not the most efficient algorithm</b> possible.
|
|
*
|
|
* @param toRefresh the listView to refresh
|
|
* @param <T> the type of its {@code listcells}
|
|
* @since Envoy Client v0.1-beta
|
|
*/
|
|
public static <T> void deepRefresh(ListView<T> toRefresh) {
|
|
final var items = toRefresh.getItems();
|
|
toRefresh.setItems(null);
|
|
toRefresh.setItems(items);
|
|
}
|
|
}
|