use of com.intellij.openapi.actionSystem.ex.ActionManagerEx in project intellij-community by JetBrains.
the class MacrosGroup method getChildren.
@NotNull
public AnAction[] getChildren(@Nullable AnActionEvent e) {
ArrayList<AnAction> actions = new ArrayList<>();
final ActionManagerEx actionManager = ((ActionManagerEx) ActionManager.getInstance());
String[] ids = actionManager.getActionIds(ActionMacro.MACRO_ACTION_PREFIX);
for (String id : ids) {
actions.add(actionManager.getAction(id));
}
return actions.toArray(new AnAction[actions.size()]);
}
use of com.intellij.openapi.actionSystem.ex.ActionManagerEx in project intellij-community by JetBrains.
the class ActionButton method performAction.
private void performAction(MouseEvent e) {
AnActionEvent event = AnActionEvent.createFromInputEvent(e, myPlace, myPresentation, getDataContext());
if (!ActionUtil.lastUpdateAndCheckDumb(myAction, event, false)) {
return;
}
if (isButtonEnabled()) {
final ActionManagerEx manager = ActionManagerEx.getInstanceEx();
final DataContext dataContext = event.getDataContext();
manager.fireBeforeActionPerformed(myAction, dataContext, event);
Component component = PlatformDataKeys.CONTEXT_COMPONENT.getData(dataContext);
if (component != null && !component.isShowing()) {
return;
}
actionPerformed(event);
manager.queueActionPerformedEvent(myAction, dataContext, event);
}
}
use of com.intellij.openapi.actionSystem.ex.ActionManagerEx in project intellij-community by JetBrains.
the class EditorTestUtil method executeAction.
public static void executeAction(@NotNull Editor editor, boolean assertActionIsEnabled, @NotNull AnAction action) {
AnActionEvent event = AnActionEvent.createFromAnAction(action, null, "", createEditorContext(editor));
action.beforeActionPerformedUpdate(event);
if (!event.getPresentation().isEnabled()) {
assertFalse("Action " + action + " is disabled", assertActionIsEnabled);
return;
}
ActionManagerEx actionManager = ActionManagerEx.getInstanceEx();
actionManager.fireBeforeActionPerformed(action, event.getDataContext(), event);
action.actionPerformed(event);
actionManager.fireAfterActionPerformed(action, event.getDataContext(), event);
}
use of com.intellij.openapi.actionSystem.ex.ActionManagerEx in project intellij-community by JetBrains.
the class IdeKeyEventDispatcher method processAction.
public boolean processAction(final InputEvent e, @NotNull ActionProcessor processor) {
ActionManagerEx actionManager = ActionManagerEx.getInstanceEx();
final Project project = CommonDataKeys.PROJECT.getData(myContext.getDataContext());
final boolean dumb = project != null && DumbService.getInstance(project).isDumb();
List<AnActionEvent> nonDumbAwareAction = new ArrayList<>();
List<AnAction> actions = myContext.getActions();
for (final AnAction action : actions.toArray(new AnAction[actions.size()])) {
Presentation presentation = myPresentationFactory.getPresentation(action);
// Mouse modifiers are 0 because they have no any sense when action is invoked via keyboard
final AnActionEvent actionEvent = processor.createEvent(e, myContext.getDataContext(), ActionPlaces.MAIN_MENU, presentation, ActionManager.getInstance());
try (AccessToken ignored = ProhibitAWTEvents.start("update")) {
ActionUtil.performDumbAwareUpdate(LaterInvocator.isInModalContext(), action, actionEvent, true);
}
if (dumb && !action.isDumbAware()) {
if (!Boolean.FALSE.equals(presentation.getClientProperty(ActionUtil.WOULD_BE_ENABLED_IF_NOT_DUMB_MODE))) {
nonDumbAwareAction.add(actionEvent);
}
continue;
}
if (!presentation.isEnabled()) {
continue;
}
processor.onUpdatePassed(e, action, actionEvent);
if (myContext.getDataContext() instanceof DataManagerImpl.MyDataContext) {
// this is not true for test data contexts
((DataManagerImpl.MyDataContext) myContext.getDataContext()).setEventCount(IdeEventQueue.getInstance().getEventCount(), this);
}
actionManager.fireBeforeActionPerformed(action, actionEvent.getDataContext(), actionEvent);
Component component = PlatformDataKeys.CONTEXT_COMPONENT.getData(actionEvent.getDataContext());
if (component != null && !component.isShowing()) {
return true;
}
((TransactionGuardImpl) TransactionGuard.getInstance()).performUserActivity(() -> processor.performAction(e, action, actionEvent));
actionManager.fireAfterActionPerformed(action, actionEvent.getDataContext(), actionEvent);
return true;
}
if (!nonDumbAwareAction.isEmpty()) {
showDumbModeWarningLaterIfNobodyConsumesEvent(e, nonDumbAwareAction.toArray(new AnActionEvent[nonDumbAwareAction.size()]));
}
return false;
}
use of com.intellij.openapi.actionSystem.ex.ActionManagerEx in project intellij-community by JetBrains.
the class YYYYYYY method processKeyTyped.
private boolean processKeyTyped(char c) {
// [vova] This is patch for Mac OS X. Under Mac "input methods"
// is handled before our EventQueue consume upcoming KeyEvents.
IdeEventQueue queue = IdeEventQueue.getInstance();
if (queue.shouldNotTypeInEditor() || ProgressManager.getInstance().hasModalProgressIndicator()) {
return false;
}
FileDocumentManager manager = FileDocumentManager.getInstance();
final VirtualFile file = manager.getFile(myDocument);
if (file != null && !file.isValid()) {
return false;
}
ActionManagerEx actionManager = ActionManagerEx.getInstanceEx();
DataContext dataContext = getDataContext();
actionManager.fireBeforeEditorTyping(c, dataContext);
MacUIUtil.hideCursor();
EditorActionManager.getInstance().getTypedAction().actionPerformed(this, c, dataContext);
return true;
}
Aggregations