@FXML public void onDragDroppedFolder(DragEvent event) { Dragboard dragboard = event.getDragboard(); File folder = dragboard.getFiles().get(0); DestinationFolder dest = new DestinationFolder(folder); if (this.repository.existsSameFolder(dest)) { Alert alert = new Alert(AlertType.ERROR); alert.setTitle("エラー"); alert.setHeaderText("既にフォルダが登録されています。"); alert.getDialogPane().setContentText(dest.getDestPath()); alert.show(); } else { TextInputDialog dialog = new TextInputDialog(); dialog.setTitle("フォルダ追加"); dialog.setContentText("フォルダ名"); dialog.setHeaderText(dest.getDestPath()); dialog.getEditor().setText(dest.getName()); dialog.setOnCloseRequest( e -> { TextInputDialog d = (TextInputDialog) e.getTarget(); String result = d.getResult(); if (result != null) { if (result.isEmpty()) { Alert alert = new Alert(AlertType.ERROR); alert.setTitle("エラー"); alert.setHeaderText("フォルダ名に空は指定できません。"); alert.show(); } else { dest.setName(result); this.repository.registerFolder(dest); this.destinationFolders = repository.findAll(); this.refreshDestFolderListView(); } } }); dialog.show(); } event.setDropCompleted(true); event.consume(); }
@Override public void initialize(URL location, ResourceBundle resources) { this.destinationFolders = repository.findAll(); this.refreshDestFolderListView(); this.clear(); }