private void dragConsume(DragEvent e, Consumer<DragEvent> c) {
   List<File> files = e.getDragboard().getFiles();
   if (files != null && !files.isEmpty()) {
     c.accept(e);
   }
   e.consume();
 }
  @FXML
  void dragDone(DragEvent event) {
    /* the drag-and-drop gesture ended */

    /* if the data was successfully moved, clear it */
    if (event.getTransferMode() == TransferMode.MOVE) {}

    event.consume();
  }
  @FXML
  public void onDragOverFolder(DragEvent event) {
    Dragboard dragboard = event.getDragboard();

    if (dragboard.hasFiles()
        && dragboard.getFiles().size() == 1
        && dragboard.getFiles().get(0).isDirectory()) {
      event.acceptTransferModes(TransferMode.COPY);
    }

    event.consume();
  }
  @FXML
  public void onDragDroppedFile(DragEvent event) {
    Dragboard dragboard = event.getDragboard();

    this.targetFiles = dragboard.getFiles();
    this.targetFilesLabel.setText(this.targetFiles.size() + " 件選択されています");
    this.targetFilesLabel.setDisable(true);
    this.filterTextField.setDisable(false);
    this.filterTextField.requestFocus();

    event.setDropCompleted(true);
    event.consume();
  }
  @FXML
  void dragOver(DragEvent event) {

    /* data is dragged over the target */

    /* accept it only if it is  not dragged from the same node
     * and if it has a string data */
    if (event.getGestureSource() != imageView && event.getDragboard().hasString()) {
      /* allow for both copying and moving, whatever user chooses */
      event.acceptTransferModes(TransferMode.COPY_OR_MOVE);
    }

    event.consume();
  }
  @FXML
  void dragEntered(DragEvent event) {

    /* the drag-and-drop gesture entered the target */

    /* show to the user that it is an actual gesture target */
    if (event.getGestureSource() != imageView && event.getDragboard().hasString()) {
      ColorAdjust colorAdjust = new ColorAdjust();
      colorAdjust.setBrightness(0.5);
      imageView.setEffect(colorAdjust);
    }

    event.consume();
  }
  @FXML
  public void onDragOverFile(DragEvent event) {
    Dragboard dragboard = event.getDragboard();

    if (dragboard.hasFiles()) {
      boolean allFile = dragboard.getFiles().stream().allMatch(File::isFile);

      if (allFile) {
        event.acceptTransferModes(TransferMode.COPY);
      }
    }

    event.consume();
  }
  @FXML
  void dragExited(DragEvent event) {
    /* mouse moved away, remove the graphical cues */
    imageView.setEffect(null);

    event.consume();
  }
  @FXML
  void dragDropped(DragEvent event) {
    /* data dropped */
    /* if there is a string data on dragboard, read it and use it */
    Dragboard db = event.getDragboard();
    boolean success = false;
    if (db.hasUrl()) {
      imageView.setImage(new LocatedImage(db.getUrl()));
      success = true;
    }
    /* let the source know whether the string was successfully
     * transferred and used */
    event.setDropCompleted(success);

    event.consume();
  }
  @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();
  }
  /*
   * Called either when the user clicks the 'paste' button, or when they drop
   * files onto the scene overlay. Supports animating multiple files, or just
   * accepting one file.
   */
  private void checkBoard(Clipboard board, DragEvent de) {
    // clean up from any previous runs
    clear();

    if (board == null) {
      System.out.println("HelloImageClipboard: sorry - null Clipboard");
    }

    if (board.hasImage()) {
      if (de != null) de.acceptTransferModes(TransferMode.ANY);
      imageView.setImage(board.getImage());
      if (de != null) de.setDropCompleted(true);
      System.out.println("HelloImageClipboard: single image");
    } else {
      if (de != null) de.setDropCompleted(false);
      System.out.println("HelloImageClipboard: sorry - no images on the Clipboard");
    }
  }
  @FXML
  public void webViewDragDropped(DragEvent event) {
    Dragboard db = event.getDragboard();
    boolean dropCompleted = false;

    if (db.hasFiles()) {
      File draggedFile = db.getFiles().get(0);

      if (draggedFile.getName().toLowerCase().endsWith(".html")) {
        try {
          URL url = new URL("file", "", draggedFile.getAbsolutePath());
          loadContent(url);
          dropCompleted = true;
        } catch (MalformedURLException ex) {
        }
      }
    }

    event.setDropCompleted(dropCompleted);
  }
 // If time allows. Implement drag and drop support for images.
 @FXML
 private void onImageDraggedDone(DragEvent event) {
   System.out.println("Dragged done: " + event.getEventType());
 }
 @FXML
 public void webViewDragOver(DragEvent event) {
   event.acceptTransferModes(TransferMode.COPY_OR_MOVE);
 }