mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-15 02:59:33 +07:00
PY-59098 PY-52618 Package(fix): Show loading panel of packages
GitOrigin-RevId: c02550b976ec859bddb72313d9fbfd8ea8447a51
This commit is contained in:
committed by
intellij-monorepo-bot
parent
08f643e0c7
commit
d41f745ce8
@@ -112,6 +112,7 @@ class PyPackagingToolWindowPanel(private val project: Project) : SimpleToolWindo
|
||||
|
||||
val actionGroup = DefaultActionGroup()
|
||||
actionGroup.add(DumbAwareAction.create(message("python.toolwindow.packages.reload.repositories.action"), AllIcons.Actions.Refresh) {
|
||||
startLoadingSdk()
|
||||
moduleController.rebuildList()
|
||||
service.reloadPackages()
|
||||
})
|
||||
@@ -207,6 +208,11 @@ class PyPackagingToolWindowPanel(private val project: Project) : SimpleToolWindo
|
||||
this.packageListController.selectPackage(name)
|
||||
}
|
||||
|
||||
fun startLoadingSdk() {
|
||||
this.descriptionController.setPackage(null)
|
||||
packageListController.startSdkInit()
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val HORIZONTAL_SPLITTER_KEY = "Python.PackagingToolWindow.Horizontal"
|
||||
private const val VERTICAL_SPLITTER_KEY = "Python.PackagingToolWindow.Vertical"
|
||||
|
||||
@@ -4,6 +4,7 @@ package com.jetbrains.python.packaging.toolwindow
|
||||
import com.intellij.notification.NotificationGroupManager
|
||||
import com.intellij.notification.NotificationType
|
||||
import com.intellij.openapi.Disposable
|
||||
import com.intellij.openapi.application.EDT
|
||||
import com.intellij.openapi.application.readAction
|
||||
import com.intellij.openapi.components.Service
|
||||
import com.intellij.openapi.components.service
|
||||
@@ -121,12 +122,24 @@ class PyPackagingToolWindowService(val project: Project, val serviceScope: Corou
|
||||
}
|
||||
|
||||
internal suspend fun initForSdk(sdk: Sdk?) {
|
||||
if (sdk == currentSdk)
|
||||
return
|
||||
|
||||
withContext(Dispatchers.EDT) {
|
||||
toolWindowPanel?.startLoadingSdk()
|
||||
}
|
||||
val previousSdk = currentSdk
|
||||
currentSdk = sdk
|
||||
if (sdk == null) {
|
||||
return
|
||||
}
|
||||
manager = PythonPackageManager.forSdk(project, currentSdk!!)
|
||||
manager.repositoryManager.initCaches()
|
||||
manager.reloadPackages()
|
||||
|
||||
if (currentSdk != null && currentSdk != previousSdk) {
|
||||
manager = PythonPackageManager.forSdk(project, currentSdk!!)
|
||||
manager.repositoryManager.initCaches()
|
||||
manager.reloadPackages()
|
||||
|
||||
|
||||
}
|
||||
withContext(Dispatchers.Main) {
|
||||
toolWindowPanel?.contentVisible = currentSdk != null
|
||||
|
||||
@@ -5,13 +5,18 @@ import com.intellij.openapi.Disposable
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.projectRoots.Sdk
|
||||
import com.intellij.openapi.ui.SimpleToolWindowPanel.LEFT_ALIGNMENT
|
||||
import com.intellij.ui.AnimatedIcon
|
||||
import com.intellij.ui.ScrollPaneFactory
|
||||
import com.intellij.ui.SimpleTextAttributes
|
||||
import com.intellij.ui.components.JBPanelWithEmptyText
|
||||
import com.intellij.util.ui.UIUtil
|
||||
import com.jetbrains.python.PyBundle.message
|
||||
import com.jetbrains.python.packaging.toolwindow.PyPackagingTablesView
|
||||
import com.jetbrains.python.packaging.toolwindow.PyPackagingToolWindowPanel
|
||||
import com.jetbrains.python.packaging.toolwindow.model.DisplayablePackage
|
||||
import com.jetbrains.python.packaging.toolwindow.model.InstalledPackage
|
||||
import com.jetbrains.python.packaging.toolwindow.model.PyPackagesViewData
|
||||
import java.awt.BorderLayout
|
||||
import javax.swing.BoxLayout
|
||||
import javax.swing.JPanel
|
||||
|
||||
@@ -24,16 +29,31 @@ class PyPackagesListController(val project: Project, val controller: PyPackaging
|
||||
|
||||
private val tablesView = PyPackagingTablesView(project, packageListPanel, controller)
|
||||
|
||||
val component = ScrollPaneFactory.createScrollPane(packageListPanel, true)
|
||||
val scrollingPackageListComponent = ScrollPaneFactory.createScrollPane(packageListPanel, true)
|
||||
|
||||
private val loadingPanel = JBPanelWithEmptyText().apply {
|
||||
emptyText.appendLine(AnimatedIcon.Default.INSTANCE, message("python.toolwindow.packages.description.panel.loading"), SimpleTextAttributes.SIMPLE_CELL_ATTRIBUTES, null)
|
||||
}
|
||||
|
||||
|
||||
val component = JPanel().apply {
|
||||
layout = BorderLayout()
|
||||
}
|
||||
|
||||
init {
|
||||
setLoadingState(true)
|
||||
}
|
||||
|
||||
override fun dispose() {}
|
||||
|
||||
fun showSearchResult(installed: List<InstalledPackage>, repoData: List<PyPackagesViewData>) {
|
||||
tablesView.showSearchResult(installed, repoData)
|
||||
setLoadingState(false)
|
||||
}
|
||||
|
||||
fun resetSearch(installed: List<InstalledPackage>, repos: List<PyPackagesViewData>, currentSdk: Sdk?) {
|
||||
tablesView.resetSearch(installed, repos, currentSdk)
|
||||
setLoadingState(false)
|
||||
}
|
||||
|
||||
fun selectPackage(name: String) {
|
||||
@@ -43,4 +63,20 @@ class PyPackagesListController(val project: Project, val controller: PyPackaging
|
||||
fun getSelectedPackages(): List<DisplayablePackage> {
|
||||
return tablesView.getSelectedPackages()
|
||||
}
|
||||
|
||||
fun startSdkInit() {
|
||||
setLoadingState(true)
|
||||
}
|
||||
|
||||
private fun setLoadingState(isLoading: Boolean) {
|
||||
val newPanel = if (isLoading) loadingPanel else scrollingPackageListComponent
|
||||
|
||||
val currentComponent = component.components.firstOrNull()
|
||||
if (currentComponent != newPanel) {
|
||||
component.removeAll()
|
||||
component.add(newPanel)
|
||||
component.revalidate()
|
||||
component.repaint()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user