From be7d172dd748bf93f627fd214b336fc572d21699 Mon Sep 17 00:00:00 2001 From: "Denis.Zhdanov" Date: Tue, 28 May 2013 18:24:41 +0400 Subject: [PATCH] IDEA-104500 Gradle: Allow to reuse common logic for other external systems Correct reflection-based processing --- .../util/ExternalSystemUiUtil.java | 40 ++++++++++--------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/util/ExternalSystemUiUtil.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/util/ExternalSystemUiUtil.java index 927a8dba6a23..e4da24c32232 100644 --- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/util/ExternalSystemUiUtil.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/util/ExternalSystemUiUtil.java @@ -147,31 +147,35 @@ public class ExternalSystemUiUtil { } public static void showUi(@NotNull Object o, boolean show) { - for (Field field : o.getClass().getFields()) { - field.setAccessible(true); - try { - Object v = field.get(o); - if (v instanceof JComponent) { - ((JComponent)v).setVisible(show); + for (Class clazz = o.getClass(); clazz != Object.class; clazz = clazz.getSuperclass()) { + for (Field field : clazz.getDeclaredFields()) { + field.setAccessible(true); + try { + Object v = field.get(o); + if (v instanceof JComponent) { + ((JComponent)v).setVisible(show); + } + } + catch (IllegalAccessException e) { + // Ignore } - } - catch (IllegalAccessException e) { - // Ignore } } } public static void disposeUi(@NotNull Object o) { - for (Field field : o.getClass().getFields()) { - field.setAccessible(true); - try { - Object v = field.get(o); - if (v instanceof JComponent) { - field.set(o, null); + for (Class clazz = o.getClass(); clazz != Object.class; clazz = clazz.getSuperclass()) { + for (Field field : clazz.getDeclaredFields()) { + field.setAccessible(true); + try { + Object v = field.get(o); + if (v instanceof JComponent) { + field.set(o, null); + } + } + catch (IllegalAccessException e) { + // Ignore } - } - catch (IllegalAccessException e) { - // Ignore } } }