Show display names of user Default/Darcula copies when switching

This commit is contained in:
Rustam Vishnyakov
2016-09-14 19:33:43 +03:00
parent 7b5f45e898
commit 60d529baab
3 changed files with 13 additions and 11 deletions
@@ -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;
}
}
@@ -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<String> 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;
}
}
@@ -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) {