mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 03:21:12 +07:00
CPP-43711: hide floating toolbar on EDT
GitOrigin-RevId: 5cdabd037a8e645c06a9bcd23dd9fdead844c027
This commit is contained in:
committed by
intellij-monorepo-bot
parent
42137002ee
commit
d79b7c14fb
@@ -4,14 +4,15 @@ package com.intellij.openapi.externalSystem.autoimport
|
||||
import com.intellij.openapi.Disposable
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys.PROJECT
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.application.invokeAndWaitIfNeeded
|
||||
import com.intellij.openapi.editor.toolbar.floating.AbstractFloatingToolbarProvider
|
||||
import com.intellij.openapi.editor.toolbar.floating.FloatingToolbarComponent
|
||||
import com.intellij.openapi.editor.toolbar.floating.FloatingToolbarProvider
|
||||
import com.intellij.openapi.editor.toolbar.floating.isInsideMainEditor
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.util.containers.DisposableWrapperList
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
import org.intellij.lang.annotations.Language
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
|
||||
@ApiStatus.Internal
|
||||
internal class ProjectRefreshFloatingProvider : AbstractFloatingToolbarProvider(ACTION_GROUP) {
|
||||
@@ -24,13 +25,21 @@ internal class ProjectRefreshFloatingProvider : AbstractFloatingToolbarProvider(
|
||||
}
|
||||
|
||||
private fun updateToolbarComponents(project: Project) {
|
||||
forEachToolbarComponent(project) {
|
||||
updateToolbarComponent(project, it)
|
||||
// init service outside of EDT if not initialized yet
|
||||
ExternalSystemProjectNotificationAware.getInstance(project)
|
||||
|
||||
invokeAndWaitIfNeeded {
|
||||
for ((componentProject, component) in toolbarComponents) {
|
||||
if (componentProject === project) {
|
||||
updateToolbarComponent(componentProject, component)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateToolbarComponent(project: Project, component: FloatingToolbarComponent) {
|
||||
val notificationAware = ExternalSystemProjectNotificationAware.getInstance(project)
|
||||
|
||||
when (notificationAware.isNotificationVisible()) {
|
||||
true -> component.scheduleShow()
|
||||
else -> component.scheduleHide()
|
||||
@@ -40,15 +49,8 @@ internal class ProjectRefreshFloatingProvider : AbstractFloatingToolbarProvider(
|
||||
override fun register(dataContext: DataContext, component: FloatingToolbarComponent, parentDisposable: Disposable) {
|
||||
val project = dataContext.getData(PROJECT) ?: return
|
||||
toolbarComponents.add(project to component, parentDisposable)
|
||||
updateToolbarComponent(project, component)
|
||||
}
|
||||
|
||||
private fun forEachToolbarComponent(project: Project, consumer: (FloatingToolbarComponent) -> Unit) {
|
||||
for ((componentProject, component) in toolbarComponents) {
|
||||
if (componentProject === project) {
|
||||
consumer(component)
|
||||
}
|
||||
}
|
||||
updateToolbarComponent(project, component)
|
||||
}
|
||||
|
||||
internal class Listener : ExternalSystemProjectNotificationAware.Listener {
|
||||
|
||||
Reference in New Issue
Block a user