From 1d101a9be147d336c2ea0add1d01d2971ea6b317 Mon Sep 17 00:00:00 2001 From: Julia Beliaeva Date: Wed, 2 Aug 2017 21:40:13 +0300 Subject: [PATCH] [file-history] highlight current revision IDEA-171358 --- .../vcs/history/FileHistoryPanelImpl.java | 36 ++++++++++++++----- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistoryPanelImpl.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistoryPanelImpl.java index 4364fe57167b..dd72622b0c50 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistoryPanelImpl.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/history/FileHistoryPanelImpl.java @@ -657,6 +657,26 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton impleme protected DualView getDualView() { return myDualView; } + + @Override + public TableCellRenderer getCustomizedRenderer(TreeNodeOnVcsRevision revision, TableCellRenderer renderer) { + if (renderer instanceof BaseHistoryCellRenderer) { + ((BaseHistoryCellRenderer)renderer).setCurrentRevision(myHistorySession.isCurrentRevision(revision.getRevision().getRevisionNumber())); + } + return renderer; + } + } + + private abstract static class BaseHistoryCellRenderer extends ColoredTableCellRenderer { + private boolean myIsCurrentRevision = false; + + protected SimpleTextAttributes getDefaultAttributes() { + return myIsCurrentRevision ? SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES : SimpleTextAttributes.REGULAR_ATTRIBUTES; + } + + public void setCurrentRevision(boolean currentRevision) { + myIsCurrentRevision = currentRevision; + } } public static class RevisionColumnInfo extends ColumnInfo { @@ -666,10 +686,10 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton impleme public RevisionColumnInfo(@Nullable Comparator comparator) { super(VcsBundle.message("column.name.revision.version")); myComparator = comparator; - myRenderer = new ColoredTableCellRenderer() { + myRenderer = new BaseHistoryCellRenderer() { protected void customizeCellRenderer(JTable table, Object value, boolean selected, boolean hasFocus, int row, int column) { setOpaque(selected); - append(VcsUtil.getShortRevisionString((VcsRevisionNumber)value)); + append(VcsUtil.getShortRevisionString((VcsRevisionNumber)value), getDefaultAttributes()); SpeedSearchUtil.applySpeedSearchHighlighting(table, this, false, selected); } }; @@ -705,12 +725,12 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton impleme public DateColumnInfo() { super(VcsBundle.message("column.name.revision.date")); - myRenderer = new ColoredTableCellRenderer() { + myRenderer = new BaseHistoryCellRenderer() { protected void customizeCellRenderer(JTable table, Object value, boolean selected, boolean hasFocus, int row, int column) { setOpaque(selected); Date date = (Date)value; if (date != null) { - append(DateFormatUtil.formatPrettyDateTime(date)); + append(DateFormatUtil.formatPrettyDateTime(date), getDefaultAttributes()); } SpeedSearchUtil.applySpeedSearchHighlighting(table, this, false, selected); } @@ -741,7 +761,7 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton impleme } } - private static class AuthorCellRenderer extends ColoredTableCellRenderer { + private static class AuthorCellRenderer extends BaseHistoryCellRenderer { private String myTooltipText; /** @@ -762,7 +782,7 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton impleme setBackground(table.getBackground()); setForeground(table.getForeground()); } - if (value != null) append(value.toString()); + if (value != null) append(value.toString(), getDefaultAttributes()); SpeedSearchUtil.applySpeedSearchHighlighting(table, this, false, selected); } } @@ -822,12 +842,12 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton impleme public MessageColumnInfo(Project project) { super(COMMIT_MESSAGE_TITLE); - myRenderer = new ColoredTableCellRenderer() { + myRenderer = new BaseHistoryCellRenderer() { protected void customizeCellRenderer(JTable table, Object value, boolean selected, boolean hasFocus, int row, int column) { setOpaque(selected); if (value instanceof String) { String message = (String)value; - myIssueLinkRenderer.appendTextWithLinks(message); + myIssueLinkRenderer.appendTextWithLinks(message, getDefaultAttributes()); SpeedSearchUtil.applySpeedSearchHighlighting(table, this, false, selected); } }