mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
git log: show current user name in bold
This commit is contained in:
@@ -17,6 +17,7 @@ package com.intellij.ui;
|
||||
|
||||
import com.intellij.openapi.editor.markup.EffectType;
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -215,4 +216,34 @@ public final class SimpleTextAttributes {
|
||||
return new SimpleTextAttributes(bg != null ? bg : getBgColor(), fg != null ? fg : getFgColor(), wave != null ? wave : getWaveColor(),
|
||||
style == -1 ? getStyle() : style);
|
||||
}
|
||||
|
||||
// take what differs from REGULAR
|
||||
public static SimpleTextAttributes merge(final SimpleTextAttributes weak, final SimpleTextAttributes strong) {
|
||||
final int style;
|
||||
final Color wave;
|
||||
final Color fg;
|
||||
final Color bg;
|
||||
if (strong.getStyle() != REGULAR_ATTRIBUTES.getStyle()) {
|
||||
style = strong.getStyle();
|
||||
} else {
|
||||
style = weak.getStyle();
|
||||
}
|
||||
if (! Comparing.equal(strong.getWaveColor(), REGULAR_ATTRIBUTES.getWaveColor())) {
|
||||
wave = strong.getWaveColor();
|
||||
} else {
|
||||
wave = weak.getWaveColor();
|
||||
}
|
||||
if (! Comparing.equal(strong.getFgColor(), REGULAR_ATTRIBUTES.getFgColor())) {
|
||||
fg = strong.getFgColor();
|
||||
} else {
|
||||
fg = weak.getFgColor();
|
||||
}
|
||||
if (! Comparing.equal(strong.getBgColor(), REGULAR_ATTRIBUTES.getBgColor())) {
|
||||
bg = strong.getBgColor();
|
||||
} else {
|
||||
bg = weak.getBgColor();
|
||||
}
|
||||
|
||||
return new SimpleTextAttributes(bg, fg, wave, style);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -776,17 +776,21 @@ public class GitLogUI implements Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
private class HighLightingRenderer extends ColoredTableCellRenderer {
|
||||
private class AuthorRenderer extends ColoredTableCellRenderer {
|
||||
private final SimpleTextAttributes myCurrentUserAttributes;
|
||||
private final SimpleTextAttributes myHighlightAttributes;
|
||||
private final List<String> mySearchContext;
|
||||
private final SimpleTextAttributes myUsualAttributes;
|
||||
protected final HighlightingRendererBase myWorker;
|
||||
|
||||
public HighLightingRenderer(SimpleTextAttributes highlightAttributes, SimpleTextAttributes usualAttributes,
|
||||
final List<String> searchContext) {
|
||||
private AuthorRenderer(SimpleTextAttributes currentUserAttributes,
|
||||
SimpleTextAttributes highlightAttributes,
|
||||
List<String> searchContext,
|
||||
SimpleTextAttributes usualAttributes) {
|
||||
myCurrentUserAttributes = currentUserAttributes;
|
||||
myHighlightAttributes = highlightAttributes;
|
||||
mySearchContext = searchContext;
|
||||
myUsualAttributes = usualAttributes == null ? SimpleTextAttributes.REGULAR_ATTRIBUTES : usualAttributes;
|
||||
myUsualAttributes = usualAttributes;
|
||||
myWorker = new HighlightingRendererBase(searchContext) {
|
||||
@Override
|
||||
protected void usual(String s) {
|
||||
@@ -807,6 +811,7 @@ public class GitLogUI implements Disposable {
|
||||
return;
|
||||
}
|
||||
final String text = value.toString();
|
||||
|
||||
if (mySearchContext.isEmpty()) {
|
||||
append(text, myUsualAttributes);
|
||||
return;
|
||||
@@ -815,6 +820,57 @@ public class GitLogUI implements Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
private class HighLightingRenderer extends ColoredTableCellRenderer {
|
||||
private final SimpleTextAttributes myHighlightAttributes;
|
||||
private final List<String> mySearchContext;
|
||||
private final SimpleTextAttributes myUsualAttributes;
|
||||
private SimpleTextAttributes myUsualAttributesForRun;
|
||||
protected final HighlightingRendererBase myWorker;
|
||||
|
||||
public HighLightingRenderer(SimpleTextAttributes highlightAttributes, SimpleTextAttributes usualAttributes,
|
||||
final List<String> searchContext) {
|
||||
myHighlightAttributes = highlightAttributes;
|
||||
mySearchContext = searchContext;
|
||||
myUsualAttributes = usualAttributes == null ? SimpleTextAttributes.REGULAR_ATTRIBUTES : usualAttributes;
|
||||
myUsualAttributesForRun = myUsualAttributes;
|
||||
myWorker = new HighlightingRendererBase(searchContext) {
|
||||
@Override
|
||||
protected void usual(String s) {
|
||||
append(s, myUsualAttributesForRun);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void highlight(String s) {
|
||||
append(s, SimpleTextAttributes.merge(myUsualAttributesForRun, myHighlightAttributes));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void customizeCellRenderer(JTable table, Object value, boolean selected, boolean hasFocus, int row, int column) {
|
||||
setBackground(getLogicBackground(selected, row));
|
||||
if (BigTableTableModel.LOADING == value) {
|
||||
return;
|
||||
}
|
||||
final String text = value.toString();
|
||||
myUsualAttributesForRun = isCurrentUser(row, text) ?
|
||||
SimpleTextAttributes.merge(myUsualAttributes, SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES) : myUsualAttributes;
|
||||
if (mySearchContext.isEmpty()) {
|
||||
append(text, myUsualAttributesForRun);
|
||||
return;
|
||||
}
|
||||
myWorker.tryHighlight(text);
|
||||
}
|
||||
|
||||
private boolean isCurrentUser(final int row, final String text) {
|
||||
final CommitI commitAt = myTableModel.getCommitAt(row);
|
||||
if (commitAt == null) return false;
|
||||
final SymbolicRefs symbolicRefs = myRefs.get(commitAt.selectRepository(myRootsUnderVcs));
|
||||
if (symbolicRefs == null) return false;
|
||||
return Comparing.equal(symbolicRefs.getUsername(), text);
|
||||
}
|
||||
}
|
||||
|
||||
private class SimpleRenderer extends ColoredTableCellRenderer {
|
||||
private final SimpleTextAttributes myAtt;
|
||||
private final boolean myShowLoading;
|
||||
|
||||
Reference in New Issue
Block a user