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


Java TransferMode类代码示例

本文整理汇总了Java中javafx.scene.input.TransferMode的典型用法代码示例。如果您正苦于以下问题:Java TransferMode类的具体用法?Java TransferMode怎么用?Java TransferMode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: setOnDragDetected

import javafx.scene.input.TransferMode; //导入依赖的package包/类
/**
 * When the dragging is detected, we place the content of the LabelCell
 * in the DragBoard.
 */
void setOnDragDetected() {
    setOnDragDetected(event -> {

        boolean isParentTask = getTreeItem().getParent().equals(root);

        boolean isEmpty = getTreeItem().getValue().getText().equals("");

        if (!isEmpty && isParentTask) {
            Dragboard db = startDragAndDrop(TransferMode.MOVE);
            ClipboardContent content = new ClipboardContent();
            content.put(controller.DATA_FORMAT, getTreeItem()
                    .getValue());
            db.setContent(content);
        }
        event.consume();
    });
}
 
开发者ID:deltadak,项目名称:plep,代码行数:22,代码来源:CustomTreeCell.java

示例2: getTransferModes

import javafx.scene.input.TransferMode; //导入依赖的package包/类
Set<TransferMode> getTransferModes(int bits) {
    Set<TransferMode> set = new HashSet<>();
    if ((bits & DND.DROP_COPY) != 0) {
      set.add(TransferMode.COPY);
    }
    if ((bits & DND.DROP_MOVE) != 0) {
      set.add(TransferMode.MOVE);
    }
    if ((bits & DND.DROP_TARGET_MOVE) != 0) {
      set.add(TransferMode.MOVE);
    }
    if ((bits & DND.DROP_LINK) != 0) {
      set.add(TransferMode.LINK);
    }
    return set;
}
 
开发者ID:TRUEJASONFANS,项目名称:JavaFX-FrameRateMeter,代码行数:17,代码来源:OldFXCanvas.java

示例3: initialize

import javafx.scene.input.TransferMode; //导入依赖的package包/类
@FXML
private void initialize() throws IOException {
  root.getChildren().addListener((ListChangeListener<? super Node>) change -> {
    while (change.next()) {
      for (Node node : change.getAddedSubList()) {
        if (node instanceof WidgetGallery.WidgetGalleryItem) {
          WidgetGallery.WidgetGalleryItem galleryItem = (WidgetGallery.WidgetGalleryItem) node;
          galleryItem.setOnDragDetected(event -> {
            Dragboard dragboard = galleryItem.startDragAndDrop(TransferMode.COPY);

            // TODO type safety
            ClipboardContent clipboard = new ClipboardContent();
            clipboard.put(DataFormats.widgetType, galleryItem.getWidget().getName());
            dragboard.setContent(clipboard);
            event.consume();
          });
        }
      }
    }
  });
}
 
开发者ID:wpilibsuite,项目名称:shuffleboard,代码行数:22,代码来源:WidgetGalleryController.java

示例4: makeLetterDraggable

import javafx.scene.input.TransferMode; //导入依赖的package包/类
/**
 * Adds to the letter the possibility to be dragged on another element.
 *
 * @param letterElement The element to be dragged
 * @param letter        The corresponding letter object
 */
public static void makeLetterDraggable(Node letterElement, LetterInterface letter) {
    // When an user starts to drag a letter
    letterElement.setOnDragDetected(event -> {
        Dragboard dragboard = letterElement.startDragAndDrop(TransferMode.ANY);
        dragboard.setDragView(letterElement.snapshot(null, null));
        letterElement.setVisible(false);

        ClipboardContent clipboardContent = new ClipboardContent();
        clipboardContent.put(LetterInterface.DATA_FORMAT, letter);

        dragboard.setContent(clipboardContent);

        event.consume();
    });

    // When the user has dropped the letter
    letterElement.setOnDragDone(event -> letterElement.setVisible(true));
}
 
开发者ID:Chrisp1tv,项目名称:ScrabbleGame,代码行数:25,代码来源:DraggableLetterManager.java

示例5: decorate

import javafx.scene.input.TransferMode; //导入依赖的package包/类
public Pane decorate(Pane pane) {
    pane.setOnDragOver(evt -> {
        if (evt.getGestureSource() != pane &&
                evt.getDragboard().hasString()) {
            evt.acceptTransferModes(TransferMode.ANY);
        }
        evt.consume();
    });

    pane.setOnDragDropped(evt -> {
        Dragboard db = evt.getDragboard();
        boolean success = false;
        if (db.hasString()) {
            // Create a button and add to pane
            if (!locked) {
                addButton(db.getString(), pane, evt.getScreenX(), evt.getScreenY());
            }
            success = true;
        }
        // Let the source know whether the string was dropped successfully
        evt.setDropCompleted(success);
        evt.consume();
    });

    return pane;
}
 
开发者ID:mbari-media-management,项目名称:vars-annotation,代码行数:27,代码来源:DragPaneDecorator.java

示例6: dragOver

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

示例7: handleDragOverEvent

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

示例8: mouseDragOver

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

示例9: initializeSetOnDragDetected

import javafx.scene.input.TransferMode; //导入依赖的package包/类
private void initializeSetOnDragDetected() {
//        LoggerFacade.INSTANCE.debug(this.getClass(), "Initialize setOnDragDetected"); // NOI18N
        
        super.setOnDragDetected(event -> {
            if (super.getItem() == null) {
                return;
            }

            final Dragboard dragboard = startDragAndDrop(TransferMode.MOVE);
            final ClipboardContent content = new ClipboardContent();
            content.putString(String.valueOf(super.getItem().getProjectId()));
//            dragboard.setDragView(
//                    birdImages.get(
//                            items.indexOf(
//                                    getItem()
//                            )
//                    )
//            );
            dragboard.setContent(content);
            event.consume();
        });
    }
 
开发者ID:Naoghuman,项目名称:Incubator,代码行数:23,代码来源:ProjectItemCell.java

示例10: onDagOver

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

示例11: treeProjectFileOnDragDetected

import javafx.scene.input.TransferMode; //导入依赖的package包/类
/**
 * 트리 드래그 디텍트 이벤트 처리. <br/>
 * 트리내에 구성된 파일의 위치정보를 드래그 드롭 기능으로 <br/>
 * 전달해주는 역할을 수행한다.<br/>
 * <br/>
 * 
 * @작성자 : KYJ
 * @작성일 : 2017. 11. 21.
 * @param ev
 */
public void treeProjectFileOnDragDetected(MouseEvent ev) {
	TreeItem<JavaProjectFileWrapper> selectedItem = treeProjectFile.getSelectionModel().getSelectedItem();
	if (selectedItem == null || selectedItem.getValue() == null) {
		return;
	}

	File file = selectedItem.getValue().getFile();
	if (file == null || !file.exists())
		return;

	Dragboard board = treeProjectFile.startDragAndDrop(TransferMode.LINK);
	ClipboardContent content = new ClipboardContent();
	content.putFiles(Arrays.asList(file));
	board.setContent(content);

	ev.consume();
}
 
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:28,代码来源:SystemLayoutViewController.java

示例12: onDagOver

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

示例13: handle

import javafx.scene.input.TransferMode; //导入依赖的package包/类
@Override
public void handle(final MouseEvent event) {
    final Pane pane = (Pane) event.getSource();
    final ImageView view = (ImageView) pane.getChildren().get(0);
    final Dragboard db = view.startDragAndDrop(TransferMode.COPY);
    final ClipboardContent content = new ClipboardContent();
    content.putString(view.getId());
    final ComponentPane componentPane = loadComponent(pane.getChildren().get(0).getId().toLowerCase());
    workspace.getChildren().add(componentPane);
    componentPane.applyCss();
    final WritableImage w  = componentPane.snapshot(null,null);
    workspace.getChildren().remove(componentPane);
    content.putImage(w);
    db.setContent(content);
    event.consume();
}
 
开发者ID:StephaneMangin,项目名称:Synth,代码行数:17,代码来源:CoreController.java

示例14: createTMSelect

import javafx.scene.input.TransferMode; //导入依赖的package包/类
private Node createTMSelect(final Set<TransferMode> tms) {
    VBox box = new VBox();

    for (final TransferMode tm : TransferMode.values()) {
        CheckBox cb = new CheckBox(tm.toString());
        cb.selectedProperty().addListener(new ChangeListener<Boolean>() {
            @Override
            public void changed(ObservableValue<? extends Boolean> ov, Boolean t, Boolean t1) {
                if (t1) {
                    tms.add(tm);
                } else {
                    tms.remove(tm);
                }
            }
        });
        if (tm == TransferMode.COPY) {
            cb.selectedProperty().set(true);
        }
        box.getChildren().add(cb);
    }

    return box;
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:24,代码来源:DragDropWithControls.java

示例15: mouseDragOver

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


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