diff --git a/source/net/sourceforge/filebot/ui/panel/sfv/ChecksumTable.java b/source/net/sourceforge/filebot/ui/panel/sfv/ChecksumTable.java index 8066f077..aa9e8e82 100644 --- a/source/net/sourceforge/filebot/ui/panel/sfv/ChecksumTable.java +++ b/source/net/sourceforge/filebot/ui/panel/sfv/ChecksumTable.java @@ -4,6 +4,8 @@ package net.sourceforge.filebot.ui.panel.sfv; import static net.sourceforge.filebot.FileBotUtilities.EMBEDDED_CHECKSUM_PATTERN; +import java.awt.Color; + import javax.swing.JTable; import javax.swing.ListSelectionModel; import javax.swing.table.TableColumn; @@ -27,6 +29,9 @@ class ChecksumTable extends JTable { setDragEnabled(true); setUI(new DragDropRowTableUI()); + // force white background (e.g. gtk-laf default table background is gray) + setBackground(Color.WHITE); + // highlight CRC32 patterns in filenames in green and with smaller font-size setDefaultRenderer(String.class, new HighlightPatternCellRenderer(EMBEDDED_CHECKSUM_PATTERN)); setDefaultRenderer(ChecksumRow.State.class, new StateIconCellRenderer()); diff --git a/source/net/sourceforge/filebot/ui/panel/sfv/HighlightPatternCellRenderer.java b/source/net/sourceforge/filebot/ui/panel/sfv/HighlightPatternCellRenderer.java index f215bb3b..d79f8fa3 100644 --- a/source/net/sourceforge/filebot/ui/panel/sfv/HighlightPatternCellRenderer.java +++ b/source/net/sourceforge/filebot/ui/panel/sfv/HighlightPatternCellRenderer.java @@ -3,12 +3,15 @@ package net.sourceforge.filebot.ui.panel.sfv; import java.awt.Component; +import java.util.EnumSet; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.swing.JTable; import javax.swing.table.DefaultTableCellRenderer; +import net.sourceforge.filebot.ui.panel.sfv.ChecksumRow.State; + /** * DefaultTableCellRenderer with highlighting of text patterns. @@ -26,10 +29,11 @@ class HighlightPatternCellRenderer extends DefaultTableCellRenderer { @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { super.getTableCellRendererComponent(table, value, isSelected, false, row, column); + + // check for error or warning + boolean isError = (EnumSet.of(State.ERROR, State.WARNING).contains(table.getValueAt(row, 0))); - boolean isWarning = (table.getValueAt(row, 0) == ChecksumRow.State.WARNING); - - // highlight CRC32 checksum patterns by using a smaller font-size and changing the font-color to a dark green + // highlight patterns by using a smaller font-size and changing the font-color to a dark green // do not change the font-color if cell is selected, because that would look ugly (imagine green text on blue background ...) Matcher matcher = pattern.matcher(value.toString()); @@ -37,7 +41,7 @@ class HighlightPatternCellRenderer extends DefaultTableCellRenderer { StringBuffer htmlText = new StringBuffer(""); while (matcher.find()) { - matcher.appendReplacement(htmlText, createReplacement(isSelected ? null : isWarning ? "#FF8C00" : "#009900", "smaller")); + matcher.appendReplacement(htmlText, createReplacement(isSelected ? null : (isError ? "red" : "#009900"), "smaller", isError ? "bold" : null)); } matcher.appendTail(htmlText); @@ -50,7 +54,7 @@ class HighlightPatternCellRenderer extends DefaultTableCellRenderer { } - protected String createReplacement(String cssColor, String cssFontSize) { + protected String createReplacement(String cssColor, String cssFontSize, String cssFontWeight) { // build replacement string like // e.g. $0 StringBuilder replacement = new StringBuilder(60); @@ -65,6 +69,10 @@ class HighlightPatternCellRenderer extends DefaultTableCellRenderer { replacement.append("font-size:").append(cssFontSize).append(';'); } + if (cssFontWeight != null) { + replacement.append("font-weight:").append(cssFontWeight).append(';'); + } + return replacement.append("'>$0").toString(); }