Package javax.swing.text.DefaultStyledDocument

Examples of javax.swing.text.DefaultStyledDocument.ElementSpec


        String text = "text";
        SimpleAttributeSet attr = new SimpleAttributeSet();
        attr.addAttribute("aaaa", "bbbb");
        action = reader.new FormAction();
        action.start(Tag.SELECT, attr);
        ElementSpec spec = (ElementSpec)reader.parseBuffer.get(1);
        final AttributeSet specAttr = spec.getAttributes();
        assertEquals(3, specAttr.getAttributeCount());
        assertSpec(spec, ElementSpec.ContentType, ElementSpec.OriginateDirection, 0, new char[] {' '});
        Object contentModel = specAttr.getAttribute(StyleConstants.ModelAttribute);
        assertNotNull(contentModel);
        assertTrue(contentModel instanceof DefaultComboBoxModel);
View Full Code Here


        String text = "text";
        SimpleAttributeSet attr = new SimpleAttributeSet();
        attr.addAttribute("aaaa", "bbbb");
        action = reader.new FormAction();
        action.start(Tag.FIELDSET, attr);
        ElementSpec spec = (ElementSpec)reader.parseBuffer.get(1);
        final AttributeSet specAttr = spec.getAttributes();
        assertEquals(3, specAttr.getAttributeCount());
        assertSpec(spec, ElementSpec.ContentType, ElementSpec.OriginateDirection, 0, new char[] {' '});
        Object contentModel = specAttr.getAttribute(StyleConstants.ModelAttribute);
        assertNotNull(contentModel);
        assertTrue(contentModel instanceof FormFieldsetModel);
View Full Code Here

        legendAttr1.addAttribute("bbbb", "aaaa");
        SimpleAttributeSet legendAttr2 = new SimpleAttributeSet();
        legendAttr2.addAttribute("bb", "aa");
        action = reader.new FormAction();
        action.start(Tag.FIELDSET, attr);
        ElementSpec spec = (ElementSpec)reader.parseBuffer.get(1);
        final AttributeSet specAttr = spec.getAttributes();
        assertEquals(3, specAttr.getAttributeCount());
        assertSpec(spec, ElementSpec.ContentType, ElementSpec.OriginateDirection, 0, new char[] {' '});
        Object contentModel = specAttr.getAttribute(StyleConstants.ModelAttribute);
        assertNotNull(contentModel);
        assertTrue(contentModel instanceof FormFieldsetModel);
View Full Code Here

        String text2 = "text2";
        SimpleAttributeSet attr = new SimpleAttributeSet();
        attr.addAttribute("aaaa", "bbbb");
        action = reader.new FormAction();
        action.start(Tag.FIELDSET, attr);
        ElementSpec spec = (ElementSpec)reader.parseBuffer.get(1);
        final AttributeSet specAttr = spec.getAttributes();
        assertEquals(3, specAttr.getAttributeCount());
        assertSpec(spec, ElementSpec.ContentType, ElementSpec.OriginateDirection, 0, new char[] {' '});
        Object contentModel = specAttr.getAttribute(StyleConstants.ModelAttribute);
        assertNotNull(contentModel);
        assertTrue(contentModel instanceof FormFieldsetModel);
View Full Code Here

    }
   
    private void checkStandardFormStart(final Tag tag, final Class modelClass, final String type, final AttributeSet additionalAttr) throws Exception {
        doFormStart(tag, type, additionalAttr);
       
        ElementSpec spec = (ElementSpec)reader.parseBuffer.get(0);
        checkOpenImpliedSpec(spec);
       
        spec = (ElementSpec)reader.parseBuffer.get(1);
        AttributeSet specAttr = spec.getAttributes();
       
        int addendum = additionalAttr != null ? additionalAttr.getAttributeCount() : 0;
        int attrNum = 2;
        if (modelClass != null) {
            attrNum++;
View Full Code Here

        final String text = "first\nsecond\nthird";
        final int textLen = text.length();
        //doc.insertString(0, text, null);
        content.insertString(0, text);
        event = doc.new DefaultDocumentEvent(0, textLen, EventType.INSERT);
        ElementSpec[] specs = { new ElementSpec(null, ElementSpec.ContentType, 6),
                new ElementSpec(null, ElementSpec.EndTagType),
                new ElementSpec(null, ElementSpec.StartTagType),
                new ElementSpec(null, ElementSpec.ContentType, 7),
                new ElementSpec(null, ElementSpec.EndTagType),
                new ElementSpec(null, ElementSpec.StartTagType),
                new ElementSpec(null, ElementSpec.ContentType, 5), };
        specs[0].setDirection(ElementSpec.JoinPreviousDirection);
        specs[specs.length - 2].setDirection(ElementSpec.JoinFractureDirection);
        specs[specs.length - 1].setDirection(ElementSpec.JoinNextDirection);
        buf.insert(0, textLen, specs, event);
        List<?> edits = getEdits(event);
View Full Code Here

     */
    public void testInsertUpdateThreePars() throws Exception {
        final String text = "first\nsecond\nthird";
        doc.insertString(0, text, null);
        //        doc.dump(System.out);
        ElementSpec[] specs = { new ElementSpec(null, ElementSpec.ContentType, 6),
                new ElementSpec(null, ElementSpec.EndTagType),
                new ElementSpec(null, ElementSpec.StartTagType),
                new ElementSpec(null, ElementSpec.ContentType, 7),
                new ElementSpec(null, ElementSpec.EndTagType),
                new ElementSpec(null, ElementSpec.StartTagType),
                new ElementSpec(null, ElementSpec.ContentType, 5), };
        specs[0].setDirection(ElementSpec.JoinPreviousDirection);
        specs[specs.length - 2].setDirection(ElementSpec.JoinFractureDirection);
        specs[specs.length - 1].setDirection(ElementSpec.JoinNextDirection);
        assertSpecs(specs, insertSpecs);
        List<?> edits = getEdits(insertEvent);
View Full Code Here

    public void testInsertRightAfterNewLineWithNewLine() throws Exception {
        final String initialText = "one\ntwo\nthree";
        doc.insertString(0, initialText, null);
        final int offset = root.getElement(0).getEndOffset();
        doc.insertString(offset, "^^^\n", null);
        ElementSpec[] specs = { new ElementSpec(null, ElementSpec.EndTagType),
                new ElementSpec(null, ElementSpec.StartTagType),
                new ElementSpec(null, ElementSpec.ContentType, 4),
                new ElementSpec(null, ElementSpec.EndTagType),
                new ElementSpec(null, ElementSpec.StartTagType) };
        specs[specs.length - 1].setDirection(ElementSpec.JoinNextDirection);
        assertSpecs(specs, insertSpecs);
        List<?> edits = getEdits(insertEvent);
        assertEquals(4, edits.size());
        assertChange(edits.get(1), 0, new int[] { 0, 8 }, new int[] { 0, 4 });
View Full Code Here

    public void testInsertRightAfterNewLineWithoutNewLine() throws Exception {
        final String initialText = "one\ntwo\nthree";
        doc.insertString(0, initialText, null);
        final int offset = root.getElement(0).getEndOffset();
        doc.insertString(offset, "^^^", null);
        ElementSpec[] specs = { new ElementSpec(null, ElementSpec.EndTagType),
                new ElementSpec(null, ElementSpec.StartTagType),
                new ElementSpec(null, ElementSpec.ContentType, 3), };
        specs[specs.length - 2].setDirection(ElementSpec.JoinNextDirection);
        specs[specs.length - 1].setDirection(ElementSpec.JoinNextDirection);
        assertSpecs(specs, insertSpecs);
        List<?> edits = getEdits(insertEvent);
        assertEquals(3, edits.size());
View Full Code Here

    public void testInsertSameAttrsDocStart() throws Exception {
        insertOffset = 0;
        // doc.insertString(insertOffset, newLine, null);
        content.insertString(insertOffset, newLine);
        event = doc.new DefaultDocumentEvent(insertOffset, newLineLen, EventType.INSERT);
        ElementSpec[] specs = { new ElementSpec(null, ElementSpec.ContentType, newLineLen),
                new ElementSpec(null, ElementSpec.EndTagType),
                new ElementSpec(null, ElementSpec.StartTagType) };
        specs[0].setDirection(ElementSpec.JoinPreviousDirection);
        specs[2].setDirection(ElementSpec.JoinFractureDirection);
        buf.insert(insertOffset, newLineLen, specs, event);
        List<?> edits = getEdits(event);
        assertEquals(2, edits.size());
View Full Code Here

TOP

Related Classes of javax.swing.text.DefaultStyledDocument.ElementSpec

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.