Package javax.swing.text.AbstractDocument

Examples of javax.swing.text.AbstractDocument.DefaultDocumentEvent


        assertFalse(view.isLayoutValid(X_AXIS));
        assertFalse(view.isLayoutValid(Y_AXIS));
    }

    public void testChangedUpdate() {
        event = doc.new DefaultDocumentEvent(4, 5, EventType.CHANGE);
        event.addEdit(new ElementEdit(p1, 0, new Element[] { p1L }, new Element[] { p1L }));
        event.end();
        view.layout(alloc.width, alloc.height);
        assertTrue(view.isAllocationValid());
        view.strategy.changedUpdate(view, event, alloc);
View Full Code Here


    public void testInsertThreePars() throws Exception {
        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),
View Full Code Here

    UndoableEdit edit = undoableEditEvent.getEdit();

    // Make sure this event is a document event
    if (edit instanceof DefaultDocumentEvent) {
      // Get the event type
      DefaultDocumentEvent event = (DefaultDocumentEvent) edit;
      EventType eventType = event.getType();

      // Check if the event type is not a change on character attributes, but instead an insertion or removal of
      // text.
      if (eventType != EventType.CHANGE) {
        boolean isEndCompoundEdit = false;

        // Check if current compound edit must be ended as it contains at least one new line
        if (eventType == EventType.INSERT) {
          try {
            // Check if the inserted text contains a new line character
            String insertedText = event.getDocument().getText(event.getOffset(), event.getLength());
            isEndCompoundEdit = insertedText.contains("\n");
          } catch (BadLocationException e) {
            e.printStackTrace();
          }
        }
View Full Code Here

            }
        };
        doc.buffer = buf;
        MutableAttributeSet attrs = new SimpleAttributeSet();
        StyleConstants.setBold(attrs, true);
        event = doc.new DefaultDocumentEvent(2, 2, EventType.CHANGE);
        doc.writeLock();
        try {
            buf.change(2, 2, event);
        } finally {
            doc.writeUnlock();
View Full Code Here

                new ElementSpec(root.getElement(1).getAttributes(), ElementSpec.StartTagType, 0),
                new ElementSpec(SimpleAttributeSet.EMPTY, ElementSpec.ContentType, 5) };
        specs[0].setDirection(ElementSpec.JoinPreviousDirection);
        specs[2].setDirection(ElementSpec.JoinFractureDirection);
        specs[3].setDirection(ElementSpec.JoinNextDirection);
        event = doc.new DefaultDocumentEvent(doc.getLength(), 6, EventType.INSERT);
        int off = doc.getLength();
        // Insert the text into the content, so that ElementBuffer
        // could use proper offsets (or BadLocationException may be thrown).
        doc.getContent().insertString(off, "\nthird");
        doc.writeLock();
View Full Code Here

                super.remove(offset, length, event);
                assertEquals(0, edits.size());
            }
        };
        doc.buffer = buf;
        event = doc.new DefaultDocumentEvent(2, 2, EventType.REMOVE);
        doc.writeLock();
        try {
            buf.remove(2, 2, event);
        } finally {
            doc.writeUnlock();
View Full Code Here

                super.remove(offset, length, event);
                assertEquals(1, edits.size());
            }
        };
        doc.buffer = buf;
        event = doc.new DefaultDocumentEvent(2, 2, EventType.REMOVE);
        doc.writeLock();
        try {
            buf.remove(4, 3, event);
        } finally {
            doc.writeUnlock();
View Full Code Here

            final AttributeSet[] attributes) {
        DefStyledDoc_Helpers.assertChildren(element, offsets, attributes);
    }

    private DefaultDocumentEvent createEvent(final int offset, final int length) {
        event = doc.new DefaultDocumentEvent(offset, length, EventType.CHANGE);
        return event;
    }
View Full Code Here

     */
    public void testInsertSameAttrsDocStart2NewLines() throws Exception {
        insertOffset = 0;
        // doc.insertString(insertOffset, newLines2, null);
        content.insertString(insertOffset, newLines2);
        event = doc.new DefaultDocumentEvent(insertOffset, newLines2Len, EventType.INSERT);
        ElementSpec[] specs = { new ElementSpec(null, ElementSpec.ContentType, newLineLen),
                new ElementSpec(null, ElementSpec.EndTagType),
                new ElementSpec(null, ElementSpec.StartTagType),
                new ElementSpec(null, ElementSpec.ContentType, newLineLen),
                new ElementSpec(null, ElementSpec.EndTagType),
View Full Code Here

     */
    public void testInsertSameAttrsDocStart3NewLines() throws Exception {
        insertOffset = 0;
        // doc.insertString(insertOffset, newLines3, null);
        content.insertString(insertOffset, newLines3);
        event = doc.new DefaultDocumentEvent(insertOffset, newLines3Len, EventType.INSERT);
        ElementSpec[] specs = { new ElementSpec(null, ElementSpec.ContentType, newLineLen),
                new ElementSpec(null, ElementSpec.EndTagType),
                new ElementSpec(null, ElementSpec.StartTagType),
                new ElementSpec(null, ElementSpec.ContentType, newLineLen),
                new ElementSpec(null, ElementSpec.EndTagType),
View Full Code Here

TOP

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

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.