-
Notifications
You must be signed in to change notification settings - Fork 273
fix(amazonq): render drag&drop overlay and fix the issue that images … #5905
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c57cb79
fix(amazonq): render drag&drop overlay and fix the issue that images …
yzhangok 0c89d77
fix(amazonq): add changelog
yzhangok fcb6a53
Merge branch 'main' into overlay
yzhangok 755d540
Merge branch 'main' into overlay
yzhangok de82c94
Merge branch 'main' into overlay
yzhangok 7bd3254
fix(amazonq): comments
yzhangok 7f57335
Merge branch 'main' into overlay
manodnyab b53623b
Merge branch 'main' into overlay
samgst-amazon 9a0ae8c
Merge branch 'main' into overlay
samgst-amazon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
.changes/next-release/bugfix-bf74f9c0-2d61-420d-854d-a5b0daa5861a.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"type" : "bugfix", | ||
"description" : "Fix the issue that sometime image added via drag & drop are incorrectly routing to pinned contexts and drag overlay is not rendered" | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,7 +49,9 @@ import software.aws.toolkits.jetbrains.services.codemodernizer.utils.isCodeTrans | |
import software.aws.toolkits.resources.message | ||
import java.awt.datatransfer.DataFlavor | ||
import java.awt.dnd.DropTarget | ||
import java.awt.dnd.DropTargetDragEvent | ||
import java.awt.dnd.DropTargetDropEvent | ||
import java.awt.dnd.DropTargetEvent | ||
import java.io.File | ||
import java.util.concurrent.CompletableFuture | ||
import javax.imageio.ImageIO.read | ||
|
@@ -138,6 +140,39 @@ class AmazonQPanel(val project: Project, private val scope: CoroutineScope) : Di | |
// As an alternative, enabling the native drag in JCEF, | ||
// and let the native handling the drop event, and update the UI through JS bridge. | ||
val dropTarget = object : DropTarget() { | ||
override fun dragEnter(dtde: DropTargetDragEvent) { | ||
try { | ||
browserInstance.jcefBrowser.cefBrowser.executeJavaScript( | ||
|
||
"window.setDragAndDropVisible('true')", | ||
browserInstance.jcefBrowser.cefBrowser.url, | ||
0 | ||
) | ||
} catch (e: Exception) { | ||
LOG.error { "Failed to handle dragEnter: ${e.message}" } | ||
} | ||
} | ||
override fun dragOver(dtde: DropTargetDragEvent) { | ||
try { | ||
browserInstance.jcefBrowser.cefBrowser.executeJavaScript( | ||
"window.setDragAndDropVisible('true')", | ||
browserInstance.jcefBrowser.cefBrowser.url, | ||
0 | ||
) | ||
} catch (e: Exception) { | ||
LOG.error { "Failed to handle dragOver: ${e.message}" } | ||
} | ||
} | ||
override fun dragExit(dte: DropTargetEvent) { | ||
try { | ||
browserInstance.jcefBrowser.cefBrowser.executeJavaScript( | ||
"window.setDragAndDropVisible('false')", | ||
browserInstance.jcefBrowser.cefBrowser.url, | ||
0 | ||
) | ||
} catch (e: Exception) { | ||
LOG.error { "Failed to handle dragExit: ${e.message}" } | ||
} | ||
} | ||
override fun drop(dtde: DropTargetDropEvent) { | ||
try { | ||
dtde.acceptDrop(dtde.dropAction) | ||
|
@@ -166,6 +201,18 @@ class AmazonQPanel(val project: Project, private val scope: CoroutineScope) : Di | |
validImages.subList(20, validImages.size).clear() | ||
} | ||
|
||
browserInstance.jcefBrowser.cefBrowser.executeJavaScript( | ||
"window.resetTopBarClicked()", | ||
browserInstance.jcefBrowser.cefBrowser.url, | ||
0 | ||
) | ||
|
||
browserInstance.jcefBrowser.cefBrowser.executeJavaScript( | ||
"window.setDragAndDropVisible('false')", | ||
browserInstance.jcefBrowser.cefBrowser.url, | ||
0 | ||
) | ||
|
||
val json = OBJECT_MAPPER.writeValueAsString(validImages) | ||
browserInstance.jcefBrowser.cefBrowser.executeJavaScript( | ||
"window.handleNativeDrop('$json')", | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.