Java Code Examples for com.intellij.openapi.actionSystem.ex.ActionManagerEx#fireAfterActionPerformed()
The following examples show how to use
com.intellij.openapi.actionSystem.ex.ActionManagerEx#fireAfterActionPerformed() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CodeInsightTestFixtureImpl.java From consulo with Apache License 2.0 | 6 votes |
private boolean _performEditorAction(String actionId) { final DataContext dataContext = getEditorDataContext(); ActionManagerEx managerEx = ActionManagerEx.getInstanceEx(); AnAction action = managerEx.getAction(actionId); AnActionEvent event = new AnActionEvent(null, dataContext, ActionPlaces.UNKNOWN, new Presentation(), managerEx, 0); action.update(event); if (!event.getPresentation().isEnabled()) { return false; } managerEx.fireBeforeActionPerformed(action, dataContext, event); action.actionPerformed(event); managerEx.fireAfterActionPerformed(action, dataContext, event); return true; }
Example 2
Source File: IdeKeyEventDispatcher.java From consulo with Apache License 2.0 | 4 votes |
public boolean processAction(final InputEvent e, @Nonnull ActionProcessor processor) { ActionManagerEx actionManager = ActionManagerEx.getInstanceEx(); final Project project = myContext.getDataContext().getData(CommonDataKeys.PROJECT); 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 BaseDataManager.DataContextWithEventCount) { // this is not true for test data contexts ((BaseDataManager.DataContextWithEventCount)myContext.getDataContext()).setEventCount(IdeEventQueue.getInstance().getEventCount(), this); } actionManager.fireBeforeActionPerformed(action, actionEvent.getDataContext(), actionEvent); Component component = actionEvent.getData(PlatformDataKeys.CONTEXT_COMPONENT); if (component != null && !component.isShowing()) { return true; } ((TransactionGuardEx)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; }