Package javax.swing.text.AbstractDocument

Examples of javax.swing.text.AbstractDocument.DefaultDocumentEvent


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


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

    }

    // Regression for HARMONY-1797
    public void testRemoveUpdate06() throws Exception {
        doc = new PlainDocument();
        insert = doc.new DefaultDocumentEvent(3, 13, EventType.INSERT);

        doc.removeUpdate(insert); // No exception should be thrown
    }
View Full Code Here

                assertTrue(remove.isInProgress());
            }
        };
        doc.insertString(0, "01234" + "\u05DC\u05DD\u05DE\u05DF\u05E0", null);
        doc.remove(3, 4);
        change = doc.new DefaultDocumentEvent(0, 10, DocumentEvent.EventType.CHANGE);
        undoName = UIManager.getString(UNDO_TEXT_KEY);
        redoName = UIManager.getString(REDO_TEXT_KEY);
    }
View Full Code Here

     * @throws BadLocationException
     */
    public void testAddEdit01() throws BadLocationException {
        // insert.isInProgress is false, so we can add no more edits
        assertFalse(insert.addEdit(remove));
        DefaultDocumentEvent edit = doc.new DefaultDocumentEvent(0, 10,
                DocumentEvent.EventType.CHANGE);
        assertTrue(edit.addEdit(insert));
        assertTrue(edit.addEdit(remove));
        assertEquals(2, getEdits(edit).size());
        // Stop collecting and make undo
        edit.end();
        edit.undo();
        // The document should be in its intial state
        assertEquals("", doc.getText(0, doc.getLength()));
    }
View Full Code Here

            @Override
            public void redo() {
                redone = true;
            }
        }
        DefaultDocumentEvent edit = doc.new DefaultDocumentEvent(0, 10, EventType.CHANGE);
        Parent[] parent = new Parent[15];
        Child[] child = new Child[parent.length];
        for (int i = 0; i < parent.length; i++) {
            assertTrue("Can't add edit at " + i, edit.addEdit(child[i] = new Child(
                    parent[i] = new Parent())));
            if (BasicSwingTestCase.isHarmony()) {
                if (i < 10) {
                    assertNull(getChanges(edit));
                } else {
                    assertNotNull(getChanges(edit));
                }
            }
        }
        edit.addEdit((UndoableEdit) getEdits(edit).get(0));
        edit.end();
        // A new edit shouldn't be added 'cause we have called end()
        assertFalse(edit.addEdit((UndoableEdit) getEdits(edit).get(1)));
        edit.undo();
        edit.redo();
        // Do the check
        for (int i = 0; i < parent.length; i++) {
            ElementChange change = edit.getChange(parent[i]);
            assertSame("Objects are not same at " + i, child[i], change);
            assertTrue("Undo didn't get called at " + i, child[i].undone);
            assertTrue("Redo didn't get called at " + i, child[i].redone);
        }
        assertEquals(16, getEdits(edit).size());
View Full Code Here

        doc.addDocumentListener(this);
        doc.addUndoableEditListener(this);
        doc.insertString(0, "01234" + "\u05DC\u05DD\u05DE\u05DF\u05E0", null);
        doc.remove(3, 4);
        // Save what we've got
        DefaultDocumentEvent insertEvent = insert;
        //Element insertChildrenAdded[] = insert.
        DefaultDocumentEvent removeEvent = remove;
        assertSame(undoEvent.getEdit(), remove);
        insert = null;
        remove = null;
        undoEvent = null;
        // Try to undo
        removeEvent.undo();
        assertNull(remove);
        assertNotNull(insert);
        assertNull(undoEvent);
        DefaultDocumentEvent undoInsertEvent = insert;
        insert = null;
        insertEvent.undo();
        assertNotNull(remove);
        assertNull(insert);
        assertNull(undoEvent);
        DefaultDocumentEvent undoRemoveEvent = remove;
        remove = null;
        assertFalse(undoInsertEvent.canUndo());
        assertTrue(undoInsertEvent.canRedo());
        assertSame(insertEvent, undoRemoveEvent);
        assertSame(EventType.INSERT, insertEvent.getType());
        assertSame(EventType.INSERT, undoRemoveEvent.getType());
        assertFalse(undoRemoveEvent.canUndo());
        assertTrue(undoRemoveEvent.canRedo());
        assertSame(removeEvent, undoInsertEvent);
        assertSame(EventType.REMOVE, removeEvent.getType());
        assertSame(EventType.REMOVE, undoInsertEvent.getType());
        //undoInsertEvent.undo();
        //insertEvent.redo();
View Full Code Here

        } catch (CannotRedoException e) {
        }
    }

    public void testDefaultDocumentEvent() {
        DefaultDocumentEvent event = doc.new DefaultDocumentEvent(10, 7,
                DocumentEvent.EventType.CHANGE);
        assertEquals(10, event.getOffset());
        assertEquals(7, event.getLength());
        assertSame(DocumentEvent.EventType.CHANGE, event.getType());
    }
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);
View Full Code Here

     */
    public void testInsertDiffAttrsDocStart() throws Exception {
        insertOffset = 0;
        // doc.insertString(insertOffset, newLine, italic);
        content.insertString(insertOffset, newLine);
        event = doc.new DefaultDocumentEvent(insertOffset, newLineLen, EventType.INSERT);
        ElementSpec[] specs = { new ElementSpec(italic, ElementSpec.ContentType, newLineLen),
                new ElementSpec(null, ElementSpec.EndTagType),
                new ElementSpec(null, ElementSpec.StartTagType) };
        specs[2].setDirection(ElementSpec.JoinFractureDirection);
        buf.insert(insertOffset, newLineLen, specs, event);
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.