[git-stash] show stash id in the editor diff preview tab title

GitOrigin-RevId: 1bb33c93ca190a428399db7621c8553201bc40d9
This commit is contained in:
Julia Beliaeva
2022-01-12 18:52:27 +00:00
committed by intellij-monorepo-bot
parent 1ee67d8074
commit a0b085eea2
3 changed files with 14 additions and 11 deletions
@@ -399,7 +399,7 @@ stash.error=Failed to stash {0}
# suppress inspection "UnusedProperty" - used in third-party plugins
stashing.title=Stashing Changes\u2026
stashing.progress.title=Stashing changes\u2026
stash.editor.diff.preview.title=Stash: {0}
stash.editor.diff.preview.id.change.title={0}: {1}
stash.editor.diff.preview.empty.title=Stash
stash.tab.name=Stash
@@ -104,7 +104,9 @@ class GitStashChangesBrowser(project: Project, parentDisposable: Disposable) : C
setData(stash, parents) { statusText -> statusText.text = "" }
}
private fun setData(stash: Collection<Change>, parents: Collection<GitCommit>, updateEmptyText: (StatusText) -> Unit) {
private fun setData(stash: Collection<Change>,
parents: Collection<GitCommit>,
updateEmptyText: (StatusText) -> Unit) {
stashedChanges = stash
otherChanges = parents.associate { parent ->
val tag = MyTag(StringUtil.capitalize(parent.subject.substringBefore(":")), parent.id)
@@ -138,7 +140,14 @@ class GitStashChangesBrowser(project: Project, parentDisposable: Disposable) : C
diffPreviewProcessor = newProcessor
if (isInEditor) {
editorTabPreview = GitStashEditorDiffPreview(newProcessor, viewer, this)
editorTabPreview = object : GitStashEditorDiffPreview(newProcessor, viewer, this@GitStashChangesBrowser) {
override fun getCurrentName(): String {
return changeViewProcessor.currentChangeName?.let { changeName ->
val stashId = currentStash?.stash?.capitalize() ?: GitBundle.message("stash.editor.diff.preview.empty.title")
GitBundle.message("stash.editor.diff.preview.id.change.title", stashId, changeName)
} ?: GitBundle.message("stash.editor.diff.preview.empty.title")
}
}
}
else {
editorTabPreview = null
@@ -1,21 +1,15 @@
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package git4idea.stash.ui
import com.intellij.openapi.vcs.changes.ui.ChangesTree
import com.intellij.openapi.vcs.changes.ui.ChangesViewContentManager
import com.intellij.openapi.vcs.changes.ui.SimpleTreeEditorDiffPreview
import git4idea.i18n.GitBundle
import javax.swing.JComponent
class GitStashEditorDiffPreview(diffProcessor: GitStashDiffPreview, tree: ChangesTree, targetComponent: JComponent)
abstract class GitStashEditorDiffPreview(diffProcessor: GitStashDiffPreview, tree: ChangesTree, targetComponent: JComponent)
: SimpleTreeEditorDiffPreview(diffProcessor, tree, targetComponent, false) {
override fun returnFocusToTree() {
ChangesViewContentManager.getToolWindowFor(project, GitStashContentProvider.TAB_NAME)?.activate(null)
}
override fun getCurrentName(): String {
return changeViewProcessor.currentChangeName?.let { changeName -> GitBundle.message("stash.editor.diff.preview.title", changeName) }
?: GitBundle.message("stash.editor.diff.preview.empty.title")
}
}