本文整理汇总了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();
}
示例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();
}
示例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();
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
}
示例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);
}
}
}
示例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();
}
示例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));
}
}
示例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();
}
}
示例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();
}
}
示例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);
}
}
示例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();
}
}
示例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