mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
close navbar on modal dialogs
This commit is contained in:
@@ -53,7 +53,7 @@ import java.util.List;
|
||||
*/
|
||||
public class NavBarListener extends WolfTheProblemSolver.ProblemListener
|
||||
implements ActionListener, FocusListener, FileStatusListener, AnActionListener, FileEditorManagerListener,
|
||||
PsiTreeChangeListener, ModuleRootListener, NavBarModelListener, PropertyChangeListener, KeyListener {
|
||||
PsiTreeChangeListener, ModuleRootListener, NavBarModelListener, PropertyChangeListener, KeyListener, WindowFocusListener {
|
||||
private static final String LISTENER = "NavBarListener";
|
||||
private static final String BUS = "NavBarMessageBus";
|
||||
private final NavBarPanel myPanel;
|
||||
@@ -62,6 +62,7 @@ public class NavBarListener extends WolfTheProblemSolver.ProblemListener
|
||||
if (panel.getClientProperty(LISTENER) != null) {
|
||||
unsubscribeFrom(panel);
|
||||
}
|
||||
|
||||
final NavBarListener listener = new NavBarListener(panel);
|
||||
final Project project = panel.getProject();
|
||||
panel.putClientProperty(LISTENER, listener);
|
||||
@@ -77,6 +78,13 @@ public class NavBarListener extends WolfTheProblemSolver.ProblemListener
|
||||
connection.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, listener);
|
||||
panel.putClientProperty(BUS, connection);
|
||||
panel.addKeyListener(listener);
|
||||
|
||||
if (panel.isInFloatingMode()) {
|
||||
final Window window = SwingUtilities.windowForComponent(panel);
|
||||
if (window != null) {
|
||||
window.addWindowFocusListener(listener);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void unsubscribeFrom(NavBarPanel panel) {
|
||||
@@ -315,7 +323,19 @@ public class NavBarListener extends WolfTheProblemSolver.ProblemListener
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowLostFocus(WindowEvent e) {
|
||||
final Window window = e.getWindow();
|
||||
final Window oppositeWindow = e.getOppositeWindow();
|
||||
System.out.println(window);
|
||||
System.out.println(oppositeWindow);
|
||||
}
|
||||
|
||||
//---- Ignored
|
||||
@Override
|
||||
public void windowGainedFocus(WindowEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.intellij.ide.navigationToolbar.ui.NavBarUIManager;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.DataProvider;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.ui.Queryable;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
@@ -35,10 +36,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -127,6 +125,22 @@ public class NavBarPopup extends LightweightHint implements Disposable{
|
||||
ListScrollingUtil.selectItem(list, myIndex);
|
||||
}
|
||||
}
|
||||
if (myPanel.isInFloatingMode()) {
|
||||
final Window window = SwingUtilities.windowForComponent(getList());
|
||||
window.addWindowFocusListener(new WindowFocusListener() {
|
||||
@Override
|
||||
public void windowGainedFocus(WindowEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void windowLostFocus(WindowEvent e) {
|
||||
final Window w = e.getOppositeWindow();
|
||||
if (w != null && DialogWrapper.findInstance(w.getComponent(0)) != null) {
|
||||
myPanel.hideHint();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user