From 498d2a050a544b9d122f37a862d2b182a6beb9e9 Mon Sep 17 00:00:00 2001 From: Carlos Galindo Date: Fri, 9 Dec 2016 16:59:53 +0100 Subject: [PATCH] Added drag'n'drop to main menu --- .../kauron/jstudy/controller/Controller.java | 20 +++++++++++++++++++ .../resources/es/kauron/jstudy/view/main.fxml | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/main/java/es/kauron/jstudy/controller/Controller.java b/src/main/java/es/kauron/jstudy/controller/Controller.java index f3b8674..d09b230 100644 --- a/src/main/java/es/kauron/jstudy/controller/Controller.java +++ b/src/main/java/es/kauron/jstudy/controller/Controller.java @@ -16,6 +16,8 @@ import javafx.scene.Parent; import javafx.scene.control.*; import javafx.scene.image.Image; import javafx.scene.image.ImageView; +import javafx.scene.input.DragEvent; +import javafx.scene.input.TransferMode; import javafx.scene.layout.BorderPane; import javafx.stage.FileChooser; @@ -205,4 +207,22 @@ public class Controller implements Initializable { } } } + + @FXML + protected void onDragDropped(DragEvent event) { + List files = event.getDragboard().getFiles(); + for (File file : files) { + List aux = TestItem.loadFrom(file, TestItem.COLONS); + if (aux != null) { + tabPane.getTabs().add(createTableTab(file.getName().substring(0, file.getName().lastIndexOf('.')), aux, file)); + } + } + event.consume(); + } + + @FXML + protected void onDragOver(DragEvent event) { + event.acceptTransferModes(TransferMode.ANY); + event.consume(); + } } diff --git a/src/main/resources/es/kauron/jstudy/view/main.fxml b/src/main/resources/es/kauron/jstudy/view/main.fxml index c862dc4..ecb6349 100644 --- a/src/main/resources/es/kauron/jstudy/view/main.fxml +++ b/src/main/resources/es/kauron/jstudy/view/main.fxml @@ -11,7 +11,7 @@ - +