[file-history] highlight current revision

IDEA-171358
This commit is contained in:
Julia Beliaeva
2017-08-29 19:46:27 +03:00
parent 0f61f0be42
commit 1d101a9be1
@@ -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<VcsFileRevision, VcsRevisionNumber> {
@@ -666,10 +686,10 @@ public class FileHistoryPanelImpl extends PanelWithActionsAndCloseButton impleme
public RevisionColumnInfo(@Nullable Comparator<VcsFileRevision> 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);
}
}