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


Java DragEvent.acceptTransferModes方法代码示例

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


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

示例1: dragOver

import javafx.scene.input.DragEvent; //导入方法依赖的package包/类
/**
 * Handle drag over.
 */
@FXThread
private void dragOver(@NotNull final DragEvent dragEvent) {

    final Dragboard dragboard = dragEvent.getDragboard();
    final List<File> files = unsafeCast(dragboard.getContent(DataFormat.FILES));

    if (files == null || files.size() != 1) {
        return;
    }

    final File file = files.get(0);
    if (!canAccept(file)) return;

    final Set<TransferMode> transferModes = dragboard.getTransferModes();
    final boolean isCopy = transferModes.contains(TransferMode.COPY);

    dragEvent.acceptTransferModes(isCopy ? TransferMode.COPY : TransferMode.MOVE);
    dragEvent.consume();
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:23,代码来源:ResourcePropertyEditorControl.java

示例2: handleDragOverEvent

import javafx.scene.input.DragEvent; //导入方法依赖的package包/类
/**
 * Handle drag over events.
 *
 * @param dragEvent the drag over event.
 */
@FXThread
private void handleDragOverEvent(@NotNull final DragEvent dragEvent) {

    final Dragboard dragboard = dragEvent.getDragboard();
    final List<File> files = unsafeCast(dragboard.getContent(DataFormat.FILES));

    if (files == null || files.size() != 1) {
        return;
    }

    final File file = files.get(0);

    if (!file.getName().endsWith(FileExtensions.JME_MATERIAL)) {
        return;
    }

    final Set<TransferMode> transferModes = dragboard.getTransferModes();
    final boolean isCopy = transferModes.contains(TransferMode.COPY);

    dragEvent.acceptTransferModes(isCopy ? TransferMode.COPY : TransferMode.MOVE);
    dragEvent.consume();
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:28,代码来源:MaterialPropertyControl.java

示例3: mouseDragOver

import javafx.scene.input.DragEvent; //导入方法依赖的package包/类
/**
 * Mouse dragover event.
 * 
 * @param event
 */
private void mouseDragOver (final DragEvent event) {
    if (event.getGestureSource() != contentPane &&
        (event.getDragboard().hasContent(VoogaFileFormat.getInstance()))) {
        VoogaFile content =
                (VoogaFile) event.getDragboard().getContent(VoogaFileFormat.getInstance());
        String color = "";
        if (content.getType() != VoogaFileType.FOLDER) {
            color = designboardProperties.getString("NonVoogaFileColor");
        }
        else {
            color = designboardProperties.getString("VoogaFileColor");
        }
        contentPane.setStyle(String
                .format(designboardProperties.getString("ContentPaneStringStyle"), color));
        event.acceptTransferModes(TransferMode.ANY);
    }
    else if (event.getDragboard().hasString()) {
        event.acceptTransferModes(TransferMode.ANY);
    }

    event.consume();
}
 
开发者ID:sjain28,项目名称:Game-Engine-Vooga,代码行数:28,代码来源:DesignBoard.java

示例4: onDagOver

import javafx.scene.input.DragEvent; //导入方法依赖的package包/类
/*********************************************************/
// 파일 드래그 드롭 처리.

/* (non-Javadoc)
 * @see com.kyj.fx.voeditor.visual.component.text.AbstractDragDropHelper#onDagOver(javafx.scene.input.DragEvent)
 */
@Override
public void onDagOver(DragEvent ev) {
	if (ev.isConsumed())
		return;

	if (ev.getDragboard().hasFiles()) {
		ev.acceptTransferModes(TransferMode.LINK);
		ev.consume();
	}

}
 
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:18,代码来源:DefaultFileDragDropHelper.java

示例5: onDagOver

import javafx.scene.input.DragEvent; //导入方法依赖的package包/类
/*********************************************************/
// 파일 드래그 드롭 처리.

/*
 * (non-Javadoc)
 * 
 * @see com.kyj.fx.voeditor.visual.component.text.AbstractDragDropHelper#
 * onDagOver(javafx.scene.input.DragEvent)
 */
@Override
public void onDagOver(DragEvent ev) {
	if (ev.isConsumed())
		return;

	if (ev.getDragboard().hasFiles()) {
		ev.acceptTransferModes(TransferMode.LINK);
		ev.consume();
	}

}
 
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:21,代码来源:CodeAreaFileDragDropHelper.java

示例6: mouseDragOver

import javafx.scene.input.DragEvent; //导入方法依赖的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

示例7: onDragOver

import javafx.scene.input.DragEvent; //导入方法依赖的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

示例8: handle

import javafx.scene.input.DragEvent; //导入方法依赖的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

示例9: over

import javafx.scene.input.DragEvent; //导入方法依赖的package包/类
private void over (DragEvent event) {
    if (event.getGestureSource() != this &&
        event.getDragboard().hasString()) {
        event.acceptTransferModes(TransferMode.MOVE);
    }

    event.consume();
}
 
开发者ID:tomrom95,项目名称:GameAuthoringEnvironment,代码行数:9,代码来源:WaveDragCell.java

示例10: mouseDragOver

import javafx.scene.input.DragEvent; //导入方法依赖的package包/类
/**
 * On mouse over, this function accepts all file types and changes dropzone
 * icon
 * 
 * @param e
 */
private void mouseDragOver(final DragEvent e) {
	final Dragboard db = e.getDragboard();
	if (db.hasFiles()) {
		e.acceptTransferModes(TransferMode.ANY);
		setContentNode(createPopoverContent(true));
	}
}
 
开发者ID:michaelnetter,项目名称:dracoon-dropzone,代码行数:14,代码来源:DropzonePopOverUI.java

示例11: autoscrollIfNeeded

import javafx.scene.input.DragEvent; //导入方法依赖的package包/类
private void autoscrollIfNeeded(DragEvent evt) {
    evt.acceptTransferModes(TransferMode.ANY);

    if (getBoundsInLocal().getWidth() < 1) {
        if (getBoundsInLocal().getWidth() < 1) {
            stopAutoScrollIfNeeded();
            return;
        }
    }

    double yOffset = 0;

    // y offset

    double delta = evt.getSceneY() - localToScene(0, 0).getY();
    if (delta < proximity) {
        yOffset = -(proximity - delta);
    }

    delta = localToScene(0, 0).getY() + getHeight() - evt.getSceneY();
    if (delta < proximity) {
        yOffset = proximity - delta;
    }

    if (yOffset != 0) {
        autoscroll(yOffset);
    } else {
        stopAutoScrollIfNeeded();
    }
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:31,代码来源:AutoScrollPane.java

示例12: autoscrollIfNeeded

import javafx.scene.input.DragEvent; //导入方法依赖的package包/类
private void autoscrollIfNeeded(DragEvent evt) {
    evt.acceptTransferModes(TransferMode.ANY);

    if (getBoundsInLocal().getWidth() < 1) {
        if (getBoundsInLocal().getWidth() < 1) {
            stopAutoScrollIfNeeded();
            return;
        }
    }

    double yOffset = 0;

    // y offset

    double delta = evt.getSceneY() - localToScene(0, 0).getY();
    double proximity = 20;
    if (delta < proximity) {
        yOffset = -(proximity - delta);
    }

    delta = localToScene(0, 0).getY() + getHeight() - evt.getSceneY();
    if (delta < proximity) {
        yOffset = proximity - delta;
    }

    if (yOffset != 0) {
        autoscroll(yOffset);
    } else {
        stopAutoScrollIfNeeded();
    }
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:32,代码来源:DayViewScrollPane.java

示例13: handleDragOver

import javafx.scene.input.DragEvent; //导入方法依赖的package包/类
@FXML
private void handleDragOver(DragEvent event) {
    // ドラッグボードを取得
    Dragboard board = event.getDragboard();
    if (board.hasFiles()) {  // ドラッグされているのがファイルなら
        // コピーモードを設定(これでマウスカーソルが矢印に+のやつになる)
        event.acceptTransferModes(TransferMode.COPY);
    }
}
 
开发者ID:Khromium,项目名称:MakeSourceList4j,代码行数:10,代码来源:Controller.java

示例14: onDragOverLinkFile

import javafx.scene.input.DragEvent; //导入方法依赖的package包/类
public void onDragOverLinkFile(DragEvent event){
    Dragboard db = event.getDragboard();
    if (db.hasFiles()) {
        event.acceptTransferModes(TransferMode.LINK);
    } else {
        event.consume();
    }
}
 
开发者ID:linchaolong,项目名称:ApkToolPlus,代码行数:9,代码来源:ApkInfoPrinterActivity.java

示例15: dragOver

import javafx.scene.input.DragEvent; //导入方法依赖的package包/类
/**
 * Drag over action
 * 
 * @param event
 */
@FXML
public void dragOver(DragEvent event) {
	Dragboard dragboard = event.getDragboard();
	if(dragboard.hasFiles() && dragboard.getFiles().size() == 1 && 
			dragboard.getFiles().get(0).getName().endsWith(".xml")) {
		event.acceptTransferModes(TransferMode.COPY);
		dropArea.getStyleClass().add("active");
	}
	event.consume();
}
 
开发者ID:ProPra16,项目名称:programmierpraktikum-abschlussprojekt-null,代码行数:16,代码来源:ImportViewController.java


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