mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[git-index] add shortcut text to the hover icon tooltips
GitOrigin-RevId: 60886a3dbe05c62982ffc08dd69f944c912d8e8b
This commit is contained in:
committed by
intellij-monorepo-bot
parent
bc329f9aca
commit
d1f31f29e3
@@ -1,7 +1,8 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package git4idea.index.actions
|
||||
|
||||
import com.intellij.icons.AllIcons
|
||||
import com.intellij.openapi.keymap.KeymapUtil
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.NlsActions
|
||||
import com.intellij.openapi.util.NlsContexts
|
||||
@@ -23,6 +24,7 @@ interface StagingAreaOperation {
|
||||
val progressTitle: @NlsContexts.ProgressTitle String
|
||||
val icon: Icon?
|
||||
val errorMessage: @NlsContexts.NotificationContent String
|
||||
val shortcutText: String? get() = null
|
||||
|
||||
fun matches(statusNode: GitFileStatusNode): Boolean
|
||||
|
||||
@@ -35,6 +37,7 @@ object GitAddOperation : StagingAreaOperation {
|
||||
override val progressTitle get() = GitBundle.message("stage.add.process")
|
||||
override val icon = AllIcons.General.Add
|
||||
override val errorMessage: String get() = GitBundle.message("stage.add.error.title")
|
||||
override val shortcutText: String get() = KeymapUtil.getFirstKeyboardShortcutText("Git.Stage.Add")
|
||||
|
||||
override fun matches(statusNode: GitFileStatusNode) = statusNode.kind == NodeKind.UNSTAGED || statusNode.kind == NodeKind.UNTRACKED
|
||||
|
||||
@@ -61,6 +64,7 @@ object GitResetOperation : StagingAreaOperation {
|
||||
override val progressTitle get() = GitBundle.message("stage.reset.process")
|
||||
override val icon = AllIcons.General.Remove
|
||||
override val errorMessage: String get() = GitBundle.message("stage.reset.error.title")
|
||||
override val shortcutText: String get() = KeymapUtil.getFirstKeyboardShortcutText("Git.Stage.Reset")
|
||||
|
||||
override fun matches(statusNode: GitFileStatusNode) = statusNode.kind == NodeKind.STAGED
|
||||
|
||||
|
||||
@@ -11,6 +11,8 @@ import com.intellij.openapi.actionSystem.*
|
||||
import com.intellij.openapi.fileChooser.actions.VirtualFileDeleteProvider
|
||||
import com.intellij.openapi.fileEditor.OpenFileDescriptor
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.text.HtmlBuilder
|
||||
import com.intellij.openapi.util.text.HtmlChunk
|
||||
import com.intellij.openapi.vcs.FilePath
|
||||
import com.intellij.openapi.vcs.FileStatus
|
||||
import com.intellij.openapi.vcs.VcsBundle
|
||||
@@ -20,11 +22,13 @@ import com.intellij.openapi.vcs.changes.UnversionedViewDialog
|
||||
import com.intellij.openapi.vcs.changes.ui.*
|
||||
import com.intellij.openapi.vcs.changes.ui.VcsTreeModelData.allUnder
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.ui.ColorUtil
|
||||
import com.intellij.ui.SimpleTextAttributes
|
||||
import com.intellij.ui.tree.TreeVisitor
|
||||
import com.intellij.util.FontUtil
|
||||
import com.intellij.util.containers.ContainerUtil
|
||||
import com.intellij.util.containers.JBIterable
|
||||
import com.intellij.util.ui.JBUI
|
||||
import com.intellij.util.ui.tree.TreeUtil
|
||||
import git4idea.conflicts.GitConflictsUtil.getConflictType
|
||||
import git4idea.i18n.GitBundle
|
||||
@@ -178,8 +182,18 @@ abstract class GitStageTree(project: Project,
|
||||
}
|
||||
}
|
||||
|
||||
private val StagingAreaOperation.tooltipText: String
|
||||
get() {
|
||||
val shortcut = shortcutText
|
||||
if (shortcut == null) return actionText.get()
|
||||
return HtmlBuilder()
|
||||
.append(actionText.get()).nbsp(2)
|
||||
.append(HtmlChunk.font(ColorUtil.toHex(JBUI.CurrentTheme.Tooltip.shortcutForeground())).addText(shortcut))
|
||||
.wrapWith("html").toString()
|
||||
}
|
||||
|
||||
private inner class GitStageHoverIcon(val operation: StagingAreaOperation)
|
||||
: HoverIcon(operation.icon!!, operation.actionText.get()) {
|
||||
: HoverIcon(operation.icon!!, operation.tooltipText) {
|
||||
override fun invokeAction(node: ChangesBrowserNode<*>) {
|
||||
val nodes = allUnder(node).userObjects(GitFileStatusNode::class.java)
|
||||
performStageOperation(nodes, operation)
|
||||
|
||||
Reference in New Issue
Block a user