|
16 | 16 | package com.skydoves.compose.stability.idea.toolwindow |
17 | 17 |
|
18 | 18 | import com.intellij.icons.AllIcons |
| 19 | +import com.intellij.ide.BrowserUtil |
19 | 20 | import com.intellij.openapi.actionSystem.ActionManager |
20 | 21 | import com.intellij.openapi.actionSystem.ActionPlaces |
21 | 22 | import com.intellij.openapi.actionSystem.AnAction |
@@ -84,14 +85,25 @@ public class StabilityToolWindow(private val project: Project) { |
84 | 85 | updateDetailsPanel(node) |
85 | 86 | } |
86 | 87 |
|
87 | | - // Add double-click listener for navigation |
| 88 | + // Add double-click listener for navigation and single-click for GitHub links |
88 | 89 | tree.addMouseListener(object : java.awt.event.MouseAdapter() { |
89 | 90 | override fun mouseClicked(e: java.awt.event.MouseEvent) { |
| 91 | + val node = tree.lastSelectedPathComponent as? DefaultMutableTreeNode |
| 92 | + |
| 93 | + // Handle single click on GitHub links |
| 94 | + if (e.clickCount == 1) { |
| 95 | + val gitHubLink = node?.userObject as? StabilityNodeData.GitHubLink |
| 96 | + if (gitHubLink != null) { |
| 97 | + BrowserUtil.browse(gitHubLink.url) |
| 98 | + return |
| 99 | + } |
| 100 | + } |
| 101 | + |
| 102 | + // Handle double click on composables for navigation |
90 | 103 | if (e.clickCount == 2) { |
91 | | - val node = tree.lastSelectedPathComponent as? DefaultMutableTreeNode |
92 | | - val data = node?.userObject as? StabilityNodeData.Composable |
93 | | - if (data != null) { |
94 | | - navigateToSource(data.info) |
| 104 | + val composable = node?.userObject as? StabilityNodeData.Composable |
| 105 | + if (composable != null) { |
| 106 | + navigateToSource(composable.info) |
95 | 107 | } |
96 | 108 | } |
97 | 109 | } |
@@ -196,16 +208,33 @@ public class StabilityToolWindow(private val project: Project) { |
196 | 208 |
|
197 | 209 | // Show helpful message if no composables found |
198 | 210 | if (results.composables.isEmpty()) { |
199 | | - val messageNode = DefaultMutableTreeNode( |
200 | | - StabilityNodeData.EmptyMessage( |
201 | | - "To view compose stability information:\n" + |
202 | | - "1. Apply the Compose Stability Analyzer Gradle plugin to your module\n" + |
203 | | - "2. Build your project to generate stability reports\n" + |
204 | | - "3. Click the refresh button above", |
| 211 | + val headerNode = DefaultMutableTreeNode( |
| 212 | + StabilityNodeData.EmptyMessage("To view compose stability information:"), |
| 213 | + ) |
| 214 | + rootNode.add(headerNode) |
| 215 | + |
| 216 | + // Add each step as a child node |
| 217 | + val steps = listOf( |
| 218 | + "1. Apply the Compose Stability Analyzer Gradle plugin to your module", |
| 219 | + "2. Build your project to generate stability reports", |
| 220 | + "3. Click the refresh button above", |
| 221 | + ) |
| 222 | + |
| 223 | + steps.forEach { step -> |
| 224 | + headerNode.add(DefaultMutableTreeNode(StabilityNodeData.EmptyMessage(step))) |
| 225 | + } |
| 226 | + |
| 227 | + // Add GitHub link |
| 228 | + val githubNode = DefaultMutableTreeNode( |
| 229 | + StabilityNodeData.GitHubLink( |
| 230 | + "For more information, check out GitHub", |
| 231 | + "https://github.com/skydoves/compose-stability-analyzer", |
205 | 232 | ), |
206 | 233 | ) |
207 | | - rootNode.add(messageNode) |
| 234 | + headerNode.add(githubNode) |
| 235 | + |
208 | 236 | treeModel.reload() |
| 237 | + tree.expandRow(0) // Expand the header to show all steps |
209 | 238 | return |
210 | 239 | } |
211 | 240 |
|
@@ -553,6 +582,17 @@ public class StabilityToolWindow(private val project: Project) { |
553 | 582 | append(data.message, SimpleTextAttributes.GRAYED_ATTRIBUTES) |
554 | 583 | } |
555 | 584 |
|
| 585 | + is StabilityNodeData.GitHubLink -> { |
| 586 | + icon = AllIcons.Ide.External_link_arrow |
| 587 | + append( |
| 588 | + data.text, |
| 589 | + SimpleTextAttributes( |
| 590 | + SimpleTextAttributes.STYLE_PLAIN, |
| 591 | + JBUI.CurrentTheme.Link.Foreground.ENABLED, |
| 592 | + ), |
| 593 | + ) |
| 594 | + } |
| 595 | + |
556 | 596 | else -> { |
557 | 597 | append(data.toString(), SimpleTextAttributes.REGULAR_ATTRIBUTES) |
558 | 598 | } |
|
0 commit comments