make sure the restored console content LaF is up-to-date

This commit is contained in:
Gregory.Shrago
2019-03-21 18:56:39 +03:00
parent 3874a741fe
commit 0f741057ca
@@ -15,6 +15,8 @@
*/
package com.intellij.openapi.editor.colors;
import com.intellij.ide.ui.UISettings;
import com.intellij.ide.ui.UISettingsListener;
import com.intellij.ui.ColorUtil;
import com.intellij.util.ui.UIUtil;
import org.jetbrains.annotations.NotNull;
@@ -77,4 +79,22 @@ public class EditorColorsUtil {
return colorsManager.isDarkEditor() ? colorsManager.getScheme(EditorColorsManager.DEFAULT_SCHEME_NAME)
: colorsManager.getGlobalScheme();
}
/**
* Use this method before showing a hidden component to make sure its LaF and colors are up-to-date.
* If a component was not reachable via Swing hierarchy and also was not reported via
* {@link UIUtil#NOT_IN_HIERARCHY_COMPONENTS}, its look-and-feel and colors need to be refreshed.
*
* @see com.intellij.util.ComponentTreeEventDispatcher
* @see UIUtil#NOT_IN_HIERARCHY_COMPONENTS
*/
public static void updateNotInHierarchyComponentUIAndColors(@Nullable Component component) {
if (component == null || component.isValid()) return;
for (Component o : UIUtil.uiTraverser(component).postOrderDfsTraversal()) {
if (o instanceof JComponent) ((JComponent)o).updateUI();
if (o instanceof UISettingsListener) ((UISettingsListener)o).uiSettingsChanged(UISettings.getInstance());
if (o instanceof EditorColorsListener)
((EditorColorsListener)o).globalSchemeChange(EditorColorsManager.getInstance().getGlobalScheme());
}
}
}