1 31 32 package org.antlr.works.generate; 33 34 import org.antlr.works.ate.ATEPanel; 35 import org.antlr.works.ate.syntax.java.ATEJavaSyntaxEngine; 36 import org.antlr.works.editor.EditorTab; 37 import org.antlr.works.prefs.AWPrefs; 38 import org.antlr.xjlib.appkit.frame.XJFrameInterface; 39 40 import java.awt.*; 41 42 public class CodeDisplay extends EditorTab { 43 44 protected ATEPanel textEditor; 45 protected String title; 46 47 public CodeDisplay(XJFrameInterface parentFrame) { 48 textEditor = new ATEPanel(parentFrame); 49 textEditor.setParserEngine(new ATEJavaSyntaxEngine()); 50 textEditor.setSyntaxColoring(true); 51 textEditor.setAnalysisColumnVisible(false); 52 textEditor.setFoldingEnabled(AWPrefs.getFoldingEnabled()); 53 textEditor.setLineNumberEnabled(AWPrefs.getLineNumberEnabled()); 54 textEditor.setHighlightCursorLine(AWPrefs.getHighlightCursorEnabled()); 55 textEditor.setEditable(false); 56 applyFont(); 57 } 58 59 public void applyFont() { 60 textEditor.getTextPane().setFont(new Font(AWPrefs.getEditorFont(), Font.PLAIN, AWPrefs.getEditorFontSize())); 61 textEditor.getTextPane().setTabSize(AWPrefs.getEditorTabSize()); 62 } 63 64 public void setText(String text) { 65 textEditor.loadText(text); 66 } 67 68 public void setTitle(String title) { 69 this.title = title; 70 } 71 72 public Container getContainer() { 73 return textEditor; 74 } 75 76 public String getTabName() { 77 return title; 78 } 79 80 public Component getTabComponent() { 81 return getContainer(); 82 } 83 } 84 | Popular Tags |