From ba46706b713bca3a0fb5bb7ce81bb8587623c0e2 Mon Sep 17 00:00:00 2001 From: "Yii.Guxing" Date: Tue, 7 Dec 2021 10:12:49 +0800 Subject: [PATCH] Clean up --- .../kotlin/cn/yiiguxing/plugin/figlet/DataManager.kt | 4 ++-- .../cn/yiiguxing/plugin/figlet/FigFontComboBoxButton.kt | 9 +++++---- .../cn/yiiguxing/plugin/figlet/GenerateASCIIArtDialog.kt | 7 +++---- src/main/kotlin/cn/yiiguxing/plugin/figlet/Settings.kt | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/kotlin/cn/yiiguxing/plugin/figlet/DataManager.kt b/src/main/kotlin/cn/yiiguxing/plugin/figlet/DataManager.kt index 0aae1b2..7d6c12a 100644 --- a/src/main/kotlin/cn/yiiguxing/plugin/figlet/DataManager.kt +++ b/src/main/kotlin/cn/yiiguxing/plugin/figlet/DataManager.kt @@ -1,7 +1,7 @@ package cn.yiiguxing.plugin.figlet +import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.components.PersistentStateComponent -import com.intellij.openapi.components.ServiceManager import com.intellij.openapi.components.State import com.intellij.openapi.components.Storage import com.intellij.util.xmlb.annotations.CollectionBean @@ -23,7 +23,7 @@ class DataManager : PersistentStateComponent { companion object { val instance: DataManager - get() = ServiceManager.getService(DataManager::class.java) + get() = ApplicationManager.getApplication().getService(DataManager::class.java) } data class State(var lastUsedFont: String, @CollectionBean var commonFonts: List) { diff --git a/src/main/kotlin/cn/yiiguxing/plugin/figlet/FigFontComboBoxButton.kt b/src/main/kotlin/cn/yiiguxing/plugin/figlet/FigFontComboBoxButton.kt index 928b158..de52783 100644 --- a/src/main/kotlin/cn/yiiguxing/plugin/figlet/FigFontComboBoxButton.kt +++ b/src/main/kotlin/cn/yiiguxing/plugin/figlet/FigFontComboBoxButton.kt @@ -7,6 +7,7 @@ import com.intellij.openapi.ui.popup.ListSeparator import com.intellij.openapi.ui.popup.PopupStep import com.intellij.openapi.ui.popup.util.BaseListPopupStep import com.intellij.ui.awt.RelativePoint +import com.intellij.ui.scale.JBUIScale import com.intellij.util.ui.JBUI import com.intellij.util.ui.UIUtil import java.awt.* @@ -81,8 +82,8 @@ class FigFontComboBoxButton( g as Graphics2D super.paint(g) - val x = (width - JBUI.scale(20)).toDouble() - val y = (height - JBUI.scale(5.0f)) * 0.5 + val x = (width - JBUIScale.scale(20)).toDouble() + val y = (height - JBUIScale.scale(5.0f)) * 0.5 g.translate(x, y) if (!isUnderDarcula) { @@ -99,8 +100,8 @@ class FigFontComboBoxButton( private fun createArrowShape(): Shape { return GeneralPath().apply { moveTo(0.0f, 0.0f) - lineTo(JBUI.scale(10.0f), 0.0f) - lineTo(JBUI.scale(5.0f), 5.0f) + lineTo(JBUIScale.scale(10.0f), 0.0f) + lineTo(JBUIScale.scale(5.0f), 5.0f) closePath() } } diff --git a/src/main/kotlin/cn/yiiguxing/plugin/figlet/GenerateASCIIArtDialog.kt b/src/main/kotlin/cn/yiiguxing/plugin/figlet/GenerateASCIIArtDialog.kt index 8f12c00..b096ea2 100644 --- a/src/main/kotlin/cn/yiiguxing/plugin/figlet/GenerateASCIIArtDialog.kt +++ b/src/main/kotlin/cn/yiiguxing/plugin/figlet/GenerateASCIIArtDialog.kt @@ -6,7 +6,6 @@ import com.intellij.openapi.project.Project import com.intellij.openapi.ui.DialogWrapper import com.intellij.openapi.util.Disposer import org.slf4j.LoggerFactory -import java.util.* import javax.swing.Action import javax.swing.JComponent import kotlin.collections.set @@ -31,12 +30,12 @@ class GenerateASCIIArtDialog(project: Project, defaultInputText: String = "") : Disposer.register(disposable, form) } - override fun createCenterPanel(): JComponent? = form.component + override fun createCenterPanel(): JComponent = form.component override fun createActions(): Array = arrayOf(okAction, cancelAction) - override fun getPreferredFocusedComponent(): JComponent? { - return form.preferredFocusedComponent ?: super.getPreferredFocusedComponent() + override fun getPreferredFocusedComponent(): JComponent { + return form.preferredFocusedComponent } fun showAndGetResult(): String? { diff --git a/src/main/kotlin/cn/yiiguxing/plugin/figlet/Settings.kt b/src/main/kotlin/cn/yiiguxing/plugin/figlet/Settings.kt index 0dc49e7..fdf7cb3 100644 --- a/src/main/kotlin/cn/yiiguxing/plugin/figlet/Settings.kt +++ b/src/main/kotlin/cn/yiiguxing/plugin/figlet/Settings.kt @@ -1,7 +1,7 @@ package cn.yiiguxing.plugin.figlet +import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.components.PersistentStateComponent -import com.intellij.openapi.components.ServiceManager import com.intellij.openapi.components.State import com.intellij.openapi.components.Storage @@ -25,6 +25,6 @@ class Settings : PersistentStateComponent { companion object { val instance: Settings - get() = ServiceManager.getService(Settings::class.java) + get() = ApplicationManager.getApplication().getService(Settings::class.java) } } \ No newline at end of file