Java 类com.intellij.openapi.actionSystem.ex.ActionUtil 实例源码

项目:intellij-ce-playground    文件:IdeKeyEventDispatcher.java   
private static ListPopupStep buildStep(@NotNull final List<Pair<AnAction, KeyStroke>> actions, final DataContext ctx) {
  return new BaseListPopupStep<Pair<AnAction, KeyStroke>>("Choose an action", ContainerUtil.findAll(actions, new Condition<Pair<AnAction, KeyStroke>>() {
    @Override
    public boolean value(Pair<AnAction, KeyStroke> pair) {
      final AnAction action = pair.getFirst();
      final Presentation presentation = action.getTemplatePresentation().clone();
      AnActionEvent event = new AnActionEvent(null, ctx,
                                              ActionPlaces.UNKNOWN,
                                              presentation,
                                              ActionManager.getInstance(),
                                              0);

      ActionUtil.performDumbAwareUpdate(action, event, true);
      return presentation.isEnabled() && presentation.isVisible();
    }
  })) {
    @Override
    public PopupStep onChosen(Pair<AnAction, KeyStroke> selectedValue, boolean finalChoice) {
      invokeAction(selectedValue.getFirst(), ctx);
      return FINAL_CHOICE;
    }
  };
}
项目:intellij-ce-playground    文件:ActionButton.java   
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);
  }
}
项目:intellij-ce-playground    文件:ButtonToolbarImpl.java   
public ActionJButton(final AnAction action) {
  super(action.getTemplatePresentation().getText());
  myAction = action;
  setMnemonic(action.getTemplatePresentation().getMnemonic());
  setDisplayedMnemonicIndex(action.getTemplatePresentation().getDisplayedMnemonicIndex());

  addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      AnActionEvent event = new AnActionEvent(
        null,
        ((DataManagerImpl)myDataManager).getDataContextTest(ButtonToolbarImpl.this),
        myPlace,
        myPresentationFactory.getPresentation(action),
        ActionManager.getInstance(),
        e.getModifiers()
      );
      if (ActionUtil.lastUpdateAndCheckDumb(action, event, false)) {
        ActionUtil.performActionDumbAware(action, event);
      }
    }
  });

}
项目:intellij-ce-playground    文件:Utils.java   
private static boolean doUpdate(final AnAction action, final AnActionEvent e, final Presentation presentation) throws ProcessCanceledException {
  if (ApplicationManager.getApplication().isDisposed()) return false;

  long startTime = System.currentTimeMillis();
  final boolean result;
  try {
    result = !ActionUtil.performDumbAwareUpdate(action, e, false);
  }
  catch (ProcessCanceledException ex) {
    throw ex;
  }
  catch (Throwable exc) {
    handleUpdateException(action, presentation, exc);
    return false;
  }
  long endTime = System.currentTimeMillis();
  if (endTime - startTime > 10 && LOG.isDebugEnabled()) {
    LOG.debug("Action " + action + ": updated in " + (endTime-startTime) + " ms");
  }
  return result;
}
项目:intellij-ce-playground    文件:SearchEverywhereAction.java   
protected boolean isEnabled(final AnAction action) {
  if (myDisabledActions.contains(action)) return false;
  final AnActionEvent e = new AnActionEvent(myActionEvent.getInputEvent(),
                                            myActionEvent.getDataContext(),
                                            myActionEvent.getPlace(),
                                            action.getTemplatePresentation().clone(),
                                            myActionEvent.getActionManager(),
                                            myActionEvent.getModifiers());

  UIUtil.invokeAndWaitIfNeeded(new Runnable() {
    @Override
    public void run() {
      ActionUtil.performDumbAwareUpdate(action, e, false);
    }
  });
  final Presentation presentation = e.getPresentation();
  final boolean enabled = presentation.isEnabled() && presentation.isVisible() && !StringUtil.isEmpty(presentation.getText());
  if (!enabled) {
    myDisabledActions.add(action);
  }
  return enabled;
}
项目:tools-idea    文件:IdeKeyEventDispatcher.java   
private static ListPopupStep buildStep(@NotNull final List<Pair<AnAction, KeyStroke>> actions, final DataContext ctx) {
  return new BaseListPopupStep<Pair<AnAction, KeyStroke>>("Choose an action", ContainerUtil.findAll(actions, new Condition<Pair<AnAction, KeyStroke>>() {
    @Override
    public boolean value(Pair<AnAction, KeyStroke> pair) {
      final AnAction action = pair.getFirst();
      final Presentation presentation = action.getTemplatePresentation().clone();
      AnActionEvent event = new AnActionEvent(null, ctx,
                                              ActionPlaces.UNKNOWN,
                                              presentation,
                                              ActionManager.getInstance(),
                                              0);

      ActionUtil.performDumbAwareUpdate(action, event, true);
      return presentation.isEnabled() && presentation.isVisible();
    }
  })) {
    @Override
    public PopupStep onChosen(Pair<AnAction, KeyStroke> selectedValue, boolean finalChoice) {
      invokeAction(selectedValue.getFirst(), ctx);
      return FINAL_CHOICE;
    }
  };
}
项目:tools-idea    文件:ActionButton.java   
private void performAction(MouseEvent e) {
  AnActionEvent event = new AnActionEvent(
    e, getDataContext(),
    myPlace,
    myPresentation,
    ActionManager.getInstance(),
    e.getModifiers()
  );
  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);
  }
}
项目:tools-idea    文件:ButtonToolbarImpl.java   
public ActionJButton(final AnAction action) {
  super(action.getTemplatePresentation().getText());
  myAction = action;
  setMnemonic(action.getTemplatePresentation().getMnemonic());
  setDisplayedMnemonicIndex(action.getTemplatePresentation().getDisplayedMnemonicIndex());

  addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      AnActionEvent event = new AnActionEvent(
        null,
        ((DataManagerImpl)myDataManager).getDataContextTest(ButtonToolbarImpl.this),
        myPlace,
        myPresentationFactory.getPresentation(action),
        ActionManager.getInstance(),
        e.getModifiers()
      );
      if (ActionUtil.lastUpdateAndCheckDumb(action, event, false)) {
        ActionUtil.performActionDumbAware(action, event);
      }
    }
  });

}
项目:tools-idea    文件:Utils.java   
private static boolean doUpdate(final AnAction action, final AnActionEvent e, final Presentation presentation) throws ProcessCanceledException {
  if (ApplicationManager.getApplication().isDisposed()) return false;

  long startTime = System.currentTimeMillis();
  final boolean result;
  try {
    result = !ActionUtil.performDumbAwareUpdate(action, e, false);
  }
  catch (ProcessCanceledException ex) {
    throw ex;
  }
  catch (Throwable exc) {
    handleUpdateException(action, presentation, exc);
    return false;
  }
  long endTime = System.currentTimeMillis();
  if (endTime - startTime > 10 && LOG.isDebugEnabled()) {
    LOG.debug("Action " + action + ": updated in " + (endTime-startTime) + " ms");
  }
  return result;
}
项目:consulo    文件:ThreesideDiffViewer.java   
public ShowPartialDiffAction(@Nonnull PartialDiffMode mode) {
  String id;
  switch (mode) {
    case LEFT_BASE:
      mySide1 = ThreeSide.LEFT;
      mySide2 = ThreeSide.BASE;
      id = "Diff.ComparePartial.Base.Left";
      break;
    case BASE_RIGHT:
      mySide1 = ThreeSide.BASE;
      mySide2 = ThreeSide.RIGHT;
      id = "Diff.ComparePartial.Base.Right";
      break;
    case LEFT_RIGHT:
      mySide1 = ThreeSide.LEFT;
      mySide2 = ThreeSide.RIGHT;
      id = "Diff.ComparePartial.Left.Right";
      break;
    default:
      throw new IllegalArgumentException();
  }
  ActionUtil.copyFrom(this, id);
}
项目:consulo    文件:ActionGroupUtil.java   
private static boolean isActionEnabledAndVisible(@Nonnull final AnActionEvent e,
                                                 @Nonnull final Map<AnAction, Presentation> action2presentation,
                                                 @Nonnull final AnAction action,
                                                 boolean isInModalContext) {
  Presentation presentation = getPresentation(action, action2presentation);
  AnActionEvent event = new AnActionEvent(e.getInputEvent(),
                                          e.getDataContext(),
                                          ActionPlaces.UNKNOWN,
                                          presentation,
                                          ActionManager.getInstance(),
                                          e.getModifiers());
  event.setInjectedContext(action.isInInjectedContext());
  ActionUtil.performDumbAwareUpdate(isInModalContext, action, event, false);

  return presentation.isEnabled() && presentation.isVisible();
}
项目:consulo    文件:ActionLink.java   
public ActionLink(String text, Icon icon, @Nonnull AnAction action, @Nullable final Runnable onDone) {
  super(text, icon);
  setListener(new LinkListener() {
    @Override
    public void linkSelected(LinkLabel aSource, Object aLinkData) {
      final Presentation presentation = myAction.getTemplatePresentation().clone();
      final AnActionEvent event = new AnActionEvent(myEvent,
                                                    DataManager.getInstance().getDataContext(ActionLink.this),
                                                    myPlace,
                                                    presentation,
                                                    ActionManager.getInstance(),
                                                    0);
      ActionUtil.performDumbAwareUpdate(false, myAction, event, true);
      if (event.getPresentation().isEnabled() && event.getPresentation().isVisible()) {
        myAction.actionPerformed(event);
        if (onDone != null) {
          onDone.run();
        }
      }
    }
  }, null);
  myAction = action;
}
项目:consulo    文件:Notification.java   
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);
  }
}
项目:consulo    文件:IdeKeyEventDispatcher.java   
@Override
public void performAction(@Nonnull InputEvent e, @Nonnull AnAction action, @Nonnull AnActionEvent actionEvent) {
  e.consume();

  DataContext ctx = actionEvent.getDataContext();
  if (action instanceof ActionGroup && !((ActionGroup)action).canBePerformed(ctx)) {
    ActionGroup group = (ActionGroup)action;
    JBPopupFactory.getInstance().createActionGroupPopup(group.getTemplatePresentation().getText(), group, ctx, JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, false).showInBestPositionFor(ctx);
  }
  else {
    ActionUtil.performActionDumbAware(action, actionEvent);
  }

  if (Registry.is("actionSystem.fixLostTyping")) {
    IdeEventQueue.getInstance().doWhenReady(() -> IdeEventQueue.getInstance().getKeyEventDispatcher().resetState());
  }
}
项目:consulo    文件:IdeKeyEventDispatcher.java   
private static ListPopupStep buildStep(@Nonnull final List<Pair<AnAction, KeyStroke>> actions, final DataContext ctx) {
  return new BaseListPopupStep<Pair<AnAction, KeyStroke>>("Choose an action", ContainerUtil.findAll(actions, pair -> {
    final AnAction action = pair.getFirst();
    final Presentation presentation = action.getTemplatePresentation().clone();
    AnActionEvent event = new AnActionEvent(null, ctx, ActionPlaces.UNKNOWN, presentation, ActionManager.getInstance(), 0);

    ActionUtil.performDumbAwareUpdate(LaterInvocator.isInModalContext(), action, event, true);
    return presentation.isEnabled() && presentation.isVisible();
  })) {
    @Override
    public PopupStep onChosen(Pair<AnAction, KeyStroke> selectedValue, boolean finalChoice) {
      invokeAction(selectedValue.getFirst(), ctx);
      return FINAL_CHOICE;
    }
  };
}
项目:consulo    文件:FrameWrapper.java   
private void addCloseOnEsc(final RootPaneContainer frame) {
  JRootPane rootPane = frame.getRootPane();
  ActionListener closeAction = new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      if (!PopupUtil.handleEscKeyEvent()) {
        // if you remove this line problems will start happen on Mac OS X
        // 2 projects opened, call Cmd+D on the second opened project and then Esc.
        // Weird situation: 2nd IdeFrame will be active, but focus will be somewhere inside the 1st IdeFrame
        // App is unusable until Cmd+Tab, Cmd+tab
        FrameWrapper.this.myFrame.setVisible(false);
        close();
      }
    }
  };
  rootPane.registerKeyboardAction(closeAction, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);
  ActionUtil.registerForEveryKeyboardShortcut(rootPane, closeAction, CommonShortcuts.getCloseActiveWindow());
}
项目:consulo    文件:ActionButton.java   
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);
    }
  }
}
项目:consulo    文件:ButtonToolbarImpl.java   
public ActionJButton(final AnAction action) {
  super(action.getTemplatePresentation().getText());
  myAction = action;
  setMnemonic(action.getTemplatePresentation().getMnemonic());
  setDisplayedMnemonicIndex(action.getTemplatePresentation().getDisplayedMnemonicIndex());

  addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      AnActionEvent event = new AnActionEvent(
        null,
        ((DataManagerImpl)myDataManager).getDataContextTest(ButtonToolbarImpl.this),
        myPlace,
        myPresentationFactory.getPresentation(action),
        ActionManager.getInstance(),
        e.getModifiers()
      );
      if (ActionUtil.lastUpdateAndCheckDumb(action, event, false)) {
        ActionUtil.performActionDumbAware(action, event);
      }
    }
  });

}
项目:consulo    文件:Utils.java   
private static boolean doUpdate(boolean isInModalContext, final AnAction action, final AnActionEvent e, final Presentation presentation)
        throws ProcessCanceledException {
  if (ApplicationManager.getApplication().isDisposed()) return false;

  long startTime = System.currentTimeMillis();
  final boolean result;
  try {
    result = !ActionUtil.performDumbAwareUpdate(isInModalContext, action, e, false);
  }
  catch (ProcessCanceledException ex) {
    throw ex;
  }
  catch (Throwable exc) {
    handleUpdateException(action, presentation, exc);
    return false;
  }
  long endTime = System.currentTimeMillis();
  if (endTime - startTime > 10 && LOG.isDebugEnabled()) {
    LOG.debug("Action " + action + ": updated in " + (endTime - startTime) + " ms");
  }
  return result;
}
项目:consulo    文件:EditorImpl.java   
private static boolean isMouseActionEvent(@Nonnull MouseEvent e, String actionId) {
  KeymapManager keymapManager = KeymapManager.getInstance();
  if (keymapManager == null) return false;
  Keymap keymap = keymapManager.getActiveKeymap();
  if (keymap == null) return false;
  MouseShortcut mouseShortcut = KeymapUtil.createMouseShortcut(e);
  String[] mappedActions = keymap.getActionIds(mouseShortcut);
  if (!ArrayUtil.contains(actionId, mappedActions)) return false;
  if (mappedActions.length < 2) 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;
}
项目:MissingInActions    文件:ActionSelectionAdjuster.java   
@SuppressWarnings("WeakerAccess")
public void runAction(AnAction action, boolean autoTriggered) {
    AnActionEvent event = createAnEvent(action, autoTriggered);
    Editor editor = EDITOR.getData(event.getDataContext());
    if (editor == myEditor) {
        beforeActionPerformed(action, event.getDataContext(), event);
        ActionUtil.performActionDumbAware(action, event);
        afterActionPerformed(action, event.getDataContext(), event);
    }
}
项目:intellij-ce-playground    文件:ActionGroupUtil.java   
private static boolean isActionEnabledAndVisible(@NotNull final AnActionEvent e,
                                                 @NotNull final Map<AnAction, Presentation> action2presentation,
                                                 @NotNull final AnAction action) {
  Presentation presentation = getPresentation(action, action2presentation);
  AnActionEvent event = new AnActionEvent(e.getInputEvent(),
                                          e.getDataContext(),
                                          ActionPlaces.UNKNOWN,
                                          presentation,
                                          ActionManager.getInstance(),
                                          e.getModifiers());
  event.setInjectedContext(action.isInInjectedContext());
  ActionUtil.performDumbAwareUpdate(action, event, false);

  return presentation.isEnabled() && presentation.isVisible();
}
项目:intellij-ce-playground    文件:IdeKeyEventDispatcher.java   
private static void showDumbModeWarningLaterIfNobodyConsumesEvent(final InputEvent e, final AnActionEvent... actionEvents) {
  if (ModalityState.current() == ModalityState.NON_MODAL) {
      ApplicationManager.getApplication().invokeLater(new Runnable() {
        @Override
        public void run() {
          if (e.isConsumed()) return;

          ActionUtil.showDumbModeWarning(actionEvents);
        }
      });
    }
}
项目:intellij-ce-playground    文件:IdeKeyEventDispatcher.java   
private static void invokeAction(@NotNull final AnAction action, final DataContext ctx) {
  ApplicationManager.getApplication().invokeLater(new Runnable() {
    @Override
    public void run() {
      final AnActionEvent event =
        new AnActionEvent(null, ctx, ActionPlaces.UNKNOWN, action.getTemplatePresentation().clone(),
                          ActionManager.getInstance(), 0);
      if (ActionUtil.lastUpdateAndCheckDumb(action, event, true)) {
        ActionUtil.performActionDumbAware(action, event);
      }
    }
  });
}
项目:intellij-ce-playground    文件:ActionButton.java   
private void actionPerformed(final AnActionEvent event) {
  if (myAction instanceof ActionGroup && !(myAction instanceof CustomComponentAction) && ((ActionGroup)myAction).isPopup()) {
    final ActionManagerImpl am = (ActionManagerImpl)ActionManager.getInstance();
    ActionPopupMenuImpl popupMenu = (ActionPopupMenuImpl)am.createActionPopupMenu(event.getPlace(), (ActionGroup)myAction, new MenuItemPresentationFactory() {
      @Override
      protected void processPresentation(Presentation presentation) {
        if (myNoIconsInPopup) {
          presentation.setIcon(null);
          presentation.setHoveredIcon(null);
        }
      }
    });
    popupMenu.setDataContextProvider(new Getter<DataContext>() {
      @Override
      public DataContext get() {
        return ActionButton.this.getDataContext();
      }
    });
    if (ActionPlaces.isToolbarPlace(event.getPlace())) {
      popupMenu.getComponent().show(this, 0, getHeight());
    }
    else {
      popupMenu.getComponent().show(this, getWidth(), 0);
    }

  } else {
    ActionUtil.performActionDumbAware(myAction, event);
  }
}
项目:intellij-ce-playground    文件:ActionButton.java   
public void addNotify() {
  super.addNotify();
  if (myActionButtonSynchronizer == null) {
    myActionButtonSynchronizer = new ActionButtonSynchronizer();
    myPresentation.addPropertyChangeListener(myActionButtonSynchronizer);
  }
  AnActionEvent e = new AnActionEvent(null, getDataContext(), myPlace, myPresentation, ActionManager.getInstance(), 0);
  ActionUtil.performDumbAwareUpdate(myAction, e, false);
  updateToolTipText();
  updateIcon();
}
项目:intellij-ce-playground    文件:PopupFactoryImpl.java   
@NotNull
private Presentation updateActionItem(@NotNull ActionItem actionItem) {
  AnAction action = actionItem.getAction();
  Presentation presentation = new Presentation();
  presentation.setDescription(action.getTemplatePresentation().getDescription());

  final AnActionEvent actionEvent =
    new AnActionEvent(null, DataManager.getInstance().getDataContext(myComponent), myActionPlace, presentation,
                      ActionManager.getInstance(), 0);
  actionEvent.setInjectedContext(action.isInInjectedContext());
  ActionUtil.performDumbAwareUpdate(action, actionEvent, false);
  return presentation;
}
项目:intellij-ce-playground    文件:PopupFactoryImpl.java   
public void performAction(@NotNull AnAction action, int modifiers) {
  final DataManager mgr = DataManager.getInstance();
  final DataContext dataContext = myContext != null ? mgr.getDataContext(myContext) : mgr.getDataContext();
  final AnActionEvent event = new AnActionEvent(null, dataContext, ActionPlaces.UNKNOWN, action.getTemplatePresentation().clone(),
                                                ActionManager.getInstance(), modifiers);
  event.setInjectedContext(action.isInInjectedContext());
  if (ActionUtil.lastUpdateAndCheckDumb(action, event, false)) {
    action.actionPerformed(event);
  }
}
项目:intellij-ce-playground    文件:XEvaluateInConsoleFromEditorActionHandler.java   
@Nullable
public static ConsoleExecuteAction getConsoleExecuteAction(@Nullable ConsoleView consoleView) {
  if (!(consoleView instanceof LanguageConsoleView)) {
    return null;
  }

  List<AnAction> actions = ActionUtil.getActions(((LanguageConsoleView)consoleView).getConsoleEditor().getComponent());
  ConsoleExecuteAction action = ContainerUtil.findInstance(actions, ConsoleExecuteAction.class);
  return action == null || !action.isEnabled() ? null : action;
}
项目:intellij-ce-playground    文件:LineStatusTrackerDrawing.java   
@NotNull
private static ActionToolbar buildToolbar(@NotNull Range range,
                                          @NotNull Editor editor,
                                          @NotNull LineStatusTracker tracker,
                                          @NotNull Disposable parentDisposable) {
  final DefaultActionGroup group = new DefaultActionGroup();

  final ShowPrevChangeMarkerAction localShowPrevAction = new ShowPrevChangeMarkerAction(tracker.getPrevRange(range), tracker, editor);
  final ShowNextChangeMarkerAction localShowNextAction = new ShowNextChangeMarkerAction(tracker.getNextRange(range), tracker, editor);
  final RollbackLineStatusRangeAction rollback = new RollbackLineStatusRangeAction(tracker, range, editor);
  final ShowLineStatusRangeDiffAction showDiff = new ShowLineStatusRangeDiffAction(tracker, range, editor);
  final CopyLineStatusRangeAction copyRange = new CopyLineStatusRangeAction(tracker, range);

  group.add(localShowPrevAction);
  group.add(localShowNextAction);
  group.add(rollback);
  group.add(showDiff);
  group.add(copyRange);

  JComponent editorComponent = editor.getComponent();
  EmptyAction.setupAction(localShowPrevAction, "VcsShowPrevChangeMarker", editorComponent);
  EmptyAction.setupAction(localShowNextAction, "VcsShowNextChangeMarker", editorComponent);
  EmptyAction.setupAction(rollback, IdeActions.SELECTED_CHANGES_ROLLBACK, editorComponent);
  EmptyAction.setupAction(showDiff, "ChangesView.Diff", editorComponent);
  EmptyAction.setupAction(copyRange, IdeActions.ACTION_COPY, editorComponent);

  final List<AnAction> actionList = ActionUtil.getActions(editorComponent);
  Disposer.register(parentDisposable, new Disposable() {
    @Override
    public void dispose() {
      actionList.remove(localShowPrevAction);
      actionList.remove(localShowNextAction);
      actionList.remove(rollback);
      actionList.remove(showDiff);
      actionList.remove(copyRange);
    }
  });

  return ActionManager.getInstance().createActionToolbar(ActionPlaces.FILEHISTORY_VIEW_TOOLBAR, group, true);
}
项目:intellij-ce-playground    文件:GotoActionAction.java   
public static void performAction(Object element, @Nullable final Component component, @Nullable final AnActionEvent e) {
  // element could be AnAction (SearchEverywhere)
  final AnAction action = element instanceof AnAction ? (AnAction)element : ((GotoActionModel.ActionWrapper)element).getAction();
  ApplicationManager.getApplication().invokeLater(new Runnable() {
    @Override
    public void run() {
      if (component == null) return;
      DataManager instance = DataManager.getInstance();
      DataContext context = instance != null ? instance.getDataContext(component) : DataContext.EMPTY_CONTEXT;
      InputEvent inputEvent = e == null ? null : e.getInputEvent();
      AnActionEvent event = AnActionEvent.createFromAnAction(action, inputEvent, ActionPlaces.ACTION_SEARCH, context);

      if (ActionUtil.lastUpdateAndCheckDumb(action, event, false)) {
        if (action instanceof ActionGroup && ((ActionGroup)action).getChildren(event).length > 0) {
          ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(
            event.getPresentation().getText(), (ActionGroup)action, context, JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, false);
          Window window = SwingUtilities.getWindowAncestor(component);
          if (window != null) {
            popup.showInCenterOf(window);
          }
          else {
            popup.showInFocusCenter();
          }
        } 
        else {
          ActionUtil.performActionDumbAware(action, event);
        }
      }
    }
  }, ModalityState.NON_MODAL);
}
项目:tools-idea    文件:ActionGroupUtil.java   
private static boolean isActionEnabledAndVisible(@NotNull final AnActionEvent e,
                                                 @NotNull final Map<AnAction, Presentation> action2presentation,
                                                 @NotNull final AnAction action) {
  Presentation presentation = getPresentation(action, action2presentation);
  AnActionEvent event = new AnActionEvent(e.getInputEvent(),
                                          e.getDataContext(),
                                          ActionPlaces.UNKNOWN,
                                          presentation,
                                          ActionManager.getInstance(),
                                          e.getModifiers());
  event.setInjectedContext(action.isInInjectedContext());
  ActionUtil.performDumbAwareUpdate(action, event, false);

  return presentation.isEnabled() && presentation.isVisible();
}
项目:tools-idea    文件:IdeKeyEventDispatcher.java   
private static void showDumbModeWarningLaterIfNobodyConsumesEvent(final InputEvent e, final AnActionEvent... actionEvents) {
  if (ModalityState.current() == ModalityState.NON_MODAL) {
      ApplicationManager.getApplication().invokeLater(new Runnable() {
        @Override
        public void run() {
          if (e.isConsumed()) return;

          ActionUtil.showDumbModeWarning(actionEvents);
        }
      });
    }
}
项目:tools-idea    文件:IdeKeyEventDispatcher.java   
private static void invokeAction(@NotNull final AnAction action, final DataContext ctx) {
  ApplicationManager.getApplication().invokeLater(new Runnable() {
    @Override
    public void run() {
      final AnActionEvent event =
        new AnActionEvent(null, ctx, ActionPlaces.UNKNOWN, action.getTemplatePresentation().clone(),
                          ActionManager.getInstance(), 0);
      if (ActionUtil.lastUpdateAndCheckDumb(action, event, true)) {
        ActionUtil.performActionDumbAware(action, event);
      }
    }
  });
}
项目:tools-idea    文件:ActionButton.java   
private void actionPerformed(final AnActionEvent event) {
  if (myAction instanceof ActionGroup && !(myAction instanceof CustomComponentAction) && ((ActionGroup)myAction).isPopup()) {
    final ActionManagerImpl am = (ActionManagerImpl)ActionManager.getInstance();
    ActionPopupMenuImpl popupMenu = (ActionPopupMenuImpl)am.createActionPopupMenu(event.getPlace(), (ActionGroup)myAction, new MenuItemPresentationFactory() {
      @Override
      protected Presentation processPresentation(Presentation presentation) {
        if (myNoIconsInPopup) {
          presentation.setIcon(null);
          presentation.setHoveredIcon(null);
        }
        return presentation;
      }
    });
    popupMenu.setDataContextProvider(new Getter<DataContext>() {
      @Override
      public DataContext get() {
        return ActionButton.this.getDataContext();
      }
    });
    if (ActionPlaces.isToolbarPlace(event.getPlace())) {
      popupMenu.getComponent().show(this, 0, getHeight());
    }
    else {
      popupMenu.getComponent().show(this, getWidth(), 0);
    }

  } else {
    ActionUtil.performActionDumbAware(myAction, event);
  }
}
项目:tools-idea    文件:GotoActionModel.java   
public static AnActionEvent updateActionBeforeShow(AnAction anAction, DataContext dataContext) {
  final AnActionEvent event = new AnActionEvent(null, dataContext,
                                                ActionPlaces.UNKNOWN, new Presentation(), ActionManager.getInstance(),
                                                0);
  ActionUtil.performDumbAwareUpdate(anAction, event, false);
  ActionUtil.performDumbAwareUpdate(anAction, event, true);
  return event;
}
项目:consulo    文件:MergeRequestProcessor.java   
@RequiredDispatchThread
private void destroyViewer() {
  Disposer.dispose(myViewer);

  ActionUtil.clearActions(myMainPanel);

  myContentPanel.setContent(null);
  myToolbarPanel.setContent(null);
  myToolbarStatusPanel.setContent(null);
  myCloseHandler = null;
  myBottomActions = null;
}
项目:consulo    文件:DiffRequestProcessor.java   
@RequiredDispatchThread
private void doApplyRequest(@Nonnull DiffRequest request, boolean force, @javax.annotation.Nullable ScrollToPolicy scrollToChangePolicy) {
  if (!force && request == myActiveRequest) return;

  request.putUserData(DiffUserDataKeysEx.SCROLL_TO_CHANGE, scrollToChangePolicy);

  boolean hadFocus = isFocused();

  myState.destroy();
  myToolbarStatusPanel.setContent(null);
  myToolbarPanel.setContent(null);
  myContentPanel.setContent(null);
  ActionUtil.clearActions(myMainPanel);

  myActiveRequest.onAssigned(false);
  myActiveRequest = request;
  myActiveRequest.onAssigned(true);

  try {
    myState = createState();
    myState.init();
  }
  catch (Throwable e) {
    LOG.error(e);
    myState = new ErrorState(new ErrorDiffRequest("Error: can't show diff"), getFittedTool());
    myState.init();
  }

  if (hadFocus) requestFocusInternal();
}
项目:consulo    文件:ActionButton.java   
@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);
  }
}
项目:consulo    文件:IdeKeyEventDispatcher.java   
private static void showDumbModeWarningLaterIfNobodyConsumesEvent(final InputEvent e, final AnActionEvent... actionEvents) {
  if (ModalityState.current() == ModalityState.NON_MODAL) {
    ApplicationManager.getApplication().invokeLater(() -> {
      if (e.isConsumed()) return;

      ActionUtil.showDumbModeWarning(actionEvents);
    });
  }
}