editor: do not ignore initial state of "Hide tabs if there is not space" flag

We should update layout after changing the "mySupportsCompression" flag,
just like we update it on "hideTabsIfNeed" settings change.

JBEditorTabs sets `mySupportsCompression` flag in constructor,
but it is used in super constructor via `createSingleRowLayout` method.
Thus, initial state of "hideTabsIfNeed" flag was ignored as "unsupported".
This commit is contained in:
Aleksey Pivovarov
2019-03-11 15:57:57 +03:00
parent c7163ad6cb
commit f06bc994b7
@@ -320,22 +320,26 @@ public class JBTabsImpl extends JComponent
}
boolean oldHideTabsIfNeed = mySingleRowLayout instanceof ScrollableSingleRowLayout;
boolean newHideTabsIfNeed = UISettings.getInstance().getHideTabsIfNeed();
boolean wasSingleRow = isSingleRow();
if (oldHideTabsIfNeed != newHideTabsIfNeed) {
if (mySingleRowLayout != null) {
remove(mySingleRowLayout.myLeftGhost);
remove(mySingleRowLayout.myRightGhost);
}
mySingleRowLayout = createSingleRowLayout();
if (wasSingleRow) {
myLayout = mySingleRowLayout;
}
add(mySingleRowLayout.myLeftGhost);
add(mySingleRowLayout.myRightGhost);
relayout(true, true);
updateRowLayout();
}
}
private void updateRowLayout() {
boolean wasSingleRow = isSingleRow();
if (mySingleRowLayout != null) {
remove(mySingleRowLayout.myLeftGhost);
remove(mySingleRowLayout.myRightGhost);
}
mySingleRowLayout = createSingleRowLayout();
if (wasSingleRow) {
myLayout = mySingleRowLayout;
}
add(mySingleRowLayout.myLeftGhost);
add(mySingleRowLayout.myRightGhost);
relayout(true, true);
}
protected SingleRowLayout createSingleRowLayout() {
return new SingleRowLayout(this);
}
@@ -3292,6 +3296,7 @@ public class JBTabsImpl extends JComponent
@Override
public JBTabsPresentation setSupportsCompression(boolean supportsCompression) {
mySupportsCompression = supportsCompression;
updateRowLayout();
return this;
}