[ide-console] Add tooltips to all icons
This commit is contained in:
committed by
Pavel V. Talanov
parent
b4224bf9f3
commit
bd52462420
@@ -112,6 +112,6 @@ public class KotlinConsoleKeeper(val project: Project) {
|
||||
}
|
||||
|
||||
companion object {
|
||||
jvmStatic fun getInstance(project: Project) = ServiceManager.getService(project, javaClass<KotlinConsoleKeeper>())
|
||||
jvmStatic fun getInstance(project: Project) = ServiceManager.getService(project, KotlinConsoleKeeper::class.java)
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,7 @@ import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.Disposer
|
||||
import org.jetbrains.kotlin.console.actions.BuildAndRestartConsoleAction
|
||||
import org.jetbrains.kotlin.console.actions.KtExecuteCommandAction
|
||||
import org.jetbrains.kotlin.console.gutter.IconPack
|
||||
import org.jetbrains.kotlin.console.gutter.KotlinConsoleGutterContentProvider
|
||||
import org.jetbrains.kotlin.console.gutter.KotlinConsoleIndicatorRenderer
|
||||
import org.jetbrains.kotlin.console.gutter.ReplIcons
|
||||
@@ -41,7 +42,6 @@ import org.jetbrains.kotlin.idea.JetLanguage
|
||||
import java.awt.Color
|
||||
import java.awt.Font
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
import javax.swing.Icon
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
public class KotlinConsoleRunner(
|
||||
@@ -137,7 +137,7 @@ public class KotlinConsoleRunner(
|
||||
}
|
||||
|
||||
fun setupGutters() {
|
||||
fun configureEditorGutter(editor: EditorEx, color: Color, icon: Icon) {
|
||||
fun configureEditorGutter(editor: EditorEx, color: Color, iconPack: IconPack) {
|
||||
editor.settings.isLineMarkerAreaShown = true // hack to show gutter
|
||||
editor.settings.isFoldingOutlineShown = true
|
||||
editor.gutterComponentEx.setPaintBackground(true)
|
||||
@@ -145,7 +145,7 @@ public class KotlinConsoleRunner(
|
||||
editorColorScheme.setColor(EditorColors.GUTTER_BACKGROUND, color)
|
||||
editor.colorsScheme = editorColorScheme
|
||||
|
||||
addGutterIndicator(editor, icon)
|
||||
addGutterIndicator(editor, iconPack)
|
||||
}
|
||||
|
||||
val historyEditor = consoleView.historyViewer
|
||||
@@ -162,8 +162,8 @@ public class KotlinConsoleRunner(
|
||||
consoleEditor.settings.additionalLinesCount = 2
|
||||
}
|
||||
|
||||
fun addGutterIndicator(editor: EditorEx, icon: Icon) {
|
||||
val indicator = KotlinConsoleIndicatorRenderer(icon)
|
||||
fun addGutterIndicator(editor: EditorEx, iconPack: IconPack) {
|
||||
val indicator = KotlinConsoleIndicatorRenderer(iconPack)
|
||||
val editorMarkup = editor.markupModel
|
||||
val indicatorHighlighter = editorMarkup.addRangeHighlighter(
|
||||
0, editor.document.textLength, HighlighterLayer.LAST, null, HighlighterTargetArea.LINES_IN_RANGE
|
||||
@@ -173,9 +173,9 @@ public class KotlinConsoleRunner(
|
||||
indicatorHighlighter.gutterIconRenderer = indicator
|
||||
}
|
||||
|
||||
fun changeConsoleEditorIndicator(newIcon: Icon) {
|
||||
fun changeConsoleEditorIndicator(newIconPack: IconPack) {
|
||||
val editorHighlighter = editorToHighlighter[consoleView.consoleEditor]
|
||||
editorHighlighter?.gutterIconRenderer = KotlinConsoleIndicatorRenderer(newIcon)
|
||||
editorHighlighter?.gutterIconRenderer = KotlinConsoleIndicatorRenderer(newIconPack)
|
||||
}
|
||||
|
||||
// this method shouldn't be called in normal usage; it is for test purpose only
|
||||
|
||||
+9
-5
@@ -17,10 +17,14 @@
|
||||
package org.jetbrains.kotlin.console.gutter
|
||||
|
||||
import com.intellij.openapi.editor.markup.GutterIconRenderer
|
||||
import javax.swing.Icon
|
||||
|
||||
public class KotlinConsoleIndicatorRenderer(private val indicatorIcon: Icon) : GutterIconRenderer() {
|
||||
override fun getIcon() = indicatorIcon
|
||||
override fun hashCode() = indicatorIcon.hashCode()
|
||||
override fun equals(other: Any?) = indicatorIcon == (other as? KotlinConsoleIndicatorRenderer)?.indicatorIcon ?: null
|
||||
public class KotlinConsoleIndicatorRenderer(iconPack: IconPack) : GutterIconRenderer() {
|
||||
private val icon = iconPack.icon
|
||||
private val tooltip = iconPack.tooltip
|
||||
|
||||
override fun getIcon() = icon
|
||||
override fun getTooltipText() = tooltip
|
||||
|
||||
override fun hashCode() = icon.hashCode()
|
||||
override fun equals(other: Any?) = icon == (other as? KotlinConsoleIndicatorRenderer)?.icon ?: null
|
||||
}
|
||||
@@ -20,17 +20,19 @@ import com.intellij.icons.AllIcons
|
||||
import org.jetbrains.kotlin.idea.JetIcons
|
||||
import javax.swing.Icon
|
||||
|
||||
public data class IconPack(val icon: Icon, val tooltip: String)
|
||||
|
||||
public object ReplIcons {
|
||||
public val BUILD_WARNING_INDICATOR: Icon = AllIcons.Ide.Warning_notifications
|
||||
public val HISTORY_INDICATOR: Icon = AllIcons.General.MessageHistory
|
||||
public val EDITOR_INDICATOR: Icon = JetIcons.LAUNCH
|
||||
public val EDITOR_READLINE_INDICATOR: Icon = AllIcons.General.Balloon
|
||||
public val COMMAND_MARKER: Icon = AllIcons.General.Run
|
||||
public val READLINE_MARKER: Icon = AllIcons.Icons.Ide.SpeedSearchPrompt
|
||||
public val BUILD_WARNING_INDICATOR: IconPack = IconPack(AllIcons.Ide.Warning_notifications, "Some issues with module <make>")
|
||||
public val HISTORY_INDICATOR: IconPack = IconPack(AllIcons.General.MessageHistory, "History of executed commands")
|
||||
public val EDITOR_INDICATOR: IconPack = IconPack(JetIcons.LAUNCH, "Write your commands here")
|
||||
public val EDITOR_READLINE_INDICATOR: IconPack = IconPack(AllIcons.General.Balloon, "Waiting for input...")
|
||||
public val COMMAND_MARKER: IconPack = IconPack(AllIcons.General.Run, "Executed command")
|
||||
public val READLINE_MARKER: IconPack = IconPack(AllIcons.Icons.Ide.SpeedSearchPrompt, "Input line")
|
||||
|
||||
// command result icons
|
||||
public val SYSTEM_HELP: Icon = AllIcons.Actions.Menu_help
|
||||
public val RESULT: Icon = AllIcons.Vcs.Equal
|
||||
public val SYSTEM_HELP: IconPack = IconPack(AllIcons.Actions.Menu_help, "System help")
|
||||
public val RESULT: IconPack = IconPack(AllIcons.Vcs.Equal, "Result")
|
||||
public val COMPILER_ERROR: Icon = AllIcons.General.Error
|
||||
public val RUNTIME_EXCEPTION: Icon = AllIcons.General.BalloonWarning
|
||||
public val RUNTIME_EXCEPTION: IconPack = IconPack(AllIcons.General.BalloonWarning, "Runtime exception")
|
||||
}
|
||||
+4
-4
@@ -31,11 +31,11 @@ import com.intellij.psi.PsiDocumentManager
|
||||
import org.jetbrains.kotlin.console.KotlinConsoleHistoryManager
|
||||
import org.jetbrains.kotlin.console.KotlinConsoleRunner
|
||||
import org.jetbrains.kotlin.console.SeverityDetails
|
||||
import org.jetbrains.kotlin.console.gutter.IconPack
|
||||
import org.jetbrains.kotlin.console.gutter.KotlinConsoleErrorRenderer
|
||||
import org.jetbrains.kotlin.console.gutter.KotlinConsoleIndicatorRenderer
|
||||
import org.jetbrains.kotlin.console.gutter.ReplIcons
|
||||
import org.jetbrains.kotlin.diagnostics.Severity
|
||||
import javax.swing.Icon
|
||||
|
||||
public class KotlinReplOutputHighlighter(
|
||||
private val runner: KotlinConsoleRunner,
|
||||
@@ -57,17 +57,17 @@ public class KotlinReplOutputHighlighter(
|
||||
return Pair(oldLen, newLen)
|
||||
}
|
||||
|
||||
private fun printOutput(output: String, contentType: ConsoleViewContentType, icon: Icon? = null) {
|
||||
private fun printOutput(output: String, contentType: ConsoleViewContentType, iconPack: IconPack? = null) {
|
||||
val (startOffset, endOffset) = textOffsets(output)
|
||||
|
||||
consoleView.print(output, contentType)
|
||||
consoleView.flushDeferredText()
|
||||
|
||||
if (icon == null) return
|
||||
if (iconPack == null) return
|
||||
|
||||
historyMarkup.addRangeHighlighter(
|
||||
startOffset, endOffset, HighlighterLayer.LAST, null, HighlighterTargetArea.EXACT_RANGE
|
||||
) apply { gutterIconRenderer = KotlinConsoleIndicatorRenderer(icon) }
|
||||
) apply { gutterIconRenderer = KotlinConsoleIndicatorRenderer(iconPack) }
|
||||
}
|
||||
|
||||
private fun printWarningMessage(message: String, isAddHyperlink: Boolean) = WriteCommandAction.runWriteCommandAction(project) {
|
||||
|
||||
Reference in New Issue
Block a user