changeset 6:001511e41f96

use a special table cell renderer that displays otherwise hidden special characters (\n for now)
author Dirk Olmes <dirk@xanthippe.ping.de>
date Mon, 12 Sep 2011 15:58:20 +0200
parents ad2b4949967e
children e4275005761d
files conflict-editor/src/main/java/de/codedo/conflicteditor/gui/ConflictEditorFrame.java conflict-editor/src/main/java/de/codedo/conflicteditor/gui/SpecialCharactersTableCellRenderer.java
diffstat 2 files changed, 24 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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()
--- /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");
+    }
+}