本文整理匯總了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