rollback changes in scheme manager and fix installers

This commit is contained in:
Konstantin Bulenkov
2018-07-20 14:54:06 +02:00
parent 4c95ccef21
commit 6575e27cdb
5 changed files with 40 additions and 6 deletions
@@ -3,6 +3,7 @@ package com.intellij.configurationStore
import com.intellij.concurrency.ConcurrentCollectionFactory
import com.intellij.configurationStore.schemeManager.*
import com.intellij.ide.ui.UITheme
import com.intellij.openapi.application.ex.DecodeDefaultsUtil
import com.intellij.openapi.application.runUndoTransparentWriteAction
import com.intellij.openapi.components.RoamingType
@@ -111,6 +112,7 @@ class SchemeManagerImpl<T : Any, MUTABLE_SCHEME : T>(val fileSpec: String,
try {
val url = when (requestor) {
is AbstractExtensionPointBean -> requestor.loaderForClass.getResource(resourceName)
is UITheme -> DecodeDefaultsUtil.getDefaults(requestor.providerClassLoader, resourceName)
else -> DecodeDefaultsUtil.getDefaults(requestor, resourceName)
}
@@ -140,6 +142,9 @@ class SchemeManagerImpl<T : Any, MUTABLE_SCHEME : T>(val fileSpec: String,
LOG.warn("Duplicated scheme ${schemeKey} - old: $oldScheme, new $scheme")
}
schemes.add(scheme)
if (requestor is UITheme) {
requestor.editorSchemeName = schemeKey
}
}
}
catch (e: ProcessCanceledException) {
@@ -36,7 +36,8 @@ public class UITheme {
private Map<String, Object> icons;
private IconPathPatcher patcher;
private Map<String, Object> background;
private ClassLoader providerClassLoader;
private ClassLoader providerClassLoader = getClass().getClassLoader();
private String editorSchemeName;
private UITheme() {
}
@@ -95,6 +96,7 @@ public class UITheme {
return patcher;
}
@NotNull
public ClassLoader getProviderClassLoader() {
return providerClassLoader;
}
@@ -204,6 +206,14 @@ public class UITheme {
return new JBDimension(Integer.parseInt(numbers.get(0)), Integer.parseInt(numbers.get(1))).asUIResource();
}
public String getEditorSchemeName() {
return editorSchemeName;
}
public void setEditorSchemeName(String editorSchemeName) {
this.editorSchemeName = editorSchemeName;
}
//
//json deserialization methods
//
@@ -4,6 +4,8 @@ package com.intellij.ide.ui.laf;
import com.intellij.ide.ui.UITheme;
import com.intellij.ide.ui.laf.darcula.DarculaLaf;
import com.intellij.ide.util.PropertiesComponent;
import com.intellij.openapi.editor.colors.EditorColorsManager;
import com.intellij.openapi.editor.colors.EditorColorsScheme;
import com.intellij.openapi.util.IconLoader;
import com.intellij.openapi.util.IconPathPatcher;
import com.intellij.openapi.util.text.StringUtil;
@@ -36,6 +38,17 @@ public class UIThemeBasedLookAndFeelInfo extends UIManager.LookAndFeelInfo {
}
installBackgroundImage();
installEditorScheme();
}
private void installEditorScheme() {
String name = myTheme.getEditorSchemeName();
if (name != null) {
EditorColorsScheme scheme = EditorColorsManager.getInstance().getScheme(name);
if (scheme != null) {
EditorColorsManager.getInstance().setGlobalScheme(scheme);
}
}
}
private void installBackgroundImage() {
@@ -36,14 +36,13 @@ public class DecodeDefaultsUtil {
public static URL getDefaults(Object requestor, @NotNull String componentResourcePath) {
URL url = RESOURCE_CACHE.get(componentResourcePath);
if (url == null) {
Class<?> requestorClass = requestor instanceof Class ? (Class<?>)requestor : requestor.getClass();
if (StringUtil.startsWithChar(componentResourcePath, '/')) {
url = requestorClass.getResource(appendExt(componentResourcePath));
url = getResource(appendExt(componentResourcePath), requestor);
}
else {
url = requestorClass.getResource(appendExt('/' + ApplicationManagerEx.getApplicationEx().getName() + '/' + componentResourcePath));
url = getResource(appendExt('/' + ApplicationManagerEx.getApplicationEx().getName() + '/' + componentResourcePath), requestor);
if (url == null) {
url = requestorClass.getResource(appendExt('/' + componentResourcePath));
url = getResource(appendExt('/' + componentResourcePath), requestor);
}
}
RESOURCE_CACHE.put(componentResourcePath, url);
@@ -51,6 +50,13 @@ public class DecodeDefaultsUtil {
return url;
}
private static URL getResource(String path, Object requestor) {
if (requestor instanceof ClassLoader) {
return ((ClassLoader)requestor).getResource(path);
}
return requestor.getClass().getResource(path);
}
private static String appendExt(@NotNull String s) {
return appendIfNeeded(s, FileStorageCoreUtil.DEFAULT_EXT);
}
@@ -185,7 +185,7 @@ public class EditorColorsManagerImpl extends EditorColorsManager implements Pers
UITheme theme = ((UIThemeBasedLookAndFeelInfo)laf).getTheme();
String path = theme.getEditorScheme();
if (path != null) {
mySchemeManager.loadBundledScheme(path, theme.getProviderClassLoader());
mySchemeManager.loadBundledScheme(path, theme);
}
}
}