[file-history] show path relative to the root in the tooltip

GitOrigin-RevId: 7483eaded0727e87407b8a3b2680e8189ebf12d2
This commit is contained in:
Julia Beliaeva
2019-06-14 23:07:20 +03:00
committed by intellij-monorepo-bot
parent 19f96aed52
commit 9607eac146
4 changed files with 20 additions and 5 deletions
@@ -2,13 +2,16 @@
package com.intellij.vcs.log.history
import com.intellij.openapi.vcs.FilePath
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.vcs.log.VcsLogDataPack
import com.intellij.vcs.log.history.FileHistoryVisiblePack.Companion.filePaths
import com.intellij.vcs.log.ui.VcsLogColorManager
import com.intellij.vcs.log.ui.VcsLogColorManagerImpl
import com.intellij.vcsUtil.VcsFileUtil
import java.awt.Color
class FileHistoryColorManager(private val path: FilePath) : VcsLogColorManager {
class FileHistoryColorManager(private val root: VirtualFile,
private val path: FilePath) : VcsLogColorManager {
private var baseColorManager = VcsLogColorManagerImpl(setOf(path))
override fun getPathColor(path: FilePath): Color {
@@ -28,4 +31,8 @@ class FileHistoryColorManager(private val path: FilePath) : VcsLogColorManager {
override fun getPaths(): Collection<FilePath> {
return baseColorManager.paths
}
override fun getLongName(path: FilePath): String {
return VcsFileUtil.relativePath(root, path)
}
}
@@ -64,7 +64,7 @@ public class FileHistoryUi extends AbstractVcsLogUi {
@NotNull FilePath path,
@Nullable Hash revision,
@NotNull VirtualFile root) {
super(getFileHistoryLogId(path, revision), logData, new FileHistoryColorManager(path), refresher);
super(getFileHistoryLogId(path, revision), logData, new FileHistoryColorManager(root, path), refresher);
myPath = path;
myRoot = root;
@@ -41,4 +41,12 @@ public interface VcsLogColorManager {
*/
@NotNull
Collection<FilePath> getPaths();
/**
* Returns long name for this file path (to be shown in the tooltip, etc.).
*/
@NotNull
default String getLongName(@NotNull FilePath path) {
return path.getPresentableUrl();
}
}
@@ -433,10 +433,10 @@ public class VcsLogGraphTable extends TableWithProgress implements DataProvider,
return null;
}
if (column == ROOT_COLUMN) {
Object at = getValueAt(row, column);
if (at instanceof FilePath) {
Object path = getValueAt(row, column);
if (path instanceof FilePath) {
return "<html><b>" +
((FilePath)at).getPresentableUrl() +
myColorManager.getLongName((FilePath)path) +
"</b><br/>Click to " +
(isShowRootNames() ? "collapse" : "expand") +
"</html>";