From 4d5a76de109effbb0eb2cd6032c0ad8ff0afb25b Mon Sep 17 00:00:00 2001 From: Konstantin Bulenkov Date: Wed, 7 Sep 2011 11:54:51 +0200 Subject: [PATCH] standard colors for Non-Project and Tests scopes --- .../com/intellij/ui/tabs/FileColorManagerImpl.java | 14 ++++++++++++-- .../src/com/intellij/ui/tabs/FileColorsModel.java | 11 +++++++---- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/ui/tabs/FileColorManagerImpl.java b/platform/lang-impl/src/com/intellij/ui/tabs/FileColorManagerImpl.java index 2fc9cb6daad4..14aef568c560 100644 --- a/platform/lang-impl/src/com/intellij/ui/tabs/FileColorManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/ui/tabs/FileColorManagerImpl.java @@ -57,11 +57,11 @@ public class FileColorManagerImpl extends FileColorManager implements Persistent static { ourDefaultColors = new LinkedHashMap(); ourDefaultColors.put("Blue", new Color(215, 237, 243)); - ourDefaultColors.put("Green", new Color(228, 241, 209)); + ourDefaultColors.put("Green", new Color(231, 250, 219)); ourDefaultColors.put("Orange", new Color(246, 224, 202)); ourDefaultColors.put("Rose", new Color(242, 206, 202)); ourDefaultColors.put("Violet", new Color(222, 213, 241)); - ourDefaultColors.put("Yellow", new Color(247, 241, 203)); + ourDefaultColors.put("Yellow", new Color(255, 255, 228)); } public FileColorManagerImpl(@NotNull final Project project) { @@ -218,6 +218,16 @@ public class FileColorManagerImpl extends FileColorManager implements Persistent return myModel.getSharedConfigurations(); } + @Nullable + public static String getColorName(Color color) { + for (String name : ourDefaultColors.keySet()) { + if (color.equals(ourDefaultColors.get(name))) { + return name; + } + } + return null; + } + @Nullable private static FileColorConfiguration findConfigurationByName(String name, List configurations) { for (FileColorConfiguration configuration : configurations) { diff --git a/platform/lang-impl/src/com/intellij/ui/tabs/FileColorsModel.java b/platform/lang-impl/src/com/intellij/ui/tabs/FileColorsModel.java index 73aa4d318b59..42b813c4e5e7 100644 --- a/platform/lang-impl/src/com/intellij/ui/tabs/FileColorsModel.java +++ b/platform/lang-impl/src/com/intellij/ui/tabs/FileColorsModel.java @@ -70,7 +70,8 @@ public class FileColorsModel implements Cloneable { assert scope != null : "There is no custom scope with name " + scopeName; final Color color = ColorUtil.getColor(scope.getClass()); assert color != null : scope.getClass().getName() + " is not annotated with @Colored"; - globalScopesColors.put(scopeName, ColorUtil.toHex(color)); + final String colorName = FileColorManagerImpl.getColorName(color); + globalScopesColors.put(scopeName, colorName == null ? ColorUtil.toHex(color) : colorName); } } initGlobalScopes(); @@ -89,10 +90,12 @@ public class FileColorsModel implements Cloneable { private void initGlobalScopes() { for (String scopeName : globalScopes.keySet()) { - if (findConfiguration(scopeName, false) == null) { - final String color = PropertiesComponent.getInstance().getOrInit(globalScopes.get(scopeName), globalScopesColors.get(scopeName)); + if (findConfiguration(scopeName, false) == null) { + final String color = PropertiesComponent.getInstance().getOrInit(globalScopes.get(scopeName), globalScopesColors.get(scopeName)); if (color.length() != 0) { - myConfigurations.add(new FileColorConfiguration(scopeName, color)); + final Color col = ColorUtil.fromHex(color, null); + final String name = col == null ? null : FileColorManagerImpl.getColorName(col); + myConfigurations.add(new FileColorConfiguration(scopeName, name == null ? color : name)); } } }