mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[util] extract ellipsis symbol
GitOrigin-RevId: 3c808b49f634e0dfd579f02d4046af8d3156f8b0
This commit is contained in:
committed by
intellij-monorepo-bot
parent
f5e2a982b1
commit
95d1cd538b
@@ -41,6 +41,7 @@ public class StringUtil extends StringUtilRt {
|
||||
private static final Pattern EOL_SPLIT_PATTERN = Pattern.compile(" *(\r|\n|\r\n)+ *");
|
||||
private static final Pattern EOL_SPLIT_PATTERN_WITH_EMPTY = Pattern.compile(" *(\r|\n|\r\n) *");
|
||||
private static final Pattern EOL_SPLIT_DONT_TRIM_PATTERN = Pattern.compile("(\r|\n|\r\n)+");
|
||||
public static final String ELLIPSIS = "\u2026";
|
||||
|
||||
/**
|
||||
* @return a lightweight CharSequence which results from replacing {@code [start, end)} range in the {@code charSeq} with {@code replacement}.
|
||||
@@ -2093,7 +2094,7 @@ public class StringUtil extends StringUtilRt {
|
||||
@Contract(pure = true)
|
||||
public static String firstLast(@NotNull String text, int length) {
|
||||
return text.length() > length
|
||||
? text.subSequence(0, length / 2) + "\u2026" + text.subSequence(text.length() - length / 2 - 1, text.length())
|
||||
? text.subSequence(0, length / 2) + ELLIPSIS + text.subSequence(text.length() - length / 2 - 1, text.length())
|
||||
: text;
|
||||
}
|
||||
|
||||
@@ -3073,7 +3074,7 @@ public class StringUtil extends StringUtilRt {
|
||||
final int maxLength,
|
||||
final int suffixLength,
|
||||
boolean useEllipsisSymbol) {
|
||||
String symbol = useEllipsisSymbol ? "\u2026" : "...";
|
||||
String symbol = useEllipsisSymbol ? ELLIPSIS : "...";
|
||||
return shortenTextWithEllipsis(text, maxLength, suffixLength, symbol);
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,6 @@ public class LabelPainter {
|
||||
public static final JBValue MIDDLE_PADDING = JBVG.value(12);
|
||||
public static final JBValue LABEL_ARC = JBVG.value(6);
|
||||
private static final int MAX_LENGTH = 22;
|
||||
private static final String THREE_DOTS = "...";
|
||||
private static final String TWO_DOTS = "..";
|
||||
private static final String SEPARATOR = "/";
|
||||
private static final JBColor TEXT_COLOR = CurrentBranchComponent.TEXT_COLOR;
|
||||
@@ -281,9 +280,9 @@ public class LabelPainter {
|
||||
}
|
||||
|
||||
if (availableWidth > 0) {
|
||||
return VcsLogUiUtil.shortenTextToFit(refName, fontMetrics, availableWidth, MAX_LENGTH, THREE_DOTS);
|
||||
return VcsLogUiUtil.shortenTextToFit(refName, fontMetrics, availableWidth, MAX_LENGTH, StringUtil.ELLIPSIS);
|
||||
}
|
||||
return StringUtil.shortenTextWithEllipsis(refName, MAX_LENGTH, 0, THREE_DOTS);
|
||||
return StringUtil.shortenTextWithEllipsis(refName, MAX_LENGTH, 0, StringUtil.ELLIPSIS);
|
||||
}
|
||||
return refName;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.vcs.log.ui.table;
|
||||
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.ui.ScrollingUtil;
|
||||
import com.intellij.ui.SimpleColoredRenderer;
|
||||
@@ -69,7 +70,7 @@ class RootCellRenderer extends SimpleColoredRenderer implements TableCellRendere
|
||||
int availableWidth = ((VcsLogGraphTable)table).getRootColumn().getWidth() -
|
||||
VcsLogUiUtil.getHorizontalTextPadding(this);
|
||||
text = VcsLogUiUtil.shortenTextToFit(text, getFontMetrics(VcsLogGraphTable.getTableFont()),
|
||||
availableWidth, 0, "\u2026");
|
||||
availableWidth, 0, StringUtil.ELLIPSIS);
|
||||
append(text);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user