Removed deprecated icons usages

#KT-35918 Comment
This commit is contained in:
Alexander Podkhalyuzin
2020-01-23 10:14:50 +01:00
committed by Vladimir Dolzhenko
parent d880a507dd
commit 46526ab53c
3 changed files with 43 additions and 32 deletions
@@ -20,12 +20,12 @@ import com.intellij.execution.filters.OpenFileHyperlinkInfo
import com.intellij.execution.impl.ConsoleViewImpl import com.intellij.execution.impl.ConsoleViewImpl
import com.intellij.execution.runners.ExecutionUtil import com.intellij.execution.runners.ExecutionUtil
import com.intellij.execution.ui.ConsoleViewContentType import com.intellij.execution.ui.ConsoleViewContentType
import com.intellij.ide.scratch.ScratchFileType
import com.intellij.openapi.Disposable import com.intellij.openapi.Disposable
import com.intellij.openapi.application.ApplicationManager import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.application.TransactionGuard import com.intellij.openapi.application.TransactionGuard
import com.intellij.openapi.command.WriteCommandAction import com.intellij.openapi.command.WriteCommandAction
import com.intellij.openapi.editor.ex.EditorEx import com.intellij.openapi.editor.ex.EditorEx
import com.intellij.openapi.fileTypes.PlainTextFileType
import com.intellij.openapi.project.Project import com.intellij.openapi.project.Project
import com.intellij.openapi.util.Disposer import com.intellij.openapi.util.Disposer
import com.intellij.openapi.wm.ToolWindow import com.intellij.openapi.wm.ToolWindow
@@ -113,8 +113,8 @@ private class ToolWindowScratchOutputHandler(private val parentDisposable: Dispo
OpenFileHyperlinkInfo( OpenFileHyperlinkInfo(
project, project,
psiFile.virtualFile, psiFile.virtualFile,
expression.lineStart expression.lineStart,
) ),
) )
print(" ", ConsoleViewContentType.NORMAL_OUTPUT) print(" ", ConsoleViewContentType.NORMAL_OUTPUT)
} }
@@ -149,7 +149,7 @@ private class ToolWindowScratchOutputHandler(private val parentDisposable: Dispo
toolWindow.show(null) toolWindow.show(null)
} }
toolWindow.icon = ExecutionUtil.getLiveIndicator(ScratchFileType.INSTANCE.icon) toolWindow.icon = ExecutionUtil.getLiveIndicator(scratchIcon())
} }
} }
@@ -168,7 +168,7 @@ private class ToolWindowScratchOutputHandler(private val parentDisposable: Dispo
toolWindow.hide(null) toolWindow.hide(null)
} }
toolWindow.icon = ScratchFileType.INSTANCE.icon toolWindow.icon = scratchIcon()
} }
} }
@@ -190,14 +190,19 @@ private class ToolWindowScratchOutputHandler(private val parentDisposable: Dispo
val window = toolWindowManager.getToolWindow(ScratchToolWindowFactory.ID) val window = toolWindowManager.getToolWindow(ScratchToolWindowFactory.ID)
ScratchToolWindowFactory().createToolWindowContent(project, window) ScratchToolWindowFactory().createToolWindowContent(project, window)
Disposer.register(parentDisposable, Disposable { Disposer.register(
toolWindowManager.unregisterToolWindow(ScratchToolWindowFactory.ID) parentDisposable,
}) Disposable {
toolWindowManager.unregisterToolWindow(ScratchToolWindowFactory.ID)
},
)
return window return window
} }
} }
private fun scratchIcon() = PlainTextFileType.INSTANCE.icon
private fun getLineInfo(psiFile: PsiFile, expression: ScratchExpression) = private fun getLineInfo(psiFile: PsiFile, expression: ScratchExpression) =
"${psiFile.name}:${expression.lineStart + 1}" "${psiFile.name}:${expression.lineStart + 1}"
@@ -209,7 +214,7 @@ private class ScratchToolWindowFactory : ToolWindowFactory {
override fun createToolWindowContent(project: Project, toolWindow: ToolWindow) { override fun createToolWindowContent(project: Project, toolWindow: ToolWindow) {
val consoleView = ConsoleViewImpl(project, true) val consoleView = ConsoleViewImpl(project, true)
toolWindow.isToHideOnEmptyContent = true toolWindow.isToHideOnEmptyContent = true
toolWindow.icon = ScratchFileType.INSTANCE.icon toolWindow.icon = scratchIcon()
toolWindow.hide(null) toolWindow.hide(null)
val contentManager = toolWindow.contentManager val contentManager = toolWindow.contentManager
@@ -237,27 +242,33 @@ private object TestOutputHandler : ScratchOutputHandlerAdapter() {
} }
override fun onFinish(file: ScratchFile) { override fun onFinish(file: ScratchFile) {
TransactionGuard.submitTransaction(file.project, Runnable { TransactionGuard.submitTransaction(
val psiFile = file.getPsiFile() file.project,
?: error( Runnable {
"PsiFile cannot be found for scratch to render inlays in tests:\n" + val psiFile = file.getPsiFile()
"project.isDisposed = ${file.project.isDisposed}\n" + ?: error(
"inlays = ${inlays.joinToString { it.second }}\n" + "PsiFile cannot be found for scratch to render inlays in tests:\n" +
"errors = ${errors.joinToString()}" "project.isDisposed = ${file.project.isDisposed}\n" +
) "inlays = ${inlays.joinToString { it.second }}\n" +
"errors = ${errors.joinToString()}",
)
if (inlays.isNotEmpty()) { if (inlays.isNotEmpty()) {
testPrint(psiFile, inlays.map { (expression, text) -> testPrint(
"/** ${getLineInfo(psiFile, expression)} $text */" psiFile,
}) inlays.map { (expression, text) ->
inlays.clear() "/** ${getLineInfo(psiFile, expression)} $text */"
} },
)
inlays.clear()
}
if (errors.isNotEmpty()) { if (errors.isNotEmpty()) {
testPrint(psiFile, listOf(errors.joinToString(prefix = "/** ", postfix = " */"))) testPrint(psiFile, listOf(errors.joinToString(prefix = "/** ", postfix = " */")))
errors.clear() errors.clear()
} }
}) },
)
} }
private fun testPrint(file: PsiFile, comments: List<String>) { private fun testPrint(file: PsiFile, comments: List<String>) {
@@ -265,7 +276,7 @@ private object TestOutputHandler : ScratchOutputHandlerAdapter() {
for (comment in comments) { for (comment in comments) {
file.addAfter( file.addAfter(
KtPsiFactory(file.project).createComment(comment), KtPsiFactory(file.project).createComment(comment),
file.lastChild file.lastChild,
) )
} }
} }
@@ -23,12 +23,12 @@ import javax.swing.Icon
data class IconWithTooltip(val icon: Icon, val tooltip: String?) data class IconWithTooltip(val icon: Icon, val tooltip: String?)
object ReplIcons { object ReplIcons {
val BUILD_WARNING_INDICATOR: IconWithTooltip = IconWithTooltip(AllIcons.Ide.Warning_notifications, null) val BUILD_WARNING_INDICATOR: IconWithTooltip = IconWithTooltip(AllIcons.General.Warning, null)
val HISTORY_INDICATOR: IconWithTooltip = IconWithTooltip(AllIcons.Vcs.History, "History of executed commands") val HISTORY_INDICATOR: IconWithTooltip = IconWithTooltip(AllIcons.Vcs.History, "History of executed commands")
val EDITOR_INDICATOR: IconWithTooltip = IconWithTooltip(KotlinIcons.LAUNCH, "Write your commands here") val EDITOR_INDICATOR: IconWithTooltip = IconWithTooltip(KotlinIcons.LAUNCH, "Write your commands here")
val EDITOR_READLINE_INDICATOR: IconWithTooltip = IconWithTooltip(AllIcons.General.Balloon, "Waiting for input...") val EDITOR_READLINE_INDICATOR: IconWithTooltip = IconWithTooltip(AllIcons.General.Balloon, "Waiting for input...")
val COMMAND_MARKER: IconWithTooltip = IconWithTooltip(AllIcons.RunConfigurations.TestState.Run, "Executed command") val COMMAND_MARKER: IconWithTooltip = IconWithTooltip(AllIcons.RunConfigurations.TestState.Run, "Executed command")
val READLINE_MARKER: IconWithTooltip = IconWithTooltip(AllIcons.Icons.Ide.SpeedSearchPrompt, "Input line") val READLINE_MARKER: IconWithTooltip = IconWithTooltip(AllIcons.Debugger.PromptInput, "Input line")
// command result icons // command result icons
val SYSTEM_HELP: IconWithTooltip = IconWithTooltip(AllIcons.Actions.Help, "System help") val SYSTEM_HELP: IconWithTooltip = IconWithTooltip(AllIcons.Actions.Help, "System help")
@@ -101,7 +101,7 @@ public class KotlinCallHierarchyNodeDescriptor extends HierarchyNodeDescriptor i
if (changes && myIsBase) { if (changes && myIsBase) {
LayeredIcon icon = new LayeredIcon(2); LayeredIcon icon = new LayeredIcon(2);
icon.setIcon(newIcon, 0); icon.setIcon(newIcon, 0);
icon.setIcon(AllIcons.Hierarchy.Base, 1, -AllIcons.Hierarchy.Base.getIconWidth() / 2, 0); icon.setIcon(AllIcons.General.Modified, 1, -AllIcons.General.Modified.getIconWidth() / 2, 0);
newIcon = icon; newIcon = icon;
} }
setIcon(newIcon); setIcon(newIcon);