/** * Constructs a plain text document. A default root element is created, * and the tab size set to 5. * * @param tmf The <code>TokenMakerFactory</code> for this document. If * this is <code>null</code>, a default factory is used. * @param syntaxStyle The syntax highlighting scheme to use. */ public RSyntaxDocument(TokenMakerFactory tmf, String syntaxStyle) { putProperty(tabSizeAttribute, Integer.valueOf(5)); lastTokensOnLines = new DynamicIntArray(400); lastTokensOnLines.add(Token.NULL); // Initial (empty) line. s = new Segment(); setTokenMakerFactory(tmf); setSyntaxStyle(syntaxStyle); }
/** * Deserializes a document. * * @param in The stream to read from. * @throws ClassNotFoundException * @throws IOException */ private void readObject(ObjectInputStream in) throws ClassNotFoundException, IOException { in.defaultReadObject(); // Install default TokenMakerFactory. To support custom TokenMakers, // both JVM's should install default TokenMakerFactories that support // the language they want to use beforehand. setTokenMakerFactory(null); // Handle other transient stuff this.s = new Segment(); int lineCount = getDefaultRootElement().getElementCount(); lastTokensOnLines = new DynamicIntArray(lineCount); setSyntaxStyle(syntaxStyle); // Actually install (transient) TokenMaker }
@Test public void testSetTokenMakerFactory() { String syntaxStyle = SyntaxConstants.SYNTAX_STYLE_C; doc = new RSyntaxDocument(syntaxStyle); // By default, we do indeed get syntax highlighting for Java doc.setSyntaxStyle(SyntaxConstants.SYNTAX_STYLE_JAVA); Assert.assertNotNull(doc.getLineCommentStartAndEnd(0)); // No mappings -> default to PlainTextTokenMaker doc.setTokenMakerFactory(new EmptyTokenMakerFactory()); doc.setSyntaxStyle(SyntaxConstants.SYNTAX_STYLE_JAVA); // Ghetto test to show we are not picking up a JavaTokenMaker Assert.assertNull(doc.getLineCommentStartAndEnd(0)); // Verify restoring default instance doc.setTokenMakerFactory(null); doc.setSyntaxStyle(SyntaxConstants.SYNTAX_STYLE_JAVA); Assert.assertNotNull(doc.getLineCommentStartAndEnd(0)); }
/** * Constructs a plain text document. A default root element is created, * and the tab size set to 5. * * @param tmf The <code>TokenMakerFactory</code> for this document. If * this is <code>null</code>, a default factory is used. * @param syntaxStyle The syntax highlighting scheme to use. */ public RSyntaxDocument(TokenMakerFactory tmf, String syntaxStyle) { putProperty(tabSizeAttribute, Integer.valueOf(5)); lastTokensOnLines = new DynamicIntArray(400); lastTokensOnLines.add(Token.NULL); // Initial (empty) line. s = new Segment(); setTokenMakerFactory(tmf); setSyntaxStyle(syntaxStyle); }
/** * Deserializes a document. * * @param in The stream to read from. * @throws ClassNotFoundException * @throws IOException */ private void readObject(ObjectInputStream in) throws ClassNotFoundException, IOException { in.defaultReadObject(); // Install default TokenMakerFactory. To support custom TokenMakers, // both JVM's should install default TokenMakerFactories that support // the language they want to use beforehand. setTokenMakerFactory(null); // Handle other transient stuff this.s = new Segment(); int lineCount = getDefaultRootElement().getElementCount(); lastTokensOnLines = new DynamicIntArray(lineCount); setSyntaxStyle(syntaxStyle); // Actually install (transient) TokenMaker }
/** * Constructs a plain text document. A default root element is created, * and the tab size set to 5. * * @param tmf The <code>TokenMakerFactory</code> for this document. If * this is <code>null</code>, a default factory is used. * @param syntaxStyle The syntax highlighting scheme to use. */ public RSyntaxDocument(TokenMakerFactory tmf, String syntaxStyle) { super(new RGapContent()); putProperty(tabSizeAttribute, new Integer(5)); lastTokensOnLines = new DynamicIntArray(400); lastTokensOnLines.add(Token.NULL); // Initial (empty) line. s = new Segment(); setTokenMakerFactory(tmf); setSyntaxStyle(syntaxStyle); }
/** * Constructs a plain text document. A default root element is created, * and the tab size set to 5. * * @param tmf The <code>TokenMakerFactory</code> for this document. If * this is <code>null</code>, a default factory is used. * @param syntaxStyle The syntax highlighting scheme to use. */ public RSyntaxDocument(TokenMakerFactory tmf, String syntaxStyle) { super(new GapContent()); putProperty(tabSizeAttribute, new Integer(5)); lastTokensOnLines = new DynamicIntArray(400); lastTokensOnLines.add(Token.NULL); // Initial (empty) line. s = new Segment(); setTokenMakerFactory(tmf); setSyntaxStyle(syntaxStyle); }
public HttpPanelSyntaxHighlightTextArea() { ((RSyntaxDocument)getDocument()).setTokenMakerFactory(getTokenMakerFactory()); setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_NONE);