Java Code Examples for com.intellij.openapi.actionSystem.ex.ActionUtil#lastUpdateAndCheckDumb()

The following examples show how to use com.intellij.openapi.actionSystem.ex.ActionUtil#lastUpdateAndCheckDumb() . 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: Notification.java    From consulo with Apache License 2.0 6 votes vote down vote up
public static void fire(@Nonnull final Notification notification, @Nonnull AnAction action, @Nullable DataContext context) {
  AnActionEvent event = AnActionEvent.createFromAnAction(action, null, ActionPlaces.UNKNOWN, new DataContext() {
    @Nullable
    @Override
    @SuppressWarnings("unchecked")
    public <T> T getData(@Nonnull Key<T> dataId) {
      if (KEY == dataId) {
        return (T)notification;
      }
      return context == null ? null : context.getData(dataId);
    }
  });

  if (ActionUtil.lastUpdateAndCheckDumb(action, event, false)) {
    ActionUtil.performActionDumbAware(action, event);
  }
}
 
Example 2
Source File: ActionButton.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void performAction(MouseEvent e) {
  AnActionEvent event = AnActionEvent.createFromInputEvent(e, myPlace, myPresentation, getDataContext(), false, true);
  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 = dataContext.getData(PlatformDataKeys.CONTEXT_COMPONENT);
    if (component != null && !component.isShowing()) {
      return;
    }
    actionPerformed(event);
    manager.queueActionPerformedEvent(myAction, dataContext, event);
    if (event.getInputEvent() instanceof MouseEvent) {
      //FIXME [VISTALL] we need that ?ToolbarClicksCollector.record(myAction, myPlace);
    }
  }
}
 
Example 3
Source File: DesktopEditorImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
private static boolean isMouseActionEvent(@Nonnull MouseEvent e, String actionId) {
  KeymapManager keymapManager = KeymapManager.getInstance();
  if (keymapManager == null) return false;
  Keymap keymap = keymapManager.getActiveKeymap();
  MouseShortcut mouseShortcut = KeymapUtil.createMouseShortcut(e);
  String[] mappedActions = keymap.getActionIds(mouseShortcut);
  if (!ArrayUtil.contains(actionId, mappedActions)) return false;
  if (mappedActions.length < 2 || e.getID() == MouseEvent.MOUSE_DRAGGED /* 'normal' actions are not invoked on mouse drag */) return true;
  ActionManager actionManager = ActionManager.getInstance();
  for (String mappedActionId : mappedActions) {
    if (actionId.equals(mappedActionId)) continue;
    AnAction action = actionManager.getAction(mappedActionId);
    AnActionEvent actionEvent = AnActionEvent.createFromAnAction(action, e, ActionPlaces.MAIN_MENU, DataManager.getInstance().getDataContext(e.getComponent()));
    if (ActionUtil.lastUpdateAndCheckDumb(action, actionEvent, false)) return false;
  }
  return true;
}
 
Example 4
Source File: ContentTabLabel.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
protected void execute(final MouseEvent e) {

  Optional<Runnable> first = myAdditionalIcons.stream().filter(icon -> mouseOverIcon(icon)).map(icon -> icon.getAction()).findFirst();

  if (first.isPresent()) {
    first.get().run();
    return;
  }

  selectContent();

  if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1 && !myLayout.myDoubleClickActions.isEmpty()) {
    DataContext dataContext = DataManager.getInstance().getDataContext(ContentTabLabel.this);
    for (AnAction action : myLayout.myDoubleClickActions) {
      AnActionEvent event = AnActionEvent.createFromInputEvent(e, ActionPlaces.UNKNOWN, null, dataContext);
      if (ActionUtil.lastUpdateAndCheckDumb(action, event, false)) {
        ActionManagerEx.getInstanceEx().fireBeforeActionPerformed(action, dataContext, event);
        ActionUtil.performActionDumbAware(action, event);
      }
    }
  }
}
 
Example 5
Source File: ActionButton.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void actionPerformed(final ActionEvent e) {
  AnActionEvent event = createAnEvent(null, e.getModifiers());
  if (event != null && ActionUtil.lastUpdateAndCheckDumb(myAction, event, true)) {
    ActionUtil.performActionDumbAware(myAction, event);
  }
}
 
Example 6
Source File: ActionPopupStep.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void performAction(@Nonnull AnAction action, int modifiers, InputEvent inputEvent) {
  DataContext dataContext = myContext.get();
  AnActionEvent event = new AnActionEvent(inputEvent, dataContext, myActionPlace, action.getTemplatePresentation().clone(), ActionManager.getInstance(), modifiers);
  event.setInjectedContext(action.isInInjectedContext());
  if (ActionUtil.lastUpdateAndCheckDumb(action, event, false)) {
    ActionUtil.performActionDumbAwareWithCallbacks(action, event, dataContext);
  }
}