From b72af4246d632f2e6c7036ac9322e17f5a697169 Mon Sep 17 00:00:00 2001 From: Brice Dutheil Date: Tue, 21 Mar 2023 11:39:54 +0100 Subject: [PATCH] feature: Replace deprecated ActionLink Fixes the warning: ``` 'ActionLink' is deprecated. Deprecated in Java ``` Refs: #116 --- .../lppedd/cc/whatsnew/WhatsNewEmptyPanel.kt | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/main/kotlin/com/github/lppedd/cc/whatsnew/WhatsNewEmptyPanel.kt b/src/main/kotlin/com/github/lppedd/cc/whatsnew/WhatsNewEmptyPanel.kt index 1a0e4cb..8d0d3e1 100644 --- a/src/main/kotlin/com/github/lppedd/cc/whatsnew/WhatsNewEmptyPanel.kt +++ b/src/main/kotlin/com/github/lppedd/cc/whatsnew/WhatsNewEmptyPanel.kt @@ -1,14 +1,13 @@ package com.github.lppedd.cc.whatsnew import com.github.lppedd.cc.CCBundle -import com.intellij.openapi.actionSystem.AnAction -import com.intellij.openapi.actionSystem.AnActionEvent +import com.intellij.ide.BrowserUtil import com.intellij.ui.components.JBLabel -import com.intellij.ui.components.labels.ActionLink +import com.intellij.ui.components.labels.LinkLabel +import com.intellij.ui.components.labels.LinkListener import com.intellij.util.ui.JBUI import com.intellij.util.ui.UIUtil import java.awt.Component -import java.awt.Desktop import java.net.URI import javax.swing.Box import javax.swing.BoxLayout @@ -24,8 +23,8 @@ internal class WhatsNewEmptyPanel : JPanel() { it.foreground = UIUtil.getInactiveTextColor() } - val link = ActionLink(CCBundle["cc.whatsnew.dialog.visitPage"], VisitPageAction()).also { - it.alignmentX = Component.CENTER_ALIGNMENT + val link = LinkLabel(CCBundle["cc.whatsnew.dialog.visitPage"], null, VisitPageAction()).also { + it.alignmentX = CENTER_ALIGNMENT it.setPaintUnderline(false) } @@ -37,13 +36,9 @@ internal class WhatsNewEmptyPanel : JPanel() { border = JBUI.Borders.empty(40, 30) } - private class VisitPageAction : AnAction() { - override fun actionPerformed(event: AnActionEvent) { - try { - Desktop.getDesktop().browse(URI(CCBundle["cc.plugin.repository"])) - } catch (_: Exception) { - // - } + private class VisitPageAction : LinkListener { + override fun linkSelected(aSource: LinkLabel?, aLinkData: Any?) { + BrowserUtil.browse(URI(CCBundle["cc.plugin.repository"])) } } }