本文整理汇总了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;
}
示例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;
}