mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
toolwindow: optionally do not track last focused component
This commit is contained in:
@@ -47,5 +47,8 @@ public interface ToolWindowEx extends ToolWindow {
|
||||
|
||||
InternalDecorator getDecorator();
|
||||
|
||||
void setUseLastFocusedOnActivation(boolean focus);
|
||||
|
||||
boolean isUseLastFocusedOnActivation();
|
||||
|
||||
}
|
||||
|
||||
@@ -71,6 +71,7 @@ public final class ToolWindowImpl implements ToolWindowEx {
|
||||
return myComponent != null && myComponent.isShowing();
|
||||
}
|
||||
};
|
||||
private boolean myUseLastFocused = true;
|
||||
|
||||
ToolWindowImpl(final ToolWindowManagerImpl toolWindowManager, final String id, boolean canCloseContent, @Nullable final JComponent component) {
|
||||
myToolWindowManager = toolWindowManager;
|
||||
@@ -427,4 +428,14 @@ public final class ToolWindowImpl implements ToolWindowEx {
|
||||
public void showContentPopup(InputEvent inputEvent) {
|
||||
myContentUI.showContentPopup(inputEvent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUseLastFocusedOnActivation(boolean focus) {
|
||||
myUseLastFocused = focus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseLastFocusedOnActivation() {
|
||||
return myUseLastFocused;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -23,6 +23,7 @@ import com.intellij.openapi.wm.FocusWatcher;
|
||||
import com.intellij.openapi.wm.IdeFocusManager;
|
||||
import com.intellij.openapi.wm.WindowManager;
|
||||
import com.intellij.openapi.wm.ex.IdeFocusTraversalPolicy;
|
||||
import com.intellij.openapi.wm.ex.ToolWindowEx;
|
||||
import com.intellij.openapi.wm.impl.FloatingDecorator;
|
||||
import com.intellij.openapi.wm.impl.ToolWindowImpl;
|
||||
import com.intellij.openapi.wm.impl.WindowManagerImpl;
|
||||
@@ -70,7 +71,7 @@ public final class RequestFocusInToolWindowCmd extends FinalizableCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
Component preferredFocusedComponent = myFocusWatcher.getFocusedComponent();
|
||||
Component preferredFocusedComponent = myToolWindow.isUseLastFocusedOnActivation() ? myFocusWatcher.getFocusedComponent() : null;
|
||||
|
||||
if (preferredFocusedComponent == null && myToolWindow.getContentManager().getSelectedContent() != null) {
|
||||
preferredFocusedComponent = myToolWindow.getContentManager().getSelectedContent().getPreferredFocusableComponent();
|
||||
|
||||
Reference in New Issue
Block a user