Skip to content

Commit 9f6d83f

Browse files
First time use we may help user with "Got It" tooltip (#255)
1 parent 81d7bd1 commit 9f6d83f

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/ui/Notifications.kt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
11
package org.utbot.intellij.plugin.ui
22

3+
import com.intellij.ide.util.PropertiesComponent
34
import com.intellij.notification.NotificationDisplayType
45
import com.intellij.notification.NotificationGroup
56
import com.intellij.notification.NotificationListener
67
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
711
import com.intellij.openapi.module.Module
812
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
920

1021
abstract class Notifier {
1122
protected abstract val notificationType: NotificationType
@@ -97,3 +108,22 @@ object TestsReportNotifier : InformationUrlNotifier() {
97108

98109
override fun content(project: Project?, module: Module?, info: String): String = info
99110
}
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+
}

utbot-intellij/src/main/resources/META-INF/plugin.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
<!--suppress PluginXmlValidity -->
3434
<projectService serviceImplementation="org.utbot.intellij.plugin.settings.Settings" preload="true"/>
3535
<registryKey defaultValue="false" description="Enable editing Kotlin test files" key="kotlin.ultra.light.classes.empty.text.range"/>
36+
<postStartupActivity implementation="org.utbot.intellij.plugin.ui.GotItTooltipActivity"/>
3637
</extensions>
3738

3839
<!-- Minimum and maximum build of IDE compatible with the plugin -->

0 commit comments

Comments
 (0)