1 45 46 package edu.rice.cs.drjava.model.repl; 47 48 import edu.rice.cs.drjava.model.definitions.ColoringGlyphPainter; 49 import javax.swing.text.*; 50 import java.awt.*; 51 52 53 58 public class InteractionsEditorKit extends StyledEditorKit { 59 60 63 public InteractionsEditorKit() { 64 } 65 66 67 private static ViewFactory _factory = new ViewFactory() { 68 69 public View create(Element elem) { 70 String kind = elem.getName(); 71 72 if (kind != null) { 73 if (kind.equals(AbstractDocument.ContentElementName)) { 74 return _createColoringView(elem); 75 } else if (kind.equals(AbstractDocument.ParagraphElementName)) { 76 return new ParagraphView(elem); 77 } else if (kind.equals(AbstractDocument.SectionElementName)) { 78 return new BoxView(elem, View.Y_AXIS); 79 } else if (kind.equals(StyleConstants.ComponentElementName)) { 80 return new ComponentView(elem); 81 } else if (kind.equals(StyleConstants.IconElementName)) { 82 return new IconView(elem); 83 } 84 } 85 86 return _createColoringView(elem); 88 } 89 90 }; 91 92 95 public String getContentType() { return "text/java"; } 96 97 98 public final ViewFactory getViewFactory() { return _factory; } 99 100 public InteractionsDJDocument createDefaultDocument() { 101 return new InteractionsDJDocument(); 102 } 103 104 110 private static GlyphView _createColoringView(Element elem) { 111 final GlyphView view = new GlyphView(elem); 112 view.setGlyphPainter(new ColoringGlyphPainter(new Runnable () { 113 public void run() { 114 if (view.getContainer() != null) view.getContainer().repaint(); 115 } 116 })); 117 return view; 118 } 119 } 120 121 122 | Popular Tags |