DefaultStyledDocument doc = new DefaultStyledDocument();
doc.setDocumentFilter(new GroovyFilter(doc));
textEditor.setDocument(doc);
// create and add the undo/redo manager
this.undoManager = new TextUndoManager();
doc.addUndoableEditListener(undoManager);
// add the undo actions
undoManager.addPropertyChangeListener(undoAction);
undoManager.addPropertyChangeListener(redoAction);