From 0874e6173a733d04f89638bc2adfa699b8d7e346 Mon Sep 17 00:00:00 2001 From: "Aleksei.Luchinin" Date: Tue, 18 Jun 2024 12:59:02 +0300 Subject: [PATCH] Fix new and some old warnings --- .../ArendDocumentationLibHtmlUtil.kt | 3 +-- .../GenerateArendLibHtmlStarter.kt | 2 +- .../kotlin/org/arend/graph/GraphSimulator.kt | 22 ++++++++++--------- .../FileOutsideSourcesProvider.kt | 2 +- .../org/arend/search/proof/ProofSearchUI.kt | 3 ++- .../arend/yaml/YamlNotificationProvider.kt | 2 +- src/main/resources/META-INF/plugin.xml | 2 +- 7 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/main/kotlin/org/arend/documentation/ArendDocumentationLibHtmlUtil.kt b/src/main/kotlin/org/arend/documentation/ArendDocumentationLibHtmlUtil.kt index fd90a6acc..f206efca0 100644 --- a/src/main/kotlin/org/arend/documentation/ArendDocumentationLibHtmlUtil.kt +++ b/src/main/kotlin/org/arend/documentation/ArendDocumentationLibHtmlUtil.kt @@ -16,7 +16,6 @@ import com.intellij.psi.PsiManager import com.intellij.psi.PsiRecursiveElementVisitor import com.intellij.psi.util.elementType import com.intellij.testFramework.LightVirtualFile -import org.apache.commons.lang.StringEscapeUtils import org.arend.highlight.ArendHighlightingColors import org.arend.highlight.ArendHighlightingPass import org.arend.highlight.ArendSyntaxHighlighter @@ -279,7 +278,7 @@ private fun generateHtmlForArend( counter = result.second append("${StringEscapeUtils.escapeHtml(element.text)}") + cssClass?.let { " class=\"$it\"" } ?: ""}>${element.text.htmlEscape()}") } }) append("") diff --git a/src/main/kotlin/org/arend/documentation/GenerateArendLibHtmlStarter.kt b/src/main/kotlin/org/arend/documentation/GenerateArendLibHtmlStarter.kt index c8e1ae7fc..6f8af56a5 100644 --- a/src/main/kotlin/org/arend/documentation/GenerateArendLibHtmlStarter.kt +++ b/src/main/kotlin/org/arend/documentation/GenerateArendLibHtmlStarter.kt @@ -1,9 +1,9 @@ package org.arend.documentation import com.intellij.openapi.application.ApplicationStarter -import com.intellij.openapi.editor.colors.EditorColorsManager class GenerateArendLibHtmlStarter : ApplicationStarter { + @Suppress("OVERRIDE_DEPRECATION") override val commandName: String get() = "generateArendLibHtml" diff --git a/src/main/kotlin/org/arend/graph/GraphSimulator.kt b/src/main/kotlin/org/arend/graph/GraphSimulator.kt index 4576d0133..6ff059b41 100644 --- a/src/main/kotlin/org/arend/graph/GraphSimulator.kt +++ b/src/main/kotlin/org/arend/graph/GraphSimulator.kt @@ -1,13 +1,13 @@ package org.arend.graph -import com.intellij.notification.NotificationListener +import com.intellij.ide.BrowserUtil +import com.intellij.notification.NotificationAction import com.intellij.notification.Notifications import com.intellij.openapi.project.Project import com.intellij.openapi.ui.DialogWrapper import com.intellij.openapi.ui.MessageType import com.intellij.openapi.updateSettings.impl.pluginsAdvertisement.notificationGroup -import com.intellij.ui.util.minimumHeight -import com.intellij.ui.util.minimumWidth +import com.intellij.ui.components.JBPanel import guru.nidi.graphviz.engine.Format import guru.nidi.graphviz.engine.Graphviz import guru.nidi.graphviz.model.Factory.graph @@ -88,17 +88,17 @@ class GraphSimulator( } override fun createCenterPanel(): JComponent { - val panel = JPanel() + val panel = JBPanel>() panel.add(imageLabel) panel.background = Color.WHITE panel.addComponentListener(object : ComponentAdapter() { override fun componentResized(e: ComponentEvent) { val component = panel.components.getOrNull(0) ?: return - panel.minimumWidth = baseImageIcon.iconWidth + size.width - e.component.width - panel.minimumHeight = baseImageIcon.iconHeight + size.height - e.component.height + panel.withMinimumWidth(baseImageIcon.iconWidth + size.width - e.component.width) + panel.withMinimumHeight(baseImageIcon.iconHeight + size.height - e.component.height) - val imageIcon = getImageIcon(baseImageIcon, graphviz, e.component.width - component.bounds.x * 2, e.component.height - component.bounds.y * 2) - imageLabel = JLabel(imageIcon) + val newImageIcon = getImageIcon(baseImageIcon, graphviz, e.component.width - component.bounds.x * 2, e.component.height - component.bounds.y * 2) + imageLabel = JLabel(newImageIcon) panel.removeAll() panel.add(imageLabel) @@ -137,8 +137,10 @@ class GraphSimulator( dialogWrapper.pack() dialogWrapper.show() } catch (e: Exception) { - val notification = notificationGroup.createNotification("It is not possible to visualize the diagram on your device. Install Graphviz please", MessageType.WARNING) - notification.setListener(NotificationListener.UrlOpeningListener(true)) + val notification = notificationGroup.createNotification("It is not possible to visualize the diagram on your device. Install Graphviz please", MessageType.WARNING) + .addAction(NotificationAction.createSimple("Open Graphviz") { + BrowserUtil.open("https://graphviz.org/download/") + }) Notifications.Bus.notify(notification, project) } } diff --git a/src/main/kotlin/org/arend/notification/FileOutsideSourcesProvider.kt b/src/main/kotlin/org/arend/notification/FileOutsideSourcesProvider.kt index 61b535d6e..e3d64de49 100644 --- a/src/main/kotlin/org/arend/notification/FileOutsideSourcesProvider.kt +++ b/src/main/kotlin/org/arend/notification/FileOutsideSourcesProvider.kt @@ -24,7 +24,7 @@ class FileOutsideSourcesProvider : EditorNotificationProvider { return null } - return Function { fileEditor: FileEditor? -> + return Function { fileEditor: FileEditor? -> fileEditor?.let { createPanel(fileEditor) } } } diff --git a/src/main/kotlin/org/arend/search/proof/ProofSearchUI.kt b/src/main/kotlin/org/arend/search/proof/ProofSearchUI.kt index 07aacc7be..64d55de20 100644 --- a/src/main/kotlin/org/arend/search/proof/ProofSearchUI.kt +++ b/src/main/kotlin/org/arend/search/proof/ProofSearchUI.kt @@ -13,6 +13,7 @@ import com.intellij.codeInsight.lookup.impl.actions.ChooseItemAction import com.intellij.icons.AllIcons import com.intellij.ide.actions.BigPopupUI import com.intellij.openapi.actionSystem.* +import com.intellij.openapi.actionSystem.toolbarLayout.ToolbarLayoutStrategy import com.intellij.openapi.application.invokeAndWaitIfNeeded import com.intellij.openapi.application.invokeLater import com.intellij.openapi.application.runInEdt @@ -172,7 +173,7 @@ class ProofSearchUI(private val project: Project, private val caret: Caret?) : B actionGroup.addAction(ShowInFindWindowAction(this, project)) actionGroup.addAction(ShowHelpAction(this)) val toolbar = ActionManager.getInstance().createActionToolbar("proof.search.top.toolbar", actionGroup, true) - toolbar.layoutPolicy = ActionToolbar.NOWRAP_LAYOUT_POLICY + toolbar.layoutStrategy = ToolbarLayoutStrategy.NOWRAP_STRATEGY toolbar.targetComponent = this val toolbarComponent = toolbar.component toolbarComponent.isOpaque = false diff --git a/src/main/kotlin/org/arend/yaml/YamlNotificationProvider.kt b/src/main/kotlin/org/arend/yaml/YamlNotificationProvider.kt index 5b8549d07..8969fee3c 100644 --- a/src/main/kotlin/org/arend/yaml/YamlNotificationProvider.kt +++ b/src/main/kotlin/org/arend/yaml/YamlNotificationProvider.kt @@ -17,7 +17,7 @@ class YamlNotificationProvider : EditorNotificationProvider { if (!yamlFileService.containsChangedFile(virtualFile)) { return null } - return Function { fileEditor: FileEditor? -> + return Function { fileEditor: FileEditor? -> fileEditor?.let { createPanel(yamlFileService, virtualFile, it) } } } diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 7b9ddc4a5..09fe91ea2 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -441,7 +441,7 @@ - +