[platform UI] IJPL-176359 Search Everywhere for RD: add preview

Move creating PreviewAction to FilterEditors to fix icon's index

GitOrigin-RevId: 474fdd3e070c05e69e38caca2d7aabc8a4025e80
This commit is contained in:
Tatiana Elfimova
2025-10-23 19:33:12 +00:00
committed by intellij-monorepo-bot
parent dd947ee2a5
commit df600763e7
8 changed files with 20 additions and 17 deletions
@@ -4,6 +4,7 @@ package com.intellij.platform.searchEverywhere.frontend.tabs.all
import com.intellij.ide.IdeBundle
import com.intellij.ide.actions.searcheverywhere.CheckBoxSearchEverywhereToggleAction
import com.intellij.ide.actions.searcheverywhere.PersistentSearchEverywhereContributorFilter
import com.intellij.ide.actions.searcheverywhere.PreviewAction
import com.intellij.ide.actions.searcheverywhere.SearchEverywhereFiltersAction
import com.intellij.ide.actions.searcheverywhere.SearchEverywhereManagerImpl
import com.intellij.ide.util.gotoByName.SearchEverywhereConfiguration
@@ -94,7 +95,7 @@ class SeAllTab(private val delegate: SeTabDelegate) : SeTab {
}
private class SeAllFilterEditor(providersIdToName: Map<SeProviderId, @Nls String>) : SeFilterEditorBase<SeEverywhereFilter>(SeEverywhereFilter(true, false, disabledProviders)) {
private val actions = listOf(getEverywhereToggleAction(), getFilterTypesAction(providersIdToName))
private val actions = listOf(getEverywhereToggleAction(), PreviewAction(), getFilterTypesAction(providersIdToName))
override fun getHeaderActions(): List<AnAction> = actions
private fun getEverywhereToggleAction() = object : CheckBoxSearchEverywhereToggleAction(IdeUICustomization.getInstance().projectMessage("checkbox.include.non.project.items")), AutoToggleAction {
@@ -28,7 +28,7 @@ class SeClassesTab(private val delegate: SeTabDelegate) : SeTab {
override val isIndexingDependent: Boolean get() = true
private val filterEditor: SuspendLazyProperty<SeFilterEditor> = initAsync(delegate.scope) {
SeTargetsFilterEditor(delegate.getSearchScopesInfos().firstOrNull(), delegate.getTypeVisibilityStates())
SeTargetsFilterEditor(delegate.getSearchScopesInfos().firstOrNull(), delegate.getTypeVisibilityStates(), true)
}
override fun getItems(params: SeParams): Flow<SeResultEvent> = delegate.getItems(params)
@@ -28,7 +28,7 @@ class SeFilesTab(private val delegate: SeTabDelegate) : SeTab {
override val isIndexingDependent: Boolean get() = true
private val filterEditor: SuspendLazyProperty<SeFilterEditor> = initAsync(delegate.scope) {
SeTargetsFilterEditor(delegate.getSearchScopesInfos().firstOrNull(), delegate.getTypeVisibilityStates())
SeTargetsFilterEditor(delegate.getSearchScopesInfos().firstOrNull(), delegate.getTypeVisibilityStates(), true)
}
override fun getItems(params: SeParams): Flow<SeResultEvent> = delegate.getItems(params)
@@ -28,7 +28,7 @@ open class SeSymbolsTab(private val delegate: SeTabDelegate) : SeTab {
override val isIndexingDependent: Boolean get() = true
private val filterEditor: SuspendLazyProperty<SeFilterEditor> = initAsync(delegate.scope) {
SeTargetsFilterEditor(delegate.getSearchScopesInfos().firstOrNull(), delegate.getTypeVisibilityStates())
SeTargetsFilterEditor(delegate.getSearchScopesInfos().firstOrNull(), delegate.getTypeVisibilityStates(), true)
}
override fun getItems(params: SeParams): Flow<SeResultEvent> = delegate.getItems(params)
@@ -2,6 +2,7 @@
package com.intellij.platform.searchEverywhere.frontend.tabs.target
import com.intellij.ide.actions.searcheverywhere.PersistentSearchEverywhereContributorFilter
import com.intellij.ide.actions.searcheverywhere.PreviewAction
import com.intellij.ide.actions.searcheverywhere.SearchEverywhereFiltersAction
import com.intellij.ide.ui.icons.icon
import com.intellij.openapi.actionSystem.AnAction
@@ -13,8 +14,11 @@ import com.intellij.platform.searchEverywhere.providers.target.SeTypeVisibilityS
import org.jetbrains.annotations.ApiStatus.Internal
@Internal
class SeTargetsFilterEditor(private val scopesInfo: SearchScopesInfo?,
typeVisibilityStates: List<SeTypeVisibilityStatePresentation>?) : SeFilterEditorBase<SeTargetsFilter>(
class SeTargetsFilterEditor(
private val scopesInfo: SearchScopesInfo?,
typeVisibilityStates: List<SeTypeVisibilityStatePresentation>?,
private val hasPreviewAction: Boolean,
) : SeFilterEditorBase<SeTargetsFilter>(
SeTargetsFilter(scopesInfo?.selectedScopeId,
scopesInfo?.selectedScopeId != scopesInfo?.everywhereScopeId,
hiddenTypes(typeVisibilityStates))
@@ -34,7 +38,9 @@ class SeTargetsFilterEditor(private val scopesInfo: SearchScopesInfo?,
}.getAction()
}
override fun getHeaderActions(): List<AnAction> = listOfNotNull(getScopeFilterAction(), getTypeFilterAction())
override fun getHeaderActions(): List<AnAction> = listOfNotNull(getScopeFilterAction(),
if (hasPreviewAction) PreviewAction() else null,
getTypeFilterAction())
private fun getScopeFilterAction(): AnAction? {
return scopeFilterAction
@@ -5,6 +5,7 @@ import com.intellij.find.FindManager
import com.intellij.find.FindSettings
import com.intellij.find.impl.JComboboxAction
import com.intellij.find.impl.TextSearchRightActionAction.*
import com.intellij.ide.actions.searcheverywhere.PreviewAction
import com.intellij.openapi.Disposable
import com.intellij.openapi.actionSystem.*
import com.intellij.openapi.observable.properties.AtomicBooleanProperty
@@ -61,7 +62,7 @@ class SeTextFilterEditor(
}
}, registerShortcut) { }
override fun getHeaderActions(): List<AnAction> = listOfNotNull(scopeFilterAction, typesFilterAction)
override fun getHeaderActions(): List<AnAction> = listOfNotNull(scopeFilterAction, typesFilterAction, PreviewAction())
override fun getSearchFieldActions(): List<AnAction> = listOf(caseSensitiveAction, wordAction, regexpAction)
@@ -286,12 +286,10 @@ class SePopupContentPane(
vm.currentTabFlow.collectLatest { tabVm ->
val filterEditor = tabVm.filterEditor.getValue()
filterEditor?.let { filterEditor ->
val isPreviewEnabled = tabVm.isPreviewEnabled.getValue()
withContext(Dispatchers.EDT) {
if (!isActive) return@withContext
headerPane.setFilterActions(filterEditor.getHeaderActions(), vm.ShowInFindToolWindowAction(), isPreviewEnabled)
headerPane.setFilterActions(filterEditor.getHeaderActions(), vm.ShowInFindToolWindowAction())
hintHelper.removeRightExtensions()
val rightActions = filterEditor.getSearchFieldActions()
if (rightActions.isNotEmpty()) {
@@ -949,7 +947,7 @@ class SePopupContentPane(
return usagePreviewPanel
}
private fun createSplitter() : OnePixelSplitter {
private fun createSplitter(): OnePixelSplitter {
val splitter = OnePixelSplitter(true, .33f)
splitter.splitterProportionKey = SearchEverywhereUI.SPLITTER_SERVICE_KEY
splitter.divider.setBackground(OnePixelDivider.BACKGROUND)
@@ -72,7 +72,7 @@ class SePopupHeaderPane(
}
.component
setFilterActions(emptyList(), null, false)
setFilterActions(emptyList(), null)
cell(tabFilterContainer).align(AlignY.FILL + AlignX.RIGHT).resizableColumn()
}
@@ -152,15 +152,12 @@ class SePopupHeaderPane(
}
}
fun setFilterActions(actions: List<AnAction>, showInFindToolWindowAction: AnAction?, isPreviewEnabled: Boolean) {
fun setFilterActions(actions: List<AnAction>, showInFindToolWindowAction: AnAction?) {
toolbarListenerDisposable?.let { Disposer.dispose(it) }
val toolbarListenerDisposable = Disposer.newDisposable()
this.toolbarListenerDisposable = toolbarListenerDisposable
val actionGroup = DefaultActionGroup(actions)
if (isPreviewEnabled) {
actionGroup.add(PreviewAction())
}
showInFindToolWindowAction?.let { actionGroup.add(it) }
toolbar = ActionManager.getInstance().createActionToolbar("search.everywhere.toolbar", actionGroup, true)
toolbar.setLayoutStrategy(ToolbarLayoutStrategy.NOWRAP_STRATEGY)