Package javax.swing.text.AbstractDocument

Examples of javax.swing.text.AbstractDocument.DefaultDocumentEvent


                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

    }

    // 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

            @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, caps, null);
        content.insertString(insertOffset, caps);
        event = doc.new DefaultDocumentEvent(insertOffset, capsLen, EventType.INSERT);
        ElementSpec spec = new ElementSpec(null, ElementSpec.ContentType, capsLen);
        spec.setDirection(ElementSpec.JoinPreviousDirection);
        buf.insert(insertOffset, capsLen, new ElementSpec[] { spec }, event);
        List<?> edits = getEdits(event);
        assertEquals(0, edits.size());
View Full Code Here

     */
    public void testInsertDiffAttrsDocStart() throws Exception {
        insertOffset = 0;
        // doc.insertString(insertOffset, caps, italic);
        content.insertString(insertOffset, caps);
        event = doc.new DefaultDocumentEvent(insertOffset, capsLen, EventType.INSERT);
        ElementSpec spec = new ElementSpec(null, ElementSpec.ContentType, capsLen);
        buf.insert(insertOffset, capsLen, new ElementSpec[] { spec }, event);
        List<?> edits = getEdits(event);
        assertEquals(1, edits.size());
        assertChange(edits.get(0), new int[] { 0, 8 }, new int[] { 0, 3, 3, 8 });
View Full Code Here

     * <code>setUp()</code>.
     */
    public void testInsertSameAttrsMiddle() throws Exception {
        // doc.insertString(insertOffset, caps, bold);
        content.insertString(insertOffset, caps);
        event = doc.new DefaultDocumentEvent(insertOffset, capsLen, EventType.INSERT);
        ElementSpec spec = new ElementSpec(null, ElementSpec.ContentType, capsLen);
        spec.setDirection(ElementSpec.JoinPreviousDirection);
        buf.insert(insertOffset, capsLen, new ElementSpec[] { spec }, event);
        List<?> edits = getEdits(event);
        assertEquals(0, edits.size());
View Full Code Here

     */
    public void testInsertSameAttrsEnd() throws Exception {
        insertOffset += 2;
        // doc.insertString(insertOffset, caps, bold);
        content.insertString(insertOffset, caps);
        event = doc.new DefaultDocumentEvent(insertOffset, capsLen, EventType.INSERT);
        ElementSpec spec = new ElementSpec(null, ElementSpec.ContentType, capsLen);
        spec.setDirection(ElementSpec.JoinPreviousDirection);
        buf.insert(insertOffset, capsLen, new ElementSpec[] { spec }, event);
        List<?> edits = getEdits(event);
        assertEquals(0, edits.size());
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.