当前位置: 首页>>代码示例>>Java>>正文


Java Dragboard.hasFiles方法代码示例

本文整理汇总了Java中javafx.scene.input.Dragboard.hasFiles方法的典型用法代码示例。如果您正苦于以下问题:Java Dragboard.hasFiles方法的具体用法?Java Dragboard.hasFiles怎么用?Java Dragboard.hasFiles使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.scene.input.Dragboard的用法示例。


在下文中一共展示了Dragboard.hasFiles方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: mouseDragDropped

import javafx.scene.input.Dragboard; //导入方法依赖的package包/类
/**
 * Handle mouse drop events
 * 
 * @param e
 */
private void mouseDragDropped(final DragEvent e) {
	final Dragboard db = e.getDragboard();
	boolean success = false;

	if (db.hasFiles()) {
		success = true;
		boolean ctrlKeyPressed = popOver.isCtrlKeyPressed();
		boolean altKeyPressed = popOver.isAltKeyPressed();
		
		popOver.notifyDragEventListener(new DropzoneDragEvent(e, ctrlKeyPressed, altKeyPressed));

	}
	e.setDropCompleted(success);
	e.consume();
}
 
开发者ID:michaelnetter,项目名称:dracoon-dropzone,代码行数:21,代码来源:DropzonePopOverUI.java

示例2: handleDropped

import javafx.scene.input.Dragboard; //导入方法依赖的package包/类
@FXML
private void handleDropped(DragEvent event) {
    // ドラッグボードを取得
    Dragboard board = event.getDragboard();
    if (board.hasFiles()) {
        board.getFiles().stream().forEach((f) -> {
            if (f.isDirectory()) {
                List<String> filePathList = new ArrayList<>();
                getFileRecursion(filePathList, f.getAbsolutePath()).stream().filter(s -> isTextFile(s)).collect(Collectors.toList()).forEach(s -> fileList.getItems().add(new Label(s)));
            } else {
                if (isTextFile(f.getAbsolutePath()))
                    fileList.getItems().add(new Label(f.getAbsolutePath()));
            }
        });
        // ドロップ受け入れ
        event.setDropCompleted(true);
    } else {    // ファイル以外なら
        // ドロップ受け入れ拒否
        event.setDropCompleted(false);
    }
}
 
开发者ID:Khromium,项目名称:MakeSourceList4j,代码行数:22,代码来源:Controller.java

示例3: mouseDragOver

import javafx.scene.input.Dragboard; //导入方法依赖的package包/类
@FXML void mouseDragOver(final DragEvent e) {
    final Dragboard db = e.getDragboard();
 
    final boolean isAccepted = db.getFiles().get(0).getName().toLowerCase().endsWith(".log")
            || db.getFiles().get(0).getName().toLowerCase().endsWith(".txt");
 
    if (db.hasFiles()) {
        if (isAccepted) {
            tabpane.setStyle("-fx-border-color: red;"
          + "-fx-border-width: 5;"
          + "-fx-background-color: #C6C6C6;"
          + "-fx-border-style: solid;");//TODO move to css
            e.acceptTransferModes(TransferMode.COPY);
        }
    } else {
        e.consume();
    }
}
 
开发者ID:bkusche,项目名称:bktail2,代码行数:19,代码来源:TabbedMainController.java

示例4: onDragOver

import javafx.scene.input.Dragboard; //导入方法依赖的package包/类
private void onDragOver(final TreeTableRow<GPXLineItem> row, final DragEvent event) {
    Dragboard db = event.getDragboard();
    if (db.getContent(SERIALIZED_MIME_TYPE) != null) {
        if (!row.isEmpty()) {
            event.acceptTransferModes(TransferMode.COPY_OR_MOVE);
            event.consume();
        }
    } else {
        if (db.hasFiles()) {
            for (File file:db.getFiles()) {
                // accept only gpx files
                if (GPXEditorWorker.GPX_EXT.equals(FilenameUtils.getExtension(file.getName()).toLowerCase())) {
                    event.acceptTransferModes(TransferMode.COPY_OR_MOVE);
                    break;
                }
            }
        } else {
            event.consume();
        }
    }
}
 
开发者ID:ThomasDaheim,项目名称:GPXEditor,代码行数:22,代码来源:GPXTreeTableView.java

示例5: songPathDragDropped

import javafx.scene.input.Dragboard; //导入方法依赖的package包/类
@FXML
public void songPathDragDropped(final DragEvent ev) {
	Dragboard db = ev.getDragboard();
	if (db.hasFiles()) {
		for (File f : db.getFiles()) {
			if (f.isDirectory()) {
				boolean unique = true;
				for (String path : bmsroot.getItems()) {
					if (path.equals(f.getPath()) || f.getPath().startsWith(path + File.separatorChar)) {
						unique = false;
						break;
					}
				}
				if (unique) {
					bmsroot.getItems().add(f.getPath());
				}
			}
		}
	}
}
 
开发者ID:exch-bms2,项目名称:beatoraja,代码行数:21,代码来源:PlayConfigurationView.java

示例6: handle

import javafx.scene.input.Dragboard; //导入方法依赖的package包/类
@Override
  public void handle(DragEvent event) {
      Dragboard dragboard = event.getDragboard();
      Object source = event.getSource();
      // Look for the viewer that we dragged on to - may be null, if drag was on
      QuPathViewer viewer = null;
      for (QuPathViewer viewer2 : gui.getViewers()) {
      	if (viewer2.getView() == source) {
      		viewer = viewer2;
      		break;
      	}
      }
      // If only one viewer is available, there is no ambiguity... use it
      if (viewer == null && gui.getViewers().size() == 1)
      	viewer = gui.getViewer();
      
if (dragboard.hasFiles()) {
       logger.debug("Files dragged onto {}", source);
	handleFileDrop(viewer, dragboard.getFiles());
}
event.setDropCompleted(true);
event.consume();
  }
 
开发者ID:qupath,项目名称:qupath,代码行数:24,代码来源:DragDropFileImportListener.java

示例7: handle

import javafx.scene.input.Dragboard; //导入方法依赖的package包/类
@Override
public void handle(DragEvent event) {
  if (event.getEventType() == DragEvent.DRAG_OVER) {
    if (event.getDragboard().hasFiles()) {
      event.acceptTransferModes(TransferMode.COPY);
    }
    event.consume();
  } else if (event.getEventType() == DragEvent.DRAG_DROPPED) {
    boolean isTransferDone = false;
    List<File> files = new ArrayList<>();
    Dragboard dragBoard = event.getDragboard();
    if (dragBoard.hasFiles()) {
      isTransferDone = true;
      files = dragBoard.getFiles();
    }
    event.setDropCompleted(isTransferDone);
    event.consume();
    try {
      this.controller.filesDropped(files);
    } catch (Exception ex) {
      new ExceptionAlert().showAndWait(null, ex);
    }
  }
}
 
开发者ID:adakitesystems,项目名称:DropLauncher,代码行数:25,代码来源:View.java

示例8: CellFactoryCallback

import javafx.scene.input.Dragboard; //导入方法依赖的package包/类
public CellFactoryCallback(ContextMenus callbackContainer)
{
    this.callbackContainer = callbackContainer;

    this.dragOverHandler = event -> {
        Dragboard db = event.getDragboard();
        if (db.hasFiles() && db.getFiles().size() == 1)
        {
            event.acceptTransferModes(TransferMode.COPY);
        }
        else
        {
            event.consume();
        }
    };
}
 
开发者ID:AstromechZA,项目名称:bunkr,代码行数:17,代码来源:CellFactoryCallback.java

示例9: handDragDropped

import javafx.scene.input.Dragboard; //导入方法依赖的package包/类
@FXML
private void handDragDropped(DragEvent event) {
	Dragboard dragboard = event.getDragboard();
	boolean success = false;
	if (dragboard.hasFiles()) {
		for (File file : dragboard.getFiles()) {
			if (file.isFile() && ViFileSupportType.accept(file)) {
				ViFile viFile = new ViFile(file);
				ObservableList<ViFile> viFiles = this.listProperty().get();
				if (!viFiles.contains(viFile)) {
					viFiles.add(viFile);
					success = true;
				}
			}
		}
	}
	event.setDropCompleted(success);
	event.consume();
}
 
开发者ID:daileyet,项目名称:ViMixer,代码行数:20,代码来源:MainFrameController.java

示例10: handleDrop

import javafx.scene.input.Dragboard; //导入方法依赖的package包/类
public static void handleDrop(DragEvent ev, Consumer<File> ifValid, boolean multi) {
	final Dragboard db = ev.getDragboard();
	boolean success = false;

	if (db.hasFiles()) {
		success = true;

		final Stream<File> files = db.getFiles().stream()
			.filter(File::isFile)
			.filter(DropHelper::isExtensionAccepted);
		
		if (multi) {
			files.forEach(ifValid);
		} else {
			files.findFirst().ifPresent(ifValid);
		}
	}

	ev.setDropCompleted(success);
	ev.consume();
}
 
开发者ID:Pyknic,项目名称:SocialPhotoNetworkClient,代码行数:22,代码来源:DropHelper.java

示例11: handleTextAreaOnDragDropped

import javafx.scene.input.Dragboard; //导入方法依赖的package包/类
@FXML
void handleTextAreaOnDragDropped(DragEvent evt) {
    Dragboard dragboard = evt.getDragboard();
    boolean success = false;
    if (dragboard.hasFiles()) {
        if (!_appendAddressesCheckBox.isSelected()
                && !_textArea.getText().isEmpty()) {
            _textArea.clear();
        }
        // add each dropped file's path to text area
        dragboard.getFiles().forEach((file) -> {
            _textArea.appendText(file.getAbsolutePath() + "\n");
        });
        success = true;
    }
    evt.setDropCompleted(success);
    evt.consume();
}
 
开发者ID:turbolocust,项目名称:GZipper,代码行数:19,代码来源:DropViewController.java

示例12: onDragDropped

import javafx.scene.input.Dragboard; //导入方法依赖的package包/类
@FXML
  void onDragDropped(DragEvent event) {
  	Dragboard dragBoard = event.getDragboard();
boolean dragSuccess = false;
if (dragBoard.hasFiles()) {
	dragSuccess = true;
	// get first drag & droped file
	File file = dragBoard.getFiles().get(0);
	if(canProcess(file)) {
		processInputFile(file);
	}
	else {
		updateBottomStatus(STATUS.FILE_NOT_SUPPORTED);
	}
}
  }
 
开发者ID:liudonghua123,项目名称:signapk_fx,代码行数:17,代码来源:MainPaneController.java

示例13: compositeTokenPane_DragDropped

import javafx.scene.input.Dragboard; //导入方法依赖的package包/类
@FXML
void compositeTokenPane_DragDropped(DragEvent event) {
	Dragboard db = event.getDragboard();

	// Strangely, we get an error if we try to paste an image we put in the clipboard ourselves but File works ok?
	// -Dprism.order=sw also fixes it but not sure why...
	// So lets just check for File first...
	if (db.hasFiles()) {
		db.getFiles().forEach(file -> {
			try {
				updateFileNameTextField(FilenameUtils.getBaseName(file.toURI().toURL().toExternalForm()));
				updatePortrait(new Image(file.toURI().toURL().toExternalForm()));
			} catch (Exception e) {
				log.error("Could not load image " + file, e);
			}
		});
		event.setDropCompleted(true);
	} else if (db.hasImage()) {
		updatePortrait(db.getImage());
		event.setDropCompleted(true);
	} else if (db.hasUrl()) {
		updateFileNameTextField(FileSaveUtil.searchURL(db.getUrl()));
		updatePortrait(new Image(db.getUrl()));
		event.setDropCompleted(true);
	}
}
 
开发者ID:RPTools,项目名称:tokentool,代码行数:27,代码来源:TokenTool_Controller.java

示例14: overlayViewFlowPane_DragDropped

import javafx.scene.input.Dragboard; //导入方法依赖的package包/类
@FXML
void overlayViewFlowPane_DragDropped(DragEvent event) {
	Dragboard db = event.getDragboard();
	if (db.hasImage()) {
		try {
			// Prompt for name & return file name
			File newOverlayFile = new File(currentDirectory.getCanonicalPath() + "/somefilename.png");
			ImageIO.write(SwingFXUtils.fromFXImage(db.getImage(), null), "png", newOverlayFile);
		} catch (IOException e) {
			log.error("Error writing new overlay image.", e);
		}

		loadImages(overlayTreeView.getSelectionModel().getSelectedItem());
		event.setDropCompleted(true);
	} else if (db.hasFiles()) {
		db.getFiles().forEach(file -> {
			FileSaveUtil.copyFile(file, currentDirectory);
		});
		loadImages(overlayTreeView.getSelectionModel().getSelectedItem());
		event.setDropCompleted(true);
	} else if (db.hasUrl()) {
		FileSaveUtil.copyFile(new File(db.getUrl()), currentDirectory);
		loadImages(overlayTreeView.getSelectionModel().getSelectedItem());
		event.setDropCompleted(true);
	}
}
 
开发者ID:RPTools,项目名称:tokentool,代码行数:27,代码来源:ManageOverlays_Controller.java

示例15: onDragDropped

import javafx.scene.input.Dragboard; //导入方法依赖的package包/类
@FXML
private void onDragDropped(DragEvent event) {
    if (fieldPassword.getText().isEmpty()) {
        alert("No password entered");
        return;
    }

    Dragboard db = event.getDragboard();
    boolean success = false;
    if (db.hasFiles()) {
        success = true;

        Path file = db.getFiles().get(0).toPath();
        char[] password = fieldPassword.getText().toCharArray();

        // TODO: do this as a task
        if (isDecrypt.isSelected()) {
            decryptAndWrite(file, password);
        } else {
            encryptAndWrite(file, password);
        }
    }
    event.setDropCompleted(success);
    event.consume();
}
 
开发者ID:AlmasB,项目名称:jEncrypt,代码行数:26,代码来源:Controller.java


注:本文中的javafx.scene.input.Dragboard.hasFiles方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。