Incompatible scheme notification

This commit is contained in:
Rustam Vishnyakov
2017-06-25 17:57:41 +03:00
parent 17b62d40d9
commit 55a98e26f1
2 changed files with 18 additions and 7 deletions
@@ -1010,8 +1010,9 @@ public abstract class AbstractColorsScheme extends EditorFontCacheImpl implement
if (myParentScheme instanceof TemporaryParent) {
String parentName = ((TemporaryParent)myParentScheme).getParentName();
EditorColorsScheme newParent = nameResolver.apply(parentName);
assert newParent != null : "Can not resolve '" + parentName + "' color scheme.";
assert newParent instanceof ReadOnlyColorsScheme : "Resolved parent color scheme must be read-only.";
if (newParent == null || !(newParent instanceof ReadOnlyColorsScheme)) {
throw new InvalidDataException(parentName);
}
myParentScheme = newParent;
}
}
@@ -22,6 +22,9 @@ import com.intellij.configurationStore.SchemeDataHolder;
import com.intellij.configurationStore.SchemeExtensionProvider;
import com.intellij.ide.WelcomeWizardUtil;
import com.intellij.ide.ui.LafManager;
import com.intellij.notification.Notification;
import com.intellij.notification.NotificationType;
import com.intellij.notification.Notifications;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.impl.ApplicationImpl;
@@ -41,6 +44,7 @@ import com.intellij.openapi.options.SchemeManagerFactory;
import com.intellij.openapi.options.SchemeState;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.ComponentTreeEventDispatcher;
import com.intellij.util.JdomKt;
@@ -52,10 +56,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.*;
import java.util.function.Function;
@State(
@@ -190,7 +191,16 @@ public class EditorColorsManagerImpl extends EditorColorsManager implements Pers
private void resolveLinksToBundledSchemes() {
for (EditorColorsScheme scheme : mySchemeManager.getAllSchemes()) {
if (scheme instanceof AbstractColorsScheme && !(scheme instanceof ReadOnlyColorsScheme)) {
((AbstractColorsScheme)scheme).resolveParent(name -> mySchemeManager.findSchemeByName(name));
try {
((AbstractColorsScheme)scheme).resolveParent(name -> mySchemeManager.findSchemeByName(name));
}
catch (InvalidDataException e) {
String message = "Color scheme '" + scheme.getName() + "'" +
" points to incorrect or non-existent default (base) scheme " +
e.getMessage();
Notifications.Bus.notify(
new Notification(Notifications.SYSTEM_MESSAGES_GROUP_ID, "Incompatible color scheme", message, NotificationType.ERROR));
}
}
}
}