# HG changeset patch # User Dirk Olmes # Date 1315835900 -7200 # Node ID 001511e41f9693a2a8abb4008ba4d27bf5758808 # Parent ad2b4949967eb801dd60102b1853fd91868da4f3 use a special table cell renderer that displays otherwise hidden special characters (\n for now) diff -r ad2b4949967e -r 001511e41f96 conflict-editor/src/main/java/de/codedo/conflicteditor/gui/ConflictEditorFrame.java --- a/conflict-editor/src/main/java/de/codedo/conflicteditor/gui/ConflictEditorFrame.java Mon Sep 12 15:50:00 2011 +0200 +++ b/conflict-editor/src/main/java/de/codedo/conflicteditor/gui/ConflictEditorFrame.java Mon Sep 12 15:58:20 2011 +0200 @@ -74,9 +74,10 @@ private void buildDifferencesTable() { _differencesTable = new JTable(); + _differencesTable.setDefaultRenderer(Object.class, new SpecialCharactersTableCellRenderer()); + TableModel model = new DifferenceTableModel(); _differencesTable.setModel(model); - } public String getDatabaseUrl() diff -r ad2b4949967e -r 001511e41f96 conflict-editor/src/main/java/de/codedo/conflicteditor/gui/SpecialCharactersTableCellRenderer.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/conflict-editor/src/main/java/de/codedo/conflicteditor/gui/SpecialCharactersTableCellRenderer.java Mon Sep 12 15:58:20 2011 +0200 @@ -0,0 +1,22 @@ + +package de.codedo.conflicteditor.gui; + +import javax.swing.table.DefaultTableCellRenderer; + +public class SpecialCharactersTableCellRenderer extends DefaultTableCellRenderer +{ + @Override + protected void setValue(Object value) + { + if (value instanceof String) + { + value = escapeSpecialCharacters((String)value); + } + super.setValue(value); + } + + private Object escapeSpecialCharacters(String value) + { + return value.replace("\n", "\\n"); + } +}