package cc.redpen.intellij;

import javax.swing.*;
import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.PlainDocument;

class SingleCharEditor extends DefaultCellEditor {
  public SingleCharEditor() {
    super(new JTextField(new SingleCharDocument(), null, 1));
  }

  @Override public boolean stopCellEditing() {
    return ((JTextField)getComponent()).getText().length() == 1 && super.stopCellEditing();
  }

  static class SingleCharDocument extends PlainDocument {
    public void insertString(int offset, String str, AttributeSet a) throws BadLocationException {
      if (str != null && str.length() + getLength() == 1) super.insertString(offset, str, a);
    }
  }
}

@@ -44,16 +44,54 @@
 wing.*;%0A
+import javax.swing.border.LineBorder;%0A
 import j
@@ -120,16 +120,16 @@
 uteSet;%0A
-
 import j
@@ -204,16 +204,35 @@
 ocument;
+%0Aimport java.awt.*;
 %0A%0Aclass 
@@ -302,24 +302,24 @@
 rEditor() %7B%0A
-
     super(ne
@@ -368,16 +368,89 @@
 l, 1));%0A
+    ((JComponent)getComponent()).setBorder(new LineBorder(Color.black));%0A
   %7D%0A%0A  @

use the same border as native JTable editors