From 72f42620c1cef187f0c803920320ec8bae558d9d Mon Sep 17 00:00:00 2001 From: Maxim Shafirov Date: Sat, 12 May 2012 16:04:15 +0400 Subject: [PATCH] unused state --- .../com/intellij/ui/tabs/impl/DragHelper.java | 2 +- .../com/intellij/ui/tabs/impl/JBTabsImpl.java | 134 ++++++++---------- .../com/intellij/ui/tabs/impl/TabsBorder.java | 2 +- 3 files changed, 64 insertions(+), 74 deletions(-) diff --git a/platform/platform-api/src/com/intellij/ui/tabs/impl/DragHelper.java b/platform/platform-api/src/com/intellij/ui/tabs/impl/DragHelper.java index fda9ee1622d0..41b4fa0b798a 100644 --- a/platform/platform-api/src/com/intellij/ui/tabs/impl/DragHelper.java +++ b/platform/platform-api/src/com/intellij/ui/tabs/impl/DragHelper.java @@ -238,7 +238,7 @@ class DragHelper extends MouseDragHelper { if (!willDragOutStart) { myTabs.fireTabsMoved(); } - myTabs.relayout(true, false); + myTabs.relayout(false); myTabs.revalidate(); } diff --git a/platform/platform-api/src/com/intellij/ui/tabs/impl/JBTabsImpl.java b/platform/platform-api/src/com/intellij/ui/tabs/impl/JBTabsImpl.java index f0623fa5895c..c8ec1ea8d08f 100644 --- a/platform/platform-api/src/com/intellij/ui/tabs/impl/JBTabsImpl.java +++ b/platform/platform-api/src/com/intellij/ui/tabs/impl/JBTabsImpl.java @@ -111,8 +111,6 @@ public class JBTabsImpl extends JComponent private LayoutPassInfo myLastLayoutPass; private TabInfo myLastPaintedSelection; - public boolean myForcedRelayout; - private UiDecorator myUiDecorator; static final UiDecorator ourDefaultDecorator = new DefaultDecorator(); @@ -387,7 +385,7 @@ public class JBTabsImpl extends JComponent } if (needsUpdate) { - relayout(true, false); + relayout(false); } } @@ -675,7 +673,7 @@ public class JBTabsImpl extends JComponent adjust(info); - updateAll(false, false); + updateAll(false); if (info.isHidden()) { updateHiding(); @@ -728,9 +726,9 @@ public class JBTabsImpl extends JComponent return this; } - private void updateAll(final boolean forcedRelayout, final boolean now) { + private void updateAll(final boolean now) { mySelectedInfo = getSelectedInfo(); - updateContainer(forcedRelayout, now); + updateContainer(now); removeDeferred(); updateListeners(); updateTabActions(false); @@ -801,7 +799,7 @@ public class JBTabsImpl extends JComponent fireBeforeSelectionChanged(oldInfo, newInfo); - updateContainer(false, true); + updateContainer(true); fireSelectionChanged(oldInfo, newInfo); @@ -944,10 +942,10 @@ public class JBTabsImpl extends JComponent final TabInfo tabInfo = (TabInfo)evt.getSource(); if (TabInfo.ACTION_GROUP.equals(evt.getPropertyName())) { updateSideComponent(tabInfo); - relayout(false, false); + relayout(false); } else if (TabInfo.COMPONENT.equals(evt.getPropertyName())) { - relayout(true, false); + relayout(false); } else if (TabInfo.TEXT.equals(evt.getPropertyName())) { updateText(tabInfo); @@ -964,11 +962,11 @@ public class JBTabsImpl extends JComponent } else if (TabInfo.TAB_ACTION_GROUP.equals(evt.getPropertyName())) { updateTabActions(tabInfo); - relayout(false, false); + relayout(false); } else if (TabInfo.HIDDEN.equals(evt.getPropertyName())) { updateHiding(); - relayout(false, false); + relayout(false); } else if (TabInfo.ENABLED.equals(evt.getPropertyName())) { updateEnabling(); @@ -1021,7 +1019,7 @@ public class JBTabsImpl extends JComponent if (mySelectedInfo != null && myHiddenInfos.containsKey(mySelectedInfo)) { mySelectedInfo = getToSelectOnRemoveOf(mySelectedInfo); } - updateAll(true, false); + updateAll(false); } } @@ -1345,51 +1343,46 @@ public class JBTabsImpl extends JComponent public void doLayout() { - try { - myHeaderFitSize = computeHeaderFitSize(); + myHeaderFitSize = computeHeaderFitSize(); - final Collection labels = myInfo2Label.values(); - for (TabLabel each : labels) { - each.setTabActionsAutoHide(myTabLabelActionsAutoHide); - } - - - List visible = new ArrayList(); - visible.addAll(myVisibleInfos); - - if (myDropInfo != null && !visible.contains(myDropInfo) && myShowDropLocation) { - if (getDropInfoIndex() >= 0 && getDropInfoIndex() < visible.size()) { - visible.add(getDropInfoIndex(), myDropInfo); - } else { - visible.add(myDropInfo); - } - } - - if (isSingleRow()) { - myLastLayoutPass = mySingleRowLayout.layoutSingleRow(visible); - myTableLayout.myLastTableLayout = null; - } - else { - myLastLayoutPass = myTableLayout.layoutTable(visible); - mySingleRowLayout.myLastSingRowLayout = null; - } - - if (isStealthModeEffective() && !isHideTabs()) { - final TabLabel label = getSelectedLabel(); - final Rectangle bounds = label.getBounds(); - final Insets insets = getLayoutInsets(); - layout(label, insets.left, bounds.y, getWidth() - insets.right - insets.left, bounds.height); - } - - - moveDraggedTabLabel(); - - myTabActionsAutoHideListener.processMouseOver(); + final Collection labels = myInfo2Label.values(); + for (TabLabel each : labels) { + each.setTabActionsAutoHide(myTabLabelActionsAutoHide); } - finally { - myForcedRelayout = false; + + + List visible = new ArrayList(); + visible.addAll(myVisibleInfos); + + if (myDropInfo != null && !visible.contains(myDropInfo) && myShowDropLocation) { + if (getDropInfoIndex() >= 0 && getDropInfoIndex() < visible.size()) { + visible.add(getDropInfoIndex(), myDropInfo); + } else { + visible.add(myDropInfo); + } } + if (isSingleRow()) { + myLastLayoutPass = mySingleRowLayout.layoutSingleRow(visible); + myTableLayout.myLastTableLayout = null; + } + else { + myLastLayoutPass = myTableLayout.layoutTable(visible); + mySingleRowLayout.myLastSingRowLayout = null; + } + + if (isStealthModeEffective() && !isHideTabs()) { + final TabLabel label = getSelectedLabel(); + final Rectangle bounds = label.getBounds(); + final Insets insets = getLayoutInsets(); + layout(label, insets.left, bounds.y, getWidth() - insets.right - insets.left, bounds.height); + } + + + moveDraggedTabLabel(); + + myTabActionsAutoHideListener.processMouseOver(); + applyResetComponents(); } @@ -2377,7 +2370,7 @@ public class JBTabsImpl extends JComponent myInfo2Toolbar.remove(info); resetTabsCache(); - updateAll(false, false); + updateAll(false); // avoid leaks myLastPaintedSelection = null; @@ -2442,7 +2435,7 @@ public class JBTabsImpl extends JComponent final Dimension myToolbar = new Dimension(); } - private void updateContainer(boolean forced, final boolean layoutNow) { + private void updateContainer(final boolean layoutNow) { for (TabInfo each : myVisibleInfos) { final JComponent eachComponent = each.getComponent(); if (getSelectedInfo() == each && getSelectedInfo() != null) { @@ -2469,7 +2462,7 @@ public class JBTabsImpl extends JComponent } mySingleRowLayout.scrollSelectionInView(); - relayout(forced, layoutNow); + relayout(layoutNow); } protected void addImpl(final Component comp, final Object constraints, final int index) { @@ -2487,10 +2480,7 @@ public class JBTabsImpl extends JComponent return c.getRootPane() != null; } - void relayout(boolean forced, final boolean layoutNow) { - if (!myForcedRelayout) { - myForcedRelayout = forced; - } + void relayout(final boolean layoutNow) { revalidateAndRepaint(layoutNow); } @@ -2588,7 +2578,7 @@ public class JBTabsImpl extends JComponent myHideTabs = hideTabs; - relayout(true, false); + relayout(false); } public JBTabsPresentation setPaintBorder(int top, int left, int right, int bottom) { @@ -2755,7 +2745,7 @@ public class JBTabsImpl extends JComponent public JBTabsPresentation setStealthTabMode(final boolean stealthTabMode) { myStealthTabMode = stealthTabMode; - relayout(true, false); + relayout(false); return this; } @@ -2772,7 +2762,7 @@ public class JBTabsImpl extends JComponent } - relayout(true, false); + relayout(false); return this; } @@ -2781,7 +2771,7 @@ public class JBTabsImpl extends JComponent public JBTabsPresentation setSideComponentOnTabs(boolean onTabs) { mySideComponentOnTabs = onTabs; - relayout(true, false); + relayout(false); return this; } @@ -2789,7 +2779,7 @@ public class JBTabsImpl extends JComponent public JBTabsPresentation setSingleRow(boolean singleRow) { myLayout = singleRow ? mySingleRowLayout : myTableLayout; - relayout(true, false); + relayout(false); return this; } @@ -2797,7 +2787,7 @@ public class JBTabsImpl extends JComponent public JBTabsPresentation setGhostsAlwaysVisible(final boolean visible) { myGhostsAlwaysVisible = visible; - relayout(true, false); + relayout(false); return this; } @@ -2858,7 +2848,7 @@ public class JBTabsImpl extends JComponent adjust(each); } - relayout(true, false); + relayout(false); } private void adjust(final TabInfo each) { @@ -2870,7 +2860,7 @@ public class JBTabsImpl extends JComponent public void sortTabs(Comparator comparator) { Collections.sort(myVisibleInfos, comparator); - relayout(true, false); + relayout(false); } private boolean isRequestFocusOnLastFocusedComponent() { @@ -2992,7 +2982,7 @@ public class JBTabsImpl extends JComponent @NotNull public JBTabsPresentation setTabsPosition(final JBTabsPosition position) { myPosition = position; - relayout(true, false); + relayout(false); return this; } @@ -3027,7 +3017,7 @@ public class JBTabsImpl extends JComponent myVisibleInfos.add(targetIndex, source); invalidate(); - relayout(true, true); + relayout(true); } boolean isHorizontalTabs() { @@ -3147,7 +3137,7 @@ public class JBTabsImpl extends JComponent label.paintOffscreen(g); g.dispose(); - relayout(true, false); + relayout(false); return img; } @@ -3157,7 +3147,7 @@ public class JBTabsImpl extends JComponent int index = myLayout.getDropIndexFor(point.getPoint(this)); if (index != getDropInfoIndex()) { setDropInfoIndex(index); - relayout(true, false); + relayout(false); } } diff --git a/platform/platform-api/src/com/intellij/ui/tabs/impl/TabsBorder.java b/platform/platform-api/src/com/intellij/ui/tabs/impl/TabsBorder.java index 1d53f9a7b62f..45cdc869bed2 100644 --- a/platform/platform-api/src/com/intellij/ui/tabs/impl/TabsBorder.java +++ b/platform/platform-api/src/com/intellij/ui/tabs/impl/TabsBorder.java @@ -47,7 +47,7 @@ public class TabsBorder { myEffectiveBorder = null; - myTabs.relayout(true, false); + myTabs.relayout(false); return myTabs; }