From d267ff40f9baf6c05f16762815b3d97bf5b4141d Mon Sep 17 00:00:00 2001 From: irengrig Date: Fri, 26 Feb 2016 14:05:14 +0100 Subject: [PATCH] do not show notification if user schema overrides system schema - according to discussion in review of WEB-20499 JSON Schema: in case of system and user schemas overlapping - use user schema only --- .../JsonSchemaConflictNotificationProvider.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/json/src/com/jetbrains/jsonSchema/impl/JsonSchemaConflictNotificationProvider.java b/json/src/com/jetbrains/jsonSchema/impl/JsonSchemaConflictNotificationProvider.java index 139ad3fa0db5..fb0da093362f 100644 --- a/json/src/com/jetbrains/jsonSchema/impl/JsonSchemaConflictNotificationProvider.java +++ b/json/src/com/jetbrains/jsonSchema/impl/JsonSchemaConflictNotificationProvider.java @@ -65,10 +65,12 @@ public class JsonSchemaConflictNotificationProvider extends EditorNotifications. final Worker worker = new Worker(); final String message = worker.createMessage(descriptors); + if (message == null) return null; + final EditorNotificationPanel panel = new EditorNotificationPanel() { @Override public Color getBackground() { - return worker.myIsOverridingSystemSchemaCase ? LightColors.SLIGHTLY_GREEN : LightColors.RED; + return LightColors.RED; } }; panel.setText(message); @@ -83,21 +85,15 @@ public class JsonSchemaConflictNotificationProvider extends EditorNotifications. } private static class Worker { - private boolean myIsOverridingSystemSchemaCase; - public String createMessage(@NotNull final List> descriptors) { int numOfSystemSchemas = 0; - String systemSchemaName = ""; for (Pair pair : descriptors) { if (!Boolean.TRUE.equals(pair.getFirst())) { ++ numOfSystemSchemas; - systemSchemaName = pair.getSecond(); } } - String additionalInfo = ""; if (numOfSystemSchemas == 1) { - myIsOverridingSystemSchemaCase = true; - additionalInfo = "
System schema '" + systemSchemaName + "' was not applied."; + return null; } boolean withTypes = numOfSystemSchemas > 0; final List names = new ArrayList<>(); @@ -108,7 +104,7 @@ public class JsonSchemaConflictNotificationProvider extends EditorNotifications. names.add(pair.getSecond()); } } - return "There are several JSON Schemas mapped to this file: " + StringUtil.join(names, "; ") + additionalInfo + ""; + return "There are several JSON Schemas mapped to this file: " + StringUtil.join(names, "; ") + ""; } } }