Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ build/
out/
.DS_Store
.gradle/
.intellijPlatform
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- update dependencies
- upgrade to gradle 9.x
- upgrade to intellij 2026.2
- removed usage of internal intellij api

## [1.11.0]

Expand Down
22 changes: 20 additions & 2 deletions src/main/kotlin/de/ehmkah/projects/imgdiff/ImgDiffViewer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import com.intellij.diff.tools.util.ThreeDiffSplitter
import com.intellij.openapi.ui.DialogBuilder
import org.jetbrains.annotations.NotNull
import java.awt.BorderLayout
import java.awt.Component
import java.awt.Container
import java.awt.event.ActionEvent
import java.awt.event.ActionListener
import javax.swing.*
Expand All @@ -24,14 +26,30 @@ class ImgDiffViewer(context: @NotNull DiffContext, request: @NotNull DiffRequest


fun showBlinkingDiff(imageData: ByteArray) {
val component: ThreeDiffSplitter = myContentPanel.getComponent(0) as ThreeDiffSplitter
val contentPanel = component.getComponent(3) as JPanel
val splitter = findComponentOfType<ThreeDiffSplitter>(component)
?: return
val contentPanel = splitter.getComponent(3) as JPanel
while (contentPanel.componentCount > 0) {
contentPanel.remove(0)
}
addBlinkingDiff(contentPanel, imageData)
}

private inline fun <reified T : Component> findComponentOfType(root: Component): T? =
findComponentOfType(root, T::class.java)

private fun <T : Component> findComponentOfType(root: Component, type: Class<T>): T? {
if (type.isInstance(root)) {
return type.cast(root)
}
if (root is Container) {
for (child in root.components) {
findComponentOfType(child, type)?.let { return it }
}
}
return null
}


fun addBlinkingDiff(panel: JPanel, imageData: ByteArray) {
panel.layout = BorderLayout()
Expand Down
Loading