當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。