Skip to content

Commit

Permalink
feature: Replace deprecated ActionLink
Browse files Browse the repository at this point in the history
Fixes the warning:

```
'ActionLink' is deprecated. Deprecated in Java
```

Refs: lppedd#116
  • Loading branch information
bric3 authored and lppedd committed Mar 25, 2023
1 parent 4ec61e8 commit 9adaf4e
Showing 1 changed file with 8 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
}

Expand All @@ -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<Any> {
override fun linkSelected(aSource: LinkLabel<Any>?, aLinkData: Any?) {
BrowserUtil.browse(URI(CCBundle["cc.plugin.repository"]))
}
}
}

0 comments on commit 9adaf4e

Please sign in to comment.