mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 14:23:28 +07:00
IJPL-161797 Remove code duplication in DefaultCutStrategy
The logic there matches exactly the one in UiUtil. Except that the preferred size here is the same as the full text size. GitOrigin-RevId: be62bdb8b4696a62d06c27e439229ec333585af5
This commit is contained in:
committed by
intellij-monorepo-bot
parent
207960de92
commit
2aa9576a72
@@ -1,6 +1,7 @@
|
|||||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||||
package com.intellij.openapi.wm.impl;
|
package com.intellij.openapi.wm.impl;
|
||||||
|
|
||||||
|
import com.intellij.util.ui.UIUtil;
|
||||||
import org.jetbrains.annotations.ApiStatus;
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@@ -28,8 +29,6 @@ public final class DefaultCutStrategy implements TextCutStrategy {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int calcMinTextWidth(@NotNull String text, @NotNull FontMetrics metrics) {
|
public int calcMinTextWidth(@NotNull String text, @NotNull FontMetrics metrics) {
|
||||||
if (text.length() < MIN_TEXT_LENGTH) return metrics.stringWidth(text);
|
return UIUtil.computeTextComponentMinimumSize(metrics.stringWidth(text), text, metrics, MIN_TEXT_LENGTH - 1);
|
||||||
text = text.substring(0, MIN_TEXT_LENGTH - 1);
|
|
||||||
return metrics.stringWidth(text + "...");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user