@@ -0,0 +1,1112 @@
+/**%0D%0A * %0D%0A */%0D%0Apackage net.sf.taverna.t2.lang.ui;%0D%0A%0D%0Aimport java.util.regex.Pattern;%0D%0A%0D%0Aimport javax.swing.text.AttributeSet;%0D%0Aimport javax.swing.text.BadLocationException;%0D%0Aimport javax.swing.text.DocumentFilter;%0D%0A%0D%0A/**%0D%0A * @author alanrw%0D%0A *%0D%0A */%0D%0Apublic class SanitisingDocumentFilter extends DocumentFilter %7B%0D%0A%09public void insertString(DocumentFilter.FilterBypass fb, int offset, String string, AttributeSet attr) throws BadLocationException %7B%0D%0A%09%09%0D%0A%09%09fb.insertString(offset, sanitiseString(string), attr);%0D%0A%09%7D%0D%0A%09%0D%0A%09public void replace(DocumentFilter.FilterBypass fb, int offset, int length,%0D%0A%09%09      String text, javax.swing.text.AttributeSet attr)%0D%0A%0D%0A%09%09      throws BadLocationException %7B%0D%0A%09%09           fb.insertString(offset, sanitiseString(text), attr);   %0D%0A%09%09 %7D%0D%0A%09%0D%0A%09private static String sanitiseString(String text) %7B%0D%0A%09%09String result = text;%0D%0A%09%09if (Pattern.matches(%22%5C%5Cw++%22, text) == false) %7B%0D%0A%09%09%09result = %22%22;%0D%0A%09%09%09for (char c : text.toCharArray()) %7B%0D%0A%09%09%09%09if (Character.isLetterOrDigit(c) %7C%7C c == '_') %7B%0D%0A%09%09%09%09%09result += c;%0D%0A%09%09%09%09%7D else %7B%0D%0A%09%09%09%09%09result += %22_%22;%0D%0A%09%09%09%09%7D%0D%0A%09%09%09%7D%0D%0A%09%09%7D%0D%0A%09%09return result;%09%09%0D%0A%09%7D%0D%0A%7D%0D%0A

Document filter for names