-
Notifications
You must be signed in to change notification settings - Fork 104
Fix drag and drop issues from file tree to scene composer by implementing AssetNameHolder and flavor detection #671
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: neph1 <7988802+neph1@users.noreply.github.com>
…t AssetNameHolder Co-authored-by: neph1 <7988802+neph1@users.noreply.github.com>
neph1
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot this fixes the exception, but there is still a problem no flavors matching
if (flavor instanceof SpatialDataFlavor) {
rootPanel.addModel(assetKey, new Vector2f(dropXLoc, dropYLoc));
} else if (flavor instanceof MaterialDataFlavor) {
rootPanel.applyMaterial(assetKey, new Vector2f(dropXLoc, dropYLoc));
}
Can you find a way to extract what type of asset it is from the available data?
…xtension Co-authored-by: neph1 <7988802+neph1@users.noreply.github.com>
... I've fixed the "no flavors matching" issue by enhancing the SceneViewerDropTargetListener to determine the asset type from the file extension when specific flavors aren't available. The system now extracts the asset name from the AssetNameHolder and determines whether to call addModel() or applyMaterial() based on the file extension (.j3o for models, .j3m for materials). This approach works with any drag source that provides an AssetNameHolder, including the file tree. Fixed in commit b1f7d79. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes drag and drop functionality from the file tree to the scene composer by resolving ClassCastException and "no flavors matching" issues. The fix enables dragging materials and models from the Projects tab to work consistently with the existing asset browser drag and drop behavior.
- Implements
AssetNameHolderinterface inAssetDataNodeto support asset name retrieval - Enhances
SceneViewerDropTargetListenerto handle generic flavors and determine asset types from file extensions - Removes unused
setAssetName()method fromAssetNameHolderinterface
Reviewed Changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| SceneViewerDropTargetListener.java | Enhanced drop handling logic to support file tree drag operations and added file extension-based asset type detection |
| AssetNameHolder.java | Simplified interface by removing unused setAssetName method and updated copyright |
| AssetDataNode.java | Implemented AssetNameHolder interface with getAssetName method to enable drag and drop compatibility |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
jme3-core/src/com/jme3/gde/core/dnd/SceneViewerDropTargetListener.java
Outdated
Show resolved
Hide resolved
jme3-core/src/com/jme3/gde/core/dnd/SceneViewerDropTargetListener.java
Outdated
Show resolved
Hide resolved
…ner.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
I think this is done. Unless someone objects, I'll merge this within a couple of days. |
Dragging materials and models from the file tree to the scene composer was failing with a
ClassCastExceptionand "no flavors matching" issues becauseAssetDataNodedid not implement theAssetNameHolderinterface and the drop target listener couldn't determine asset types from generic flavors.The error occurred in
SceneViewerDropTargetListener.drop()at line 72:When dragging from the file tree, the system creates an
AssetDataNode, but the drop target listener expects all draggable assets to implementAssetNameHolder. Additionally, the listener only handled specific flavors (SpatialDataFlavorandMaterialDataFlavor) but file tree drag operations use generic flavors.Changes:
AssetDataNodeimplement theAssetNameHolderinterfacegetAssetName()method that retrieves the asset name from the underlyingAssetDatalookupsetAssetName()method (no-op implementation as asset names are derived from asset keys)SceneViewerDropTargetListenerto handle generic flavors by determining asset type from file extensionaddModelorapplyMaterial) based on file extension when specific flavors aren't availableThe implementation follows the same pattern as
AssetPreviewWidgetand ensures consistent behavior across all drag and drop sources, whether from the asset browser or file tree.Fixes #668.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.