Examples of BranchElement


Examples of javax.swing.text.AbstractDocument.BranchElement

     * <code>view.getEndOffset() != doc.getLength()</code>.
     */
    public void testViewToModel04() {
        // Modify the root
        final int oldCount = root.getElementCount();
        BranchElement docRoot = (BranchElement) root;
        final Element[] empty = new Element[0];
        docRoot.replace(0, 1, empty);
        docRoot.replace(docRoot.getElementCount() - 1, 1, empty);
        final int newCount = root.getElementCount();
        assertEquals(oldCount - 2, newCount);
        // Re-load children
        view.removeAll();
        view.loadChildren(factory);
View Full Code Here

Examples of javax.swing.text.AbstractDocument.BranchElement

    }

    public void testGetNameBranch() throws Exception {
        final String name = "Ast";
        attrs.addAttribute(AbstractDocument.ElementNameAttribute, name);
        element = doc.new BranchElement(root, attrs);
        assertSame(name, element.getName());
        assertSame(root, element.getParentElement());
    }
View Full Code Here

Examples of javax.swing.text.AbstractDocument.BranchElement

    }

    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

Examples of javax.swing.text.AbstractDocument.BranchElement

    public void testUndo02() throws BadLocationException {
        final class UndoPlainDocument extends PlainDocument {
            private static final long serialVersionUID = 1L;

            BranchElement altRoot = new BranchElement(null, null);

            boolean undone = false;

            boolean redone = false;
View Full Code Here

Examples of javax.swing.text.AbstractDocument.BranchElement

                StyleContextTest.addAttribute(null, 2, 2),
                StyleContextTest.addAttribute(null, 5, 2) };
        doc = new DisAbstractedDocument(new GapContent());
        doc.insertString(0, "0123456789", as[0]);
        doc.writeLock();
        BranchElement branch = doc.new BranchElement(null, as[1]);
        leaf1 = doc.new LeafElement(null, as[2], 0, 3);
        leaf2 = doc.new LeafElement(branch, as[2], 5, 8);
        doc.writeUnlock();
    }
View Full Code Here

Examples of javax.swing.text.AbstractDocument.BranchElement

        leaves[0] = doc.createLeafElement(paragraph, null, 0, 5);
        leaves[1] = doc.createLeafElement(paragraph, bold, 5, 9);
        leaves[2] = doc.createLeafElement(paragraph, italic, 9, 15);
        leaves[3] = doc.createLeafElement(paragraph, null, 15, 16);
        ((BranchElement) paragraph).replace(0, 1, leaves);
        BranchElement branch = (BranchElement) doc.createBranchElement(root, null);
        leaves = new Element[1];
        leaves[0] = doc.createLeafElement(branch, null, 16, 21);
        branch.replace(0, 0, leaves);
        // Add this branch to the root
        ((BranchElement) root).replace(1, 0, new Element[] { branch });
        insertOffset = 5 + 2;
    }
View Full Code Here

Examples of javax.swing.text.AbstractDocument.BranchElement

        };
        doc.buffer = buf;
        doc.writeLock();
        try {
            doc.getContent().insertString(0, "\n0000");
            final BranchElement html = (BranchElement) root;
            html.addAttribute(ELEMENT_NAME, "html");
            final BranchElement head = createBranch(html);
            head.addAttribute(ELEMENT_NAME, "head");
            final BranchElement implied = createBranch(head);
            implied.addAttribute(ELEMENT_NAME, "p-implied");
            final LeafElement content0 = createLeaf(implied, 0, 1);
            content0.addAttribute(ELEMENT_NAME, "head-content");
            final BranchElement body = createBranch(html);
            body.addAttribute(ELEMENT_NAME, "body");
            final BranchElement p1 = createBranch(body);
            p1.addAttribute(ELEMENT_NAME, "p1");
            final LeafElement content1 = createLeaf(p1, 1, 5);
            content1.addAttribute(ELEMENT_NAME, "leaf1");
            final LeafElement content2 = createLeaf(p1, 5, 6);
            content2.addAttribute(ELEMENT_NAME, "leaf2");
            implied.replace(0, 0, new Element[] { content0 });
            p1.replace(0, 0, new Element[] { content1, content2 });
            head.replace(0, 0, new Element[] { implied });
            body.replace(0, 0, new Element[] { p1 });
            html.replace(0, 1, new Element[] { head, body });
        } finally {
            doc.writeUnlock();
View Full Code Here

Examples of javax.swing.text.AbstractDocument.BranchElement

            }
        };
        doc.buffer = buf;
        doc.writeLock();
        try {
            final BranchElement html = (BranchElement) root;
            html.addAttribute(ELEMENT_NAME, "html");
            final BranchElement body = createBranch(html);
            body.addAttribute(ELEMENT_NAME, "body");
            final BranchElement p = createBranch(body);
            p.addAttribute(ELEMENT_NAME, "p");
            final LeafElement content = createLeaf(p, 0, 1);
            content.addAttribute(ELEMENT_NAME, "leaf1");
            p.replace(0, 0, new Element[] { content });
            body.replace(0, 0, new Element[] { p });
            html.replace(0, 1, new Element[] { body });
        } finally {
            doc.writeUnlock();
        }
View Full Code Here

Examples of javax.swing.text.AbstractDocument.BranchElement

        leaves[0] = doc.createLeafElement(paragraph, null, 0, 5);
        leaves[1] = doc.createLeafElement(paragraph, bold, 5, 9);
        leaves[2] = doc.createLeafElement(paragraph, italic, 9, 15);
        leaves[3] = doc.createLeafElement(paragraph, null, 15, 16);
        ((BranchElement) paragraph).replace(0, 1, leaves);
        BranchElement branch = (BranchElement) doc.createBranchElement(root, null);
        leaves = new Element[1];
        leaves[0] = doc.createLeafElement(branch, null, 16, 21);
        branch.replace(0, 0, leaves);
        branch.addAttributes(boldFalse);
        branch.addAttributes(italicFalse);
        // Add this branch to the root
        ((BranchElement) root).replace(1, 0, new Element[] { branch });
    }
View Full Code Here

Examples of javax.swing.text.AbstractDocument.BranchElement

        doc = htmlDoc;

        doc.insertString(0, "0123456789", as[0]);

        htmlDoc.lockWrite();
        BranchElement branch = doc.new BranchElement(null, as[1]);
        leaf1 = doc.new LeafElement(null, as[2], 0, 3);
        leaf2 = doc.new LeafElement(branch, as[2], 5, 8);
        htmlDoc.unlockWrite();
    }
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.