com.intellij.ui.FocusTrackback Maven / Gradle / Ivy
/*
* Copyright 2000-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.ui;
import com.intellij.ide.DataManager;
import com.intellij.openapi.actionSystem.CommonDataKeys;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.popup.JBPopup;
import com.intellij.openapi.util.ActionCallback;
import com.intellij.openapi.util.ExpirableRunnable;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.wm.FocusCommand;
import com.intellij.openapi.wm.IdeFocusManager;
import com.intellij.openapi.wm.ex.LayoutFocusTraversalPolicyExt;
import com.intellij.ui.popup.AbstractPopup;
import com.intellij.util.containers.WeakKeyWeakValueHashMap;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
import java.lang.ref.WeakReference;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.WeakHashMap;
public class FocusTrackback {
private static final Logger LOG = Logger.getInstance("FocusTrackback");
private Window myParentWindow;
private Window myRoot;
private WeakReference myFocusOwner = new WeakReference(null);
private WeakReference myLocalFocusOwner = new WeakReference(null);
private static final Map> ourRootWindowToParentsStack = new WeakHashMap>();
private static final Map ourRootWindowToFocusedMap = new WeakKeyWeakValueHashMap();
private final String myRequestorName;
private ComponentQuery myFocusedComponentQuery;
private boolean myMustBeShown;
private boolean myConsumed;
private final WeakReference myRequestor;
private boolean mySheduledForRestore;
private boolean myWillBeSheduledForRestore;
private boolean myForcedRestore;
public FocusTrackback(@NotNull Object requestor, Component parent, boolean mustBeShown) {
this(requestor, parent == null ? null : UIUtil.getWindow(parent), mustBeShown);
}
public FocusTrackback(@NotNull Object requestor, Window parent, boolean mustBeShown) {
myRequestor = new WeakReference
© 2015 - 2025 Weber Informatics LLC | Privacy Policy