mirror of
https://gitlab.com/kauron/jstudy
synced 2024-12-23 00:43:32 +01:00
Added drag'n'drop to main menu
This commit is contained in:
parent
d26978946b
commit
498d2a050a
2 changed files with 21 additions and 1 deletions
|
@ -16,6 +16,8 @@ import javafx.scene.Parent;
|
||||||
import javafx.scene.control.*;
|
import javafx.scene.control.*;
|
||||||
import javafx.scene.image.Image;
|
import javafx.scene.image.Image;
|
||||||
import javafx.scene.image.ImageView;
|
import javafx.scene.image.ImageView;
|
||||||
|
import javafx.scene.input.DragEvent;
|
||||||
|
import javafx.scene.input.TransferMode;
|
||||||
import javafx.scene.layout.BorderPane;
|
import javafx.scene.layout.BorderPane;
|
||||||
import javafx.stage.FileChooser;
|
import javafx.stage.FileChooser;
|
||||||
|
|
||||||
|
@ -205,4 +207,22 @@ public class Controller implements Initializable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
protected void onDragDropped(DragEvent event) {
|
||||||
|
List<File> files = event.getDragboard().getFiles();
|
||||||
|
for (File file : files) {
|
||||||
|
List<TestItem> 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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
<tabs>
|
<tabs>
|
||||||
<Tab closable="false" text="Welcome">
|
<Tab closable="false" text="Welcome">
|
||||||
<content>
|
<content>
|
||||||
<HBox alignment="CENTER" spacing="25.0">
|
<HBox alignment="CENTER" onDragDropped="#onDragDropped" onDragOver="#onDragOver" spacing="25.0">
|
||||||
<children>
|
<children>
|
||||||
<VBox alignment="CENTER" spacing="15.0">
|
<VBox alignment="CENTER" spacing="15.0">
|
||||||
<children>
|
<children>
|
||||||
|
|
Loading…
Reference in a new issue