mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fixed side-effects for disabled awt focus traversal policy (no default component) -- wrong default focused component in the breakpoints dialog
This commit is contained in:
@@ -17,6 +17,7 @@ package com.intellij.openapi.wm.ex;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.impl.EditorComponentImpl;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -56,11 +57,22 @@ public class IdeFocusTraversalPolicy extends LayoutFocusTraversalPolicyExt {
|
||||
if (focusTraversalPolicy.getClass().getName().indexOf("LegacyGlueFocusTraversalPolicy") >=0) {
|
||||
return component;
|
||||
}
|
||||
final Component defaultComponent = focusTraversalPolicy.getDefaultComponent(component);
|
||||
|
||||
Component defaultComponent;
|
||||
if (focusTraversalPolicy instanceof LayoutFocusTraversalPolicyExt) {
|
||||
final LayoutFocusTraversalPolicyExt extPolicy = (LayoutFocusTraversalPolicyExt)focusTraversalPolicy;
|
||||
defaultComponent = extPolicy.queryImpl(new Computable<Component>() {
|
||||
@Override
|
||||
public Component compute() {
|
||||
return extPolicy.getDefaultComponent(component);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
defaultComponent = focusTraversalPolicy.getDefaultComponent(component);
|
||||
}
|
||||
|
||||
if (defaultComponent instanceof JComponent) {
|
||||
return (JComponent)defaultComponent;
|
||||
}else{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+15
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.openapi.wm.ex;
|
||||
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -33,6 +34,8 @@ public class LayoutFocusTraversalPolicyExt extends LayoutFocusTraversalPolicy{
|
||||
private boolean myNoDefaultComponent;
|
||||
private Object myNoDefaultComponentRequestor;
|
||||
|
||||
private boolean myQueryImpl = false;
|
||||
|
||||
public void setNoDefaultComponent(boolean noDefaultComponent, Object requestor) {
|
||||
if (noDefaultComponent) {
|
||||
myNoDefaultComponent = noDefaultComponent;
|
||||
@@ -46,6 +49,8 @@ public class LayoutFocusTraversalPolicyExt extends LayoutFocusTraversalPolicy{
|
||||
}
|
||||
|
||||
public boolean isNoDefaultComponent() {
|
||||
if (myQueryImpl) return false;
|
||||
|
||||
return myNoDefaultComponent || Registry.is("actionSystem.noDefaultComponent");
|
||||
}
|
||||
|
||||
@@ -158,4 +163,14 @@ public class LayoutFocusTraversalPolicyExt extends LayoutFocusTraversalPolicy{
|
||||
protected Component getComponentBeforeImpl(final Container focusCycleRoot, final Component aComponent) {
|
||||
return super.getComponentBefore(focusCycleRoot, aComponent);
|
||||
}
|
||||
|
||||
public Component queryImpl(Computable<Component> runnable) {
|
||||
try {
|
||||
myQueryImpl = true;
|
||||
return runnable.compute();
|
||||
}
|
||||
finally {
|
||||
myQueryImpl = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user