From 60d529baaba485f9430e20d72816bbeeb3408b02 Mon Sep 17 00:00:00 2001 From: Rustam Vishnyakov Date: Wed, 14 Sep 2016 19:33:06 +0300 Subject: [PATCH] Show display names of user Default/Darcula copies when switching --- .../editor/colors/impl/AbstractColorsScheme.java | 8 ++++++++ .../application/options/colors/SchemesPanel.java | 13 +++---------- .../ide/actions/QuickChangeColorSchemeAction.java | 3 ++- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java b/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java index 385df80dd010..497b88fe2218 100644 --- a/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java +++ b/platform/editor-ui-ex/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java @@ -853,4 +853,12 @@ public abstract class AbstractColorsScheme implements EditorColorsScheme { public static boolean isVisible(@NotNull EditorColorsScheme scheme) { return !(scheme instanceof AbstractColorsScheme) || ((AbstractColorsScheme)scheme).isVisible(); } + + public static String getDisplayName(@NotNull EditorColorsScheme scheme) { + String schemeName = scheme.getName(); + return + schemeName.startsWith(DefaultColorsScheme.EDITABLE_COPY_PREFIX) ? + schemeName.substring(DefaultColorsScheme.EDITABLE_COPY_PREFIX.length()) : + schemeName; + } } diff --git a/platform/lang-impl/src/com/intellij/application/options/colors/SchemesPanel.java b/platform/lang-impl/src/com/intellij/application/options/colors/SchemesPanel.java index 1725c615a530..c9fceee7ab3a 100644 --- a/platform/lang-impl/src/com/intellij/application/options/colors/SchemesPanel.java +++ b/platform/lang-impl/src/com/intellij/application/options/colors/SchemesPanel.java @@ -22,7 +22,6 @@ import com.intellij.application.options.SkipSelfSearchComponent; import com.intellij.openapi.application.ApplicationBundle; import com.intellij.openapi.editor.colors.EditorColorsScheme; import com.intellij.openapi.editor.colors.impl.AbstractColorsScheme; -import com.intellij.openapi.editor.colors.impl.DefaultColorsScheme; import com.intellij.openapi.editor.colors.impl.EditorColorsSchemeImpl; import com.intellij.openapi.editor.colors.impl.EmptyColorScheme; import com.intellij.openapi.extensions.Extensions; @@ -169,7 +168,7 @@ public class SchemesPanel extends JPanel implements SkipSelfSearchComponent { private void showSaveAsDialog() { List names = ContainerUtil.newArrayList(myOptions.getSchemeNames()); - String selectedName = getSchemeDisplayName(myOptions.getSelectedScheme().getName()); + String selectedName = AbstractColorsScheme.getDisplayName(myOptions.getSelectedScheme()); SaveSchemeDialog dialog = new SaveSchemeDialog(this, ApplicationBundle.message("title.save.color.scheme.as"), names, selectedName); if (dialog.showAndGet()) { myOptions.saveSchemeAs(dialog.getSchemeName()); @@ -274,14 +273,8 @@ public class SchemesPanel extends JPanel implements SkipSelfSearchComponent { @Override public String toString() { - return getSchemeDisplayName(getSchemeName()); + return AbstractColorsScheme.getDisplayName(myScheme); } } - - private static String getSchemeDisplayName(@NotNull String schemeName) { - return - schemeName.startsWith(DefaultColorsScheme.EDITABLE_COPY_PREFIX) ? - schemeName.substring(DefaultColorsScheme.EDITABLE_COPY_PREFIX.length()) : - schemeName; - } + } diff --git a/platform/platform-impl/src/com/intellij/ide/actions/QuickChangeColorSchemeAction.java b/platform/platform-impl/src/com/intellij/ide/actions/QuickChangeColorSchemeAction.java index 9c66b28fb289..818a82fdf6e7 100644 --- a/platform/platform-impl/src/com/intellij/ide/actions/QuickChangeColorSchemeAction.java +++ b/platform/platform-impl/src/com/intellij/ide/actions/QuickChangeColorSchemeAction.java @@ -20,6 +20,7 @@ import com.intellij.openapi.actionSystem.DataContext; import com.intellij.openapi.actionSystem.DefaultActionGroup; import com.intellij.openapi.editor.colors.EditorColorsManager; import com.intellij.openapi.editor.colors.EditorColorsScheme; +import com.intellij.openapi.editor.colors.impl.AbstractColorsScheme; import com.intellij.openapi.project.DumbAwareAction; import com.intellij.openapi.project.Project; import org.jetbrains.annotations.NotNull; @@ -41,7 +42,7 @@ public class QuickChangeColorSchemeAction extends QuickSwitchSchemeAction { final EditorColorsScheme current, final EditorColorsScheme scheme, final boolean addScheme) { - group.add(new DumbAwareAction(scheme.getName(), "", scheme == current ? ourCurrentAction : ourNotCurrentAction) { + group.add(new DumbAwareAction(AbstractColorsScheme.getDisplayName(scheme), "", scheme == current ? ourCurrentAction : ourNotCurrentAction) { @Override public void actionPerformed(@Nullable AnActionEvent e) { if (addScheme) {