mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-289478 Terminal tab name is hidden when tool window open for the first time
(cherry picked from commit a354d1b16dd339a7135de0716c6320bde91db48c) IJ-CR-22047 GitOrigin-RevId: 6546cc0c64ae11717d93df32856aa7d4730e6163
This commit is contained in:
committed by
intellij-monorepo-bot
parent
20f3458894
commit
6496faa31f
+29
-17
@@ -18,6 +18,9 @@ import com.intellij.ui.LayeredIcon;
|
||||
import com.intellij.ui.content.Content;
|
||||
import com.intellij.ui.content.ContentManager;
|
||||
import com.intellij.ui.scale.JBUIScale;
|
||||
import com.intellij.util.Alarm;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import com.intellij.util.SingleAlarm;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtilities;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -66,24 +69,33 @@ public class ContentTabLabel extends ContentLabel {
|
||||
}
|
||||
|
||||
private void updateText() {
|
||||
if (myText != null && myText.startsWith("<html>")) {
|
||||
super.setText(myText); // SwingUtilities2.clipString does not support HTML
|
||||
return;
|
||||
try {
|
||||
if (myText != null && myText.startsWith("<html>")) {
|
||||
super.setText(myText); // SwingUtilities2.clipString does not support HTML
|
||||
return;
|
||||
}
|
||||
FontMetrics fm = getFontMetrics(getFont());
|
||||
int textWidth = UIUtilities.stringWidth(this, fm, myText);
|
||||
int prefWidth = myIconWithInsetsWidth + textWidth;
|
||||
|
||||
int maxWidth = getMaximumSize().width;
|
||||
|
||||
if (prefWidth > maxWidth) {
|
||||
int offset = maxWidth - myIconWithInsetsWidth;
|
||||
String s = UIUtilities.clipString(this, fm, myText, offset);
|
||||
super.setText(s);
|
||||
return;
|
||||
}
|
||||
|
||||
super.setText(myText);
|
||||
} finally {
|
||||
new SingleAlarm(() -> {
|
||||
ObjectUtils.consumeIfNotNull(getParent(), c -> {
|
||||
c.revalidate();
|
||||
c.repaint();
|
||||
});
|
||||
}, 50, myContent, Alarm.ThreadToUse.SWING_THREAD).request();
|
||||
}
|
||||
FontMetrics fm = getFontMetrics(getFont());
|
||||
int textWidth = UIUtilities.stringWidth(this, fm, myText);
|
||||
int prefWidth = myIconWithInsetsWidth + textWidth;
|
||||
|
||||
int maxWidth = getMaximumSize().width;
|
||||
|
||||
if (prefWidth > maxWidth) {
|
||||
int offset = maxWidth - myIconWithInsetsWidth;
|
||||
String s = UIUtilities.clipString(this, fm, myText, offset);
|
||||
super.setText(s);
|
||||
return;
|
||||
}
|
||||
|
||||
super.setText(myText);
|
||||
}
|
||||
|
||||
ContentTabLabel(@NotNull Content content, @NotNull TabContentLayout layout) {
|
||||
|
||||
Reference in New Issue
Block a user