From df600763e77b34fc0ac5890ad5052f88a43155fc Mon Sep 17 00:00:00 2001 From: Tatiana Elfimova Date: Tue, 21 Oct 2025 13:25:15 +0200 Subject: [PATCH] [platform UI] IJPL-176359 Search Everywhere for RD: add preview Move creating PreviewAction to FilterEditors to fix icon's index GitOrigin-RevId: 474fdd3e070c05e69e38caca2d7aabc8a4025e80 --- .../frontend/src/tabs/all/SeAllTab.kt | 3 ++- .../frontend/src/tabs/classes/SeClassesTab.kt | 2 +- .../frontend/src/tabs/files/SeFilesTab.kt | 2 +- .../frontend/src/tabs/symbols/SeSymbolsTab.kt | 2 +- .../src/tabs/target/SeTargetsFilterEditor.kt | 12 +++++++++--- .../frontend/src/tabs/text/SeTextFilterEditor.kt | 3 ++- .../frontend/src/ui/SePopupContentPane.kt | 6 ++---- .../frontend/src/ui/SePopupHeaderPane.kt | 7 ++----- 8 files changed, 20 insertions(+), 17 deletions(-) diff --git a/platform/searchEverywhere/frontend/src/tabs/all/SeAllTab.kt b/platform/searchEverywhere/frontend/src/tabs/all/SeAllTab.kt index fcc580473adf..b0a10d7b3a16 100644 --- a/platform/searchEverywhere/frontend/src/tabs/all/SeAllTab.kt +++ b/platform/searchEverywhere/frontend/src/tabs/all/SeAllTab.kt @@ -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) : SeFilterEditorBase(SeEverywhereFilter(true, false, disabledProviders)) { - private val actions = listOf(getEverywhereToggleAction(), getFilterTypesAction(providersIdToName)) + private val actions = listOf(getEverywhereToggleAction(), PreviewAction(), getFilterTypesAction(providersIdToName)) override fun getHeaderActions(): List = actions private fun getEverywhereToggleAction() = object : CheckBoxSearchEverywhereToggleAction(IdeUICustomization.getInstance().projectMessage("checkbox.include.non.project.items")), AutoToggleAction { diff --git a/platform/searchEverywhere/frontend/src/tabs/classes/SeClassesTab.kt b/platform/searchEverywhere/frontend/src/tabs/classes/SeClassesTab.kt index ce548f0bcb30..44c950c24441 100644 --- a/platform/searchEverywhere/frontend/src/tabs/classes/SeClassesTab.kt +++ b/platform/searchEverywhere/frontend/src/tabs/classes/SeClassesTab.kt @@ -28,7 +28,7 @@ class SeClassesTab(private val delegate: SeTabDelegate) : SeTab { override val isIndexingDependent: Boolean get() = true private val filterEditor: SuspendLazyProperty = initAsync(delegate.scope) { - SeTargetsFilterEditor(delegate.getSearchScopesInfos().firstOrNull(), delegate.getTypeVisibilityStates()) + SeTargetsFilterEditor(delegate.getSearchScopesInfos().firstOrNull(), delegate.getTypeVisibilityStates(), true) } override fun getItems(params: SeParams): Flow = delegate.getItems(params) diff --git a/platform/searchEverywhere/frontend/src/tabs/files/SeFilesTab.kt b/platform/searchEverywhere/frontend/src/tabs/files/SeFilesTab.kt index f133d473ed16..0f8c78925a52 100644 --- a/platform/searchEverywhere/frontend/src/tabs/files/SeFilesTab.kt +++ b/platform/searchEverywhere/frontend/src/tabs/files/SeFilesTab.kt @@ -28,7 +28,7 @@ class SeFilesTab(private val delegate: SeTabDelegate) : SeTab { override val isIndexingDependent: Boolean get() = true private val filterEditor: SuspendLazyProperty = initAsync(delegate.scope) { - SeTargetsFilterEditor(delegate.getSearchScopesInfos().firstOrNull(), delegate.getTypeVisibilityStates()) + SeTargetsFilterEditor(delegate.getSearchScopesInfos().firstOrNull(), delegate.getTypeVisibilityStates(), true) } override fun getItems(params: SeParams): Flow = delegate.getItems(params) diff --git a/platform/searchEverywhere/frontend/src/tabs/symbols/SeSymbolsTab.kt b/platform/searchEverywhere/frontend/src/tabs/symbols/SeSymbolsTab.kt index 11820d4260d3..4fa52e869550 100644 --- a/platform/searchEverywhere/frontend/src/tabs/symbols/SeSymbolsTab.kt +++ b/platform/searchEverywhere/frontend/src/tabs/symbols/SeSymbolsTab.kt @@ -28,7 +28,7 @@ open class SeSymbolsTab(private val delegate: SeTabDelegate) : SeTab { override val isIndexingDependent: Boolean get() = true private val filterEditor: SuspendLazyProperty = initAsync(delegate.scope) { - SeTargetsFilterEditor(delegate.getSearchScopesInfos().firstOrNull(), delegate.getTypeVisibilityStates()) + SeTargetsFilterEditor(delegate.getSearchScopesInfos().firstOrNull(), delegate.getTypeVisibilityStates(), true) } override fun getItems(params: SeParams): Flow = delegate.getItems(params) diff --git a/platform/searchEverywhere/frontend/src/tabs/target/SeTargetsFilterEditor.kt b/platform/searchEverywhere/frontend/src/tabs/target/SeTargetsFilterEditor.kt index b1335b933185..134ba50d6a20 100644 --- a/platform/searchEverywhere/frontend/src/tabs/target/SeTargetsFilterEditor.kt +++ b/platform/searchEverywhere/frontend/src/tabs/target/SeTargetsFilterEditor.kt @@ -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?) : SeFilterEditorBase( +class SeTargetsFilterEditor( + private val scopesInfo: SearchScopesInfo?, + typeVisibilityStates: List?, + private val hasPreviewAction: Boolean, +) : SeFilterEditorBase( SeTargetsFilter(scopesInfo?.selectedScopeId, scopesInfo?.selectedScopeId != scopesInfo?.everywhereScopeId, hiddenTypes(typeVisibilityStates)) @@ -34,7 +38,9 @@ class SeTargetsFilterEditor(private val scopesInfo: SearchScopesInfo?, }.getAction() } - override fun getHeaderActions(): List = listOfNotNull(getScopeFilterAction(), getTypeFilterAction()) + override fun getHeaderActions(): List = listOfNotNull(getScopeFilterAction(), + if (hasPreviewAction) PreviewAction() else null, + getTypeFilterAction()) private fun getScopeFilterAction(): AnAction? { return scopeFilterAction diff --git a/platform/searchEverywhere/frontend/src/tabs/text/SeTextFilterEditor.kt b/platform/searchEverywhere/frontend/src/tabs/text/SeTextFilterEditor.kt index 907f889ffbca..5077f44fc66f 100644 --- a/platform/searchEverywhere/frontend/src/tabs/text/SeTextFilterEditor.kt +++ b/platform/searchEverywhere/frontend/src/tabs/text/SeTextFilterEditor.kt @@ -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 = listOfNotNull(scopeFilterAction, typesFilterAction) + override fun getHeaderActions(): List = listOfNotNull(scopeFilterAction, typesFilterAction, PreviewAction()) override fun getSearchFieldActions(): List = listOf(caseSensitiveAction, wordAction, regexpAction) diff --git a/platform/searchEverywhere/frontend/src/ui/SePopupContentPane.kt b/platform/searchEverywhere/frontend/src/ui/SePopupContentPane.kt index 4fbb75b6d2e7..bed315680fff 100644 --- a/platform/searchEverywhere/frontend/src/ui/SePopupContentPane.kt +++ b/platform/searchEverywhere/frontend/src/ui/SePopupContentPane.kt @@ -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) diff --git a/platform/searchEverywhere/frontend/src/ui/SePopupHeaderPane.kt b/platform/searchEverywhere/frontend/src/ui/SePopupHeaderPane.kt index 916856fd6aeb..f3101b65fd98 100644 --- a/platform/searchEverywhere/frontend/src/ui/SePopupHeaderPane.kt +++ b/platform/searchEverywhere/frontend/src/ui/SePopupHeaderPane.kt @@ -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, showInFindToolWindowAction: AnAction?, isPreviewEnabled: Boolean) { + fun setFilterActions(actions: List, 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)