1 16 17 package org.mc4j.console.swing.editor.xml; 18 19 import javax.swing.text.Document ; 20 import javax.swing.text.StyledEditorKit ; 21 import java.awt.*; 22 23 27 public class XMLStyleTokens extends StyleTokens { 28 public static final String TAG = "tag"; 29 public static final String TEXT = "text"; 30 public static final String COMMENT = "comment"; 31 private static final String ATTRIBUTE = "attribute"; 32 33 public XMLStyleTokens() { 34 35 addTokenType(COMMENT, "<!--[^--]*-->", Color.gray, false); 39 addTokenType(TAG, "<[^ >]*|[\\?]?>", new Color(0,0,132), true); 40 addTokenType(TEXT, "\"(?:\\\\.|[^\"\\\\])*\"", new Color(72,125,55), true); 41 addTokenType(ATTRIBUTE, "\\w+(?<=)", Color.red, false); 42 } 43 44 public static class Kit extends StyledEditorKit { 45 public Document createDefaultDocument() { 46 return new EditorDocument(new XMLStyleTokens()); 47 } 48 } 49 } 50 51 | Popular Tags |