From 95d1cd538b42841b303d21a18e30692eb8b89a77 Mon Sep 17 00:00:00 2001 From: Julia Beliaeva Date: Fri, 14 Jun 2019 20:22:55 +0300 Subject: [PATCH] [util] extract ellipsis symbol GitOrigin-RevId: 3c808b49f634e0dfd579f02d4046af8d3156f8b0 --- .../util/src/com/intellij/openapi/util/text/StringUtil.java | 5 +++-- .../src/com/intellij/vcs/log/ui/render/LabelPainter.java | 5 ++--- .../src/com/intellij/vcs/log/ui/table/RootCellRenderer.java | 3 ++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/platform/util/src/com/intellij/openapi/util/text/StringUtil.java b/platform/util/src/com/intellij/openapi/util/text/StringUtil.java index 83043f4a2524..7756609aa5de 100644 --- a/platform/util/src/com/intellij/openapi/util/text/StringUtil.java +++ b/platform/util/src/com/intellij/openapi/util/text/StringUtil.java @@ -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); } diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/LabelPainter.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/LabelPainter.java index aa38c8fd7cea..2423083b78ab 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/LabelPainter.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/render/LabelPainter.java @@ -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; } diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/table/RootCellRenderer.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/table/RootCellRenderer.java index 1d85b0101605..5fb48fff3762 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/table/RootCellRenderer.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/table/RootCellRenderer.java @@ -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); } }