Package javax.swing.text.AbstractDocument

Examples of javax.swing.text.AbstractDocument.AbstractElement


            testDoc = new PlainDocument() {
                private static final long serialVersionUID = 1L;

                @Override
                protected AbstractElement createDefaultRoot() {
                    AbstractElement root = new LeafElement(null, null, 0, 1);
                    return root;
                }
            };
            if (BasicSwingTestCase.isHarmony()) {
                fail("ClassCastException must be thrown");
            }
        } catch (ClassCastException e) {
        }
        if (BasicSwingTestCase.isHarmony()) {
            assertNull(testDoc);
            return;
        }
        AbstractElement root = (AbstractElement) testDoc.getDefaultRootElement();
        assertTrue(root instanceof LeafElement);
        assertEquals(AbstractDocument.ContentElementName, root.getName());
        assertEquals(0, root.getElementCount());
        assertFalse(root.getAllowsChildren());
        // Try to insert some text
        try {
            testDoc.insertString(0, "text", null);
            fail("ClassCastException must be thrown");
        } catch (ClassCastException e) {
View Full Code Here


        DefaultStyledDocument anotherDoc = new DefaultStyledDocument(styles);
        assertSame(doc.getAttributeContext(), anotherDoc.getAttributeContext());
    }

    public void testCreateDefaultRoot() {
        AbstractElement defRoot = doc.createDefaultRoot();
        assertTrue(defRoot instanceof SectionElement);
        assertEquals(0, defRoot.getAttributeCount());
        assertEquals(1, defRoot.getElementCount());
        assertTrue(defRoot.getElement(0) instanceof BranchElement);
    }
View Full Code Here

    public void testGetNameParent() throws Exception {
        final String parentName = "parentName";
        attrs.addAttribute(AbstractDocument.ElementNameAttribute, parentName);
        BranchElement parent = doc.new BranchElement(null, attrs);
        AbstractElement element = new AbstractElementImpl(doc, parent, null);
        assertTrue(parent.isDefined(AbstractDocument.ElementNameAttribute));
        assertEquals(parentName, parent.getName());
        assertFalse(element.isDefined(AbstractDocument.ElementNameAttribute));
        assertNull(element.getName());
    }
View Full Code Here

        assertEquals("BranchElement(bidi root) 0,15\n", bidi.toString());
        assertEquals("BranchElement(html) 0,15\n", par.toString());
    }

    public void testGetName() {
        AbstractElement block = htmlDoc.new BlockElement(null, null);
        assertEquals("paragraph", block.getName());
        htmlDoc.lockWrite();

        final String name = "asddsa";
        block = htmlDoc.new BlockElement(null, null);
        block.addAttribute(StyleConstants.NameAttribute, name);
        assertEquals(name, block.getName());
    }
View Full Code Here

    public void testBranchElement() {
    }

    public void testGetResolveParent() {
        htmlDoc.lockWrite();
        AbstractElement parent = htmlDoc.new BlockElement(null, null);
        AbstractElement block = htmlDoc.new BlockElement(parent, null);
        assertNull(parent.getResolveParent());
        assertNull(block.getResolveParent());

        block.setResolveParent(parent);
        assertNull(block.getResolveParent());
    }
View Full Code Here

                         attr.getAttribute(CSS.Attribute.TEXT_ALIGN).toString());
        }
    }

    public void testTranslateHTMLToCSSVAlignTop() throws Exception {
        AbstractElement branch =
            (AbstractElement)doc.getDefaultRootElement().getElement(0);
        assertEquals("body", branch.getName());

        branch.addAttribute(HTML.Attribute.VALIGN, "top");
        attr = ss.translateHTMLToCSS(branch);
        assertEquals(1, attr.getAttributeCount());
        assertEquals("top",
                     attr.getAttribute(CSS.Attribute.VERTICAL_ALIGN).toString());
    }
View Full Code Here

        assertEquals("top",
                     attr.getAttribute(CSS.Attribute.VERTICAL_ALIGN).toString());
    }

    public void testTranslateHTMLToCSSVAlignMiddle() throws Exception {
        AbstractElement branch =
            (AbstractElement)doc.getDefaultRootElement().getElement(0);
        assertEquals("body", branch.getName());

        branch.addAttribute(HTML.Attribute.VALIGN, "middle");
        attr = ss.translateHTMLToCSS(branch);
        assertEquals(1, attr.getAttributeCount());
        assertEquals("middle",
                     attr.getAttribute(CSS.Attribute.VERTICAL_ALIGN).toString());
    }
View Full Code Here

        assertEquals("middle",
                     attr.getAttribute(CSS.Attribute.VERTICAL_ALIGN).toString());
    }

    public void testTranslateHTMLToCSSVAlignBottom() throws Exception {
        AbstractElement branch =
            (AbstractElement)doc.getDefaultRootElement().getElement(0);
        assertEquals("body", branch.getName());

        branch.addAttribute(HTML.Attribute.VALIGN, "bottom");
        attr = ss.translateHTMLToCSS(branch);
        assertEquals(1, attr.getAttributeCount());
        assertEquals("bottom",
                     attr.getAttribute(CSS.Attribute.VERTICAL_ALIGN).toString());
    }
View Full Code Here

        assertEquals("bottom",
                     attr.getAttribute(CSS.Attribute.VERTICAL_ALIGN).toString());
    }

    public void testTranslateHTMLToCSSVAlignBaseline() throws Exception {
        AbstractElement branch =
            (AbstractElement)doc.getDefaultRootElement().getElement(0);
        assertEquals("body", branch.getName());

        branch.addAttribute(HTML.Attribute.VALIGN, "baseline");
        attr = ss.translateHTMLToCSS(branch);
        assertEquals(1, attr.getAttributeCount());
        assertEquals("baseline",
                     attr.getAttribute(CSS.Attribute.VERTICAL_ALIGN).toString());
    }
View Full Code Here

        assertEquals("baseline",
                     attr.getAttribute(CSS.Attribute.VERTICAL_ALIGN).toString());
    }

    public void testTranslateHTMLToCSSWidth() throws Exception {
        AbstractElement branch = (AbstractElement)doc.getParagraphElement(0);
        assertEquals("p", branch.getName());

        branch.addAttribute(HTML.Attribute.WIDTH, "50%");
        attr = ss.translateHTMLToCSS(branch);
        assertEquals(2, attr.getAttributeCount());
        assertEquals("50%",
                     attr.getAttribute(CSS.Attribute.WIDTH).toString());
        assertEquals("0",
View Full Code Here

TOP

Related Classes of javax.swing.text.AbstractDocument.AbstractElement

Copyright © 2018 www.massapicom. 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.