From 8a0f7db2f579d96d5bafd382d9bf62171126853e Mon Sep 17 00:00:00 2001 From: "Gregory.Shrago" Date: Fri, 31 Aug 2012 18:47:48 +0400 Subject: [PATCH] IDEA-90868/EA-38125 - CME: ActionToolbarImpl.updateAllToolbarsImmediately --- .../actionSystem/impl/ActionToolbarImpl.java | 32 ++++++------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionToolbarImpl.java b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionToolbarImpl.java index 1a6aac5d6fdf..92239a9fd20c 100644 --- a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionToolbarImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionToolbarImpl.java @@ -55,7 +55,6 @@ import java.awt.event.ComponentAdapter; import java.awt.event.ComponentEvent; import java.awt.event.MouseEvent; import java.util.ArrayList; -import java.util.ConcurrentModificationException; import java.util.LinkedList; import java.util.List; @@ -63,17 +62,10 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar { private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.actionSystem.impl.ActionToolbarImpl"); private static List ourToolbars = new LinkedList(); - private static Throwable ourLastModification = null; public static void updateAllToolbarsImmediately() { - try { - ourLastModification = null; - for (ActionToolbarImpl toolbar : ourToolbars) { - toolbar.updateActionsImmediately(); - } - } - catch (ConcurrentModificationException e) { - LOG.error(ourLastModification == null? e : ourLastModification); + for (ActionToolbarImpl toolbar : new ArrayList(ourToolbars)) { + toolbar.updateActionsImmediately(); } } @@ -178,7 +170,6 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar { @Override public void addNotify() { super.addNotify(); - ourLastModification = new ConcurrentModificationException(); ourToolbars.add(this); myActionManager.addTimerListener(500, myWeakTimerListener); myActionManager.addTransparentTimerListener(500, myWeakTimerListener); @@ -199,7 +190,6 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar { @Override public void removeNotify() { super.removeNotify(); - ourLastModification = new ConcurrentModificationException(); ourToolbars.remove(this); myActionManager.removeTimerListener(myWeakTimerListener); myActionManager.removeTransparentTimerListener(myWeakTimerListener); @@ -484,7 +474,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar { for (final Rectangle r : bounds) { if (r.height < maxHeight) { - r.y = r.y + (maxHeight - r.height) / 2; + r.y += (maxHeight - r.height) / 2; } } @@ -555,7 +545,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar { // Lay components out int xOffset = insets.left; int yOffset = insets.top; - // Calculate max size of a row. It's not possible to make more then 3 row toolbar + // Calculate max size of a row. It's not possible to make more than 3 row toolbar final int maxRowWidth = Math.max(sizeToFit.width, componentCount * maxWidth / 3); for (int i = 0; i < componentCount; i++) { if (xOffset + maxWidth > maxRowWidth) { // place component at new row @@ -1185,14 +1175,12 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar { ArrayList result = new ArrayList(); ArrayList secondary = new ArrayList(); - if (myActionGroup != null) { - AnAction[] kids = myActionGroup.getChildren(null); - for (AnAction each : kids) { - if (myActionGroup.isPrimary(each)) { - result.add(each); - } else { - secondary.add(each); - } + AnAction[] kids = myActionGroup.getChildren(null); + for (AnAction each : kids) { + if (myActionGroup.isPrimary(each)) { + result.add(each); + } else { + secondary.add(each); } } result.add(new Separator());