Skip to content

Commit

Permalink
squash with highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
mbien committed Mar 23, 2024
1 parent ec86036 commit a1c63a0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public Component getTableCellRendererComponent (JTable table, Object value, bool
try {
tooltip = XMLUtil.toElementContent(tooltip);
} catch (CharConversionException e1) {
Logger.getLogger(DiffTreeTable.class.getName()).log(Level.INFO, "Can not HTML escape: ", tooltip); //NOI18N
Logger.getLogger(DiffTreeTable.class.getName()).log(Level.INFO, "Can not HTML escape: " + tooltip); //NOI18N
}
}
if (tooltip.contains("\n")) {
Expand Down
29 changes: 21 additions & 8 deletions ide/git/src/org/netbeans/modules/git/ui/history/RevisionNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Rectangle;
import java.io.CharConversionException;
import java.text.DateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.Action;
import javax.swing.BorderFactory;
import javax.swing.Icon;
Expand All @@ -42,12 +45,13 @@
import org.netbeans.api.editor.mimelookup.MimePath;
import org.netbeans.api.editor.settings.FontColorSettings;
import org.netbeans.modules.git.options.AnnotationColorProvider;
import org.netbeans.modules.versioning.history.AbstractSummaryView;
import org.netbeans.modules.versioning.history.AbstractSummaryView.SummaryViewMaster.SearchHighlight;
import org.openide.nodes.AbstractNode;
import org.openide.nodes.Children;
import org.openide.nodes.PropertySupport;
import org.openide.nodes.Sheet;
import org.openide.util.ImageUtilities;
import org.openide.xml.XMLUtil;

import static org.netbeans.modules.git.utils.GitUtils.getColorString;

Expand Down Expand Up @@ -100,11 +104,15 @@ RepositoryRevision.Event getEvent() {

@Override
public String getHtmlDisplayName() {
// Note: quicksearch highlighting impl for the filename colum is missing.
// NB uses a custom html renderer for the tree's primary column which
// doesn't support background-color.
String name = escape(getName());
if (isCommitNode()) {
return "<b>"+getName()+"</b>";
return "<b>"+name+"</b>";
} else {
String c = annotationColorForAction(event.getAction());
return c != null ? "<font color="+c+">"+getName()+"</font>" : getName();
return c != null ? "<font color="+c+">"+name+"</font>" : name;
}
}

Expand Down Expand Up @@ -194,7 +202,12 @@ public PropertyEditor getPropertyEditor() {
}

private static String escape(String text) {
return text.replace("<", "&lt;");
try {
return XMLUtil.toElementContent(text);
} catch (CharConversionException ex) {
Logger.getLogger(RevisionNode.class.getName()).log(Level.INFO, "Can not HTML escape: " + text); //NOI18N
return ""; //NOI18N
}
}

private static String highlight(String text, String needle, String bgColor, String fgColor) {
Expand All @@ -221,8 +234,8 @@ public UsernameProperty() {
@Override
public Object getValue() throws IllegalAccessException, InvocationTargetException {
if (isCommitNode()) {
for (AbstractSummaryView.SummaryViewMaster.SearchHighlight h : getLookup().lookup(SearchHistoryPanel.class).getSearchHighlights()) {
if (h.getKind() == AbstractSummaryView.SummaryViewMaster.SearchHighlight.Kind.AUTHOR) {
for (SearchHighlight h : getLookup().lookup(SearchHistoryPanel.class).getSearchHighlights()) {
if (h.getKind() == SearchHighlight.Kind.AUTHOR) {
return highlight(container.getLog().getAuthor().toString(), h.getSearchText(), bgColor, fgColor);
}
}
Expand Down Expand Up @@ -282,8 +295,8 @@ public MessageProperty() {
@Override
public Object getValue() throws IllegalAccessException, InvocationTargetException {
if (isCommitNode()) {
for (AbstractSummaryView.SummaryViewMaster.SearchHighlight h : getLookup().lookup(SearchHistoryPanel.class).getSearchHighlights()) {
if (h.getKind() == AbstractSummaryView.SummaryViewMaster.SearchHighlight.Kind.MESSAGE) {
for (SearchHighlight h : getLookup().lookup(SearchHistoryPanel.class).getSearchHighlights()) {
if (h.getKind() == SearchHighlight.Kind.MESSAGE) {
return highlight(container.getLog().getFullMessage(), h.getSearchText(), bgColor, fgColor);
}
}
Expand Down

0 comments on commit a1c63a0

Please sign in to comment.