This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 192491
Collapse All | Expand All

(-)a/openide.text/src/org/openide/text/CloneableEditorSupport.java (-5 / +4 lines)
Lines 125-132 Link Here
125
* really implement and which not.
125
* really implement and which not.
126
* <P>
126
* <P>
127
* This class supports collecting multiple edits into a group which is treated
127
* This class supports collecting multiple edits into a group which is treated
128
* as a single edit by undo/redo. Send {@BEGIN_COMMIT_GROUP} and
128
* as a single edit by undo/redo. Send {@link #BEGIN_COMMIT_GROUP} and
129
* {@END_COMMIT_GROUP} to UndoableEditListener. These must always be paired.
129
* {@link #END_COMMIT_GROUP} to UndoableEditListener. These must always be paired.
130
*
130
*
131
* @author Jaroslav Tulach
131
* @author Jaroslav Tulach
132
*/
132
*/
Lines 3460-3470 Link Here
3460
     * <ol>
3460
     * <ol>
3461
     * <li> Default behavior is defined by {@link UndoManager}.</li>
3461
     * <li> Default behavior is defined by {@link UndoManager}.</li>
3462
     * <li> <tt>UnddoableEdit</tt>s issued between {@link #BEGIN_COMMIT_GROUP}
3462
     * <li> <tt>UnddoableEdit</tt>s issued between {@link #BEGIN_COMMIT_GROUP}
3463
     * and {@link END_COMMIT_GROUP} are placed into a single
3463
     * and {@link #END_COMMIT_GROUP} are placed into a single
3464
     * {@link CompoundEdit}.
3464
     * {@link CompoundEdit}.
3465
     * Thus <tt>undo()</tt> and <tt>redo()</tt> treat them 
3465
     * Thus <tt>undo()</tt> and <tt>redo()</tt> treat them 
3466
     * as a single undo/redo.</li>
3466
     * as a single undo/redo.</li>
3467
     * <li> Use {@link commitUndoGroup} to commit accumulated
3467
     * <li> Use {@link #commitUndoGroup} to commit accumulated
3468
     * <tt>UndoableEdit</tt>s into a single <tt>CompoundEdit</tt>
3468
     * <tt>UndoableEdit</tt>s into a single <tt>CompoundEdit</tt>
3469
     * (and to continue accumulating);
3469
     * (and to continue accumulating);
3470
     * an application could do this at strategic points, such as EndOfLine
3470
     * an application could do this at strategic points, such as EndOfLine
Lines 3616-3622 Link Here
3616
            }
3616
            }
3617
        }
3617
        }
3618
3618
3619
        /** {@inheritDoc} */
3620
        @Override
3619
        @Override
3621
        public synchronized void discardAllEdits() {
3620
        public synchronized void discardAllEdits() {
3622
            commitUndoGroup();
3621
            commitUndoGroup();
(-)a/openide.text/test/unit/src/org/openide/text/UndoRedoWrappingCooperationTest.java (-88 lines)
Lines 47-54 Link Here
47
import java.beans.PropertyChangeListener;
47
import java.beans.PropertyChangeListener;
48
import java.io.IOException;
48
import java.io.IOException;
49
import java.util.ArrayList;
49
import java.util.ArrayList;
50
import java.util.logging.Level;
51
import java.util.logging.Logger;
52
import javax.swing.event.UndoableEditEvent;
50
import javax.swing.event.UndoableEditEvent;
53
import javax.swing.event.UndoableEditListener;
51
import javax.swing.event.UndoableEditListener;
54
import javax.swing.text.*;
52
import javax.swing.text.*;
Lines 371-462 Link Here
371
        ur().undo();
369
        ur().undo();
372
        assertEquals("undo3", "", d.getText(0, d.getLength()));
370
        assertEquals("undo3", "", d.getText(0, d.getLength()));
373
    }
371
    }
374
375
    // This is testSaveDocumentWhileActiveChunk WITHOUT chunking
376
    private void doSaveDocumentCommon(boolean doFailCase) throws Exception {
377
        content = "";
378
        StyledDocument d = support.openDocument();
379
        d.insertString(d.getLength(), "a", null);
380
381
        support.saveDocument (); // creates a separate undoable chunk
382
        assertFalse("save: not modified", support.isModified());
383
        assertTrue("save: can undo", ur().canUndo());
384
        assertFalse("save: no redo", ur().canRedo());
385
386
        d.insertString(d.getLength(), "b", null);
387
388
        assertEquals("insert, after save: data", "ab", d.getText(0, d.getLength()));
389
        assertTrue("insert, after save: modified", support.isModified());
390
        assertTrue("insert, after save: can undo", ur().canUndo());
391
        assertFalse("insert, after save: no redo", ur().canRedo());
392
393
        ur().undo();
394
        assertEquals("undo, at save: data", "a", d.getText(0, d.getLength()));
395
        assertFalse("undo, at save: not modified", support.isModified());
396
        assertTrue("undo, at save: can undo", ur().canUndo());
397
        assertTrue("undo, at save: can redo", ur().canRedo());
398
399
        ur().undo();
400
        assertEquals("undo, before save: data", "", d.getText(0, d.getLength()));
401
402
        if(doFailCase) {
403
            // ****************************************************************
404
            // CES BUG???
405
            assertTrue("undo, before save: modified", support.isModified());
406
            // ****************************************************************
407
        }
408
409
        assertFalse("undo, before save: can undo", ur().canUndo());
410
        assertTrue("undo, before save: can redo", ur().canRedo());
411
412
        ur().redo();
413
        assertEquals("redo, at save: data", "a", d.getText(0, d.getLength()));
414
        assertFalse("redo, at save: not modified", support.isModified());
415
        assertTrue("redo, at save: can undo", ur().canUndo());
416
        assertTrue("redo, at save: can redo", ur().canRedo());
417
    }
418
419
    public void testSaveDocument() throws Exception {
420
        doSaveDocumentCommon(false);
421
    }
422
423
    public void testSaveDocumentErrorCase() throws Exception {
424
        // NOTE: following fail is issue in CES, use true as parameter
425
        doSaveDocumentCommon(false);
426
    }
427
428
    // NOTE: following fail is issue in CES
429
    public void testRedoAfterSave() throws Exception {
430
        content = "";
431
        StyledDocument d = support.openDocument();
432
        d.insertString(d.getLength(), "a", null);
433
434
        d.insertString(d.getLength(), "b", null);
435
436
        assertEquals("insert: data", "ab", d.getText(0, d.getLength()));
437
        assertTrue("insert: modified", support.isModified());
438
        assertTrue("insert: can undo", ur().canUndo());
439
        assertFalse("insert: no redo", ur().canRedo());
440
441
        ur().undo();
442
        assertEquals("undo: data", "a", d.getText(0, d.getLength()));
443
        assertTrue("undo: modified", support.isModified());
444
        assertTrue("undo: can undo", ur().canUndo());
445
        assertTrue("undo: can redo", ur().canRedo());
446
447
        support.saveDocument ();
448
        assertFalse("save: not modified", support.isModified());
449
        assertTrue("save: can undo", ur().canUndo());
450
        /* XXX: Fails right now
451
        assertTrue("save: can redo", ur().canRedo());
452
453
        ur().redo();
454
        assertEquals("redo: data", "ab", d.getText(0, d.getLength()));
455
        assertTrue("redo: modified", support.isModified());
456
        assertTrue("redo: can undo", ur().canUndo());
457
        assertFalse("redo: no redo", ur().canRedo());
458
         */
459
    }
460
    
372
    
461
    //
373
    //
462
    // Implementation of the CloneableEditorSupport.Env
374
    // Implementation of the CloneableEditorSupport.Env

Return to bug 192491