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


Java Dragboard.getContent方法代码示例

本文整理汇总了Java中javafx.scene.input.Dragboard.getContent方法的典型用法代码示例。如果您正苦于以下问题:Java Dragboard.getContent方法的具体用法?Java Dragboard.getContent怎么用?Java Dragboard.getContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javafx.scene.input.Dragboard的用法示例。


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

示例1: handleRowDragDropped

import javafx.scene.input.Dragboard; //导入方法依赖的package包/类
protected void handleRowDragDropped(TreeTableRow<T> r, DragEvent ev)
{
	Dragboard db = ev.getDragboard();
	if(isAcceptable(db, r))
	{
		int ix = (Integer)db.getContent(JAVA_DATA_FORMAT);
		TreeItem item = tree.getTreeItem(ix);
		item.getParent().getChildren().remove(item);
		getTarget(r).getChildren().add(item);
		ev.setDropCompleted(true);
		
		tree.getSelectionModel().clearSelection();
		tree.getSelectionModel().select(item);
		// FIX focus and selection differ after this
		
		ev.consume();
	}
}
 
开发者ID:andy-goryachev,项目名称:ReqTraq,代码行数:19,代码来源:TreeTableHandler.java

示例2: onDragOver

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

示例3: acceptable

import javafx.scene.input.Dragboard; //导入方法依赖的package包/类
private boolean acceptable(final Dragboard db, final TreeTableRow<GPXLineItem> row) {
    boolean result = false;
    if (db.hasContent(SERIALIZED_MIME_TYPE)) {
        final int index = (Integer) db.getContent(SERIALIZED_MIME_TYPE);
        //System.out.println("index: " + index + ", row index:" + row.getIndex());
        if (!row.isEmpty() && (row.getIndex() != index)) {
            final TreeItem<GPXLineItem> target = row.getTreeItem();
            final GPXLineItem.GPXLineItemType targetType = target.getValue().getType();
            
            final TreeItem<GPXLineItem> item = myTreeTableView.getTreeItem(index);
            final GPXLineItem.GPXLineItemType itemType = item.getValue().getType();
            
            // don't create loops and only insert on same level or drop on direct parent type
            result = !isParent(item, target) && 
                    (GPXLineItem.GPXLineItemType.isSameTypeAs(targetType, itemType) || GPXLineItem.GPXLineItemType.isParentTypeOf(targetType, itemType));
        }
    }
    return result;
}
 
开发者ID:ThomasDaheim,项目名称:GPXEditor,代码行数:20,代码来源:GPXTreeTableView.java

示例4: onDragDropped

import javafx.scene.input.Dragboard; //导入方法依赖的package包/类
@Override
protected void onDragDropped(DragEvent e) {
    Dragboard db = e.getDragboard();
    if (db.hasContent(DataFormatConstants.COMPONENT_ENTITY)) {
        ComponentDefine c = (ComponentDefine) db.getContent(DataFormatConstants.COMPONENT_ENTITY);
        e.setDropCompleted(true);
        e.consume();

        // 当拖动物体到3D场景的时候必须把JFX中的鼠标坐标转到到JME中的坐标.
        // 不能直接用jme场景中获取鼠标坐标的方式,因为JME是放在awt canvas上的,这时还未获得焦点,直接用
        // JME中的方式获取鼠标坐标会错位。
        lastDragXPos = e.getX();
        lastDragYPos = e.getY();

        // 必须隔一帧,即等拖放操作完成执行后再弹窗.
        // 这里不能直接执行CustomDialog,因为当CustomDialog为模态时会锁住窗口,这会导致当第二次拖放操作时发生:
        // Exception in thread "JavaFX Application Thread" java.lang.IllegalArgumentException: 
        // Key already associated with a running event loop: [email protected]
        Jfx.runOnJfx(() -> {
            ComponentManager.createComponent(c, this);
        });
    }
}
 
开发者ID:huliqing,项目名称:LuoYing,代码行数:24,代码来源:JfxSceneEdit.java

示例5: mouseDragDropped

import javafx.scene.input.Dragboard; //导入方法依赖的package包/类
private void mouseDragDropped (final DragEvent event) {
    Dragboard db = event.getDragboard();
    boolean success = false;
    if (db.hasContent(VoogaFileFormat.getInstance())) {
        VoogaFile node = (VoogaFile) db.getContent(VoogaFileFormat.getInstance());
        if (node.getType() != VoogaFileType.FOLDER) {
            if (node.getType() != VoogaFileType.ARCHETYPE &&
                node.getType() != VoogaFileType.GAME_OBJECT) {
                if (elementManager.hasElement(node.getPath())) {
                    moveElement(node.getPath(), event);
                }
                else {
                    addElement(node, event, "");
                }
            }
            else {
                if (node.getType() == VoogaFileType.ARCHETYPE) {
                    addElement(node, event, node.toString());
                }
            }
        }
        success = true;
    }

    if (db.hasString()) {
        Node object = (Node) elementManager.getElement(db.getString());
        object.setTranslateX(event.getX() - x_offset);
        object.setTranslateY(event.getY() - y_offset);
    }

    event.setDropCompleted(success);
}
 
开发者ID:sjain28,项目名称:Game-Engine-Vooga,代码行数:33,代码来源:DesignBoard.java

示例6: isAcceptable

import javafx.scene.input.Dragboard; //导入方法依赖的package包/类
protected boolean isAcceptable(Dragboard db, TreeTableRow<T> row)
{
	if(db.hasContent(JAVA_DATA_FORMAT))
	{
		int index = (Integer)db.getContent(JAVA_DATA_FORMAT);
		if(row.getIndex() != index)
		{
			TreeItem target = getTarget(row);
			TreeItem item = tree.getTreeItem(index);
			return !isParent(item, target);
		}
	}
	return false;
}
 
开发者ID:andy-goryachev,项目名称:ReqTraq,代码行数:15,代码来源:TreeTableHandler.java

示例7: dragDropped

import javafx.scene.input.Dragboard; //导入方法依赖的package包/类
@Override
public void dragDropped(DragEvent event, TreeTableRow row) {
    Dragboard dragboard = event.getDragboard();
    if (dragboard.hasContent(SERIALIZED_MIME_TYPE)) {
        int draggedIndex = (Integer) dragboard.getContent(SERIALIZED_MIME_TYPE);
        controller.getCommandExecutor().execute(new DragNDropResourceCommand(controller.getProject(), row, draggedIndex));
        event.setDropCompleted(true);
        row.getTreeTableView().getSelectionModel().select(row.getIndex());
        event.consume();
    }
}
 
开发者ID:khasang,项目名称:Cachoeira,代码行数:12,代码来源:ResourceTableDragAndDrop.java

示例8: dragDropped

import javafx.scene.input.Dragboard; //导入方法依赖的package包/类
@Override
public void dragDropped(DragEvent event, TreeTableRow row) {
    Dragboard db = event.getDragboard();
    if (db.hasContent(SERIALIZED_MIME_TYPE)) {
        int draggedIndex = (Integer) db.getContent(SERIALIZED_MIME_TYPE);
        controller.getCommandExecutor().execute(new DragNDropTaskCommand(controller.getProject(), row, draggedIndex));
        event.setDropCompleted(true);
        row.getTreeTableView().getSelectionModel().select(row.getIndex());
        event.consume();
    }
}
 
开发者ID:khasang,项目名称:Cachoeira,代码行数:12,代码来源:TaskTableDragAndDrop.java

示例9: handleOnDragDropped

import javafx.scene.input.Dragboard; //导入方法依赖的package包/类
private void handleOnDragDropped(LinkedFileViewModel originalItem, DragEvent event) {
    Dragboard dragboard = event.getDragboard();
    boolean success = false;

    ObservableList<LinkedFileViewModel> items = listView.itemsProperty().get();

    if (dragboard.hasContent(DragAndDropDataFormats.LINKED_FILE)) {

        LinkedFile linkedFile = (LinkedFile) dragboard.getContent(DragAndDropDataFormats.LINKED_FILE);
        LinkedFileViewModel transferedItem = null;
        int draggedIdx = 0;
        for (int i = 0; i < items.size(); i++) {
            if (items.get(i).getFile().equals(linkedFile)) {
                draggedIdx = i;
                transferedItem = items.get(i);
                break;
            }
        }
        int thisIdx = items.indexOf(originalItem);
        items.set(draggedIdx, originalItem);
        items.set(thisIdx, transferedItem);
        success = true;
    }
    if (dragboard.hasFiles()) {
        List<LinkedFileViewModel> linkedFiles = dragboard.getFiles().stream().map(File::toPath).map(viewModel::fromFile).collect(Collectors.toList());
        items.addAll(linkedFiles);
    }
    event.setDropCompleted(success);
    event.consume();

}
 
开发者ID:JabRef,项目名称:jabref,代码行数:32,代码来源:LinkedFilesEditor.java

示例10: onDragDropped

import javafx.scene.input.Dragboard; //导入方法依赖的package包/类
private void onDragDropped(final TreeTableRow<GPXLineItem> row, final DragEvent event) {
    Dragboard db = event.getDragboard();
    if (db.getContent(SERIALIZED_MIME_TYPE) != null) {
        if (acceptable(db, row)) {
            // get dragged item and item drop on to
            final int draggedIndex = (Integer) db.getContent(SERIALIZED_MIME_TYPE);
            final int targetIndex = row.getIndex();

            final TreeItem<GPXLineItem> draggedItem = myTreeTableView.getTreeItem(draggedIndex);
            final TreeItem<GPXLineItem> targetItem = myTreeTableView.getTreeItem(targetIndex);

            final GPXLineItem draggedLineItem = draggedItem.getValue();
            final GPXLineItem targetLineItem = targetItem.getValue();

            final GPXLineItem.GPXLineItemType draggedType = draggedLineItem.getType();
            final GPXLineItem.GPXLineItemType targetType = targetLineItem.getType();
            
            draggedItem.getParent().getChildren().remove(draggedItem);
            final List<GPXLineItem> draggedList = draggedLineItem.getParent().getChildren();
            draggedList.remove(draggedLineItem);
            draggedLineItem.getParent().setChildren(draggedList);
            
            List<GPXLineItem> targetList;
            if (GPXLineItem.GPXLineItemType.isSameTypeAs(targetType, draggedType)) {
                // index of dropped item under its parent - thats where we want to place the dragged item before
                final int childIndex = targetItem.getParent().getChildren().indexOf(targetItem);
                targetItem.getParent().getChildren().add(childIndex, draggedItem);
                
                // update GPXLineItem as well
                targetList = targetLineItem.getParent().getChildren();
                targetList.add(childIndex, draggedLineItem);
                targetLineItem.getParent().setChildren(targetList);
            } else {
                // droppped on parent type - always add in front
                targetItem.getChildren().add(0, draggedItem);
                
                // update GPXLineItem as well
                targetList = targetLineItem.getChildren();
                targetList.add(0, draggedLineItem);
                targetLineItem.setChildren(targetList);
            }

            event.setDropCompleted(true);
            myTreeTableView.getSelectionModel().clearSelection();
            myTreeTableView.getSelectionModel().select(draggedItem);
            myTreeTableView.refresh();
            event.consume();
        }           
    } else {
        boolean success = false;
        if (db.hasFiles()) {
            success = true;
            final List<File> files = new ArrayList<>();
            for (File file:db.getFiles()) {
                // accept only gpx files
                if (GPXEditorWorker.GPX_EXT.equals(FilenameUtils.getExtension(file.getName()).toLowerCase())) {
                    files.add(file);
                }
            }
            // read and add to list
            myEditor.parseAndAddFiles(files);
        }
        event.setDropCompleted(success);
        event.consume();
    }
}
 
开发者ID:ThomasDaheim,项目名称:GPXEditor,代码行数:67,代码来源:GPXTreeTableView.java


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