remove not required myButton2Info field (pass info directly)

This commit is contained in:
Vladimir Krivosheev
2018-07-09 14:55:19 +02:00
parent abe90a0b1f
commit 83cd49a8f2
2 changed files with 15 additions and 27 deletions
@@ -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<FinalizableCommand> commandsList) {
commandsList.add(myToolWindowsPane.createRemoveButtonCmd(id, myCommandProcessor));
private void appendRemoveButtonCmd(@NotNull String id, @NotNull WindowInfoImpl info, @NotNull List<FinalizableCommand> commandsList) {
FinalizableCommand cmd = myToolWindowsPane.createRemoveButtonCmd(info, id, myCommandProcessor);
if (cmd != null) {
commandsList.add(cmd);
}
}
private void appendRequestFocusInToolWindowCmd(final String id, List<FinalizableCommand> commandList) {
@@ -46,7 +46,6 @@ public final class ToolWindowsPane extends JBLayeredPane implements UISettingsLi
private final HashMap<String, StripeButton> myId2Button = new HashMap<>();
private final HashMap<String, InternalDecorator> myId2Decorator = new HashMap<>();
private final HashMap<StripeButton, WindowInfoImpl> myButton2Info = new HashMap<>();
private final HashMap<InternalDecorator, WindowInfoImpl> myDecorator2Info = new HashMap<>();
private final HashMap<String, Float> myId2SplitProportion = new HashMap<>();
private Pair<ToolWindow, Integer> 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;
}