From a1c63a0ed82e241e73825c951a2f6457f243e9fa Mon Sep 17 00:00:00 2001 From: Michael Bien Date: Sat, 23 Mar 2024 10:24:09 +0100 Subject: [PATCH] squash with highlighting --- .../modules/git/ui/history/DiffTreeTable.java | 2 +- .../modules/git/ui/history/RevisionNode.java | 29 ++++++++++++++----- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/ide/git/src/org/netbeans/modules/git/ui/history/DiffTreeTable.java b/ide/git/src/org/netbeans/modules/git/ui/history/DiffTreeTable.java index f2e69c6b79de..552b1d93c44f 100644 --- a/ide/git/src/org/netbeans/modules/git/ui/history/DiffTreeTable.java +++ b/ide/git/src/org/netbeans/modules/git/ui/history/DiffTreeTable.java @@ -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")) { diff --git a/ide/git/src/org/netbeans/modules/git/ui/history/RevisionNode.java b/ide/git/src/org/netbeans/modules/git/ui/history/RevisionNode.java index 45e4d07cd47b..4207c119ce3a 100644 --- a/ide/git/src/org/netbeans/modules/git/ui/history/RevisionNode.java +++ b/ide/git/src/org/netbeans/modules/git/ui/history/RevisionNode.java @@ -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; @@ -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; @@ -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 ""+getName()+""; + return ""+name+""; } else { String c = annotationColorForAction(event.getAction()); - return c != null ? ""+getName()+"" : getName(); + return c != null ? ""+name+"" : name; } } @@ -194,7 +202,12 @@ public PropertyEditor getPropertyEditor() { } private static String escape(String text) { - return text.replace("<", "<"); + 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) { @@ -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); } } @@ -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); } }