Skip to content

First time use we may help user with "Got It" tooltip #255

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
package org.utbot.intellij.plugin.ui

import com.intellij.ide.util.PropertiesComponent
import com.intellij.notification.NotificationDisplayType
import com.intellij.notification.NotificationGroup
import com.intellij.notification.NotificationListener
import com.intellij.notification.NotificationType
import com.intellij.openapi.actionSystem.ActionManager
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.keymap.KeymapUtil
import com.intellij.openapi.module.Module
import com.intellij.openapi.project.Project
import com.intellij.openapi.startup.StartupActivity
import com.intellij.openapi.ui.popup.Balloon
import com.intellij.openapi.wm.WindowManager
import com.intellij.ui.GotItMessage
import com.intellij.ui.awt.RelativePoint
import com.intellij.util.ui.JBFont
import java.awt.Point

abstract class Notifier {
protected abstract val notificationType: NotificationType
Expand Down Expand Up @@ -97,3 +108,22 @@ object TestsReportNotifier : InformationUrlNotifier() {

override fun content(project: Project?, module: Module?, info: String): String = info
}

object GotItTooltipActivity : StartupActivity {
private const val KEY = "UTBot.GotItMessageWasShown"
override fun runActivity(project: Project) {
if (PropertiesComponent.getInstance().isTrueValue(KEY)) return
ApplicationManager.getApplication().invokeLater {
val shortcut = ActionManager.getInstance()
.getKeyboardShortcut("org.utbot.intellij.plugin.ui.actions.GenerateTestsAction")?:return@invokeLater
val shortcutText = KeymapUtil.getShortcutText(shortcut)
val message = GotItMessage.createMessage("UTBot is ready!",
"<div style=\"font-size:${JBFont.label().biggerOn(2.toFloat()).size}pt;\">" +
"You can get test coverage for methods, Java classes<br>and even for whole source roots<br> with <b>$shortcutText</b></div>")
message.setCallback { PropertiesComponent.getInstance().setValue(KEY, true) }
WindowManager.getInstance().getFrame(project)?.rootPane?.let {
message.show(RelativePoint(it, Point(it.width, it.height)), Balloon.Position.above)
}
}
}
}
1 change: 1 addition & 0 deletions utbot-intellij/src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<!--suppress PluginXmlValidity -->
<projectService serviceImplementation="org.utbot.intellij.plugin.settings.Settings" preload="true"/>
<registryKey defaultValue="false" description="Enable editing Kotlin test files" key="kotlin.ultra.light.classes.empty.text.range"/>
<postStartupActivity implementation="org.utbot.intellij.plugin.ui.GotItTooltipActivity"/>
</extensions>

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