private void mousePressedInIconsArea(MouseEvent e) { EditorMessageIconRenderer iconRenderer = getIconRendererUnderMouse(e); if (iconRenderer != null) { if (e.getButton() == MouseEvent.BUTTON3) { JPopupMenu popupMenu = iconRenderer.getPopupMenu(); if (popupMenu != null && e.getID() == MouseEvent.MOUSE_PRESSED) { e.consume(); Component component = e.getComponent(); popupMenu.show(component == null ? myEditorComponent : component, e.getX(), e.getY()); } return; } AnAction action = iconRenderer.getClickAction(); if (e.getButton() == MouseEvent.BUTTON1 && action != null) { if (e.getID() == MouseEvent.MOUSE_CLICKED) { AnActionEvent actionEvent = new AnActionEvent( e, new LeftEditorHighlighterDataContext(myEditorComponent, iconRenderer.getNode()), ICON_AREA, action.getTemplatePresentation(), ActionManager.getInstance(), e.getModifiers()); action.update(actionEvent); action.actionPerformed(actionEvent); } e.consume(); } } }
public static void invokeNamedAction(final String actionId) { final AnAction action = ActionManager.getInstance().getAction(actionId); assertNotNull(action); final Presentation presentation = new Presentation(); @SuppressWarnings("deprecation") final DataContext context = DataManager.getInstance().getDataContext(); final AnActionEvent event = new AnActionEvent(null, context, "", presentation, ActionManager.getInstance(), 0); action.update(event); Assert.assertTrue(presentation.isEnabled()); action.actionPerformed(event); }
public void playBack(DataContext context) { AnAction action = ActionManager.getInstance().getAction(getActionId()); if (action == null) return; Presentation presentation = (Presentation) action.getTemplatePresentation().clone(); AnActionEvent event = new AnActionEvent( null, context, "MACRO_PLAYBACK", presentation, ActionManager.getInstance(), 0); action.beforeActionPerformedUpdate(event); if (!presentation.isEnabled()) { return; } action.actionPerformed(event); }
private void executeAction(final String watch) { AnAction action = ActionManager.getInstance().getAction(watch); Presentation presentation = action.getTemplatePresentation().clone(); DataContext context = DataManager.getInstance().getDataContext(myTreePanel.getTree()); AnActionEvent actionEvent = new AnActionEvent( null, context, ActionPlaces.DEBUGGER_TOOLBAR, presentation, ActionManager.getInstance(), 0); action.actionPerformed(actionEvent); }
public void performAction( final InputEvent e, final AnAction action, final AnActionEvent actionEvent) { e.consume(); action.actionPerformed(actionEvent); if (Registry.is("actionSystem.fixLostTyping")) { IdeEventQueue.getInstance() .doWhenReady( new Runnable() { @Override public void run() { IdeEventQueue.getInstance().getKeyEventDispatcher().resetState(); } }); } }
public static void performReferenceCopy(DataContext dataContext) { ActionManager actionManager = ActionManager.getInstance(); AnAction action = actionManager.getAction(IdeActions.ACTION_COPY_REFERENCE); AnActionEvent event = new AnActionEvent( null, dataContext, "", action.getTemplatePresentation(), ActionManager.getInstance(), 0); action.update(event); Assert.assertTrue(event.getPresentation().isEnabled()); action.actionPerformed(event); }
public static void executeAction( @NotNull Editor editor, @NotNull String actionId, boolean assertActionIsEnabled) { ActionManager actionManager = ActionManager.getInstance(); AnAction action = actionManager.getAction(actionId); assertNotNull(action); DataContext dataContext = createEditorContext(editor); AnActionEvent event = new AnActionEvent( null, dataContext, "", action.getTemplatePresentation(), actionManager, 0); action.beforeActionPerformedUpdate(event); if (!event.getPresentation().isEnabled()) { assertFalse("Action " + actionId + " is disabled", assertActionIsEnabled); return; } action.actionPerformed(event); }
private void performEditAction() { final AnAction action = getEditAction(); if (action != null) { final int row = myInjectionsTable.getSelectedRow(); action.actionPerformed( new AnActionEvent( null, DataManager.getInstance().getDataContext(myInjectionsTable), ActionPlaces.UNKNOWN, new Presentation(""), ActionManager.getInstance(), 0)); myInjectionsTable.getListTableModel().fireTableDataChanged(); myInjectionsTable.getSelectionModel().setSelectionInterval(row, row); updateCountLabel(); } }
/** * @return <code>true</code> if and only if the passed event is already dispatched by the <code> * IdeMouseEventDispatcher</code> and there is no need for any other processing of the event. * If the method returns <code>false</code> then it means that the event should be delivered * to normal event dispatching. */ public boolean dispatchMouseEvent(MouseEvent e) { Component c = e.getComponent(); // frame activation by mouse click if (e.getID() == MOUSE_PRESSED && c instanceof IdeFrame && !c.hasFocus()) { IdeFocusManager focusManager = IdeFocusManager.getGlobalInstance(); if (focusManager instanceof FocusManagerImpl) { Component at = SwingUtilities.getDeepestComponentAt(c, e.getX(), e.getY()); if (at != null && at.isFocusable()) { ((FocusManagerImpl) focusManager).setLastFocusedAtDeactivation((IdeFrame) c, at); } } } if (SystemInfo.isXWindow && e.isPopupTrigger() && e.getButton() != 3) { // we can do better than silly triggering popup on everything but left click resetPopupTrigger(e); } boolean ignore = false; if (!(e.getID() == MouseEvent.MOUSE_PRESSED || e.getID() == MouseEvent.MOUSE_RELEASED || e.getID() == MOUSE_CLICKED)) { ignore = true; } patchClickCount(e); if (e.isConsumed() || e.isPopupTrigger() || (e.getButton() > 3 ? e.getID() != MOUSE_PRESSED : e.getID() != MOUSE_RELEASED) || e.getClickCount() < 1 || e.getButton() == MouseEvent.NOBUTTON) { // See #16995. It did happen ignore = true; } int modifiers = e.getModifiers(); int modifiersEx = e.getModifiersEx(); if (e.getID() == MOUSE_PRESSED) { myPressedModifiersStored = true; myModifiers = modifiers; myModifiersEx = modifiersEx; } else if (e.getID() == MOUSE_RELEASED) { if (myPressedModifiersStored) { myPressedModifiersStored = false; modifiers = myModifiers; modifiersEx = myModifiersEx; } } final JRootPane root = findRoot(e); if (root != null) { BlockState blockState = myRootPane2BlockedId.get(root); if (blockState != null) { if (SWING_EVENTS_PRIORITY.indexOf(blockState.currentEventId) < SWING_EVENTS_PRIORITY.indexOf(e.getID())) { blockState.currentEventId = e.getID(); if (blockState.blockMode == IdeEventQueue.BlockMode.COMPLETE) { return true; } else { ignore = true; } } else { myRootPane2BlockedId.remove(root); } } } if (c == null) { throw new IllegalStateException("component cannot be null"); } c = SwingUtilities.getDeepestComponentAt(c, e.getX(), e.getY()); if (c instanceof IdeGlassPaneImpl) { c = ((IdeGlassPaneImpl) c).getTargetComponentFor(e); } if (c == null) { // do nothing if component doesn't contains specified point return false; } if (isHorizontalScrolling(c, e)) { boolean done = doHorizontalScrolling(c, (MouseWheelEvent) e); if (done) return true; } if (ignore) return false; // avoid "cyclic component initialization error" in case of dialogs shown because of component // initialization failure if (!KeymapManagerImpl.ourKeymapManagerInitialized) { return false; } final MouseShortcut shortcut = new MouseShortcut(e.getButton(), modifiersEx, e.getClickCount()); fillActionsList(c, shortcut, IdeKeyEventDispatcher.isModalContext(c)); ActionManagerEx actionManager = ActionManagerEx.getInstanceEx(); if (actionManager != null) { AnAction[] actions = myActions.toArray(new AnAction[myActions.size()]); for (AnAction action : actions) { DataContext dataContext = DataManager.getInstance().getDataContext(c); Presentation presentation = myPresentationFactory.getPresentation(action); AnActionEvent actionEvent = new AnActionEvent( e, dataContext, ActionPlaces.MAIN_MENU, presentation, ActionManager.getInstance(), modifiers); action.beforeActionPerformedUpdate(actionEvent); if (presentation.isEnabled()) { actionManager.fireBeforeActionPerformed(action, dataContext, actionEvent); final Component context = PlatformDataKeys.CONTEXT_COMPONENT.getData(dataContext); if (context != null && !context.isShowing()) continue; action.actionPerformed(actionEvent); e.consume(); } } if (actions.length > 0 && e.isConsumed()) return true; } return e.getButton() > 3; }
@Override public void actionPerformed(AnActionEvent e) { myAction.actionPerformed(e); }