move action customization keys to ActionUtil

See
IJPL-157278 Make `ActionMenu.SECONDARY_ICON` public API

GitOrigin-RevId: 2da0f7c6e489169f55ee9ede092a63b14cb3ee71
This commit is contained in:
Gregory.Shrago
2024-06-28 17:20:20 +00:00
committed by intellij-monorepo-bot
parent 69cb70983f
commit be04e5725f
4 changed files with 68 additions and 40 deletions
@@ -1944,10 +1944,15 @@ com.intellij.openapi.actionSystem.ex.ActionPopupMenuListener
- actionPopupMenuReleased(com.intellij.openapi.actionSystem.ActionPopupMenu):V
f:com.intellij.openapi.actionSystem.ex.ActionUtil
- sf:ALLOW_PlAIN_LETTER_SHORTCUTS:com.intellij.openapi.util.Key
- sf:ALWAYS_VISIBLE_GROUP:com.intellij.openapi.util.Key
- sf:HIDE_DROPDOWN_ICON:com.intellij.openapi.util.Key
- sf:INLINE_ACTIONS:com.intellij.openapi.util.Key
- sf:INSTANCE:com.intellij.openapi.actionSystem.ex.ActionUtil
- sf:KEYBOARD_SHORTCUT_SUFFIX:com.intellij.openapi.util.Key
- sf:SEARCH_TAG:com.intellij.openapi.util.Key
- sf:SECONDARY_ICON:com.intellij.openapi.util.Key
- sf:SECONDARY_TEXT:com.intellij.openapi.util.Key
- sf:SUPPRESS_SUBMENU:com.intellij.openapi.util.Key
- sf:clearActions(javax.swing.JComponent):V
- sf:copyFrom(com.intellij.openapi.actionSystem.AnAction,java.lang.String):com.intellij.openapi.actionSystem.AnAction
- sf:copyRegisteredShortcuts(javax.swing.JComponent,javax.swing.JComponent):V
@@ -26,6 +26,7 @@ import com.intellij.openapi.util.Computable
import com.intellij.openapi.util.Key
import com.intellij.openapi.util.NlsActions.ActionText
import com.intellij.openapi.util.NlsContexts
import com.intellij.openapi.util.NlsSafe
import com.intellij.openapi.util.ThrowableComputable
import com.intellij.openapi.util.registry.Registry
import com.intellij.openapi.util.text.StringUtil
@@ -44,6 +45,7 @@ import java.util.*
import java.util.concurrent.TimeUnit
import java.util.function.Consumer
import javax.swing.Action
import javax.swing.Icon
import javax.swing.JComponent
import javax.swing.KeyStroke
@@ -52,6 +54,41 @@ private val InputEventDummyAction = EmptyAction.createEmptyAction(null, null, tr
object ActionUtil {
/**
* By default, a "performable" non-empty popup action group menu item still shows a submenu.
* Use this key to disable the submenu and avoid children expansion on update as follows:
*
* `presentation.putClientProperty(ActionMenu.SUPPRESS_SUBMENU, true)`.
*
* Both ordinary and template presentations are supported.
* @see Presentation.setPerformGroup
*/
@JvmField
val SUPPRESS_SUBMENU: Key<Boolean> = Key.create("SUPPRESS_SUBMENU")
/**
* By default, a toolbar button for a popup action group paints the additional "drop-down-arrow" mark over its icon.
* Use this key to disable the painting of that mark as follows:
*
* `presentation.putClientProperty(ActionButton.HIDE_DROPDOWN_ICON, true)`
*
* Both ordinary and template presentations are supported.
* @see Presentation.setPerformGroup
*/
@JvmField
val HIDE_DROPDOWN_ICON: Key<Boolean> = Key.create("HIDE_DROPDOWN_ICON");
@JvmField
val KEYBOARD_SHORTCUT_SUFFIX: Key<@NlsSafe String> = Key.create("KEYBOARD_SHORTCUT_SUFFIX");
/** The icon that will be placed after the text */
@JvmField
val SECONDARY_ICON: Key<Icon> = Key.create("SECONDARY_ICON")
/** Same as [AlwaysVisibleActionGroup] */
@JvmField
val ALWAYS_VISIBLE_GROUP: Key<Boolean> = Key.create("ALWAYS_VISIBLE_GROUP")
@JvmField
val ALLOW_PlAIN_LETTER_SHORTCUTS: Key<Boolean> = Key.create("ALLOW_PlAIN_LETTER_SHORTCUTS")
@@ -59,25 +96,27 @@ object ActionUtil {
@JvmField
val ALLOW_ACTION_PERFORM_WHEN_HIDDEN: Key<Boolean> = Key.create("ALLOW_ACTION_PERFORM_WHEN_HIDDEN")
@JvmField
@Suppress("DEPRECATION", "removal")
val SECONDARY_TEXT: Key<@Nls String> = Presentation.PROP_VALUE
@JvmField
val SEARCH_TAG: Key<@NonNls String> = Key.create("SEARCH_TAG")
@JvmField
val INLINE_ACTIONS: Key<List<AnAction>> = Key.create("INLINE_ACTIONS")
// Internal keys
@JvmStatic
private val WAS_ENABLED_BEFORE_DUMB = Key.create<Boolean>("WAS_ENABLED_BEFORE_DUMB")
private val WAS_ENABLED_BEFORE_DUMB: Key<Boolean> = Key.create("WAS_ENABLED_BEFORE_DUMB")
@ApiStatus.Internal
@JvmField
val WOULD_BE_ENABLED_IF_NOT_DUMB_MODE: Key<Boolean> = Key.create("WOULD_BE_ENABLED_IF_NOT_DUMB_MODE")
@JvmStatic
private val WOULD_BE_VISIBLE_IF_NOT_DUMB_MODE = Key.create<Boolean>("WOULD_BE_VISIBLE_IF_NOT_DUMB_MODE")
@JvmField
@Suppress("DEPRECATION", "removal")
val SECONDARY_TEXT: Key<@Nls String> = Presentation.PROP_VALUE
@JvmField
val SEARCH_TAG: Key<String?> = Key.create<@NonNls String?>("SEARCH_TAG")
@JvmField
val INLINE_ACTIONS: Key<List<AnAction>> = Key.create("INLINE_ACTIONS")
private val WOULD_BE_VISIBLE_IF_NOT_DUMB_MODE: Key<Boolean> = Key.create("WOULD_BE_VISIBLE_IF_NOT_DUMB_MODE")
@JvmStatic
fun showDumbModeWarning(project: Project?,
@@ -52,17 +52,9 @@ public class ActionButton extends JComponent implements ActionButtonComponent, A
// Contains action IDs which descriptions are permitted for displaying in the ActionButton tooltip
private static final @NonNls Set<String> WHITE_LIST = Set.of("ExternalSystem.ProjectRefreshAction", "LoadConfigurationAction");
/**
* By default, a toolbar button for a popup action group paints additional "drop-down-arrow" mark over its icon.
* Set this key to disable the painting of that mark as follows:
* <p>
* {@code presentation.putClientProperty(ActionButton.HIDE_DROPDOWN_ICON, true)}.
* <p>
* Both ordinary and template presentations are supported.
*
* @see Presentation#setPerformGroup(boolean)
*/
public static final Key<Boolean> HIDE_DROPDOWN_ICON = Key.create("HIDE_DROPDOWN_ICON");
/** @deprecated Use {@link ActionUtil#HIDE_DROPDOWN_ICON} instead */
@Deprecated
public static final Key<Boolean> HIDE_DROPDOWN_ICON = ActionUtil.HIDE_DROPDOWN_ICON;
public static final Key<HelpTooltip> CUSTOM_HELP_TOOLTIP = Key.create("CUSTOM_HELP_TOOLTIP");
@@ -10,6 +10,7 @@ import com.intellij.internal.inspector.UiInspectorContextProvider
import com.intellij.internal.inspector.UiInspectorUtil
import com.intellij.openapi.Disposable
import com.intellij.openapi.actionSystem.*
import com.intellij.openapi.actionSystem.ex.ActionUtil
import com.intellij.openapi.actionSystem.ex.MainMenuPresentationAware
import com.intellij.openapi.actionSystem.impl.ActionPresentationDecorator.decorateTextIfNeeded
import com.intellij.openapi.actionSystem.impl.actionholder.createActionRef
@@ -93,30 +94,21 @@ class ActionMenu constructor(private val context: DataContext?,
}
companion object {
/**
* By default, a "performable" non-empty popup action group menu item still shows a submenu.
* Use this key to disable the submenu and avoid children expansion on update as follows:
*
* `presentation.putClientProperty(ActionMenu.SUPPRESS_SUBMENU, true)`.
*
* Both ordinary and template presentations are supported.
* @see Presentation.setPerformGroup
*/
@Deprecated("Use ActionUtil.SUPPRESS_SUBMENU")
@JvmField
val SUPPRESS_SUBMENU: Key<Boolean> = Key.create("SUPPRESS_SUBMENU")
val SUPPRESS_SUBMENU = ActionUtil.SUPPRESS_SUBMENU
/**
* Same as [AlwaysVisibleActionGroup]
*/
@Deprecated("Use ActionUtil.ALWAYS_VISIBLE_GROUP")
@JvmField
val ALWAYS_VISIBLE: Key<Boolean> = Key.create("ALWAYS_VISIBLE")
val ALWAYS_VISIBLE = ActionUtil.ALWAYS_VISIBLE_GROUP
@Deprecated("Use ActionUtil.KEYBOARD_SHORTCUT_SUFFIX")
@JvmField
val KEYBOARD_SHORTCUT_SUFFIX: Key<@NlsSafe String> = Key.create("keyboardShortcutTextSuffix");
val KEYBOARD_SHORTCUT_SUFFIX = ActionUtil.KEYBOARD_SHORTCUT_SUFFIX
/** The icon that will be placed after the text */
@Deprecated("Use ActionUtil.SECONDARY_ICON")
@JvmField
val SECONDARY_ICON: Key<Icon> = Key.create("SECONDARY_ICON")
val SECONDARY_ICON = ActionUtil.SECONDARY_ICON
@JvmStatic
fun shouldConvertIconToDarkVariant(): Boolean {