From 97ade8df9d996a67b74b2c1be1174d0cee6635ac Mon Sep 17 00:00:00 2001 From: "Gregory.Shrago" Date: Tue, 22 Apr 2014 23:45:47 +0400 Subject: [PATCH] ability to enable only visible components --- platform/util/src/com/intellij/util/ui/UIUtil.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/platform/util/src/com/intellij/util/ui/UIUtil.java b/platform/util/src/com/intellij/util/ui/UIUtil.java index 59272d4d93c0..2195ede58d47 100644 --- a/platform/util/src/com/intellij/util/ui/UIUtil.java +++ b/platform/util/src/com/intellij/util/ui/UIUtil.java @@ -384,6 +384,10 @@ public class UIUtil { } public static void setEnabled(Component component, boolean enabled, boolean recursively) { + setEnabled(component, enabled, recursively, false); + } + + public static void setEnabled(Component component, boolean enabled, boolean recursively, boolean visibleOnly) { component.setEnabled(enabled); if (component instanceof JComboBox && isUnderAquaLookAndFeel()) { // On Mac JComboBox instances have children: com.apple.laf.AquaComboBoxButton and javax.swing.CellRendererPane. @@ -401,7 +405,9 @@ public class UIUtil { final Container container = (Container)component; final int subComponentCount = container.getComponentCount(); for (int i = 0; i < subComponentCount; i++) { - setEnabled(container.getComponent(i), enabled, recursively); + Component child = container.getComponent(i); + if (visibleOnly && !child.isVisible()) continue; + setEnabled(child, enabled, recursively, visibleOnly); } } }