IJPL-43794 Add Search Everywhere step to New Users Onboarding

Also, have to fix the regex used to parse the shortcut definition in the GotIt tooltip. It was skipping the `Shift` keystroke because it is converted to `pressed SHIFT` and the space inside it was not recognized.

GitOrigin-RevId: e1a9e37bf204454be281e62dc33c94094a9e78cd
This commit is contained in:
Konstantin Hudyakov
2024-07-11 18:17:43 +03:00
committed by intellij-monorepo-bot
parent 27158d8cd1
commit 74b0dd5834
8 changed files with 60 additions and 2 deletions

View File

@@ -38,5 +38,6 @@
<orderEntry type="module" module-name="intellij.platform.statistics" />
<orderEntry type="library" name="jcef" level="project" />
<orderEntry type="module" module-name="intellij.platform.util.coroutines" />
<orderEntry type="module" module-name="intellij.platform.lang.impl" />
</component>
</module>

View File

@@ -18,6 +18,7 @@
<step key="toolWindowLayouts" implementationClass="com.intellij.platform.ide.newUiOnboarding.steps.ToolWindowLayoutsStep"/>
<step key="moreToolWindows" implementationClass="com.intellij.platform.ide.newUiOnboarding.steps.MoreToolWindowsStep"/>
<step key="navigationBar" implementationClass="com.intellij.platform.ide.newUiOnboarding.steps.NavigationBarStep"/>
<step key="searchEverywhere" implementationClass="com.intellij.platform.ide.newUiOnboarding.steps.SearchEverywhereStep"/>
</extensions>
<extensions defaultExtensionNs="com.intellij">

View File

@@ -40,4 +40,9 @@ newUsersOnboarding.dialog.text=Before you get to work, take a quick onboarding t
It will guide you through the essential UI elements you'll be using every day.
newUsersOnboarding.notification.group=Onboarding tour
newUsersOnboarding.notification.text=You can always find UI Overview under <b>Help</b> > <b>Start Onboarding Tour</b>
newUsersOnboarding.notification.text=You can always find UI Overview under <b>Help</b> > <b>Start Onboarding Tour</b>
search.everywhere.step.header=Search Everywhere
# Parameter is the keyboard shortcut
search.everywhere.step.text=Click the Search button or press {0} twice to quickly find any class, file, symbol, \
or even IDE actions and settings \u2014 all from a single search box.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -71,6 +71,7 @@ internal class NewUsersOnboardingService(private val project: Project, private v
"projectWidget",
"gitWidget",
"runWidget",
"searchEverywhere",
"toolWindowLayouts",
"moreToolWindows"
)

View File

@@ -0,0 +1,48 @@
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.platform.ide.newUiOnboarding.steps
import com.intellij.ide.actions.SearchEverywhereAction
import com.intellij.openapi.actionSystem.impl.ActionButton
import com.intellij.openapi.project.Project
import com.intellij.openapi.ui.popup.Balloon
import com.intellij.openapi.util.CheckedDisposable
import com.intellij.platform.ide.newUiOnboarding.NewUiOnboardingBundle
import com.intellij.platform.ide.newUiOnboarding.NewUiOnboardingStep
import com.intellij.platform.ide.newUiOnboarding.NewUiOnboardingStepData
import com.intellij.platform.ide.newUiOnboarding.NewUiOnboardingUtil
import com.intellij.ui.GotItComponentBuilder
import com.intellij.ui.awt.RelativePoint
import com.intellij.util.ui.JBUI
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import java.awt.Point
import java.awt.event.KeyEvent
import javax.swing.KeyStroke
internal class SearchEverywhereStep : NewUiOnboardingStep {
override suspend fun performStep(project: Project, disposable: CheckedDisposable): NewUiOnboardingStepData? {
val searchEverywhereButton = NewUiOnboardingUtil.findUiComponent(project) { button: ActionButton ->
button.action is SearchEverywhereAction
} ?: return null
val builder = GotItComponentBuilder {
val shiftShortcut = shortcut(KeyStroke.getKeyStroke(KeyEvent.VK_SHIFT, 0))
NewUiOnboardingBundle.message("search.everywhere.step.text", shiftShortcut)
}
builder.withHeader(NewUiOnboardingBundle.message("search.everywhere.step.header"))
val lottiePageData = withContext(Dispatchers.IO) {
NewUiOnboardingUtil.createLottieAnimationPage(LOTTIE_JSON_PATH, SearchEverywhereStep::class.java.classLoader)
}
lottiePageData?.let { (html, size) ->
builder.withBrowserPage(html, size, withBorder = true)
}
val point = Point(searchEverywhereButton.width / 2, searchEverywhereButton.height + JBUI.scale(3))
return NewUiOnboardingStepData(builder, RelativePoint(searchEverywhereButton, point), Balloon.Position.below)
}
companion object {
private const val LOTTIE_JSON_PATH = "newUiOnboarding/SearchEverywhereAnimation.json"
}
}

View File

@@ -829,7 +829,7 @@ class ShortcutExtension : ExtendableHTMLViewFactory.Extension {
private fun shortcutSpan(shortcutText: @NlsSafe String) = HtmlChunk.span().attr("class", "shortcut").addText(shortcutText).toString()
private val SHORTCUT_REGEX: Regex = Regex("""<shortcut (?<type>actionId|raw)="(?<value>[\w.]+)"/>""")
private val SHORTCUT_REGEX: Regex = Regex("""<shortcut (?<type>actionId|raw)="(?<value>[\w. ]+)"/>""")
}
private class ShortcutView(elem: Element) : InlineView(elem) {