mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[platform UI][se] IJPL-182688 Search Everywhere for RD: implement findElementsForPattern
...add warning for changeScope Space-RevId: d3b15b25be60d828acf30c9dfd8cd0a4f598f3fd GitOrigin-RevId: c6f4dcf80a7a6bc7af5ba94107fb0dd4a1970566
This commit is contained in:
committed by
intellij-monorepo-bot
parent
972e0f7d1c
commit
fc9e2c7740
@@ -8,11 +8,13 @@ import com.intellij.ide.actions.searcheverywhere.SplitSearchListener
|
||||
import com.intellij.ide.util.scopeChooser.ScopeDescriptor
|
||||
import com.intellij.openapi.actionSystem.AnAction
|
||||
import com.intellij.openapi.actionSystem.ex.ActionUtil
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.platform.searchEverywhere.frontend.ui.SePopupContentPane
|
||||
import com.intellij.platform.searchEverywhere.frontend.vm.SePopupVm
|
||||
import com.intellij.platform.searchEverywhere.providers.SeLog
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import org.jetbrains.annotations.TestOnly
|
||||
import java.util.concurrent.CompletableFuture
|
||||
import java.util.concurrent.Future
|
||||
import javax.swing.text.Document
|
||||
|
||||
@@ -70,13 +72,37 @@ class SePopupInstance(private val popupVm: SePopupVm,
|
||||
|
||||
@ApiStatus.Internal
|
||||
override fun changeScope(processor: (ScopeDescriptor, List<ScopeDescriptor>) -> ScopeDescriptor?) {
|
||||
TODO("Not yet implemented")
|
||||
SeLog.warn("Changing scope is not supported in the split implementation.")
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
@TestOnly
|
||||
override fun findElementsForPattern(pattern: String): Future<List<Any>> {
|
||||
TODO("Not yet implemented")
|
||||
val future = CompletableFuture<List<Any>>()
|
||||
|
||||
ApplicationManager.getApplication().invokeLater {
|
||||
var listenerToRemove: SplitSearchListener? = null
|
||||
val listener = object: SplitSearchListener {
|
||||
override fun searchStarted(pattern: String, tabId: String) {}
|
||||
override fun elementsAdded(uuidToElement: Map<String, Any>) {}
|
||||
|
||||
override fun searchFinished(count: Int) {
|
||||
if (count < 0) return
|
||||
|
||||
listenerToRemove?.let { combinedListener.removeListener(it) }
|
||||
val results = popupContentPane.currentResultsInList.mapNotNull { it.fetchItemIfExists()?.rawObject }
|
||||
future.complete(results)
|
||||
}
|
||||
}
|
||||
|
||||
listenerToRemove = listener
|
||||
combinedListener.addListener(listener)
|
||||
|
||||
popupContentPane.searchFieldDocument.remove(0, popupContentPane.searchFieldDocument.length)
|
||||
popupContentPane.searchFieldDocument.insertString(0, pattern, null)
|
||||
}
|
||||
|
||||
return future
|
||||
}
|
||||
|
||||
fun saveSearchText() {
|
||||
|
||||
@@ -184,6 +184,9 @@ class SePopupContentPane(
|
||||
|
||||
private var quickDocPopup: JBPopup? = null
|
||||
|
||||
val currentResultsInList: List<SeItemData> get() =
|
||||
resultListModel.elements().iterator().asSequence().mapNotNull { (it as? SeResultListItemRow)?.item }.toList()
|
||||
|
||||
init {
|
||||
layout = GridLayout()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user