Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 23 additions & 19 deletions src/main/java/org/jabref/gui/groups/GroupTreeView.java
Original file line number Diff line number Diff line change
Expand Up @@ -195,20 +195,21 @@ public void initialize() {

// Drag and drop support
row.setOnDragDetected(event -> {
TreeItem<GroupNodeViewModel> selectedItem = treeTable.getSelectionModel().getSelectedItem();
if ((selectedItem != null) && (selectedItem.getValue() != null)) {
Dragboard dragboard = treeTable.startDragAndDrop(TransferMode.MOVE);

// Display the group when dragging
dragboard.setDragView(row.snapshot(null, null));

// Put the group node as content
ClipboardContent content = new ClipboardContent();
content.put(DragAndDropDataFormats.GROUP, selectedItem.getValue().getPath());
dragboard.setContent(content);

event.consume();
List<String> groupsToMove = new ArrayList<>();
for (TreeItem<GroupNodeViewModel> selectedItem : treeTable.getSelectionModel().getSelectedItems()) {
if ((selectedItem != null) && (selectedItem.getValue() != null)) {
groupsToMove.add(selectedItem.getValue().getPath());
}
}

// Put the group nodes as content
Dragboard dragboard = treeTable.startDragAndDrop(TransferMode.MOVE);
// Display the group when dragging
dragboard.setDragView(row.snapshot(null, null));
ClipboardContent content = new ClipboardContent();
content.put(DragAndDropDataFormats.GROUP, groupsToMove);
dragboard.setContent(content);
event.consume();
});
row.setOnDragOver(event -> {
Dragboard dragboard = event.getDragboard();
Expand Down Expand Up @@ -240,13 +241,16 @@ public void initialize() {
row.setOnDragDropped(event -> {
Dragboard dragboard = event.getDragboard();
boolean success = false;

if (dragboard.hasContent(DragAndDropDataFormats.GROUP)) {
String pathToSource = (String) dragboard.getContent(DragAndDropDataFormats.GROUP);
Optional<GroupNodeViewModel> source = viewModel.rootGroupProperty().get()
.getChildByPath(pathToSource);
if (source.isPresent()) {
source.get().draggedOn(row.getItem(), getDroppingMouseLocation(row, event));
success = true;
List<String> pathToSources = (List<String>) dragboard.getContent(DragAndDropDataFormats.GROUP);
for (String pathToSource : pathToSources) {
Optional<GroupNodeViewModel> source = viewModel.rootGroupProperty().get()
.getChildByPath(pathToSource);
if (source.isPresent()) {
source.get().draggedOn(row.getItem(), getDroppingMouseLocation(row, event));
success = true;
}
}
}

Expand Down