当前位置: 首页>>代码示例>>Java>>正文


Java IdeFocusManager.getLastFocusedFor方法代码示例

本文整理汇总了Java中com.intellij.openapi.wm.IdeFocusManager.getLastFocusedFor方法的典型用法代码示例。如果您正苦于以下问题:Java IdeFocusManager.getLastFocusedFor方法的具体用法?Java IdeFocusManager.getLastFocusedFor怎么用?Java IdeFocusManager.getLastFocusedFor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.wm.IdeFocusManager的用法示例。


在下文中一共展示了IdeFocusManager.getLastFocusedFor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getActiveSplitters

import com.intellij.openapi.wm.IdeFocusManager; //导入方法依赖的package包/类
@NotNull
private AsyncResult<EditorsSplitters> getActiveSplitters(boolean syncUsage) {
  final boolean async = Registry.is("ide.windowSystem.asyncSplitters") && !syncUsage;

  final AsyncResult<EditorsSplitters> result = new AsyncResult<EditorsSplitters>();
  final IdeFocusManager fm = IdeFocusManager.getInstance(myProject);
  Runnable run = new Runnable() {
    @Override
    public void run() {
      if (myProject.isDisposed()) {
        result.setRejected();
        return;
      }

      Component focusOwner = fm.getFocusOwner();
      if (focusOwner == null && !async) {
        focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
      }

      if (focusOwner == null && !async) {
        focusOwner = fm.getLastFocusedFor(fm.getLastFocusedFrame());
      }

      DockContainer container = myDockManager.getContainerFor(focusOwner);
      if (container == null && !async) {
        focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow();
        container = myDockManager.getContainerFor(focusOwner);
      }

      if (container instanceof DockableEditorTabbedContainer) {
        result.setDone(((DockableEditorTabbedContainer)container).getSplitters());
      }
      else {
        result.setDone(getMainSplitters());
      }
    }
  };

  if (async) {
    fm.doWhenFocusSettlesDown(run);
  }
  else {
    UIUtil.invokeLaterIfNeeded(run);
  }

  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:48,代码来源:FileEditorManagerImpl.java

示例2: getForemostWindow

import com.intellij.openapi.wm.IdeFocusManager; //导入方法依赖的package包/类
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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:56,代码来源:JBMacMessages.java


注:本文中的com.intellij.openapi.wm.IdeFocusManager.getLastFocusedFor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。