|
1 | 1 | package org.utbot.intellij.plugin.ui
|
2 | 2 |
|
| 3 | +import com.intellij.ide.util.PropertiesComponent |
3 | 4 | import com.intellij.notification.NotificationDisplayType
|
4 | 5 | import com.intellij.notification.NotificationGroup
|
5 | 6 | import com.intellij.notification.NotificationListener
|
6 | 7 | import com.intellij.notification.NotificationType
|
| 8 | +import com.intellij.openapi.actionSystem.ActionManager |
| 9 | +import com.intellij.openapi.application.ApplicationManager |
| 10 | +import com.intellij.openapi.keymap.KeymapUtil |
7 | 11 | import com.intellij.openapi.module.Module
|
8 | 12 | import com.intellij.openapi.project.Project
|
| 13 | +import com.intellij.openapi.startup.StartupActivity |
| 14 | +import com.intellij.openapi.ui.popup.Balloon |
| 15 | +import com.intellij.openapi.wm.WindowManager |
| 16 | +import com.intellij.ui.GotItMessage |
| 17 | +import com.intellij.ui.awt.RelativePoint |
| 18 | +import com.intellij.util.ui.JBFont |
| 19 | +import java.awt.Point |
9 | 20 |
|
10 | 21 | abstract class Notifier {
|
11 | 22 | protected abstract val notificationType: NotificationType
|
@@ -97,3 +108,22 @@ object TestsReportNotifier : InformationUrlNotifier() {
|
97 | 108 |
|
98 | 109 | override fun content(project: Project?, module: Module?, info: String): String = info
|
99 | 110 | }
|
| 111 | + |
| 112 | +object GotItTooltipActivity : StartupActivity { |
| 113 | + private const val KEY = "UTBot.GotItMessageWasShown" |
| 114 | + override fun runActivity(project: Project) { |
| 115 | + if (PropertiesComponent.getInstance().isTrueValue(KEY)) return |
| 116 | + ApplicationManager.getApplication().invokeLater { |
| 117 | + val shortcut = ActionManager.getInstance() |
| 118 | + .getKeyboardShortcut("org.utbot.intellij.plugin.ui.actions.GenerateTestsAction")?:return@invokeLater |
| 119 | + val shortcutText = KeymapUtil.getShortcutText(shortcut) |
| 120 | + val message = GotItMessage.createMessage("UTBot is ready!", |
| 121 | + "<div style=\"font-size:${JBFont.label().biggerOn(2.toFloat()).size}pt;\">" + |
| 122 | + "You can get test coverage for methods, Java classes<br>and even for whole source roots<br> with <b>$shortcutText</b></div>") |
| 123 | + message.setCallback { PropertiesComponent.getInstance().setValue(KEY, true) } |
| 124 | + WindowManager.getInstance().getFrame(project)?.rootPane?.let { |
| 125 | + message.show(RelativePoint(it, Point(it.width, it.height)), Balloon.Position.above) |
| 126 | + } |
| 127 | + } |
| 128 | + } |
| 129 | +} |
0 commit comments