public final class ActionUtil
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
ActionUtil.ActionPauses |
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
WOULD_BE_ENABLED_IF_NOT_DUMB_MODE |
Modifier and Type | Method and Description |
---|---|
static boolean |
anyActionFromGroupMatches(ActionGroup group,
boolean processPopupSubGroups,
java.util.function.Predicate<? super AnAction> condition) |
static void |
clearActions(javax.swing.JComponent component) |
static AnAction |
copyFrom(AnAction action,
java.lang.String actionId)
Convenience method for copying properties from a registered action
|
static void |
copyRegisteredShortcuts(javax.swing.JComponent to,
javax.swing.JComponent from) |
static java.awt.event.ActionListener |
createActionListener(java.lang.String actionId,
java.awt.Component component,
java.lang.String place) |
static AnActionEvent |
createEmptyEvent() |
static java.util.List<AnAction> |
getActions(javax.swing.JComponent component) |
static ShortcutSet |
getMnemonicAsShortcut(AnAction action) |
static java.lang.String |
getUnavailableMessage(java.lang.String action,
boolean plural) |
static void |
invokeAction(AnAction action,
java.awt.Component component,
java.lang.String place,
java.awt.event.InputEvent inputEvent,
java.lang.Runnable onDone) |
static void |
invokeAction(AnAction action,
DataContext dataContext,
java.lang.String place,
java.awt.event.InputEvent inputEvent,
java.lang.Runnable onDone) |
static boolean |
isDumbMode(Project project) |
static boolean |
lastUpdateAndCheckDumb(AnAction action,
AnActionEvent e,
boolean visibilityMatters) |
static AnAction |
mergeFrom(AnAction action,
java.lang.String actionId)
Convenience method for merging not null properties from a registered action
|
static void |
moveActionTo(java.util.List<AnAction> list,
java.lang.String actionText,
java.lang.String targetActionText,
boolean before)
Tries to find an 'action' and 'target action' by text and put the 'action' just before of after the 'target action'
|
static void |
performActionDumbAware(AnAction action,
AnActionEvent e) |
static void |
performActionDumbAwareWithCallbacks(AnAction action,
AnActionEvent e,
DataContext context) |
static boolean |
performDumbAwareUpdate(AnAction action,
AnActionEvent e,
boolean beforeActionPerformed)
Deprecated.
|
static boolean |
performDumbAwareUpdate(boolean isInModalContext,
AnAction action,
AnActionEvent e,
boolean beforeActionPerformed) |
static void |
performFastUpdate(boolean isInModalContext,
AnAction action,
AnActionEvent event,
boolean forceUseCached)
Calculates time spent for update,
remember average time (with exponential smoothing) and caches update results inside action.getTemplatePresentation().getClientProperty(ACTION_UPDATE_DATA),
if average time is quite big then skip update invocation and use cached presentation.
|
static boolean |
recursiveContainsAction(ActionGroup group,
AnAction action) |
static void |
recursiveRegisterShortcutSet(ActionGroup group,
javax.swing.JComponent component,
Disposable parentDisposable) |
static void |
registerForEveryKeyboardShortcut(javax.swing.JComponent component,
java.awt.event.ActionListener action,
ShortcutSet shortcuts) |
static void |
showDumbModeWarning(AnActionEvent... events) |
static void |
sortAlphabetically(java.util.List<? extends AnAction> list) |
static <T> T |
underModalProgress(Project project,
java.lang.String progressTitle,
Computable<T> computable)
Show a cancellable modal progress running the given computation under read action with the same
DumbService.isAlternativeResolveEnabled()
as the caller. |
public static final java.lang.String WOULD_BE_ENABLED_IF_NOT_DUMB_MODE
public static void showDumbModeWarning(AnActionEvent... events)
public static java.lang.String getUnavailableMessage(java.lang.String action, boolean plural)
public static void performFastUpdate(boolean isInModalContext, AnAction action, AnActionEvent event, boolean forceUseCached)
forceUseCached
- use cached results for slow actions if presented (relax time doesn't take into account)public static boolean performDumbAwareUpdate(boolean isInModalContext, AnAction action, AnActionEvent e, boolean beforeActionPerformed)
action
- actione
- action eventbeforeActionPerformed
- whether to call
AnAction.beforeActionPerformedUpdate(AnActionEvent)
or
AnAction.update(AnActionEvent)
@Deprecated public static boolean performDumbAwareUpdate(AnAction action, AnActionEvent e, boolean beforeActionPerformed)
performDumbAwareUpdate(boolean, AnAction, AnActionEvent, boolean)
insteadpublic static <T> T underModalProgress(Project project, java.lang.String progressTitle, Computable<T> computable) throws ProcessCanceledException
DumbService.isAlternativeResolveEnabled()
as the caller. To be used in actions which need to perform potentially long-running computations synchronously without freezing UI.ProcessCanceledException
- if the user has canceled the progress. If the action can be safely stopped at this point
without leaving inconsistent data behind, this exception doesn't need to be caught and processed.public static boolean isDumbMode(Project project)
DumbService
public static boolean lastUpdateAndCheckDumb(AnAction action, AnActionEvent e, boolean visibilityMatters)
public static void performActionDumbAwareWithCallbacks(AnAction action, AnActionEvent e, DataContext context)
public static void performActionDumbAware(AnAction action, AnActionEvent e)
public static AnActionEvent createEmptyEvent()
public static void sortAlphabetically(java.util.List<? extends AnAction> list)
public static void moveActionTo(java.util.List<AnAction> list, java.lang.String actionText, java.lang.String targetActionText, boolean before)
public static java.util.List<AnAction> getActions(javax.swing.JComponent component)
public static void clearActions(javax.swing.JComponent component)
public static void copyRegisteredShortcuts(javax.swing.JComponent to, javax.swing.JComponent from)
public static void registerForEveryKeyboardShortcut(javax.swing.JComponent component, java.awt.event.ActionListener action, ShortcutSet shortcuts)
public static void recursiveRegisterShortcutSet(ActionGroup group, javax.swing.JComponent component, Disposable parentDisposable)
public static boolean recursiveContainsAction(ActionGroup group, AnAction action)
public static boolean anyActionFromGroupMatches(ActionGroup group, boolean processPopupSubGroups, java.util.function.Predicate<? super AnAction> condition)
public static AnAction copyFrom(AnAction action, java.lang.String actionId)
actionId
- action idpublic static AnAction mergeFrom(AnAction action, java.lang.String actionId)
action
- action to merge toactionId
- action id to merge frompublic static void invokeAction(AnAction action, java.awt.Component component, java.lang.String place, java.awt.event.InputEvent inputEvent, java.lang.Runnable onDone)
public static void invokeAction(AnAction action, DataContext dataContext, java.lang.String place, java.awt.event.InputEvent inputEvent, java.lang.Runnable onDone)
public static java.awt.event.ActionListener createActionListener(java.lang.String actionId, java.awt.Component component, java.lang.String place)
public static ShortcutSet getMnemonicAsShortcut(AnAction action)