mirror of
https://gitlab.com/kauron/jstudy
synced 2024-12-22 00:13:33 +01:00
Moved and documented DraggableRowFactory
This commit is contained in:
parent
a0e3a1fb17
commit
7c46dee784
2 changed files with 6 additions and 4 deletions
|
@ -2,6 +2,7 @@ package es.kauron.jstudy.controller;
|
|||
|
||||
import es.kauron.jstudy.model.AppPrefs;
|
||||
import es.kauron.jstudy.model.TestItem;
|
||||
import es.kauron.jstudy.util.DraggableRowFactory;
|
||||
import javafx.beans.binding.Bindings;
|
||||
import javafx.beans.property.*;
|
||||
import javafx.collections.FXCollections;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package es.kauron.jstudy.controller;
|
||||
package es.kauron.jstudy.util;
|
||||
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.scene.control.TableRow;
|
||||
|
@ -11,17 +11,18 @@ import javafx.scene.input.TransferMode;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
class DraggableRowFactory<S> {
|
||||
// Adapted from https://stackoverflow.com/a/52437193
|
||||
public class DraggableRowFactory<S> {
|
||||
private static final DataFormat SERIALIZED_MIME_TYPE = new DataFormat("application/x-java-serialized-object");
|
||||
|
||||
private final ObservableList<S> data;
|
||||
private final List<S> dragging = new ArrayList<>();
|
||||
|
||||
DraggableRowFactory(ObservableList<S> data) {
|
||||
public DraggableRowFactory(ObservableList<S> data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
TableRow<S> generator(TableView<S> table) {
|
||||
public TableRow<S> generator(TableView<S> table) {
|
||||
TableRow<S> row = new TableRow<>();
|
||||
row.setOnDragDetected((event) -> {
|
||||
if (!row.isEmpty() && table.getItems().size() == data.size()) {
|
Loading…
Reference in a new issue