Java 类com.intellij.ui.mac.foundation.MacUtil 实例源码

项目:intellij-ce-playground    文件:Messages.java   
protected void _init(@Nls(capitalization = Nls.Capitalization.Title) String title,
                     String message,
                     @NotNull String[] options,
                     int defaultOptionIndex,
                     int focusedOptionIndex,
                     @Nullable Icon icon,
                     @Nullable DoNotAskOption doNotAskOption) {
  setTitle(title);
  if (isMacSheetEmulation()) {
    setUndecorated(true);
  }
  myMessage = message;
  myOptions = options;
  myDefaultOptionIndex = defaultOptionIndex;
  myFocusedOptionIndex = focusedOptionIndex;
  myIcon = icon;
  if (!SystemInfo.isMac) {
    setButtonsAlignment(SwingConstants.CENTER);
  }
  setDoNotAskOption(doNotAskOption);
  init();
  if (isMacSheetEmulation()) {
    MacUtil.adjustFocusTraversal(myDisposable);
  }
}
项目:AndroidLocalizationer    文件:MultiSelectDialog.java   
protected void _init(Project project,
                     String title,
                     String message,
                     @Nullable String checkboxText,
                     boolean checkboxStatus,
                     @Nullable DoNotAskOption doNotAskOption) {
    setTitle(title);
    if (Messages.isMacSheetEmulation()) {
        setUndecorated(true);
    }
    propertiesComponent = PropertiesComponent.getInstance(project);
    myMessage = message;
    myCheckboxText = checkboxText;
    myChecked = checkboxStatus;
    setButtonsAlignment(SwingConstants.RIGHT);
    setDoNotAskOption(doNotAskOption);
    init();
    if (Messages.isMacSheetEmulation()) {
        MacUtil.adjustFocusTraversal(myDisposable);
    }
}
项目:consulo    文件:Messages.java   
protected void _init(String title,
                     String message,
                     @Nonnull String[] options,
                     int defaultOptionIndex,
                     int focusedOptionIndex,
                     @Nullable Icon icon,
                     @Nullable DoNotAskOption doNotAskOption) {
  setTitle(title);
  if (isMacSheetEmulation()) {
    setUndecorated(true);
  }
  myMessage = message;
  myOptions = options;
  myDefaultOptionIndex = defaultOptionIndex;
  myFocusedOptionIndex = focusedOptionIndex;
  myIcon = icon;
  setButtonsAlignment(SwingConstants.CENTER);
  setDoNotAskOption(doNotAskOption);
  init();
  if (isMacSheetEmulation()) {
    MacUtil.adjustFocusTraversal(myDisposable);
  }
}
项目:consulo    文件:DialogWrapperPeerImpl.java   
@Override
public void windowOpened(final WindowEvent e) {
  if (SystemInfo.isMacOSLion) {
    Window window = e.getWindow();
    if (window instanceof Dialog) {
      ID _native = MacUtil.findWindowForTitle(((Dialog)window).getTitle());
      if (_native != null && _native.intValue() > 0) {
        // see MacMainFrameDecorator
        // NSCollectionBehaviorFullScreenAuxiliary = 1 << 8
        Foundation.invoke(_native, "setCollectionBehavior:", 1 << 8);
      }
    }
  }
  SwingUtilities.invokeLater(() -> {
    myOpened = true;
    final DialogWrapper activeWrapper = getActiveWrapper();
    for (JComponent c : UIUtil.uiTraverser(e.getWindow()).filter(JComponent.class)) {
      GraphicsUtil.setAntialiasingType(c, AntialiasingType.getAAHintForSwingComponent());
    }
    if (activeWrapper == null) {
      myFocusedCallback.setRejected();
      myTypeAheadDone.setRejected();
    }
  });
}
项目:intellij-ce-playground    文件:MacColorPipette.java   
@Nullable
private static BufferedImage captureScreen(@Nullable Window belowWindow, @NotNull Rectangle rect) {
  ID pool = Foundation.invoke("NSAutoreleasePool", "new");
  try {
    ID windowId = belowWindow != null ? MacUtil.findWindowFromJavaWindow(belowWindow) : null;
    Foundation.NSRect nsRect = new Foundation.NSRect(rect.x, rect.y, rect.width, rect.height);
    ID cgWindowId = windowId != null ? Foundation.invoke(windowId, "windowNumber") : ID.NIL;
    int windowListOptions = cgWindowId != null
                            ? FoundationLibrary.kCGWindowListOptionOnScreenBelowWindow
                            : FoundationLibrary.kCGWindowListOptionAll;
    int windowImageOptions = FoundationLibrary.kCGWindowImageNominalResolution;
    ID cgImageRef = Foundation.cgWindowListCreateImage(nsRect, windowListOptions, cgWindowId, windowImageOptions);

    ID bitmapRep = Foundation.invoke(Foundation.invoke("NSBitmapImageRep", "alloc"), "initWithCGImage:", cgImageRef);
    ID nsImage = Foundation.invoke(Foundation.invoke("NSImage", "alloc"), "init");
    Foundation.invoke(nsImage, "addRepresentation:", bitmapRep);
    ID data = Foundation.invoke(nsImage, "TIFFRepresentation");
    ID bytes = Foundation.invoke(data, "bytes");
    ID length = Foundation.invoke(data, "length");
    ByteBuffer byteBuffer = Native.getDirectByteBuffer(bytes.longValue(), length.longValue());
    Foundation.invoke(nsImage, "release");
    byte[] b = new byte[byteBuffer.remaining()];
    byteBuffer.get(b);
    return ImageIO.read(new ByteArrayInputStream(b));
  }
  catch (Throwable t) {
    LOG.error(t);
    return null;
  }
  finally {
    Foundation.invoke(pool, "release");
  }
}
项目:intellij-ce-playground    文件:AbstractProgressIndicatorBase.java   
protected void stopSystemActivity() {
  if (myMacActivity != null) {
    synchronized (myMacActivity) {
      MacUtil.matrixHasYou(myMacActivity);
      myMacActivity = null;
    }
  }
}
项目:AndroidLocalizationer    文件:GoogleAlertDialog.java   
protected void _init(String title, String message) {
    setTitle(title);
    mMessage = message;
    if (Messages.isMacSheetEmulation()) {
        setUndecorated(true);
    }

    setButtonsAlignment(SwingConstants.RIGHT);
    setDoNotAskOption(null);
    init();
    if (Messages.isMacSheetEmulation()) {
        MacUtil.adjustFocusTraversal(myDisposable);
    }
}
项目:AndroidLocalizationer    文件:AddFilterRuleDialog.java   
protected void _init(String title,
                     @Nullable DoNotAskOption doNotAskOption) {
    setTitle(title);
    if (Messages.isMacSheetEmulation()) {
        setUndecorated(true);
    }

    setButtonsAlignment(SwingConstants.RIGHT);
    setDoNotAskOption(doNotAskOption);
    init();
    if (Messages.isMacSheetEmulation()) {
        MacUtil.adjustFocusTraversal(myDisposable);
    }
}
项目:consulo-unity3d    文件:UnityOpenFilePostHandler.java   
private void activateFrame(@Nullable Project openedProject, @NotNull UnityOpenFilePostHandlerRequest body)
{
    if(openedProject == null)
    {
        return;
    }

    IdeFrame ideFrame = WindowManager.getInstance().getIdeFrame(openedProject);
    if(!((JFrame)ideFrame).isVisible())
    {
        return;
    }

    if(SystemInfo.isMac)
    {
        RequestFocusHttpRequestHandler.activateFrame(ideFrame);
        ID id = MacUtil.findWindowFromJavaWindow((Window) ideFrame);
        if(id != null)
        {
            Foundation.invoke(id, "makeKeyAndOrderFront:", ID.NIL);
        }
    }
    else if(SystemInfo.isWindows)
    {
        Pointer windowPointer = Native.getWindowPointer((Window) ideFrame);
        User32.INSTANCE.SetForegroundWindow(new WinDef.HWND(windowPointer));
    }
    else
    {
        RequestFocusHttpRequestHandler.activateFrame(ideFrame);
    }
}
项目:tools-idea    文件:Messages.java   
protected void _init(String title, String message, String[] options, int defaultOptionIndex, int focusedOptionIndex, @Nullable Icon icon, @Nullable DoNotAskOption doNotAskOption) {
  setTitle(title);
  if (isMacSheetEmulation()) {
    setUndecorated(true);
  }
  myMessage = message;
  myOptions = options;
  myDefaultOptionIndex = defaultOptionIndex;
  myFocusedOptionIndex = focusedOptionIndex;
  myIcon = icon;
  setButtonsAlignment(SwingConstants.CENTER);
  setDoNotAskOption(doNotAskOption);
  init();
  MacUtil.adjustFocusTraversal(myDisposable);
}
项目:consulo    文件:AbstractProgressIndicatorBase.java   
protected void stopSystemActivity() {
  if (myMacActivity != null) {
    synchronized (myMacActivity) {
      MacUtil.matrixHasYou(myMacActivity);
      myMacActivity = null;
    }
  }
}
项目:intellij-ce-playground    文件:JBMacMessages.java   
private static Window getForemostWindow(final Window window) {
  Window _window = null;
  IdeFocusManager ideFocusManager = IdeFocusManager.getGlobalInstance();

  Component focusOwner = IdeFocusManager.findInstance().getFocusOwner();
  // Let's ask for a focused component first
  if (focusOwner != null) {
    _window = SwingUtilities.getWindowAncestor(focusOwner);
  }

  if (_window == null) {
    // Looks like ide lost focus, let's ask about the last focused component
    focusOwner = ideFocusManager.getLastFocusedFor(ideFocusManager.getLastFocusedFrame());
    if (focusOwner != null) {
      _window = SwingUtilities.getWindowAncestor(focusOwner);
    }
  }

  if (_window == null) {
    _window = WindowManager.getInstance().findVisibleFrame();
  }

  if (_window == null && window != null) {
    // It might be we just has not opened a frame yet.
    // So let's ask AWT
    focusOwner = window.getMostRecentFocusOwner();
    if (focusOwner != null) {
      _window = SwingUtilities.getWindowAncestor(focusOwner);
    }
  }

  if (_window != null) {
    // We have successfully found the window
    // Let's check that we have not missed a blocker
    if (ModalityHelper.isModalBlocked(_window)) {
      _window = ModalityHelper.getModalBlockerFor(_window);
    }
  }

  if (SystemInfo.isAppleJvm && MacUtil.getWindowTitle(_window) == null) {
    // With Apple JDK we cannot find a window if it does not have a title
    // Let's show a dialog instead of the message.
    throw new MessageException("MacMessage parent does not have a title.");
  }
  while (_window != null && MacUtil.getWindowTitle(_window) == null) {
    _window = _window.getOwner();
    //At least our frame should have a title
  }

  while (Registry.is("skip.untitled.windows.for.mac.messages") && _window != null && _window instanceof JDialog && !((JDialog)_window).isModal()) {
    _window = _window.getOwner();
  }

  return _window;
}
项目:intellij-ce-playground    文件:MacFileChooserDialogImpl.java   
@SuppressWarnings("UnusedDeclaration")
public void callback(ID self, String selector, ID toSelect) {
  final ID nsOpenPanel = Foundation.getObjcClass("NSOpenPanel");
  final ID chooser = invoke(nsOpenPanel, "openPanel");
  // Release in OPEN_PANEL_DID_END panel
  Foundation.cfRetain(chooser);

  final FileChooserDescriptor chooserDescriptor = ourImplMap.get(self).myChooserDescriptor;

  invoke(chooser, "setPrompt:", Foundation.nsString("Choose"));
  invoke(chooser, "setCanChooseFiles:", chooserDescriptor.isChooseFiles() || chooserDescriptor.isChooseJars());
  invoke(chooser, "setCanChooseDirectories:", chooserDescriptor.isChooseFolders());
  invoke(chooser, "setAllowsMultipleSelection:", chooserDescriptor.isChooseMultiple());
  invoke(chooser, "setTreatsFilePackagesAsDirectories:", chooserDescriptor.isChooseFolders());
  invoke(chooser, "setResolvesAliases:", false);

  String description = chooserDescriptor.getDescription();
  if (!StringUtil.isEmpty(description)) {
    invoke(chooser, "setMessage:", Foundation.nsString(StringUtil.removeHtmlTags(description)));
  }

  if (Foundation.isClassRespondsToSelector(nsOpenPanel, Foundation.createSelector("setCanCreateDirectories:"))) {
    invoke(chooser, "setCanCreateDirectories:", true);
  }
  else if (Foundation.isClassRespondsToSelector(nsOpenPanel, Foundation.createSelector("_setIncludeNewFolderButton:"))) {
    invoke(chooser, "_setIncludeNewFolderButton:", true);
  }

  boolean showHidden = chooserDescriptor.isShowHiddenFiles() || Registry.is("ide.mac.file.chooser.show.hidden.files");
  if (showHidden) {
    if (Foundation.isClassRespondsToSelector(nsOpenPanel, Foundation.createSelector("setShowsHiddenFiles:"))) {
      invoke(chooser, "setShowsHiddenFiles:", true);
    }
  }

  invoke(chooser, "setDelegate:", self);

  ID directory = null;
  ID file = null;
  final String toSelectPath = toSelect == null || toSelect.intValue() == 0 ? null : Foundation.toStringViaUTF8(toSelect);
  if (toSelectPath != null) {
    final File toSelectFile = new File(toSelectPath);
    if (toSelectFile.isDirectory()) {
      directory = toSelect;
    }
    else if (toSelectFile.isFile()) {
      directory = Foundation.nsString(toSelectFile.getParent());
      file = Foundation.nsString(toSelectFile.getName());
    }
  }

  ID types = null;
  if (!chooserDescriptor.isChooseFiles() && chooserDescriptor.isChooseJars()) {
    types = invoke("NSArray", "arrayWithObjects:", Foundation.nsString("jar"), Foundation.nsString("zip"), null);
  }

  final Window activeWindow = KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow();
  if (activeWindow != null) {
    String activeWindowTitle = null;
    if (activeWindow instanceof Frame) {
      activeWindowTitle = ((Frame)activeWindow).getTitle();
    }
    else if (activeWindow instanceof JDialog) {
      activeWindowTitle = ((JDialog)activeWindow).getTitle();
    }

    final ID focusedWindow = MacUtil.findWindowForTitle(activeWindowTitle);
    if (focusedWindow != null) {
      invoke(chooser, "beginSheetForDirectory:file:types:modalForWindow:modalDelegate:didEndSelector:contextInfo:",
             directory, file, types, focusedWindow, self, Foundation.createSelector("openPanelDidEnd:returnCode:contextInfo:"), chooser);
    }
  }
}
项目:intellij-ce-playground    文件:AbstractProgressIndicatorBase.java   
protected void startSystemActivity() {
  myMacActivity = myShouldStartActivity ? MacUtil.wakeUpNeo(toString()) : null;
}
项目:tools-idea    文件:MacFileChooserDialogImpl.java   
@SuppressWarnings("UnusedDeclaration")
public void callback(ID self, String selector, ID toSelect) {
  final ID nsOpenPanel = Foundation.getObjcClass("NSOpenPanel");
  final ID chooser = invoke(nsOpenPanel, "openPanel");
  // Release in OPEN_PANEL_DID_END panel
  Foundation.cfRetain(chooser);

  final FileChooserDescriptor chooserDescriptor = ourImplMap.get(self).myChooserDescriptor;

  invoke(chooser, "setPrompt:", Foundation.nsString("Choose"));
  invoke(chooser, "setCanChooseFiles:", chooserDescriptor.isChooseFiles() || chooserDescriptor.isChooseJars());
  invoke(chooser, "setCanChooseDirectories:", chooserDescriptor.isChooseFolders());
  invoke(chooser, "setAllowsMultipleSelection:", chooserDescriptor.isChooseMultiple());
  invoke(chooser, "setTreatsFilePackagesAsDirectories:", chooserDescriptor.isChooseFolders());

  if (Foundation.isClassRespondsToSelector(nsOpenPanel, Foundation.createSelector("setCanCreateDirectories:"))) {
    invoke(chooser, "setCanCreateDirectories:", true);
  }
  else if (Foundation.isClassRespondsToSelector(nsOpenPanel, Foundation.createSelector("_setIncludeNewFolderButton:"))) {
    invoke(chooser, "_setIncludeNewFolderButton:", true);
  }

  final Boolean showHidden = chooserDescriptor.getUserData(PathChooserDialog.NATIVE_MAC_CHOOSER_SHOW_HIDDEN_FILES);
  if (Boolean.TRUE.equals(showHidden) || Registry.is("ide.mac.file.chooser.show.hidden.files")) {
    if (Foundation.isClassRespondsToSelector(nsOpenPanel, Foundation.createSelector("setShowsHiddenFiles:"))) {
      invoke(chooser, "setShowsHiddenFiles:", true);
    }
  }

  invoke(chooser, "setDelegate:", self);

  ID directory = null;
  ID file = null;
  final String toSelectPath = toSelect == null || toSelect.intValue() == 0 ? null : Foundation.toStringViaUTF8(toSelect);
  if (toSelectPath != null) {
    final File toSelectFile = new File(toSelectPath);
    if (toSelectFile.isDirectory()) {
      directory = toSelect;
    }
    else if (toSelectFile.isFile()) {
      directory = Foundation.nsString(toSelectFile.getParent());
      file = Foundation.nsString(toSelectFile.getName());
    }
  }

  ID types = null;
  if (!chooserDescriptor.isChooseFiles() && chooserDescriptor.isChooseJars()) {
    types = invoke("NSArray", "arrayWithObject:", Foundation.nsString("jar"));
  }

  final Window activeWindow = KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow();
  if (activeWindow != null) {
    String activeWindowTitle = null;
    if (activeWindow instanceof Frame) {
      activeWindowTitle = ((Frame)activeWindow).getTitle();
    }
    else if (activeWindow instanceof JDialog) {
      activeWindowTitle = ((JDialog)activeWindow).getTitle();
    }

    final ID focusedWindow = MacUtil.findWindowForTitle(activeWindowTitle);
    if (focusedWindow != null) {
      invoke(chooser, "beginSheetForDirectory:file:types:modalForWindow:modalDelegate:didEndSelector:contextInfo:",
             directory, file, types, focusedWindow, self, Foundation.createSelector("openPanelDidEnd:returnCode:contextInfo:"), chooser);
    }
  }
}
项目:consulo    文件:JBMacMessages.java   
private static Window getForemostWindow(final Window window) {
  Window _window = null;
  IdeFocusManager ideFocusManager = IdeFocusManager.getGlobalInstance();

  Component focusOwner = IdeFocusManager.findInstance().getFocusOwner();
  // Let's ask for a focused component first
  if (focusOwner != null) {
    _window = SwingUtilities.getWindowAncestor(focusOwner);
  }

  if (_window == null) {
    // Looks like ide lost focus, let's ask about the last focused component
    focusOwner = ideFocusManager.getLastFocusedFor(ideFocusManager.getLastFocusedFrame());
    if (focusOwner != null) {
      _window = SwingUtilities.getWindowAncestor(focusOwner);
    }
  }

  if (_window == null) {
    _window = WindowManager.getInstance().findVisibleFrame();
  }

  if (_window == null && window != null) {
    // It might be we just has not opened a frame yet.
    // So let's ask AWT
    focusOwner = window.getMostRecentFocusOwner();
    if (focusOwner != null) {
      _window = SwingUtilities.getWindowAncestor(focusOwner);
    }
  }

  if (_window != null) {
    // We have successfully found the window
    // Let's check that we have not missed a blocker
    if (ModalityHelper.isModalBlocked(_window)) {
      _window = ModalityHelper.getModalBlockerFor(_window);
    }
  }

  if (SystemInfo.isAppleJvm && MacUtil.getWindowTitle(_window) == null) {
    // With Apple JDK we cannot find a window if it does not have a title
    // Let's show a dialog instead of the message.
    throw new MacMessageException("MacMessage parent does not have a title.");
  }
  while (_window != null && MacUtil.getWindowTitle(_window) == null) {
    _window = _window.getOwner();
    //At least our frame should have a title
  }

  while (Registry.is("skip.untitled.windows.for.mac.messages") && _window != null && _window instanceof JDialog && !((JDialog)_window).isModal()) {
    _window = _window.getOwner();
  }

  return _window;
}
项目:consulo    文件:MacMessagesImpl.java   
private static Window showDialog(@Nullable Window window, final String methodName, final DialogParamsWrapper paramsWrapper) {

    final Window foremostWindow = getForemostWindow(window);

    final Window documentRoot = getDocumentRootFromWindow(foremostWindow);

    final ID nativeFocusedWindow = MacUtil.findWindowFromJavaWindow(foremostWindow);

    paramsWrapper.setNativeWindow(nativeFocusedWindow);

    final ID paramsArray = paramsWrapper.getParamsAsID();

    foremostWindow.addWindowListener(new WindowAdapter() {
      @Override
      public void windowClosed(WindowEvent e) {
        super.windowClosed(e);
        //if (blockedDocumentRoots.get(documentRoot) != null) {
        //   LOG.assertTrue(blockedDocumentRoots.get(documentRoot) < 2);
        //}
        queuesFromDocumentRoot.remove(documentRoot);
        if (blockedDocumentRoots.remove(documentRoot) != null) {
          throw new MacMessageException("Owner window has been removed");
        }
      }
    });

    final ID delegate = invoke(invoke(getObjcClass("NSAlertDelegate_"), "alloc"), "init");

    IdeFocusManager.getGlobalInstance().setTypeaheadEnabled(false);

    runOrPostponeForWindow(documentRoot, new Runnable() {
      @Override
      public void run() {
        invoke(delegate, "performSelectorOnMainThread:withObject:waitUntilDone:",
               createSelector(methodName), paramsArray, false);
      }
    });

    startModal(documentRoot, nativeFocusedWindow);

    IdeFocusManager.getGlobalInstance().setTypeaheadEnabled(true);
    return documentRoot;
  }
项目:consulo    文件:MacMessagesImpl.java   
private static Window getForemostWindow(final Window window) {
  Window _window = null;
  IdeFocusManager ideFocusManager = IdeFocusManager.getGlobalInstance();

  Component focusOwner = IdeFocusManager.findInstance().getFocusOwner();
  // Let's ask for a focused component first
  if (focusOwner != null) {
    _window = SwingUtilities.getWindowAncestor(focusOwner);
  }

  if (_window == null) {
    // Looks like ide lost focus, let's ask about the last focused component
    focusOwner = ideFocusManager.getLastFocusedFor(ideFocusManager.getLastFocusedFrame());
    if (focusOwner != null) {
      _window = SwingUtilities.getWindowAncestor(focusOwner);
    }
  }

  if (_window == null) {
    _window = WindowManager.getInstance().findVisibleFrame();
  }

  if (_window == null && window != null) {
    // It might be we just has not opened a frame yet.
    // So let's ask AWT
    focusOwner = window.getMostRecentFocusOwner();
    if (focusOwner != null) {
      _window = SwingUtilities.getWindowAncestor(focusOwner);
    }
  }

  if (_window != null) {
    // We have successfully found the window
    // Let's check that we have not missed a blocker
    if (ModalityHelper.isModalBlocked(_window)) {
      _window = ModalityHelper.getModalBlockerFor(_window);
    }
  }

  if (SystemInfo.isAppleJvm && MacUtil.getWindowTitle(_window) == null) {
    // With Apple JDK we cannot find a window if it does not have a title
    // Let's show a dialog instead of the message.
    throw new MacMessageException("MacMessage parent does not have a title.");
  }
  while (_window != null && MacUtil.getWindowTitle(_window) == null) {
    _window = _window.getOwner();
    //At least our frame should have a title
  }

  while (Registry.is("skip.untitled.windows.for.mac.messages") && _window != null && _window instanceof JDialog && !((JDialog)_window).isModal()) {
    _window = _window.getOwner();
  }

  return _window;
}
项目:consulo    文件:AbstractProgressIndicatorBase.java   
protected void startSystemActivity() {
  myMacActivity = myShouldStartActivity ? MacUtil.wakeUpNeo(toString()) : null;
}
项目:tools-idea    文件:MacMessagesImpl.java   
private static Window showDialog(@Nullable Window window,
                                 final String methodName, DialogParamsWrapper paramsWrapper) {

  Window foremostWindow = getForemostWindow(window);

  String foremostWindowTitle = getWindowTitle(foremostWindow);

  Window documentRoot = getDocumentRootFromWindow(foremostWindow);

  final ID nativeFocusedWindow = MacUtil.findWindowForTitle(foremostWindowTitle);

  paramsWrapper.setNativeWindow(nativeFocusedWindow);

  final ID paramsArray = paramsWrapper.getParamsAsID();


  final ID delegate = invoke(invoke(getObjcClass("NSAlertDelegate_"), "alloc"), "init");

  IdeFocusManager.getGlobalInstance().setTypeaheadEnabled(false);

  runOrPostponeForWindow(documentRoot, new Runnable() {
    @Override
    public void run() {
      invoke(delegate, "performSelectorOnMainThread:withObject:waitUntilDone:",
             createSelector(methodName), paramsArray, false);
    }
  });

  startModal(documentRoot, nativeFocusedWindow);

  IdeFocusManager.getGlobalInstance().setTypeaheadEnabled(true);
  return documentRoot;
}