diff --git a/java/java-impl/src/com/intellij/openapi/options/colors/pages/JavaColorSettingsPage.java b/java/java-impl/src/com/intellij/openapi/options/colors/pages/JavaColorSettingsPage.java index 709620fe44d1..c859efae8fce 100644 --- a/java/java-impl/src/com/intellij/openapi/options/colors/pages/JavaColorSettingsPage.java +++ b/java/java-impl/src/com/intellij/openapi/options/colors/pages/JavaColorSettingsPage.java @@ -133,14 +133,6 @@ public class JavaColorSettingsPage implements ColorSettingsPage, InspectionColor public AttributesDescriptor[] getAttributeDescriptors() { List descriptors = new ArrayList(); descriptors.addAll(Arrays.asList(ourDescriptors)); - descriptors.add(new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.unknown.symbol"), CodeInsightColors.WRONG_REFERENCES_ATTRIBUTES)); - descriptors.add(new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.deprecated.symbol"), CodeInsightColors.DEPRECATED_ATTRIBUTES)); - descriptors.add(new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.unused.symbol"), CodeInsightColors.NOT_USED_ELEMENT_ATTRIBUTES)); - descriptors.add(new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.error"), CodeInsightColors.ERRORS_ATTRIBUTES)); - descriptors.add(new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.warning"), CodeInsightColors.WARNINGS_ATTRIBUTES)); - descriptors.add(new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.info"), CodeInsightColors.INFO_ATTRIBUTES)); - descriptors.add(new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.server.problems"), CodeInsightColors.GENERIC_SERVER_ERROR_OR_WARNING)); - descriptors.add(new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.server.duplicate"), CodeInsightColors.DUPLICATE_FROM_SERVER)); descriptors.add(new AttributesDescriptor(OptionsBundle.message("options.java.color.descriptor.full.coverage"), CodeInsightColors.LINE_FULL_COVERAGE)); descriptors.add(new AttributesDescriptor(OptionsBundle.message("options.java.color.descriptor.partial.coverage"), CodeInsightColors.LINE_PARTIAL_COVERAGE)); descriptors.add(new AttributesDescriptor(OptionsBundle.message("options.java.color.descriptor.none.coverage"), CodeInsightColors.LINE_NONE_COVERAGE)); diff --git a/platform/lang-impl/src/com/intellij/application/options/colors/ColorAndFontOptions.java b/platform/lang-impl/src/com/intellij/application/options/colors/ColorAndFontOptions.java index ef82cdb1de28..c2ab2004c573 100644 --- a/platform/lang-impl/src/com/intellij/application/options/colors/ColorAndFontOptions.java +++ b/platform/lang-impl/src/com/intellij/application/options/colors/ColorAndFontOptions.java @@ -418,7 +418,7 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract ArrayList descriptions, MyColorScheme scheme) { String group = page.getDisplayName(); - AttributesDescriptor[] attributeDescriptors = page.getAttributeDescriptors(); + List attributeDescriptors = ColorSettingsUtil.getAllAttributeDescriptors(page); for (AttributesDescriptor descriptor : attributeDescriptors) { addSchemedDescription(descriptions, descriptor.getDisplayName(), group, descriptor.getKey(), scheme, null, null); } diff --git a/platform/lang-impl/src/com/intellij/application/options/colors/ColorSettingsUtil.java b/platform/lang-impl/src/com/intellij/application/options/colors/ColorSettingsUtil.java index 4bdca9d42a14..e91fb132c69a 100644 --- a/platform/lang-impl/src/com/intellij/application/options/colors/ColorSettingsUtil.java +++ b/platform/lang-impl/src/com/intellij/application/options/colors/ColorSettingsUtil.java @@ -16,14 +16,20 @@ package com.intellij.application.options.colors; +import com.intellij.openapi.editor.colors.CodeInsightColors; import com.intellij.openapi.editor.colors.EditorColorsManager; import com.intellij.openapi.editor.colors.EditorColorsScheme; import com.intellij.openapi.editor.colors.TextAttributesKey; import com.intellij.openapi.editor.colors.impl.EditorColorsManagerImpl; +import com.intellij.openapi.extensions.Extensions; +import com.intellij.openapi.options.OptionsBundle; import com.intellij.openapi.options.colors.AttributesDescriptor; import com.intellij.openapi.options.colors.ColorSettingsPage; import com.intellij.util.containers.HashMap; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; import java.util.Map; /** @@ -34,7 +40,7 @@ public class ColorSettingsUtil { } public static Map keyToDisplayTextMap(final ColorSettingsPage page) { - final AttributesDescriptor[] attributeDescriptors = page.getAttributeDescriptors(); + final List attributeDescriptors = getAllAttributeDescriptors(page); final Map displayText = new HashMap(); for (AttributesDescriptor attributeDescriptor : attributeDescriptors) { final TextAttributesKey key = attributeDescriptor.getKey(); @@ -43,7 +49,38 @@ public class ColorSettingsUtil { return displayText; } + public static List getAllAttributeDescriptors(ColorSettingsPage page) { + List result = new ArrayList(); + Collections.addAll(result, page.getAttributeDescriptors()); + if (isInspectionColorsPage(page)) { + addInspectionSeverityAttributes(result); + } + return result; + } + + private static boolean isInspectionColorsPage(ColorSettingsPage page) { + // the first registered page implementing InspectionColorSettingsPage + // gets the inspection attribute descriptors added to its list + if (!(page instanceof InspectionColorSettingsPage)) return false; + for(ColorSettingsPage settingsPage: Extensions.getExtensions(ColorSettingsPage.EP_NAME)) { + if (settingsPage == page) break; + if (settingsPage instanceof InspectionColorSettingsPage) return false; + } + return true; + } + static boolean isSharedScheme(EditorColorsScheme selected) { return ((EditorColorsManagerImpl) EditorColorsManager.getInstance()).getSchemesManager().isShared(selected); } + + private static void addInspectionSeverityAttributes(List descriptors) { + descriptors.add(new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.unknown.symbol"), CodeInsightColors.WRONG_REFERENCES_ATTRIBUTES)); + descriptors.add(new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.deprecated.symbol"), CodeInsightColors.DEPRECATED_ATTRIBUTES)); + descriptors.add(new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.unused.symbol"), CodeInsightColors.NOT_USED_ELEMENT_ATTRIBUTES)); + descriptors.add(new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.error"), CodeInsightColors.ERRORS_ATTRIBUTES)); + descriptors.add(new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.warning"), CodeInsightColors.WARNINGS_ATTRIBUTES)); + descriptors.add(new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.info"), CodeInsightColors.INFO_ATTRIBUTES)); + descriptors.add(new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.server.problems"), CodeInsightColors.GENERIC_SERVER_ERROR_OR_WARNING)); + descriptors.add(new AttributesDescriptor(OptionsBundle.message("options.java.attribute.descriptor.server.duplicate"), CodeInsightColors.DUPLICATE_FROM_SERVER)); + } } diff --git a/platform/lang-impl/src/com/intellij/application/options/colors/InspectionColorSettingsPage.java b/platform/lang-impl/src/com/intellij/application/options/colors/InspectionColorSettingsPage.java index 6c00e222acbb..bf77f84d7f9c 100644 --- a/platform/lang-impl/src/com/intellij/application/options/colors/InspectionColorSettingsPage.java +++ b/platform/lang-impl/src/com/intellij/application/options/colors/InspectionColorSettingsPage.java @@ -18,6 +18,8 @@ package com.intellij.application.options.colors; /** * Marker interface for pages capable of editing the colors for inspection problems. + * The first page implementing this interface gets the inspection attribute descriptors + * added to its attribute descriptors list automatically. * * @author yole */