Java Code Examples for com.intellij.ide.IdeEventQueue#getInstance()

The following examples show how to use com.intellij.ide.IdeEventQueue#getInstance() . 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: IdeGlassPaneImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
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 2
Source File: EditorGutterComponentImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
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: DesktopApplicationStarter.java    From consulo with Apache License 2.0 6 votes vote down vote up
@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 4
Source File: DialogWrapperPeerImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
@SuppressWarnings("deprecation")
public void show() {
  final DialogWrapper dialogWrapper = getDialogWrapper();
  boolean isAutoAdjustable = dialogWrapper.isAutoAdjustable();
  Point location = null;
  if (isAutoAdjustable) {
    pack();

    Dimension packedSize = getSize();
    Dimension minSize = getMinimumSize();
    setSize(Math.max(packedSize.width, minSize.width), Math.max(packedSize.height, minSize.height));

    setSize((int)(getWidth() * dialogWrapper.getHorizontalStretch()), (int)(getHeight() * dialogWrapper.getVerticalStretch()));

    // Restore dialog's size and location

    myDimensionServiceKey = dialogWrapper.getDimensionKey();

    if (myDimensionServiceKey != null) {
      final Project projectGuess = DataManager.getInstance().getDataContext((Component)this).getData(CommonDataKeys.PROJECT);
      location = getWindowStateService(projectGuess).getLocation(myDimensionServiceKey);
      Dimension size = getWindowStateService(projectGuess).getSize(myDimensionServiceKey);
      if (size != null) {
        myInitialSize = new Dimension(size);
        _setSizeForLocation(myInitialSize.width, myInitialSize.height, location);
      }
    }

    if (myInitialSize == null) {
      myInitialSize = getSize();
    }
  }

  if (location == null) {
    location = dialogWrapper.getInitialLocation();
  }

  if (location != null) {
    setLocation(location);
  }
  else {
    setLocationRelativeTo(getOwner());
  }

  if (isAutoAdjustable) {
    final Rectangle bounds = getBounds();
    ScreenUtil.fitToScreen(bounds);
    setBounds(bounds);
  }

  if (Registry.is("actionSystem.fixLostTyping")) {
    final IdeEventQueue queue = IdeEventQueue.getInstance();
    if (queue != null) {
      queue.getKeyEventDispatcher().resetState();
    }

  }

  // Workaround for switching workspaces on dialog show
  if (SystemInfo.isMac && myProject != null && Registry.is("ide.mac.fix.dialog.showing") && !dialogWrapper.isModalProgress()) {
    final IdeFrame frame = WindowManager.getInstance().getIdeFrame(myProject.get());
    AppIcon.getInstance().requestFocus(frame);
  }

  setBackground(UIUtil.getPanelBackground());

  final ApplicationEx app = ApplicationManagerEx.getApplicationEx();
  if (app != null && !app.isLoaded() && DesktopSplash.BOUNDS != null) {
    final Point loc = getLocation();
    loc.y = DesktopSplash.BOUNDS.y + DesktopSplash.BOUNDS.height;
    setLocation(loc);
  }
  super.show();
}