From 9f9f124de3ddf66d288b3f7b6f1b82f3240cdd37 Mon Sep 17 00:00:00 2001 From: Sergey Malenkov Date: Mon, 16 Apr 2018 17:46:26 +0300 Subject: [PATCH] fix patcher for deprecated icons --- .../DeprecatedDuplicatesIconPathPatcher.java | 116 ++++++++++++------ .../com/intellij/openapi/util/IconLoader.java | 4 - 2 files changed, 80 insertions(+), 40 deletions(-) diff --git a/platform/util/src/com/intellij/openapi/util/DeprecatedDuplicatesIconPathPatcher.java b/platform/util/src/com/intellij/openapi/util/DeprecatedDuplicatesIconPathPatcher.java index cbee05be539f..6c1bf6be6cc3 100644 --- a/platform/util/src/com/intellij/openapi/util/DeprecatedDuplicatesIconPathPatcher.java +++ b/platform/util/src/com/intellij/openapi/util/DeprecatedDuplicatesIconPathPatcher.java @@ -2,7 +2,6 @@ package com.intellij.openapi.util; import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.HashMap; @@ -15,43 +14,94 @@ public class DeprecatedDuplicatesIconPathPatcher extends IconPathPatcher { @NonNls private static final Map ourDeprecatedIconsReplacements = new HashMap(); static { - ourDeprecatedIconsReplacements.put("/general/toolWindowDebugger.png", "AllIcons.Toolwindows.ToolWindowDebugger"); - ourDeprecatedIconsReplacements.put("/general/toolWindowChanges.png", "AllIcons.Toolwindows.ToolWindowChanges"); + ourDeprecatedIconsReplacements.put("/actions/findPlain.png", "AllIcons.Actions.Find"); + ourDeprecatedIconsReplacements.put("/actions/findPlain.svg", "AllIcons.Actions.Find"); + ourDeprecatedIconsReplacements.put("/actions/menu_find.png", "AllIcons.Actions.Find"); + ourDeprecatedIconsReplacements.put("/actions/menu_find.svg", "AllIcons.Actions.Find"); - ourDeprecatedIconsReplacements.put("/general/ideOptions.png", "AllIcons.General.Settings"); - ourDeprecatedIconsReplacements.put("/general/applicationSettings.png", "AllIcons.General.Settings"); - ourDeprecatedIconsReplacements.put("/vcs/customizeView.png", "AllIcons.General.Settings"); + ourDeprecatedIconsReplacements.put("/actions/menu_help.png", "AllIcons.Actions.Help"); + ourDeprecatedIconsReplacements.put("/actions/menu_help.svg", "AllIcons.Actions.Help"); - ourDeprecatedIconsReplacements.put("/actions/refreshUsages.png", "AllIcons.Actions.Rerun"); - - ourDeprecatedIconsReplacements.put("/compiler/error.png", "AllIcons.General.Error"); - ourDeprecatedIconsReplacements.put("/compiler/hideWarnings.png", "AllIcons.General.HideWarnings"); - ourDeprecatedIconsReplacements.put("/compiler/information.png", "AllIcons.General.Information"); - ourDeprecatedIconsReplacements.put("/compiler/warning.png", "AllIcons.General.Warning"); - ourDeprecatedIconsReplacements.put("/ide/errorSign.png", "AllIcons.General.Error"); + ourDeprecatedIconsReplacements.put("/debugger/threadStates/paused.png", "AllIcons.Actions.Pause"); + ourDeprecatedIconsReplacements.put("/debugger/threadStates/paused.svg", "AllIcons.Actions.Pause"); ourDeprecatedIconsReplacements.put("/actions/showSource.png", "AllIcons.Actions.Preview"); + ourDeprecatedIconsReplacements.put("/actions/showSource.svg", "AllIcons.Actions.Preview"); + + ourDeprecatedIconsReplacements.put("/actions/sync.png", "AllIcons.Actions.Refresh"); + ourDeprecatedIconsReplacements.put("/actions/sync.svg", "AllIcons.Actions.Refresh"); + ourDeprecatedIconsReplacements.put("/actions/synchronizeFS.png", "AllIcons.Actions.Refresh"); + ourDeprecatedIconsReplacements.put("/actions/synchronizeFS.svg", "AllIcons.Actions.Refresh"); + ourDeprecatedIconsReplacements.put("/vcs/refresh.png", "AllIcons.Actions.Refresh"); + ourDeprecatedIconsReplacements.put("/vcs/refresh.svg", "AllIcons.Actions.Refresh"); + + ourDeprecatedIconsReplacements.put("/actions/refreshUsages.png", "AllIcons.Actions.Rerun"); + ourDeprecatedIconsReplacements.put("/actions/refreshUsages.svg", "AllIcons.Actions.Rerun"); + + ourDeprecatedIconsReplacements.put("/general/debug.png", "AllIcons.Actions.StartDebugger"); + ourDeprecatedIconsReplacements.put("/general/debug.svg", "AllIcons.Actions.StartDebugger"); + + + ourDeprecatedIconsReplacements.put("/debugger/watches.png", "AllIcons.Debugger.Watch"); + ourDeprecatedIconsReplacements.put("/debugger/watches.svg", "AllIcons.Debugger.Watch"); + + + ourDeprecatedIconsReplacements.put("/debugger/newWatch.png", "AllIcons.General.Add"); + ourDeprecatedIconsReplacements.put("/debugger/newWatch.svg", "AllIcons.General.Add"); + ourDeprecatedIconsReplacements.put("/toolbarDecorator/add.png", "AllIcons.General.Add"); + ourDeprecatedIconsReplacements.put("/toolbarDecorator/add.svg", "AllIcons.General.Add"); + + ourDeprecatedIconsReplacements.put("/compiler/error.png", "AllIcons.General.Error"); + ourDeprecatedIconsReplacements.put("/compiler/error.svg", "AllIcons.General.Error"); + ourDeprecatedIconsReplacements.put("/ide/errorSign.png", "AllIcons.General.Error"); + ourDeprecatedIconsReplacements.put("/ide/errorSign.svg", "AllIcons.General.Error"); + + ourDeprecatedIconsReplacements.put("/ant/filter.png", "AllIcons.General.Filter"); + ourDeprecatedIconsReplacements.put("/ant/filter.svg", "AllIcons.General.Filter"); + ourDeprecatedIconsReplacements.put("/debugger/class_filter.png", "AllIcons.General.Filter"); + ourDeprecatedIconsReplacements.put("/debugger/class_filter.svg", "AllIcons.General.Filter"); + ourDeprecatedIconsReplacements.put("/inspector/useFilter.png", "AllIcons.General.Filter"); + ourDeprecatedIconsReplacements.put("/inspector/useFilter.svg", "AllIcons.General.Filter"); + + ourDeprecatedIconsReplacements.put("/actions/showSettings.png", "AllIcons.General.GearPlain"); + ourDeprecatedIconsReplacements.put("/actions/showSettings.svg", "AllIcons.General.GearPlain"); + ourDeprecatedIconsReplacements.put("/general/projectSettings.png", "AllIcons.General.GearPlain"); + ourDeprecatedIconsReplacements.put("/general/projectSettings.svg", "AllIcons.General.GearPlain"); + ourDeprecatedIconsReplacements.put("/general/secondaryGroup.png", "AllIcons.General.GearPlain"); + ourDeprecatedIconsReplacements.put("/general/secondaryGroup.svg", "AllIcons.General.GearPlain"); + + ourDeprecatedIconsReplacements.put("/compiler/hideWarnings.png", "AllIcons.General.HideWarnings"); + ourDeprecatedIconsReplacements.put("/compiler/hideWarnings.svg", "AllIcons.General.HideWarnings"); + + ourDeprecatedIconsReplacements.put("/compiler/information.png", "AllIcons.General.Information"); + ourDeprecatedIconsReplacements.put("/compiler/information.svg", "AllIcons.General.Information"); + ourDeprecatedIconsReplacements.put("/actions/consoleHistory.png", "AllIcons.General.MessageHistory"); + ourDeprecatedIconsReplacements.put("/actions/consoleHistory.svg", "AllIcons.General.MessageHistory"); ourDeprecatedIconsReplacements.put("/vcs/messageHistory.png", "AllIcons.General.MessageHistory"); + ourDeprecatedIconsReplacements.put("/vcs/messageHistory.svg", "AllIcons.General.MessageHistory"); - register("AllIcons.Actions.Find", "/actions/findPlain", "/actions/menu_find"); - register("AllIcons.Actions.Help", "/actions/menu_help"); - register("AllIcons.Actions.Pause", "/debugger/threadStates/paused"); - register("AllIcons.Actions.Refresh", "/actions/sync", "/actions/synchronizeFS", "/vcs/refresh"); - register("AllIcons.Actions.StartDebugger", "/general/debug"); - register("AllIcons.Debugger.Watch", "/debugger/watches"); - register("AllIcons.General.Add", "/debugger/newWatch", "/toolbarDecorator/add"); - register("AllIcons.General.Filter", "/ant/filter", "/debugger/class_filter", "/inspector/useFilter"); - register("AllIcons.General.GearPlain", "/actions/showSettings", "/general/projectSettings", "/general/secondaryGroup"); - register("AllIcons.Nodes.Folder", "/nodes/treeClosed", "/nodes/treeOpen"); - } + ourDeprecatedIconsReplacements.put("/general/applicationSettings.png", "AllIcons.General.Settings"); + ourDeprecatedIconsReplacements.put("/general/applicationSettings.svg", "AllIcons.General.Settings"); + ourDeprecatedIconsReplacements.put("/general/ideOptions.png", "AllIcons.General.Settings"); + ourDeprecatedIconsReplacements.put("/general/ideOptions.svg", "AllIcons.General.Settings"); + ourDeprecatedIconsReplacements.put("/vcs/customizeView.png", "AllIcons.General.Settings"); + ourDeprecatedIconsReplacements.put("/vcs/customizeView.svg", "AllIcons.General.Settings"); - private static void register(@NotNull String id, @NotNull String... paths) { - assert paths.length > 0 : "old paths are not specified"; - for (String path : paths) { - assert null == ourDeprecatedIconsReplacements.put(path + ".png", id) : path + " is already registered"; - assert null == ourDeprecatedIconsReplacements.put(path + ".svg", id) : path + " is already registered"; - } + ourDeprecatedIconsReplacements.put("/compiler/warning.png", "AllIcons.General.Warning"); + ourDeprecatedIconsReplacements.put("/compiler/warning.svg", "AllIcons.General.Warning"); + + + ourDeprecatedIconsReplacements.put("/nodes/treeClosed.png", "AllIcons.Nodes.Folder"); + ourDeprecatedIconsReplacements.put("/nodes/treeClosed.svg", "AllIcons.Nodes.Folder"); + ourDeprecatedIconsReplacements.put("/nodes/treeOpen.png", "AllIcons.Nodes.Folder"); + ourDeprecatedIconsReplacements.put("/nodes/treeOpen.svg", "AllIcons.Nodes.Folder"); + + + ourDeprecatedIconsReplacements.put("/general/toolWindowChanges.png", "AllIcons.Toolwindows.ToolWindowChanges"); + ourDeprecatedIconsReplacements.put("/general/toolWindowChanges.svg", "AllIcons.Toolwindows.ToolWindowChanges"); + ourDeprecatedIconsReplacements.put("/general/toolWindowDebugger.png", "AllIcons.Toolwindows.ToolWindowDebugger"); + ourDeprecatedIconsReplacements.put("/general/toolWindowDebugger.svg", "AllIcons.Toolwindows.ToolWindowDebugger"); } @Nullable @@ -59,10 +109,4 @@ public class DeprecatedDuplicatesIconPathPatcher extends IconPathPatcher { public String patchPath(String path) { return ourDeprecatedIconsReplacements.get(path); } - - @Nullable - @Override - public Class getContextClass(String path) { - return DeprecatedDuplicatesIconPathPatcher.class; - } } diff --git a/platform/util/src/com/intellij/openapi/util/IconLoader.java b/platform/util/src/com/intellij/openapi/util/IconLoader.java index a03f6041db83..11fa3db6e82f 100644 --- a/platform/util/src/com/intellij/openapi/util/IconLoader.java +++ b/platform/util/src/com/intellij/openapi/util/IconLoader.java @@ -119,7 +119,6 @@ public final class IconLoader { return (Icon)field.get(null); } catch (Exception e) { - LOG.info(e); return null; } } @@ -199,14 +198,11 @@ public final class IconLoader { @NotNull private static Pair patchPath(@NotNull String path) { for (IconPathPatcher patcher : ourPatchers) { - LOG.debug("patch paths with " + patcher); String newPath = patcher.patchPath(path); if (newPath != null) { - LOG.debug("replace path " + path + " with " + newPath); return Pair.create(newPath, patcher.getContextClass(path)); } } - LOG.debug("use path " + path); return Pair.create(path, null); }