當前位置: 首頁>>代碼示例>>Java>>正文


Java Dragboard.hasContent方法代碼示例

本文整理匯總了Java中javafx.scene.input.Dragboard.hasContent方法的典型用法代碼示例。如果您正苦於以下問題:Java Dragboard.hasContent方法的具體用法?Java Dragboard.hasContent怎麽用?Java Dragboard.hasContent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javafx.scene.input.Dragboard的用法示例。


在下文中一共展示了Dragboard.hasContent方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: onDragOver

import javafx.scene.input.Dragboard; //導入方法依賴的package包/類
@Override
protected void onDragOver(DragEvent e) {
    Dragboard db = e.getDragboard();
    if (db.hasContent(DataFormatConstants.COMPONENT_ENTITY)) {
        e.acceptTransferModes(TransferMode.ANY);
    }
    e.consume();
}
 
開發者ID:huliqing,項目名稱:LuoYing,代碼行數:9,代碼來源:JfxSceneEdit.java

示例6: 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

示例7: 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

示例8: acceptableDrop

import javafx.scene.input.Dragboard; //導入方法依賴的package包/類
/**
 * Decides if the content stored in the given {@link Dragboard} can be droped on the given target row.
 * Currently, the following sources are allowed:
 *  - another group (will be added as subgroup on drop)
 *  - entries if the group implements {@link GroupEntryChanger} (will be assigned to group on drop)
 */
public boolean acceptableDrop(Dragboard dragboard) {
    // TODO: we should also check isNodeDescendant
    boolean canDropOtherGroup = dragboard.hasContent(DragAndDropDataFormats.GROUP);
    boolean canDropEntries = dragboard.hasContent(DragAndDropDataFormats.ENTRIES)
            && (groupNode.getGroup() instanceof GroupEntryChanger);
    return canDropOtherGroup || canDropEntries;
}
 
開發者ID:JabRef,項目名稱:jabref,代碼行數:14,代碼來源:GroupNodeViewModel.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: isDraggingTab

import javafx.scene.input.Dragboard; //導入方法依賴的package包/類
/**
 * Returns true if the given dragboard contains the tab that is currently dragged.
 *
 * @param dragboard dragboard
 * @return true if the given dragboard contains the tab that is currently dragged
 */
public static boolean isDraggingTab(Dragboard dragboard) {
	return dragboard.hasContent(dataFormat) && DraggableTab.draggingTab.get() != null;
}
 
開發者ID:xylo,項目名稱:DraggableTabs,代碼行數:10,代碼來源:DraggableTab.java


注:本文中的javafx.scene.input.Dragboard.hasContent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。