mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-05 01:50:56 +07:00
IJPL-149459 IDEA-346408 diff: avoid re-implementing the ToggleAction icon
'isMultiChoice' flag can now be explicitly disabled. GitOrigin-RevId: 9d9b583196cb235e3cb0be241741dc2792529e7b
This commit is contained in:
committed by
intellij-monorepo-bot
parent
3ec904c9e1
commit
51d5167d1b
@@ -261,12 +261,6 @@ f:com.intellij.diff.actions.ShowStandaloneDiffAction
|
||||
- sf:getEP_NAME():com.intellij.openapi.extensions.ExtensionPointName
|
||||
f:com.intellij.diff.actions.ShowStandaloneDiffAction$Companion
|
||||
- f:getEP_NAME():com.intellij.openapi.extensions.ExtensionPointName
|
||||
f:com.intellij.diff.actions.impl.CombinedDiffToggleAction
|
||||
- com.intellij.openapi.project.DumbAwareAction
|
||||
- <init>():V
|
||||
- actionPerformed(com.intellij.openapi.actionSystem.AnActionEvent):V
|
||||
- getActionUpdateThread():com.intellij.openapi.actionSystem.ActionUpdateThread
|
||||
- update(com.intellij.openapi.actionSystem.AnActionEvent):V
|
||||
c:com.intellij.diff.actions.impl.DiffNavigatableArrayRule
|
||||
- com.intellij.ide.impl.dataRules.GetDataRule
|
||||
- <init>():V
|
||||
|
||||
@@ -8,47 +8,30 @@ import com.intellij.diff.util.DiffUserDataKeysEx
|
||||
import com.intellij.icons.AllIcons
|
||||
import com.intellij.openapi.actionSystem.ActionUpdateThread
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.openapi.actionSystem.ToggleAction
|
||||
import com.intellij.openapi.actionSystem.impl.ActionMenu
|
||||
import com.intellij.openapi.actionSystem.impl.ActionMenu.Companion.shouldConvertIconToDarkVariant
|
||||
import com.intellij.openapi.project.DumbAwareAction
|
||||
import com.intellij.openapi.util.IconLoader
|
||||
import com.intellij.util.ui.LafIconLookup
|
||||
import com.intellij.openapi.project.DumbAware
|
||||
|
||||
class CombinedDiffToggleAction : DumbAwareAction() {
|
||||
internal class CombinedDiffToggleAction : ToggleAction(), DumbAware {
|
||||
|
||||
override fun update(e: AnActionEvent) {
|
||||
super.update(e)
|
||||
val diffModeToggle = getDiffModeToggle(e)
|
||||
e.presentation.isEnabledAndVisible = diffModeToggle != null
|
||||
e.presentation.putClientProperty(ActionMenu.SECONDARY_ICON, null)
|
||||
e.presentation.isMultiChoice = false
|
||||
|
||||
diffModeToggle ?: return
|
||||
|
||||
if (diffModeToggle.isCombinedDiffEnabled) {
|
||||
// It impossible to use ToggleAction here because it doesn't close the popup menu
|
||||
// Temporary solution is to add checkmark icon on AnAction
|
||||
//
|
||||
var checkmark = LafIconLookup.getIcon("checkmark")
|
||||
var selectedCheckmark = LafIconLookup.getSelectedIcon("checkmark")
|
||||
if (shouldConvertIconToDarkVariant()) {
|
||||
checkmark = IconLoader.getDarkIcon(checkmark, true)
|
||||
selectedCheckmark = IconLoader.getDarkIcon(selectedCheckmark, true)
|
||||
}
|
||||
e.presentation.icon = checkmark
|
||||
e.presentation.selectedIcon = selectedCheckmark
|
||||
}
|
||||
else {
|
||||
e.presentation.icon = null
|
||||
e.presentation.selectedIcon = null
|
||||
if (CombinedDiffRegistry.showBadge()) {
|
||||
e.presentation.putClientProperty(ActionMenu.SECONDARY_ICON, AllIcons.General.New_badge)
|
||||
}
|
||||
}
|
||||
val needNewBadge = diffModeToggle != null && !diffModeToggle.isCombinedDiffEnabled && CombinedDiffRegistry.showBadge()
|
||||
e.presentation.putClientProperty(ActionMenu.SECONDARY_ICON, if (needNewBadge) AllIcons.General.New_badge else null)
|
||||
}
|
||||
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
override fun isSelected(e: AnActionEvent): Boolean {
|
||||
val diffModeToggle = getDiffModeToggle(e) ?: return false
|
||||
return diffModeToggle.isCombinedDiffEnabled
|
||||
}
|
||||
|
||||
override fun setSelected(e: AnActionEvent, state: Boolean) {
|
||||
val diffModeToggle = getDiffModeToggle(e) ?: return
|
||||
diffModeToggle.isCombinedDiffEnabled = !diffModeToggle.isCombinedDiffEnabled
|
||||
diffModeToggle.isCombinedDiffEnabled = state
|
||||
}
|
||||
|
||||
override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.BGT
|
||||
|
||||
Reference in New Issue
Block a user