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


Java Dragboard.getFiles方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: handleDragDrop

import javafx.scene.input.Dragboard; //导入方法依赖的package包/类
private void handleDragDrop(DragEvent event)
{
	Dragboard db = event.getDragboard();
	boolean success = false;

	if ( !db.hasUrl())
	{
		event.setDropCompleted (success);
		event.consume();
		return;
	}
	success = true;
	String filePath = "";
	for (File file : db.getFiles())
	{
		if (file.getPath().isEmpty())
			continue;
		
		filePath = file.getAbsolutePath();

		if (filePath.trim().endsWith (".mp3"))
			this.listener.add (filePath.trim().replace ("%20", " "));
	}
}
 
开发者ID:entitycs,项目名称:AudioVisualizer2.0,代码行数:25,代码来源:TavPlaylistEventHandler.java

示例6: filesDropped

import javafx.scene.input.Dragboard; //导入方法依赖的package包/类
protected void filesDropped(final DragEvent event) {

		Dragboard db = event.getDragboard();
	   
		boolean success = false;
		
		if (db.hasFiles()) {
			success = true;
			List<Path> toAdd = new ArrayList<>();
			for (File file : db.getFiles()) {
				toAdd.add(file.toPath());
				log.debug("File '{}' dropped on Mod Manager.", file.toPath());
			}
			modList.addMods(toAdd);
		}
		
		event.setDropCompleted(success);
		event.consume();
		
		view.hideOverlay();
		
	}
 
开发者ID:KrazyTheFox,项目名称:Starbound-Mod-Manager,代码行数:23,代码来源:MainViewController.java

示例7: onDragDroppedHandleFiles

import javafx.scene.input.Dragboard; //导入方法依赖的package包/类
public void onDragDroppedHandleFiles(DragEvent event){
    Dragboard db = event.getDragboard();
    boolean success = false;
    if (db.hasFiles()) {
        success = true;
        for (File file : db.getFiles()) {
            showManifest(file);
            break;
        }
    }
    event.setDropCompleted(success);
    event.consume();
}
 
开发者ID:linchaolong,项目名称:ApkToolPlus,代码行数:14,代码来源:ApkInfoPrinterActivity.java

示例8: mouseDragDropped

import javafx.scene.input.Dragboard; //导入方法依赖的package包/类
private void mouseDragDropped(final Event e) {
    final Dragboard db = ((DragEvent) e).getDragboard();
    boolean success = false;
    if (db.hasFiles()) {
        success = true;
        final List<File> files = db.getFiles();
        Platform.runLater(new Runnable() {
            @Override
            public void run() {
                ServerFile path = null;

                // get DropPath
                if (actIntersectedNode == listView) {
                    path = selectedDir;
                } else if (actIntersectedNode instanceof TreeCell) {
                    // get path from TreeviewItem
                    TreeCell cell = (TreeCell) actIntersectedNode;
                    ServerFileTreeItem item = (ServerFileTreeItem) cell.getTreeItem();
                    path = item.getServerFile();
                }

                log.debug("Drop {} files to path {}", files.size(), path.getAbsolute());
                startTransfer(path, files);
            }
        });
    }
    ((DragEvent) e).setDropCompleted(success);
    e.consume();
}
 
开发者ID:Longri,项目名称:cachebox3.0,代码行数:30,代码来源:FileBrowserPane.java

示例9: onDragDrop

import javafx.scene.input.Dragboard; //导入方法依赖的package包/类
/**
 * Handles dropping files on the view.
 *
 * @param event
 *            drag event
 */
@FXML
public void onDragDrop(DragEvent event) {
	root.getScene().getWindow().requestFocus();

	Dragboard dragboard = event.getDragboard();
	if (dragboard.hasFiles()) {
		for (File file : dragboard.getFiles()) {
			try {
				FileStruct fileStruct = new FileStruct(file.toPath());
				System.out.println(fileStruct.getValue("path") + " added");
				FXMLLoader loader = new FXMLLoader(
						FileIconViewController.class.getResource("FileIconView.fxml"));
				final Parent view = loader.load();
				FileIconViewController controller = loader.getController();

				controller.setFileStruct(fileStruct);
				controller.setSize(Size.MEDIUM);
				controller.registerAppController(this);

				flowPane.getChildren().add(view);
				contents.put(fileStruct, view);
			} catch (IOException e) {
				logger.error("Unable to load FileIconView.fxml");
			}
		}

	}
}
 
开发者ID:rsanchez-wsu,项目名称:jfiles,代码行数:35,代码来源:ClientAppViewController.java

示例10: installWidgetsFromFiles

import javafx.scene.input.Dragboard; //导入方法依赖的package包/类
/**
 * @param db The {@link Dragboard} containing the dragged data.
 * @param selection_tracker Used to get the grid steps from its model to be
 *            used in offsetting multiple widgets.
 * @param widgets The container of the created widgets.
 * @param updates Updates to perform on widgets
 */
private static void installWidgetsFromFiles (
    final Dragboard db,
    final SelectedWidgetUITracker selection_tracker,
    final List<Widget> widgets,
    final List<Runnable> updates
) {

    final List<File> files = db.getFiles();

    if ( files.size() > 1 && files.stream().allMatch(f -> IMAGE_FILE_EXTENSIONS.contains(getExtension(f.toString()).toUpperCase())) ) {

        final List<String> fileNames = new ArrayList<>(files.size());

        files.stream().forEach(f -> fileNames.add(resolveFile(f, selection_tracker.getModel())));
        installSymbolWidgetFromImageFiles(fileNames, selection_tracker, widgets, updates);

    } else {
        for ( int i = 0; i < files.size(); i++ ) {

            final String fileName = resolveFile(files.get(i), selection_tracker.getModel());
            final String extension = getExtension(fileName).toUpperCase();

            if ( IMAGE_FILE_EXTENSIONS.contains(extension) ) {
                installPictureWidgetFromFile(fileName, selection_tracker, widgets, updates);
            } else if ( EMBEDDED_FILE_EXTENSIONS.contains(extension) ) {
                installEmbeddedDisplayWidgetFromFile(fileName, selection_tracker, widgets, updates);
            }

        }
    }

}
 
开发者ID:kasemir,项目名称:org.csstudio.display.builder,代码行数:40,代码来源:WidgetTransfer.java

示例11: onDragOver

import javafx.scene.input.Dragboard; //导入方法依赖的package包/类
@FXML
public void onDragOver(DragEvent event) {
    Dragboard db = event.getDragboard();
    if (db.hasFiles()) {
        for (File one : db.getFiles()) {
            if (Utilities.suggestFileTypeFromName(one.getName()) != Utilities.FileType.FILETYPE_UNKNOWN) {
                event.acceptTransferModes(TransferMode.COPY);
                break;
            }
        }
    }
    event.consume();
}
 
开发者ID:informationsea,项目名称:excel2csv,代码行数:14,代码来源:MainWindowController.java

示例12: getFilesFromDragboard

import javafx.scene.input.Dragboard; //导入方法依赖的package包/类
private Stream<File> getFilesFromDragboard(Dragboard board) {
    List<File> files = board.getFiles();
    if (files.size() == 1 && files.get(0).isDirectory()) {
        return stream(files.get(0).listFiles()).sorted();
    }
    return files.stream();
}
 
开发者ID:torakiki,项目名称:pdfsam,代码行数:8,代码来源:ModulesDashboardTile.java

示例13: filesDraggedOver

import javafx.scene.input.Dragboard; //导入方法依赖的package包/类
protected void filesDraggedOver(final DragEvent event) {
	
	 Dragboard db = event.getDragboard();
        
        if (db.hasFiles()) {

        	boolean filesAccepted = false;
        	String fileName = "";
        	
			for (File file : db.getFiles()) {
				if (FileHelper.isSupported(Paths.get(file.getPath()), dragOver)) {
					filesAccepted = true;
					fileName += localizer.formatMessage(dragOver, "inquotes", file.getName()) + "\n";
				}
			}
        	
			if (filesAccepted) {
				event.acceptTransferModes(TransferMode.COPY);
				if (!dragOver) {
					view.showOverlay(localizer.formatMessage("mainview.addmods", db.getFiles().size()), fileName);
					dragOver = true;
				}
			} else {
				event.consume();
			}
            
        } else {
            event.consume();
        }
        
}
 
开发者ID:KrazyTheFox,项目名称:Starbound-Mod-Manager,代码行数:32,代码来源:MainViewController.java

示例14: onDragDropped

import javafx.scene.input.Dragboard; //导入方法依赖的package包/类
private void onDragDropped(final TreeTableRow<GPXLineItem> row, final DragEvent event) {
    Dragboard db = event.getDragboard();
    if (db.getContent(SERIALIZED_MIME_TYPE) != null) {
        if (acceptable(db, row)) {
            // get dragged item and item drop on to
            final int draggedIndex = (Integer) db.getContent(SERIALIZED_MIME_TYPE);
            final int targetIndex = row.getIndex();

            final TreeItem<GPXLineItem> draggedItem = myTreeTableView.getTreeItem(draggedIndex);
            final TreeItem<GPXLineItem> targetItem = myTreeTableView.getTreeItem(targetIndex);

            final GPXLineItem draggedLineItem = draggedItem.getValue();
            final GPXLineItem targetLineItem = targetItem.getValue();

            final GPXLineItem.GPXLineItemType draggedType = draggedLineItem.getType();
            final GPXLineItem.GPXLineItemType targetType = targetLineItem.getType();
            
            draggedItem.getParent().getChildren().remove(draggedItem);
            final List<GPXLineItem> draggedList = draggedLineItem.getParent().getChildren();
            draggedList.remove(draggedLineItem);
            draggedLineItem.getParent().setChildren(draggedList);
            
            List<GPXLineItem> targetList;
            if (GPXLineItem.GPXLineItemType.isSameTypeAs(targetType, draggedType)) {
                // index of dropped item under its parent - thats where we want to place the dragged item before
                final int childIndex = targetItem.getParent().getChildren().indexOf(targetItem);
                targetItem.getParent().getChildren().add(childIndex, draggedItem);
                
                // update GPXLineItem as well
                targetList = targetLineItem.getParent().getChildren();
                targetList.add(childIndex, draggedLineItem);
                targetLineItem.getParent().setChildren(targetList);
            } else {
                // droppped on parent type - always add in front
                targetItem.getChildren().add(0, draggedItem);
                
                // update GPXLineItem as well
                targetList = targetLineItem.getChildren();
                targetList.add(0, draggedLineItem);
                targetLineItem.setChildren(targetList);
            }

            event.setDropCompleted(true);
            myTreeTableView.getSelectionModel().clearSelection();
            myTreeTableView.getSelectionModel().select(draggedItem);
            myTreeTableView.refresh();
            event.consume();
        }           
    } else {
        boolean success = false;
        if (db.hasFiles()) {
            success = true;
            final List<File> files = new ArrayList<>();
            for (File file:db.getFiles()) {
                // accept only gpx files
                if (GPXEditorWorker.GPX_EXT.equals(FilenameUtils.getExtension(file.getName()).toLowerCase())) {
                    files.add(file);
                }
            }
            // read and add to list
            myEditor.parseAndAddFiles(files);
        }
        event.setDropCompleted(success);
        event.consume();
    }
}
 
开发者ID:ThomasDaheim,项目名称:GPXEditor,代码行数:67,代码来源:GPXTreeTableView.java


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