Package javax.swing.text

Examples of javax.swing.text.DefaultStyledDocument.insertString()


        assertNotSame(paragraph.getAttributes(), view.getAttributes());
    }

    public void testInlineViewUponStyledDocument() throws BadLocationException {
        final StyledDocument styledDoc = new DefaultStyledDocument();
        styledDoc.insertString(0, "a simple paragraph", null);
        inline = styledDoc.getCharacterElement(1);
        testExceptionalCase(new ClassCastCase() {
            public void exceptionalAction() throws Exception {
                new InlineView(inline);
            }
View Full Code Here


        }
    }

    public void testTranslateHTMLToCSSStyledDocument() throws Exception {
        StyledDocument doc = new DefaultStyledDocument();
        doc.insertString(0, "line1\nline2", null);

        MutableAttributeSet mas = new SimpleAttributeSet();
        mas.addAttribute(HTML.Attribute.BGCOLOR, "#ffffff");
        mas.addAttribute(HTML.Attribute.TEXT, "black");
        doc.setParagraphAttributes(0, 1, mas, false);
View Full Code Here

        SimpleAttributeSet as1 = new SimpleAttributeSet();
        as1.addAttribute("key1", "value1");
        SimpleAttributeSet as2 = new SimpleAttributeSet();
        as2.addAttribute("key2", "value2");
        try {
            doc.insertString(0, "testReplaceSelection", as1);
            doc.insertString(4, "INSERT", as2);
        } catch (final BadLocationException e) {
            assertFalse("unexpected exception :" + e.getMessage(), true);
        }
        //temporarily commented-out: HTMLEditorKit not implemented
View Full Code Here

        as1.addAttribute("key1", "value1");
        SimpleAttributeSet as2 = new SimpleAttributeSet();
        as2.addAttribute("key2", "value2");
        try {
            doc.insertString(0, "testReplaceSelection", as1);
            doc.insertString(4, "INSERT", as2);
        } catch (final BadLocationException e) {
            assertFalse("unexpected exception :" + e.getMessage(), true);
        }
        //temporarily commented-out: HTMLEditorKit not implemented
        //jep.setEditorKit(new RTFEditorKit());
View Full Code Here

        StringWriter writer = new StringWriter();
        final String content = "Hello, World!";
        final int start = 1;
        final int end = 4;
        DefaultStyledDocument doc = new DefaultStyledDocument();
        doc.insertString(0, content, null);

        editorKit.write(writer, doc, start, end);
        String output = writer.toString();
        assertTrue(output.indexOf("<html>") != -1);
        if (isHarmony()) {
View Full Code Here

            assertTrue(output.indexOf(content.substring(start, end)) != -1);
        }

        writer = new StringWriter();
        doc = (HTMLDocument)editorKit.createDefaultDocument();
        doc.insertString(0, content, null);
        editorKit.write(writer, doc, start, end);
        output = writer.toString();
        assertTrue(output.indexOf("<html>") != -1);
        assertFalse(output.indexOf(content) != -1);
        assertTrue(output.indexOf(content.substring(start, end)) != -1);
View Full Code Here

     */
    @Test
    public void testGetIndentString() throws BadLocationException {
        DefaultStyledDocument document = new DefaultStyledDocument();
        document.putProperty(Language.class, MarkdownTokenId.language());
        document.insertString(0, "    * list\n", null); // white space
        String result = MarkdownDocUtil.getIndentString(document, 10);
        assertEquals("    ", result);

        document.insertString(0, "  * list\n", null); // tab space
        result = MarkdownDocUtil.getIndentString(document, 7);
View Full Code Here

        document.putProperty(Language.class, MarkdownTokenId.language());
        document.insertString(0, "    * list\n", null); // white space
        String result = MarkdownDocUtil.getIndentString(document, 10);
        assertEquals("    ", result);

        document.insertString(0, "  * list\n", null); // tab space
        result = MarkdownDocUtil.getIndentString(document, 7);
        assertEquals("  ", result);

        document.insertString(0, "      * list\n", null); // white space and tab space
        result = MarkdownDocUtil.getIndentString(document, 11);
View Full Code Here

        document.insertString(0, "  * list\n", null); // tab space
        result = MarkdownDocUtil.getIndentString(document, 7);
        assertEquals("  ", result);

        document.insertString(0, "      * list\n", null); // white space and tab space
        result = MarkdownDocUtil.getIndentString(document, 11);
        assertEquals("      ", result);

        document.insertString(0, "* list\n", null); // no indent
        result = MarkdownDocUtil.getIndentString(document, 6);
View Full Code Here

        document.insertString(0, "      * list\n", null); // white space and tab space
        result = MarkdownDocUtil.getIndentString(document, 11);
        assertEquals("      ", result);

        document.insertString(0, "* list\n", null); // no indent
        result = MarkdownDocUtil.getIndentString(document, 6);
        assertEquals("", result);
    }

}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.