mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[git-index] display progress during refresh
GitOrigin-RevId: 55a0b9da60f68596b6432c39634cb0bb9d50788f
This commit is contained in:
committed by
intellij-monorepo-bot
parent
95203a6b6a
commit
a6f2c944cd
@@ -42,7 +42,7 @@ abstract class BaseSingleTaskController<Request, Result>(name: String, resultCon
|
||||
}
|
||||
}
|
||||
|
||||
protected open fun createProgressIndicator() = EmptyProgressIndicator()
|
||||
protected open fun createProgressIndicator(): ProgressIndicator = EmptyProgressIndicator()
|
||||
|
||||
abstract fun process(requests: List<Request>, previousResult: Result?): Result
|
||||
}
|
||||
|
||||
@@ -563,6 +563,7 @@ stage.tree.node.unstaged=Not staged for commit
|
||||
stage.tree.node.unmerged=Unmerged
|
||||
stage.tree.node.untracked=Untracked
|
||||
stage.tree.node.ignored=Ignored
|
||||
stage.loading.status=Loading changes...
|
||||
|
||||
branches.selected.branches.updated.title=Selected {0,choice,1#branch|2#branches} Updated
|
||||
branches.update.failed=Update Failed
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
package git4idea.index
|
||||
|
||||
import com.intellij.openapi.Disposable
|
||||
import com.intellij.openapi.progress.ProgressIndicator
|
||||
import com.intellij.openapi.progress.util.ProgressIndicatorBase
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.vcs.FilePath
|
||||
import com.intellij.openapi.vcs.ProjectLevelVcsManager
|
||||
@@ -19,7 +21,6 @@ import com.intellij.vcs.log.runInEdt
|
||||
import git4idea.GitVcs
|
||||
import git4idea.repo.GitRepositoryManager
|
||||
import git4idea.repo.GitUntrackedFilesHolder
|
||||
import org.jetbrains.annotations.NotNull
|
||||
import java.util.*
|
||||
import kotlin.collections.HashSet
|
||||
|
||||
@@ -27,6 +28,9 @@ class GitStageTracker(val project: Project) : Disposable {
|
||||
private val eventDispatcher = EventDispatcher.create(GitStageTrackerListener::class.java)
|
||||
private val singleTaskController = MySingleTaskController()
|
||||
|
||||
var isRefreshInProgress = false
|
||||
private set
|
||||
|
||||
@Volatile
|
||||
var state: State = State(emptyMap())
|
||||
|
||||
@@ -63,7 +67,7 @@ class GitStageTracker(val project: Project) : Disposable {
|
||||
scheduleUpdateRoots(gitRoots())
|
||||
}
|
||||
|
||||
private fun scheduleUpdateRoots(roots: List<@NotNull VirtualFile>): Boolean {
|
||||
private fun scheduleUpdateRoots(roots: List<VirtualFile>): Boolean {
|
||||
if (roots.isNotEmpty()) {
|
||||
singleTaskController.request(Request(roots))
|
||||
return true
|
||||
@@ -121,9 +125,31 @@ class GitStageTracker(val project: Project) : Disposable {
|
||||
val newState = State(gitState)
|
||||
return previousState?.updatedWith(newState) ?: newState
|
||||
}
|
||||
|
||||
override fun createProgressIndicator(): ProgressIndicator = MyProgressIndicator()
|
||||
}
|
||||
|
||||
private inner class MyProgressIndicator : ProgressIndicatorBase() {
|
||||
override fun start() {
|
||||
super.start()
|
||||
runInEdt(this@GitStageTracker) {
|
||||
isRefreshInProgress = true
|
||||
eventDispatcher.multicaster.progressStarted()
|
||||
}
|
||||
}
|
||||
|
||||
override fun stop() {
|
||||
super.stop()
|
||||
runInEdt(this@GitStageTracker) {
|
||||
eventDispatcher.multicaster.progressStopped()
|
||||
isRefreshInProgress = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
interface GitStageTrackerListener : EventListener {
|
||||
fun update()
|
||||
fun progressStarted() = Unit
|
||||
fun progressStopped() = Unit
|
||||
}
|
||||
@@ -3,12 +3,15 @@ package git4idea.index.ui
|
||||
|
||||
import com.intellij.openapi.Disposable
|
||||
import com.intellij.openapi.actionSystem.*
|
||||
import com.intellij.openapi.progress.util.ProgressWindow
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.Disposer
|
||||
import com.intellij.openapi.vcs.changes.ui.ChangesTree
|
||||
import com.intellij.openapi.vcs.changes.ui.TreeActionsToolbarPanel
|
||||
import com.intellij.ui.ScrollPaneFactory
|
||||
import com.intellij.ui.SideBorder
|
||||
import com.intellij.vcs.log.ui.frame.ProgressStripe
|
||||
import git4idea.i18n.GitBundle
|
||||
import git4idea.index.GitStageTracker
|
||||
import git4idea.index.GitStageTrackerListener
|
||||
import java.awt.BorderLayout
|
||||
@@ -21,6 +24,7 @@ internal class GitStagePanel(private val tracker: GitStageTracker, disposablePar
|
||||
private val project = tracker.project
|
||||
|
||||
private val tree: GitStageTree
|
||||
private val progressStripe: ProgressStripe
|
||||
|
||||
private val state: GitStageTracker.State
|
||||
get() = tracker.state
|
||||
@@ -38,10 +42,15 @@ internal class GitStagePanel(private val tracker: GitStageTracker, disposablePar
|
||||
toolbar.setTargetComponent(tree)
|
||||
|
||||
val scrolledTree = ScrollPaneFactory.createScrollPane(tree, SideBorder.TOP)
|
||||
progressStripe = ProgressStripe(scrolledTree, this, ProgressWindow.DEFAULT_PROGRESS_DIALOG_POSTPONE_TIME_MILLIS)
|
||||
add(toolbar.component, BorderLayout.NORTH)
|
||||
add(scrolledTree, BorderLayout.CENTER)
|
||||
add(progressStripe, BorderLayout.CENTER)
|
||||
|
||||
tracker.addListener(MyGitStageTrackerListener(), this)
|
||||
if (tracker.isRefreshInProgress) {
|
||||
tree.setEmptyText(GitBundle.message("stage.loading.status"))
|
||||
progressStripe.startLoadingImmediately()
|
||||
}
|
||||
tracker.scheduleUpdateAll()
|
||||
|
||||
Disposer.register(disposableParent, this)
|
||||
@@ -68,5 +77,15 @@ internal class GitStagePanel(private val tracker: GitStageTracker, disposablePar
|
||||
override fun update() {
|
||||
this@GitStagePanel.update()
|
||||
}
|
||||
|
||||
override fun progressStarted() {
|
||||
tree.setEmptyText(GitBundle.message("stage.loading.status"))
|
||||
progressStripe.startLoading()
|
||||
}
|
||||
|
||||
override fun progressStopped() {
|
||||
progressStripe.stopLoading()
|
||||
tree.setEmptyText("")
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user