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