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; }
private boolean _performEditorAction(@NotNull String actionId) { final DataContext dataContext = getEditorDataContext(); final ActionManagerEx managerEx = ActionManagerEx.getInstanceEx(); final AnAction action = managerEx.getAction(actionId); final AnActionEvent event = new AnActionEvent(null, dataContext, ActionPlaces.UNKNOWN, new Presentation(), managerEx, 0); return WriteCommandAction.runWriteCommandAction(getProject(), new Computable<Boolean>() { @Override public Boolean compute() { action.update(event); if (!event.getPresentation().isEnabled()) { return false; } managerEx.fireBeforeActionPerformed(action, dataContext, event); action.actionPerformed(event); managerEx.fireAfterActionPerformed(action, dataContext, event); return true; } }); }
private void run(KeyEvent event) { myIsRunningAction = true; try { ActionManagerEx actionManager = ActionManagerEx.getInstanceEx(); AnAction action = actionManager.getAction(myActionId); DataContext context = DataManager.getInstance().getDataContext(IdeFocusManager.findInstance().getFocusOwner()); AnActionEvent anActionEvent = AnActionEvent.createFromAnAction(action, event, ActionPlaces.MAIN_MENU, context); actionManager.fireBeforeActionPerformed(action, anActionEvent.getDataContext(), anActionEvent); action.actionPerformed(anActionEvent); actionManager.fireAfterActionPerformed(action, anActionEvent.getDataContext(), anActionEvent); } finally { myIsRunningAction = false; } }
private static Group createQuickListsGroup(final Condition<AnAction> filtered, final String filter, final boolean forceFiltering, final QuickList[] quickLists) { Arrays.sort(quickLists, new Comparator<QuickList>() { public int compare(QuickList l1, QuickList l2) { return l1.getActionId().compareTo(l2.getActionId()); } }); Group group = new Group(KeyMapBundle.message("quick.lists.group.title"), null, null); for (QuickList quickList : quickLists) { if (filtered != null && filtered.value(ActionManagerEx.getInstanceEx().getAction(quickList.getActionId()))) { group.addQuickList(quickList); } else if (SearchUtil.isComponentHighlighted(quickList.getName(), filter, forceFiltering, null)) { group.addQuickList(quickList); } else if (filtered == null && StringUtil.isEmpty(filter)) { group.addQuickList(quickList); } } return group; }
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); } }
public ButtonToolbarImpl(final String place, @NotNull ActionGroup actionGroup, DataManager dataManager, ActionManagerEx actionManager) { super(new GridBagLayout()); myPlace = place; myPresentationFactory = new PresentationFactory(); myDataManager = dataManager; initButtons(actionGroup); updateActions(); // actionManager.addTimerListener(500, new WeakTimerListener(actionManager, new MyTimerListener())); enableEvents(MouseEvent.MOUSE_MOTION_EVENT_MASK | MouseEvent.MOUSE_EVENT_MASK); }
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(); myImmediatePainter.paintCharacter(myEditorComponent.getGraphics(), c); actionManager.fireBeforeEditorTyping(c, dataContext); MacUIUtil.hideCursor(); EditorActionManager.getInstance().getTypedAction().actionPerformed(this, c, dataContext); return true; }
public static void showRerunNotification(@Nullable RunContentDescriptor contentToReuse, @NotNull final ExecutionConsole executionConsole) { if (contentToReuse == null) { return; } String lastActionId = ActionManagerEx.getInstanceEx().getPrevPreformedActionId(); boolean showNotification = !RerunTestsAction.ID.equals(lastActionId); if (showNotification && !PropertiesComponent.getInstance().isTrueValue(KEY)) { UiNotifyConnector.doWhenFirstShown(executionConsole.getComponent(), new Runnable() { @Override public void run() { doShow(executionConsole); } }); } }
@Before public void setUp() { MockApplication application = new MyMockApplicationEx(parent); ActionManagerEx manager = Mockito.mock(ActionManagerEx.class); ActionToolbar actionToolbar = Mockito.mock(ActionToolbar.class); Mockito.when(actionToolbar.getComponent()).thenReturn(new JComponent() {}); Mockito.when( manager.createActionToolbar( Mockito.anyString(), Mockito.any(ActionGroup.class), Mockito.anyBoolean())) .thenReturn(actionToolbar); Mockito.when( manager.createActionToolbar( Mockito.anyString(), Mockito.any(ActionGroup.class), Mockito.anyBoolean(), Mockito.anyBoolean())) .thenReturn(actionToolbar); application.addComponent(ActionManager.class, manager); application.registerService(UISettings.class); ApplicationManager.setApplication(application, parent); XDebugSession session = Mockito.mock(XDebugSession.class); Mockito.when(handler.getProcess()).thenReturn(mockProcess); Mockito.when(mockProcess.getXDebugSession()).thenReturn(session); }
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; }
public void actionPerformed(final ActionEvent e) { AnAction action = myAlternativeAction != null && (e.getModifiers() & InputEvent.ALT_MASK) == InputEvent.ALT_MASK ? myAlternativeAction : myAction; final DataContext dataContext = DataManager.getInstance().getDataContext(this); final ActionManagerEx actionManager = ActionManagerEx.getInstanceEx(); InputEvent inputEvent = e.getSource() instanceof InputEvent ? (InputEvent) e.getSource() : null; final AnActionEvent event = new AnActionEvent(inputEvent, dataContext, ActionPlaces.UNKNOWN, action.getTemplatePresentation(), ActionManager.getInstance(), 0); actionManager.fireBeforeActionPerformed(action, dataContext, event); final Component component = PlatformDataKeys.CONTEXT_COMPONENT.getData(dataContext); if (component != null && !component.isShowing()) { return; } action.actionPerformed(event); }
private static Group createQuickListsGroup(final Condition<AnAction> filtered, final String filter, final boolean forceFiltering, final QuickList[] quickLists) { Arrays.sort(quickLists, new Comparator<QuickList>() { public int compare(QuickList l1, QuickList l2) { return l1.getActionId().compareTo(l2.getActionId()); } }); Group group = new Group(KeyMapBundle.message("quick.lists.group.title"), null, null); for (QuickList quickList : quickLists) { if (filtered != null && filtered.value(ActionManagerEx.getInstanceEx().getAction(quickList.getActionId()))) { group.addQuickList(quickList); } else if (SearchUtil.isComponentHighlighted(quickList.getDisplayName(), filter, forceFiltering, null)) { group.addQuickList(quickList); } else if (filtered == null && StringUtil.isEmpty(filter)) { group.addQuickList(quickList); } } return group; }
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); } }
public ButtonToolbarImpl(final String place, final ActionGroup actionGroup, DataManager dataManager, ActionManagerEx actionManager) { super(new GridBagLayout()); myPlace = place; myPresentationFactory = new PresentationFactory(); myDataManager = dataManager; initButtons(actionGroup); updateActions(); // actionManager.addTimerListener(500, new WeakTimerListener(actionManager, new MyTimerListener())); enableEvents(MouseEvent.MOUSE_MOTION_EVENT_MASK | MouseEvent.MOUSE_EVENT_MASK); }
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(); if (manager != null) { 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; }
public IdeMenuBar(ActionManagerEx actionManager, DataManager dataManager) { myActionManager = actionManager; myTimerListener = new MyTimerListener(); myVisibleActions = new ArrayList<AnAction>(); myNewVisibleActions = new ArrayList<AnAction>(); myPresentationFactory = new MenuItemPresentationFactory(); myDataManager = dataManager; if (WindowManagerEx.getInstanceEx().isFloatingMenuBarSupported()) { myAnimator = new MyAnimator(); myActivationWatcher = new Timer(100, new MyActionListener()); myClockPanel = new ClockPanel(); myButton = new MyExitFullScreenButton(); add(myClockPanel); add(myButton); addPropertyChangeListener(WindowManagerEx.FULL_SCREEN, evt -> updateState()); addMouseListener(new MyMouseListener()); } else { myAnimator = null; myActivationWatcher = null; myClockPanel = null; myButton = null; } }
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); } } }
private ActionToolbar createToolbar(final ActionGroup group) { final ActionToolbarImpl actionToolbar = new ActionToolbarImpl(ActionPlaces.CONTEXT_TOOLBAR, group, true, DataManager.getInstance(), ActionManagerEx.getInstanceEx(), KeymapManagerEx.getInstanceEx()) { @Override protected ActionButton createToolbarButton(final AnAction action, boolean minimalMode, boolean decorateButtons, final String place, final Presentation presentation, final Dimension minimumSize) { final ActionButton result = new ActionButton(action, presentation, place, minimumSize); result.setMinimalMode(minimalMode); result.setDecorateButtons(decorateButtons); return result; } }; actionToolbar.setTargetComponent(myEditor.getContentComponent()); return actionToolbar; }
@Override @RequiredDispatchThread public void actionPerformed(final ActionEvent e) { AnAction action = myAlternativeAction != null && BitUtil.isSet(e.getModifiers(), InputEvent.ALT_MASK) ? myAlternativeAction : myAction; final DataContext dataContext = DataManager.getInstance().getDataContext(this); final ActionManagerEx actionManager = ActionManagerEx.getInstanceEx(); InputEvent inputEvent = e.getSource() instanceof InputEvent ? (InputEvent) e.getSource() : null; final AnActionEvent event = new AnActionEvent(inputEvent, dataContext, ActionPlaces.TOOLWINDOW_TITLE, action.getTemplatePresentation(), ActionManager.getInstance(), 0); actionManager.fireBeforeActionPerformed(action, dataContext, event); final Component component = dataContext.getData(PlatformDataKeys.CONTEXT_COMPONENT); if (component != null && !component.isShowing()) { return; } action.actionPerformed(event); }
@Override public void beforeActionPerformed(AnAction action, DataContext dataContext, AnActionEvent event) { if (action instanceof ActionToIgnore) return; AnAction escapeAction = ActionManagerEx.getInstanceEx().getAction(IdeActions.ACTION_EDITOR_ESCAPE); if (action == escapeAction) return; hideHints(HIDE_BY_ANY_KEY, false, false); }
public void actionPerformed(final ActionEvent e) { AnAction action = myAlternativeAction != null && BitUtil.isSet(e.getModifiers(), InputEvent.ALT_MASK) ? myAlternativeAction : myAction; final DataContext dataContext = DataManager.getInstance().getDataContext(this); final ActionManagerEx actionManager = ActionManagerEx.getInstanceEx(); InputEvent inputEvent = e.getSource() instanceof InputEvent ? (InputEvent) e.getSource() : null; final AnActionEvent event = AnActionEvent.createFromAnAction(action, inputEvent, ActionPlaces.TOOLWINDOW_TITLE, dataContext); actionManager.fireBeforeActionPerformed(action, dataContext, event); final Component component = PlatformDataKeys.CONTEXT_COMPONENT.getData(dataContext); if (component != null && !component.isShowing()) { return; } action.actionPerformed(event); }
public IdeMenuBar(ActionManagerEx actionManager, DataManager dataManager) { myActionManager = actionManager; myTimerListener = new MyTimerListener(); myVisibleActions = new ArrayList<AnAction>(); myNewVisibleActions = new ArrayList<AnAction>(); myPresentationFactory = new MenuItemPresentationFactory(); myDataManager = dataManager; if (WindowManagerImpl.isFloatingMenuBarSupported()) { myAnimator = new MyAnimator(); myActivationWatcher = new Timer(100, new MyActionListener()); myClockPanel = new ClockPanel(); myButton = new MyExitFullScreenButton(); add(myClockPanel); add(myButton); addPropertyChangeListener(WindowManagerImpl.FULL_SCREEN, new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { updateState(); } }); addMouseListener(new MyMouseListener()); } else { myAnimator = null; myActivationWatcher = null; myClockPanel = null; myButton = null; } }
public IdeRootPane(ActionManagerEx actionManager, UISettings uiSettings, DataManager dataManager, Application application, final IdeFrame frame) { myActionManager = actionManager; myUISettings = uiSettings; myContentPane.add(myNorthPanel, BorderLayout.NORTH); myStatusBarCustomComponentFactories = application.getExtensions(StatusBarCustomComponentFactory.EP_NAME); myApplication = application; createStatusBar(frame); updateStatusBarVisibility(); updateToolbar(); myContentPane.add(myStatusBar, BorderLayout.SOUTH); if (WindowManagerImpl.isFloatingMenuBarSupported()) { menuBar = new IdeMenuBar(actionManager, dataManager); getLayeredPane().add(menuBar, new Integer(JLayeredPane.DEFAULT_LAYER - 1)); if (frame instanceof IdeFrameEx) { addPropertyChangeListener(WindowManagerImpl.FULL_SCREEN, new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { myFullScreen = ((IdeFrameEx)frame).isInFullScreen(); } }); } } else { setJMenuBar(new IdeMenuBar(actionManager, dataManager)); } myGlassPane = new IdeGlassPaneImpl(this); setGlassPane(myGlassPane); myGlassPaneInitialized = true; myGlassPane.setVisible(false); }
private static Group createMacrosGroup(Condition<AnAction> filtered) { final ActionManagerEx actionManager = ActionManagerEx.getInstanceEx(); String[] ids = actionManager.getActionIds(ActionMacro.MACRO_ACTION_PREFIX); Arrays.sort(ids); Group group = new Group(KeyMapBundle.message("macros.group.title"), null, null); for (String id : ids) { if (filtered == null || filtered.value(actionManager.getActionOrStub(id))) { group.addActionId(id); } } return group; }
private MyJFrame(IdeFrame parent) throws HeadlessException { FrameState.setFrameStateListener(this); myParent = parent; setGlassPane(new IdeGlassPaneImpl(getRootPane())); if (SystemInfo.isMac) { setJMenuBar(new IdeMenuBar(ActionManagerEx.getInstanceEx(), DataManager.getInstance())); } MouseGestureManager.getInstance().add(this); setFocusTraversalPolicy(new LayoutFocusTraversalPolicyExt()); setDefaultCloseOperation(DISPOSE_ON_CLOSE); }
public ToolbarUpdater(@NotNull ActionManagerEx actionManager, @NotNull KeymapManagerEx keymapManager, @NotNull JComponent component) { myActionManager = actionManager; myKeymapManager = keymapManager; myComponent = component; myWeakTimerListener = new WeakTimerListener(actionManager, myTimerListener); new UiNotifyConnector(component, this); }
public ActionToolbarImpl(String place, @NotNull final ActionGroup actionGroup, boolean horizontal, @NotNull DataManager dataManager, @NotNull ActionManagerEx actionManager, @NotNull KeymapManagerEx keymapManager) { this(place, actionGroup, horizontal, false, dataManager, actionManager, keymapManager, false); }
public ActionToolbarImpl(String place, @NotNull ActionGroup actionGroup, boolean horizontal, boolean decorateButtons, @NotNull DataManager dataManager, @NotNull ActionManagerEx actionManager, @NotNull KeymapManagerEx keymapManager) { this(place, actionGroup, horizontal, decorateButtons, dataManager, actionManager, keymapManager, false); }
public ActionToolbarImpl(String place, @NotNull ActionGroup actionGroup, final boolean horizontal, final boolean decorateButtons, @NotNull DataManager dataManager, @NotNull ActionManagerEx actionManager, @NotNull KeymapManagerEx keymapManager, boolean updateActionsNow) { super(null); myActionManager = actionManager; myPlace = place; myActionGroup = actionGroup; myVisibleActions = new ArrayList<AnAction>(); myDataManager = dataManager; myDecorateButtons = decorateButtons; myUpdater = new ToolbarUpdater(actionManager, keymapManager, this) { @Override protected void updateActionsImpl(boolean transparentOnly, boolean forced) { ActionToolbarImpl.this.updateActionsImpl(transparentOnly, forced); } }; setLayout(new BorderLayout()); setOrientation(horizontal ? SwingConstants.HORIZONTAL : SwingConstants.VERTICAL); mySecondaryActions.getTemplatePresentation().setIcon(AllIcons.General.SecondaryGroup); mySecondaryActions.setPopup(true); myUpdater.updateActions(updateActionsNow, false); // If the panel doesn't handle mouse event then it will be passed to its parent. // It means that if the panel is in sliding mode then the focus goes to the editor // and panel will be automatically hidden. enableEvents(AWTEvent.MOUSE_MOTION_EVENT_MASK | AWTEvent.MOUSE_EVENT_MASK | AWTEvent.COMPONENT_EVENT_MASK | AWTEvent.CONTAINER_EVENT_MASK); setMiniMode(false); }
public PopupToolbar(final String place, final ActionGroup actionGroup, final boolean horizontal, final DataManager dataManager, @NotNull ActionManagerEx actionManager, final KeymapManagerEx keymapManager, JComponent parent) { super(place, actionGroup, horizontal, false, dataManager, actionManager, keymapManager, true); myActionManager.addAnActionListener(this); myParent = parent; }
public void callback(ID self, String selector) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { ActionManagerEx am = ActionManagerEx.getInstanceEx(); MouseEvent me = new MouseEvent(JOptionPane.getRootFrame(), MouseEvent.MOUSE_CLICKED, System.currentTimeMillis(), 0, 0, 0, 1, false); am.tryToExecute(am.getAction("CheckForUpdate"), me, null, null, false); } }); }
@NotNull public AnAction[] getChildren(@Nullable AnActionEvent e) { ArrayList<AnAction> actions = new ArrayList<AnAction>(); 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()]); }
public boolean checkCanCreateMacro(String name) { final ActionManagerEx actionManager = (ActionManagerEx)ActionManager.getInstance(); final String actionId = ActionMacro.MACRO_ACTION_PREFIX + name; if (actionManager.getAction(actionId) != null) { if (Messages.showYesNoDialog(IdeBundle.message("message.macro.exists", name), IdeBundle.message("title.macro.name.already.used"), Messages.getWarningIcon()) != Messages.YES) { return false; } actionManager.unregisterAction(actionId); removeMacro(name); } return true; }
private static void changeState() { if (Comparing.strEqual(ActionManagerEx.getInstanceEx().getPrevPreformedActionId(), IdeActions.ACTION_SHOW_ERROR_DESCRIPTION)) { shouldShowDescription = descriptionShown; } else { shouldShowDescription = false; descriptionShown = true; } }
public BaseToolManager(@NotNull ActionManagerEx actionManagerEx, SchemesManagerFactory factory) { myActionManager = actionManagerEx; mySchemesManager = factory.create(getSchemesPath(), createProcessor()); mySchemesManager.loadSchemes(); registerActions(); }
@Override public void actionPerformed(ActionEvent e) { DataContext dataContext = DataManager.getInstance().getDataContext(this); ActionManagerEx actionManager = ActionManagerEx.getInstanceEx(); InputEvent inputEvent = e.getSource() instanceof InputEvent ? (InputEvent)e.getSource() : null; //noinspection ConstantConditions AnActionEvent event = AnActionEvent.createFromAnAction(myAction, inputEvent, UNKNOWN, dataContext); actionManager.fireBeforeActionPerformed(myAction, dataContext, event); myAction.actionPerformed(event); }