Skip to content

Commit

Permalink
Prepare File Dropping
Browse files Browse the repository at this point in the history
  • Loading branch information
Siedlerchr committed Feb 23, 2018
1 parent cc2c1d2 commit 9eee5ae
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/main/java/org/jabref/gui/maintable/MainTable.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.jabref.gui.maintable;

import java.awt.Color;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
Expand All @@ -18,6 +19,7 @@
import javafx.scene.control.TableRow;
import javafx.scene.control.TableView;
import javafx.scene.input.ClipboardContent;
import javafx.scene.input.DataFormat;
import javafx.scene.input.DragEvent;
import javafx.scene.input.Dragboard;
import javafx.scene.input.KeyEvent;
Expand Down Expand Up @@ -277,6 +279,15 @@ public void paste() {
}
}

private void handleOnDragOver(BibEntryTableViewModel originalItem, DragEvent event) {
if ((event.getGestureSource() != originalItem) && LocalDragboard.INSTANCE.hasType(DragAndDropDataFormats.BIBENTRY_LIST_CLASS)) {
event.acceptTransferModes(TransferMode.MOVE);
}
if (event.getDragboard().hasFiles()) {
event.acceptTransferModes(TransferMode.COPY, TransferMode.LINK);
}
}

private void handleOnDragEntered(TableRow<BibEntryTableViewModel> row, BibEntryTableViewModel entry, MouseDragEvent event) {
// Support the following gesture to select entries: click on one row -> hold mouse button -> move over other rows
// We need to select all items between the starting row and the row where the user currently hovers the mouse over
Expand Down Expand Up @@ -312,18 +323,17 @@ private void handleOnDragDropped(BibEntryTableViewModel originalItem, DragEvent
List<BibEntry> parsedEntries = LocalDragboard.INSTANCE.getValue(DragAndDropDataFormats.BIBENTRY_LIST_CLASS);
success = true;
}
if (event.getDragboard().hasContent(DataFormat.FILES)) {


List<File> files = event.getDragboard().getFiles();
System.out.println(files);
}
event.setDropCompleted(success);
event.consume();

}

private void handleOnDragOver(BibEntryTableViewModel originalItem, DragEvent event) {
if ((event.getGestureSource() != originalItem) && LocalDragboard.INSTANCE.hasType(DragAndDropDataFormats.BIBENTRY_LIST_CLASS)) {
event.acceptTransferModes(TransferMode.MOVE);
}
}


public void addSelectionListener(ListChangeListener<? super BibEntryTableViewModel> listener) {
getSelectionModel().getSelectedItems().addListener(listener);
Expand Down

0 comments on commit 9eee5ae

Please sign in to comment.