From 83cd49a8f2ebd9a00bdf573e9acd8ac549ec8173 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Mon, 9 Jul 2018 14:26:54 +0200 Subject: [PATCH] remove not required myButton2Info field (pass info directly) --- .../wm/impl/ToolWindowManagerImpl.java | 13 +++++---- .../openapi/wm/impl/ToolWindowsPane.java | 29 +++++-------------- 2 files changed, 15 insertions(+), 27 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.java index dfe7c82a60bc..df125a1edd20 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowManagerImpl.java @@ -1154,7 +1154,7 @@ public class ToolWindowManagerImpl extends ToolWindowManagerEx implements Persis myLayout.unregister(id); myActiveStack.remove(id, true); mySideStack.remove(id); - appendRemoveButtonCmd(id, commandsList); + appendRemoveButtonCmd(id, info, commandsList); appendApplyWindowInfoCmd(info, commandsList); execute(commandsList, false); @@ -1466,7 +1466,7 @@ public class ToolWindowManagerImpl extends ToolWindowManagerEx implements Persis } // if tool window isn't visible or only order number is changed then just remove/add stripe button if (!info.isVisible() || anchor == info.getAnchor() || info.isFloating() || info.isWindowed()) { - appendRemoveButtonCmd(id, commandsList); + appendRemoveButtonCmd(id, info, commandsList); myLayout.setAnchor(id, anchor, order); // update infos for all window. Actually we have to update only infos affected by // setAnchor method @@ -1478,7 +1478,7 @@ public class ToolWindowManagerImpl extends ToolWindowManagerEx implements Persis else { // for docked and sliding windows we have to move buttons and window's decorators info.setVisible(false); appendRemoveDecoratorCmd(id, false, commandsList); - appendRemoveButtonCmd(id, commandsList); + appendRemoveButtonCmd(id, info, commandsList); myLayout.setAnchor(id, anchor, order); // update infos for all window. Actually we have to update only infos affected by // setAnchor method @@ -1680,8 +1680,11 @@ public class ToolWindowManagerImpl extends ToolWindowManagerEx implements Persis /** * @see ToolWindowsPane#createAddButtonCmd */ - private void appendRemoveButtonCmd(@NotNull String id, @NotNull List commandsList) { - commandsList.add(myToolWindowsPane.createRemoveButtonCmd(id, myCommandProcessor)); + private void appendRemoveButtonCmd(@NotNull String id, @NotNull WindowInfoImpl info, @NotNull List commandsList) { + FinalizableCommand cmd = myToolWindowsPane.createRemoveButtonCmd(info, id, myCommandProcessor); + if (cmd != null) { + commandsList.add(cmd); + } } private void appendRequestFocusInToolWindowCmd(final String id, List commandList) { diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowsPane.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowsPane.java index c24fa9f11051..d3b63e6c6d40 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowsPane.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowsPane.java @@ -46,7 +46,6 @@ public final class ToolWindowsPane extends JBLayeredPane implements UISettingsLi private final HashMap myId2Button = new HashMap<>(); private final HashMap myId2Decorator = new HashMap<>(); - private final HashMap myButton2Info = new HashMap<>(); private final HashMap myDecorator2Info = new HashMap<>(); private final HashMap myId2SplitProportion = new HashMap<>(); private Pair myMaximizedProportion; @@ -199,7 +198,6 @@ public final class ToolWindowsPane extends JBLayeredPane implements UISettingsLi @NotNull Runnable finishCallBack) { final WindowInfoImpl copiedInfo = info.copy(); myId2Button.put(copiedInfo.getId(), button); - myButton2Info.put(button, copiedInfo); return new AddToolStripeButtonCmd(button, copiedInfo, comparator, finishCallBack); } @@ -240,13 +238,13 @@ public final class ToolWindowsPane extends JBLayeredPane implements UISettingsLi * * @param id {@code ID} of the button to be removed. */ - @NotNull - final FinalizableCommand createRemoveButtonCmd(@NotNull String id, @NotNull Runnable finishCallBack) { - final StripeButton button = getButtonById(id); - final WindowInfoImpl info = getButtonInfoById(id); + @Nullable + final FinalizableCommand createRemoveButtonCmd(@NotNull WindowInfoImpl info, @NotNull String id, @NotNull Runnable finishCallBack) { + StripeButton button = myId2Button.remove(id); + if (button == null) { + return null; + } - myButton2Info.remove(button); - myId2Button.remove(id); return new RemoveToolStripeButtonCmd(button, info, finishCallBack); } @@ -299,23 +297,10 @@ public final class ToolWindowsPane extends JBLayeredPane implements UISettingsLi return myLayeredPane; } - @Nullable - private StripeButton getButtonById(final String id) { - return myId2Button.get(id); - } - private InternalDecorator getDecoratorById(final String id) { return myId2Decorator.get(id); } - /** - * @param id {@code ID} of tool stripe butoon. - * @return {@code WindowInfo} associated with specified tool stripe button. - */ - private WindowInfoImpl getButtonInfoById(final String id) { - return myButton2Info.get(myId2Button.get(id)); - } - /** * @param id {@code ID} of decorator. * @return {@code WindowInfo} associated with specified window decorator. @@ -1186,7 +1171,7 @@ public final class ToolWindowsPane extends JBLayeredPane implements UISettingsLi @Override public void run() { try { - StripeButton stripeButton = getButtonById(myId); + StripeButton stripeButton = myId2Button.get(myId); if (stripeButton == null) { return; }