com.intellij.ide.IdeEventQueue Java Examples
The following examples show how to use
com.intellij.ide.IdeEventQueue.
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: BlazeSyncIntegrationTestCase.java From intellij with Apache License 2.0 | 6 votes |
protected void runBlazeSync(BlazeSyncParams syncParams) { BlazeContext context = new BlazeContext(); context.addOutputSink(IssueOutput.class, errorCollector); // We need to run sync off EDT to keep IntelliJ's transaction system happy // Because the sync task itself wants to run occasional EDT tasks, we'll have // to keep flushing the event queue. Future<?> future = Executors.newSingleThreadExecutor() .submit( () -> { SyncPhaseCoordinator.getInstance(getProject()).runSync(syncParams, true, context); context.endScope(); }); while (!future.isDone()) { IdeEventQueue.getInstance().flushQueue(); try { Thread.sleep(50); } catch (InterruptedException e) { throw new RuntimeException(e); } } }
Example #2
Source File: EditorGutterComponentImpl.java From consulo with Apache License 2.0 | 6 votes |
private void processClose(final MouseEvent e) { final IdeEventQueue queue = IdeEventQueue.getInstance(); // See IDEA-59553 for rationale on why this feature is disabled //if (isLineNumbersShown()) { // if (e.getX() >= getLineNumberAreaOffset() && getLineNumberAreaOffset() + getLineNumberAreaWidth() >= e.getX()) { // queue.blockNextEvents(e); // myEditor.getSettings().setLineNumbersShown(false); // e.consume(); // return; // } //} if (getGutterRenderer(e) != null) return; if (myEditor.getMouseEventArea(e) == EditorMouseEventArea.ANNOTATIONS_AREA) { queue.blockNextEvents(e); closeAllAnnotations(); e.consume(); } }
Example #3
Source File: EditorMouseHoverPopupManager.java From consulo with Apache License 2.0 | 6 votes |
private void showHintInEditor(AbstractPopup hint, Editor editor, Context context) { closeHint(); myMouseMovementTracker.reset(); myKeepPopupOnMouseMove = false; editor.putUserData(PopupFactoryImpl.ANCHOR_POPUP_POSITION, context.getPopupPosition(editor)); try { PopupPositionManager.positionPopupInBestPosition(hint, editor, null); } finally { editor.putUserData(PopupFactoryImpl.ANCHOR_POPUP_POSITION, null); } Window window = hint.getPopupWindow(); if (window != null) { window.setFocusableWindowState(true); IdeEventQueue.getInstance().addDispatcher(e -> { if (e.getID() == MouseEvent.MOUSE_PRESSED && e.getSource() == window) { myKeepPopupOnMouseMove = true; } return false; }, hint); } }
Example #4
Source File: FindUIHelper.java From consulo with Apache License 2.0 | 6 votes |
private FindUI getOrCreateUI() { if (myUI == null) { JComponent component; FindPopupPanel panel = new FindPopupPanel(this); component = panel; myUI = panel; registerAction("ReplaceInPath", true, component, myUI); registerAction("FindInPath", false, component, myUI); Disposer.register(myUI.getDisposable(), this); } else { IdeEventQueue.getInstance().flushDelayedKeyEvents(); } return myUI; }
Example #5
Source File: IdeKeyEventDispatcher.java From consulo with Apache License 2.0 | 6 votes |
@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()); } }
Example #6
Source File: SearchEverywhereAction.java From consulo with Apache License 2.0 | 6 votes |
public void actionPerformed(AnActionEvent e, MouseEvent me) { if (Registry.is("new.search.everywhere") && e.getProject() != null) { FeatureUsageTracker.getInstance().triggerFeatureUsed(IdeActions.ACTION_SEARCH_EVERYWHERE); SearchEverywhereManager seManager = SearchEverywhereManager.getInstance(e.getProject()); String searchProviderID = SearchEverywhereManagerImpl.ALL_CONTRIBUTORS_GROUP_ID; if (seManager.isShown()) { if (searchProviderID.equals(seManager.getSelectedContributorID())) { seManager.toggleEverywhereFilter(); } else { seManager.setSelectedContributor(searchProviderID); //FeatureUsageData data = SearchEverywhereUsageTriggerCollector.createData(searchProviderID).addInputEvent(e); //SearchEverywhereUsageTriggerCollector.trigger(e.getProject(), SearchEverywhereUsageTriggerCollector.TAB_SWITCHED, data); } return; } //FeatureUsageData data = SearchEverywhereUsageTriggerCollector.createData(searchProviderID); //SearchEverywhereUsageTriggerCollector.trigger(e.getProject(), SearchEverywhereUsageTriggerCollector.DIALOG_OPEN, data); IdeEventQueue.getInstance().getPopupManager().closeAllPopups(false); String text = GotoActionBase.getInitialTextForNavigation(e); seManager.show(searchProviderID, text, e); return; } }
Example #7
Source File: TabbedContentTabLabel.java From consulo with Apache License 2.0 | 6 votes |
@Override protected void selectContent() { IdeEventQueue.getInstance().getPopupManager().closeAllPopups(); super.selectContent(); if (hasMultipleTabs()) { final SelectContentTabStep step = new SelectContentTabStep(getContent()); final ListPopup popup = JBPopupFactory.getInstance().createListPopup(step); myPopupReference = new WeakReference<>(popup); popup.showUnderneathOf(this); popup.addListener(new JBPopupAdapter() { @Override public void onClosed(@Nonnull LightweightWindowEvent event) { repaint(); } }); } }
Example #8
Source File: DesktopToolWindowContentUi.java From consulo with Apache License 2.0 | 6 votes |
private void processHide(final MouseEvent e) { IdeEventQueue.getInstance().blockNextEvents(e); final Component c = e.getComponent(); if (c instanceof BaseLabel) { final BaseLabel tab = (BaseLabel)c; if (tab.getContent() != null) { if (myManager.canCloseContents() && tab.getContent().isCloseable()) { myManager.removeContent(tab.getContent(), true, true, true); } else { if (myManager.getContentCount() == 1) { hideWindow(e); } } } else { hideWindow(e); } } else { hideWindow(e); } }
Example #9
Source File: FileEditorManagerImpl.java From consulo with Apache License 2.0 | 6 votes |
private static boolean isOpenInNewWindow() { if (!Platform.current().isDesktop()) { return false; } AWTEvent event = IdeEventQueue.getInstance().getTrueCurrentEvent(); // Shift was used while clicking if (event instanceof MouseEvent && ((MouseEvent)event).isShiftDown() && (event.getID() == MouseEvent.MOUSE_CLICKED || event.getID() == MouseEvent.MOUSE_PRESSED || event.getID() == MouseEvent.MOUSE_RELEASED)) { return true; } if (event instanceof KeyEvent) { KeyEvent ke = (KeyEvent)event; Keymap keymap = KeymapManager.getInstance().getActiveKeymap(); String[] ids = keymap.getActionIds(KeyStroke.getKeyStroke(ke.getKeyCode(), ke.getModifiers())); return Arrays.asList(ids).contains("OpenElementInNewWindow"); } return false; }
Example #10
Source File: NoSwingUnderWriteAction.java From consulo with Apache License 2.0 | 6 votes |
static void watchForEvents(Application application) { AtomicBoolean reported = new AtomicBoolean(); IdeEventQueue.getInstance().addPostprocessor(e -> { if (application.isWriteAccessAllowed() && reported.compareAndSet(false, true)) { LOG.error("AWT events are not allowed inside write action: " + e); } return true; }, application); application.addApplicationListener(new ApplicationListener() { @Override public void afterWriteActionFinished(@Nonnull Object action) { reported.set(false); } }); }
Example #11
Source File: EditorTabbedContainer.java From consulo with Apache License 2.0 | 6 votes |
@Override public void mouseReleased(MouseEvent e) { if (UIUtil.isCloseClick(e, MouseEvent.MOUSE_RELEASED)) { final TabInfo info = myTabs.findInfo(e); if (info != null) { IdeEventQueue.getInstance().blockNextEvents(e); if (e.isAltDown() && e.getButton() == MouseEvent.BUTTON1) {//close others List<TabInfo> allTabInfos = myTabs.getTabs(); for (TabInfo tabInfo : allTabInfos) { if (tabInfo == info) continue; FileEditorManagerEx.getInstanceEx(myProject).closeFile((VirtualFile)tabInfo.getObject(), myWindow); } } else { FileEditorManagerEx.getInstanceEx(myProject).closeFile((VirtualFile)info.getObject(), myWindow); } } } }
Example #12
Source File: DesktopApplicationStarter.java From consulo with Apache License 2.0 | 6 votes |
@Override protected void patchSystem(boolean headless) { System.setProperty("sun.awt.noerasebackground", "true"); IdeEventQueue.getInstance(); // replace system event queue if (headless) return; if (Patches.SUN_BUG_ID_6209673) { RepaintManager.setCurrentManager(new IdeRepaintManager()); } if (SystemInfo.isXWindow) { String wmName = X11UiUtil.getWmName(); LOG.info("WM detected: " + wmName); if (wmName != null) { X11UiUtil.patchDetectedWm(wmName); } } IconLoader.activate(); }
Example #13
Source File: IdeMenuBar.java From consulo with Apache License 2.0 | 6 votes |
@Override public void addNotify() { super.addNotify(); updateMenuActions(); // Add updater for menus myActionManager.addTimerListener(1000, new WeakTimerListener(myTimerListener)); UISettingsListener UISettingsListener = new UISettingsListener() { @Override public void uiSettingsChanged(final UISettings source) { updateMnemonicsVisibility(); myPresentationFactory.reset(); } }; UISettings.getInstance().addUISettingsListener(UISettingsListener, myDisposable); Disposer.register(ApplicationManager.getApplication(), myDisposable); IdeEventQueue.getInstance().addDispatcher(this, myDisposable); }
Example #14
Source File: IdeGlassPaneImpl.java From consulo with Apache License 2.0 | 6 votes |
private void applyActivationState() { boolean wasVisible = isVisible(); boolean hasWork = getPainters().hasPainters() || getComponentCount() > 0; if (wasVisible != hasWork) { setVisible(hasWork); } IdeEventQueue queue = IdeEventQueue.getInstance(); if (!queue.containsDispatcher(this) && (myPreprocessorActive || isVisible())) { queue.addDispatcher(this, null); } else if (queue.containsDispatcher(this) && !myPreprocessorActive && !isVisible()) { queue.removeDispatcher(this); } if (wasVisible != isVisible()) { revalidate(); repaint(); } }
Example #15
Source File: IdeStatusBarImpl.java From consulo with Apache License 2.0 | 6 votes |
IdeStatusBarImpl(@Nullable IdeStatusBarImpl master) { setLayout(new BorderLayout()); setBorder(JBUI.Borders.empty(1, 0, 0, 6)); myInfoAndProgressPanel = new InfoAndProgressPanel(); addWidget(myInfoAndProgressPanel, Position.CENTER, "__IGNORED__"); setOpaque(true); updateUI(); if (master == null) { addWidget(new ToolWindowsWidget(this), Position.LEFT); } enableEvents(AWTEvent.MOUSE_EVENT_MASK); enableEvents(AWTEvent.MOUSE_MOTION_EVENT_MASK); IdeEventQueue.getInstance().addPostprocessor(this, this); }
Example #16
Source File: GraphConsoleView.java From jetbrains-plugin-graph-database-support with Apache License 2.0 | 6 votes |
private void createUIComponents() { graphCanvas = new JPanel(new GridLayout(0, 1)); consoleTabsPane = new JBTabsPaneImpl(null, SwingConstants.TOP, this); consoleTabs = (JBTabsImpl) consoleTabsPane.getTabs(); consoleTabs.addTabMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { if (UIUtil.isCloseClick(e, MouseEvent.MOUSE_RELEASED)) { final TabInfo info = consoleTabs.findInfo(e); if (info != null) { String tabTitle = info.getText(); if (tabTitle.startsWith(PROFILE_PLAN_TITLE) || tabTitle.startsWith(EXPLAIN_PLAN_TITLE)) { IdeEventQueue.getInstance().blockNextEvents(e); consoleTabs.removeTab(info); } } } } }); }
Example #17
Source File: PopupDispatcher.java From consulo with Apache License 2.0 | 5 votes |
static void clearRootIfNeeded(@Nonnull WizardPopup aRootPopup) { if (ourActiveWizardRoot == aRootPopup) { ourActiveWizardRoot = null; ourShowingStep = null; if (ApplicationManager.getApplication() != null) { IdeEventQueue.getInstance().getPopupManager().remove(ourInstance); } } }
Example #18
Source File: StackingPopupDispatcherImpl.java From consulo with Apache License 2.0 | 5 votes |
@Override public void onPopupShown(JBPopup popup, boolean inStack) { if (inStack) { myStack.push(popup); if (ApplicationManager.getApplication() != null) { IdeEventQueue.getInstance().getPopupManager().push(getInstance()); } } else if (popup.isPersistent()) { myPersistentPopups.add(popup); } myAllPopups.add(popup); }
Example #19
Source File: StackingPopupDispatcherImpl.java From consulo with Apache License 2.0 | 5 votes |
@Override public void onPopupHidden(JBPopup popup) { boolean wasInStack = myStack.remove(popup); myPersistentPopups.remove(popup); if (wasInStack && myStack.isEmpty()) { if (ApplicationManager.getApplication() != null) { IdeEventQueue.getInstance().getPopupManager().remove(this); } } myAllPopups.remove(popup); }
Example #20
Source File: Communicator.java From CppTools with Apache License 2.0 | 5 votes |
public void projectClosed() { if (!myProject.isDefault()) { if (myListenerAdded) IdeEventQueue.getInstance().removeIdleListener(myIdleListener); myConnection.disconnect(); myRootListener = null; myConnection = null; sendCommand(new QuitCommand()); SwingUtilities.invokeLater(new Runnable() { public void run() { myExecutableState.doDestroyProcess(); } }); } }
Example #21
Source File: ListPopupImpl.java From consulo with Apache License 2.0 | 5 votes |
@Override public void mouseReleased(MouseEvent e) { if (!isActionClick(e) || isMultiSelectionEnabled() && UIUtil.isSelectionButtonDown(e)) return; IdeEventQueue.getInstance().blockNextEvents(e); // sometimes, after popup close, MOUSE_RELEASE event delivers to other components final Object selectedValue = myList.getSelectedValue(); final ListPopupStep<Object> listStep = getListStep(); handleSelect(handleFinalChoices(e, selectedValue, listStep), e); stopTimer(); }
Example #22
Source File: OwnerOptional.java From consulo with Apache License 2.0 | 5 votes |
public static OwnerOptional fromComponent(Component parentComponent) { Window owner = findOwnerByComponent(parentComponent); IdePopupManager manager = IdeEventQueue.getInstance().getPopupManager(); if (manager.isPopupWindow(owner)) { if (!owner.isFocused() || !SystemInfo.isJetBrainsJvm) { owner = owner.getOwner(); while (owner != null && !(owner instanceof Dialog) && !(owner instanceof Frame)) { owner = owner.getOwner(); } } } if (owner instanceof Dialog) { Dialog ownerDialog = (Dialog)owner; if (ownerDialog.isModal() || UIUtil.isPossibleOwner(ownerDialog)) { owner = ownerDialog; } else { while (owner instanceof Dialog && !((Dialog)owner).isModal()) { owner = owner.getOwner(); } } } while (owner != null && !owner.isShowing()) { owner = owner.getOwner(); } // Window cannot be parent of JDialog () if (owner != null && !(owner instanceof Frame || owner instanceof Dialog)) { owner = null; } return new OwnerOptional(owner); }
Example #23
Source File: ActionMacroManager.java From consulo with Apache License 2.0 | 5 votes |
@Inject public ActionMacroManager(Application application, ActionManager actionManager) { myActionManager = actionManager; application.getMessageBus().connect(this).subscribe(AnActionListener.TOPIC, new AnActionListener() { @Override public void beforeActionPerformed(AnAction action, DataContext dataContext, final AnActionEvent event) { String id = myActionManager.getId(action); if (id == null) return; //noinspection HardCodedStringLiteral if ("StartStopMacroRecording".equals(id)) { myLastActionInputEvent.add(event.getInputEvent()); } else if (myIsRecording) { myRecordingMacro.appendAction(id); String shortcut = null; if (event.getInputEvent() instanceof KeyEvent) { shortcut = KeymapUtil.getKeystrokeText(KeyStroke.getKeyStrokeForEvent((KeyEvent)event.getInputEvent())); } notifyUser(id + (shortcut != null ? " (" + shortcut + ")" : ""), false); myLastActionInputEvent.add(event.getInputEvent()); } } }); myKeyProcessor = new MyKeyPostpocessor(); Platform.runIfDesktopPlatform(() -> IdeEventQueue.getInstance().addPostprocessor(myKeyProcessor, null)); }
Example #24
Source File: ActionMacroManager.java From consulo with Apache License 2.0 | 5 votes |
@Override public void actionPerformed(AnActionEvent e) { IdeEventQueue.getInstance().doWhenReady(new Runnable() { @Override public void run() { getInstance().playMacro(myMacro); } }); }
Example #25
Source File: ActionMacroManager.java From consulo with Apache License 2.0 | 5 votes |
public void postProcessKeyEvent(KeyEvent e) { if (e.getID() != KeyEvent.KEY_PRESSED) return; if (myLastActionInputEvent.contains(e)) { myLastActionInputEvent.remove(e); return; } final boolean modifierKeyIsPressed = e.getKeyCode() == KeyEvent.VK_CONTROL || e.getKeyCode() == KeyEvent.VK_ALT || e.getKeyCode() == KeyEvent.VK_META || e.getKeyCode() == KeyEvent.VK_SHIFT; if (modifierKeyIsPressed) return; final boolean ready = IdeEventQueue.getInstance().getKeyEventDispatcher().isReady(); final boolean isChar = e.getKeyChar() != KeyEvent.CHAR_UNDEFINED && UIUtil.isReallyTypedEvent(e); final boolean hasActionModifiers = e.isAltDown() | e.isControlDown() | e.isMetaDown(); final boolean plainType = isChar && !hasActionModifiers; final boolean isEnter = e.getKeyCode() == KeyEvent.VK_ENTER; if (plainType && ready && !isEnter) { myRecordingMacro.appendKeytyped(e.getKeyChar(), e.getKeyCode(), e.getModifiers()); notifyUser(Character.valueOf(e.getKeyChar()).toString(), true); } else if ((!plainType && ready) || isEnter) { final String stroke = KeyStroke.getKeyStrokeForEvent(e).toString(); final int pressed = stroke.indexOf("pressed"); String key = stroke.substring(pressed + "pressed".length()); String modifiers = stroke.substring(0, pressed); String shortcut = (modifiers.replaceAll("ctrl", "control").trim() + " " + key.trim()).trim(); myRecordingMacro.appendShortcut(shortcut); notifyUser(KeymapUtil.getKeystrokeText(KeyStroke.getKeyStrokeForEvent(e)), false); } }
Example #26
Source File: DockablePopupManager.java From consulo with Apache License 2.0 | 5 votes |
void restartAutoUpdate(final boolean state) { if (state && myToolWindow != null) { if (myAutoUpdateRequest == null) { myAutoUpdateRequest = this::updateComponent; UIUtil.invokeLaterIfNeeded(() -> IdeEventQueue.getInstance().addIdleListener(myAutoUpdateRequest, 500)); } } else { if (myAutoUpdateRequest != null) { IdeEventQueue.getInstance().removeIdleListener(myAutoUpdateRequest); myAutoUpdateRequest = null; } } }
Example #27
Source File: DesktopDataManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
@Override @SuppressWarnings("unchecked") public <T> T getData(@Nonnull Key<T> dataId) { int currentEventCount = Platform.current().isDesktop() ? IdeEventQueue.getInstance().getEventCount() : -1; if (myEventCount != -1 && myEventCount != currentEventCount) { LOG.error("cannot share data context between Swing events; initial event count = " + myEventCount + "; current event count = " + currentEventCount); return doGetData(dataId); } return super.getData(dataId); }
Example #28
Source File: GotoActionBase.java From consulo with Apache License 2.0 | 5 votes |
protected void showInSearchEverywherePopup(@Nonnull String searchProviderID, @Nonnull AnActionEvent event, boolean useEditorSelection, boolean sendStatistics) { Project project = event.getProject(); if (project == null) return; SearchEverywhereManager seManager = SearchEverywhereManager.getInstance(project); FeatureUsageTracker.getInstance().triggerFeatureUsed(IdeActions.ACTION_SEARCH_EVERYWHERE); if (seManager.isShown()) { if (searchProviderID.equals(seManager.getSelectedContributorID())) { seManager.toggleEverywhereFilter(); } else { seManager.setSelectedContributor(searchProviderID); //if (sendStatistics) { // FeatureUsageData data = SearchEverywhereUsageTriggerCollector.createData(searchProviderID).addInputEvent(event); // SearchEverywhereUsageTriggerCollector.trigger(project, SearchEverywhereUsageTriggerCollector.TAB_SWITCHED, data); //} } return; } //if (sendStatistics) { // FeatureUsageData data = SearchEverywhereUsageTriggerCollector.createData(searchProviderID); // SearchEverywhereUsageTriggerCollector.trigger(project, SearchEverywhereUsageTriggerCollector.DIALOG_OPEN, data); //} IdeEventQueue.getInstance().getPopupManager().closeAllPopups(false); String searchText = StringUtil.nullize(getInitialText(useEditorSelection, event).first); seManager.show(searchProviderID, searchText, event); }
Example #29
Source File: DesktopToolWindowManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
public void projectOpened() { final MyUIManagerPropertyChangeListener uiManagerPropertyListener = new MyUIManagerPropertyChangeListener(); final MyLafManagerListener lafManagerListener = new MyLafManagerListener(); UIManager.addPropertyChangeListener(uiManagerPropertyListener); LafManager.getInstance().addLafManagerListener(lafManagerListener, this); Disposer.register(this, () -> { UIManager.removePropertyChangeListener(uiManagerPropertyListener); }); WindowManagerEx windowManager = (WindowManagerEx)myWindowManager.get(); myFrame = (DesktopIdeFrameImpl)windowManager.allocateFrame(myProject); myToolWindowPanel = new DesktopToolWindowPanelImpl(myFrame, this); Disposer.register(myProject, getToolWindowPanel()); JFrame jFrame = (JFrame)TargetAWT.to(myFrame.getWindow()); ((IdeRootPane)jFrame.getRootPane()).setToolWindowsPane(myToolWindowPanel); jFrame.setTitle(FrameTitleBuilder.getInstance().getProjectTitle(myProject)); ((IdeRootPane)jFrame.getRootPane()).updateToolbar(); IdeEventQueue.getInstance().addDispatcher(e -> { if (e instanceof KeyEvent) { dispatchKeyEvent((KeyEvent)e); } if (e instanceof WindowEvent && e.getID() == WindowEvent.WINDOW_LOST_FOCUS && e.getSource() == myFrame) { resetHoldState(); } return false; }, myProject); }
Example #30
Source File: JSGraphQLExecuteEditorActionHandler.java From js-graphql-intellij-plugin with MIT License | 5 votes |
private InputEvent getKeyboardEvent() { final IdeKeyEventDispatcher keyEventDispatcher = IdeEventQueue.getInstance().getKeyEventDispatcher(); if (keyEventDispatcher != null) { final KeyProcessorContext context = keyEventDispatcher.getContext(); if (context != null) { return context.getInputEvent(); } } return null; }