javax.swing.undo.UndoManager Java Examples

The following examples show how to use javax.swing.undo.UndoManager. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OverrideEditorActions.java    From netbeans with Apache License 2.0 6 votes vote down vote up
static void flushUndoQueue(Document d) {
    SwingUtilities.invokeLater(() -> {
    if (d == null) {
        return;
    }
    for (TopComponent tc : TopComponent.getRegistry().getOpened()) {
        if (!(tc instanceof ConsoleEditor)) {
            continue;
        }
        ConsoleEditor cake = (ConsoleEditor)tc;
        if (cake.getEditorPane() == null) {
            continue;
        }
        Document check = cake.getEditorPane().getDocument();
        if (check != d) {
            continue;
        }
        UndoRedo ur = tc.getUndoRedo();
        if (ur instanceof UndoManager) {
            ((UndoManager)ur).discardAllEdits();
        }
    }});
}
 
Example #2
Source File: SyncTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testSyncUndoRename() throws Exception {
    SchemaModel model = Util.loadSchemaModel(TEST_XSD);
    UndoManager um = new UndoManager();
    model.addUndoableEditListener(um);
    assertEquals(2, model.getSchema().getElements().size());
    
    Util.setDocumentContentTo(model, "resources/PurchaseOrder_SyncUndoRename.xsd");
    model.sync();
    assertEquals(2, model.getSchema().getElements().size());
    assertEquals("purchaseOrder2", model.getSchema().getElements().iterator().next().getName());

    um.undo();
    assertEquals(2, model.getSchema().getElements().size());
    assertEquals("purchaseOrder", model.getSchema().getElements().iterator().next().getName());

    um.redo();
    assertEquals(2, model.getSchema().getElements().size());
    assertEquals("purchaseOrder2", model.getSchema().getElements().iterator().next().getName());
}
 
Example #3
Source File: STSIssuedCertProfile.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override()
public void displayConfig(WSDLComponent component, UndoManager undoManager) {
    UndoCounter undoCounter = new UndoCounter();
    WSDLModel model = component.getModel();
    
    model.addUndoableEditListener(undoCounter);

    JPanel profConfigPanel = new STSIssuedCert(component, this);
    DialogDescriptor dlgDesc = new DialogDescriptor(profConfigPanel, getDisplayName());
    Dialog dlg = DialogDisplayer.getDefault().createDialog(dlgDesc);

    dlg.setVisible(true); 
    if (dlgDesc.getValue() == DialogDescriptor.CANCEL_OPTION) {
        for (int i=0; i<undoCounter.getCounter();i++) {
            if (undoManager.canUndo()) {
                undoManager.undo();
            }
        }
    }
    
    model.removeUndoableEditListener(undoCounter);
}
 
Example #4
Source File: AbstractModelTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testUndoRedoWithoutIdentity() throws Exception {
    mModel = Util.loadModel("resources/test1_noname.xml");
    UndoManager ur = new UndoManager();
    mModel.addUndoableEditListener(ur);

    E e1 = mModel.getRootComponent().getChild(E.class);
    assertNull(e1.getValue());
    
    mModel.startTransaction();
    String v = "new test value";
    e1.setValue(v);
    mModel.endTransaction();
    assertEquals(v, e1.getValue());

    ur.undo();
    assertNull("expect null, get "+e1.getValue(), e1.getValue());
    
    ur.redo();
    assertEquals(v, e1.getValue());
}
 
Example #5
Source File: AbstractModelTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testUndoOnMutationFromSyncEvent() throws Exception {
    defaultSetup();
    mModel.addComponentListener(new Handler());
    UndoManager um = new UndoManager();
    mModel.addUndoableEditListener(um);

    Util.setDocumentContentTo(mDoc, "resources/test1_2.xml");
    mModel.sync();
    D d = mModel.getRootComponent().getChild(D.class);
    assertNotNull(d.getChild(B.class));
    um.undo();
    mModel.getAccess().flush(); // after fix for 83963 need manual flush after undo/redo

    assertNull(mModel.getRootComponent().getChild(D.class));
    mModel = Util.dumpAndReloadModel(mModel);
    assertNull(mModel.getRootComponent().getChild(D.class));
}
 
Example #6
Source File: KerberosProfile.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override()
public void displayConfig(WSDLComponent component, UndoManager undoManager) {
    UndoCounter undoCounter = new UndoCounter();
    WSDLModel model = component.getModel();
    
    model.addUndoableEditListener(undoCounter);

    JPanel profConfigPanel = new Kerberos(component, this);
    DialogDescriptor dlgDesc = new DialogDescriptor(profConfigPanel, getDisplayName());
    Dialog dlg = DialogDisplayer.getDefault().createDialog(dlgDesc);

    dlg.setVisible(true); 
    if (dlgDesc.getValue() == DialogDescriptor.CANCEL_OPTION) {
        for (int i=0; i<undoCounter.getCounter();i++) {
            if (undoManager.canUndo()) {
                undoManager.undo();
            }
        }
    }
    
    model.removeUndoableEditListener(undoCounter);
}
 
Example #7
Source File: STSIssuedEndorsingProfile.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override()
public void displayConfig(WSDLComponent component, UndoManager undoManager) {
    UndoCounter undoCounter = new UndoCounter();
    WSDLModel model = component.getModel();
    
    model.addUndoableEditListener(undoCounter);

    JPanel profConfigPanel = new STSIssuedEndorsing(component, this);
    DialogDescriptor dlgDesc = new DialogDescriptor(profConfigPanel, getDisplayName());
    Dialog dlg = DialogDisplayer.getDefault().createDialog(dlgDesc);

    dlg.setVisible(true); 
    if (dlgDesc.getValue() == DialogDescriptor.CANCEL_OPTION) {
        for (int i=0; i<undoCounter.getCounter();i++) {
            if (undoManager.canUndo()) {
                undoManager.undo();
            }
        }
    }
    
    model.removeUndoableEditListener(undoCounter);
}
 
Example #8
Source File: STSIssuedSupportingTokenProfile.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override()
public void displayConfig(WSDLComponent component, UndoManager undoManager) {
    UndoCounter undoCounter = new UndoCounter();
    WSDLModel model = component.getModel();
    
    model.addUndoableEditListener(undoCounter);

    JPanel profConfigPanel = new STSIssuedSupportingToken(component, this);
    DialogDescriptor dlgDesc = new DialogDescriptor(profConfigPanel, getDisplayName());
    Dialog dlg = DialogDisplayer.getDefault().createDialog(dlgDesc);

    dlg.setVisible(true); 
    if (dlgDesc.getValue() == DialogDescriptor.CANCEL_OPTION) {
        for (int i=0; i<undoCounter.getCounter();i++) {
            if (undoManager.canUndo()) {
                undoManager.undo();
            }
        }
    }
    
    model.removeUndoableEditListener(undoCounter);
}
 
Example #9
Source File: SAMLHolderOfKeyProfile.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override()
public void displayConfig(WSDLComponent component, UndoManager undoManager) {
    UndoCounter undoCounter = new UndoCounter();
    WSDLModel model = component.getModel();
    
    model.addUndoableEditListener(undoCounter);

    JPanel profConfigPanel = new SAMLHolderOfKey(component, this);
    DialogDescriptor dlgDesc = new DialogDescriptor(profConfigPanel, getDisplayName());
    Dialog dlg = DialogDisplayer.getDefault().createDialog(dlgDesc);

    dlg.setVisible(true); 
    if (dlgDesc.getValue() == DialogDescriptor.CANCEL_OPTION) {
        for (int i=0; i<undoCounter.getCounter();i++) {
            if (undoManager.canUndo()) {
                undoManager.undo();
            }
        }
    }
    
    model.removeUndoableEditListener(undoCounter);
}
 
Example #10
Source File: ViewHierarchyTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testLongLineUndo() throws Exception {
    loggingOn();
    JEditorPane pane = ViewUpdatesTesting.createPane();
    Document doc = pane.getDocument();
    UndoManager undoManager = ViewUpdatesTesting.getUndoManager(doc);
    int lineLen = 4000;
    StringBuilder sb = new StringBuilder(lineLen + 10);
    for (int i = 0; i < lineLen; i++) {
        sb.append('a');
    }
    sb.append('\n');
    doc.insertString(0, sb.toString(), null);
    pane.modelToView(0);
    doc.remove(0, lineLen);
    pane.modelToView(0);
    undoManager.undo();
    undoManager.redo();
}
 
Example #11
Source File: EndorsingCertificateProfile.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override()
public void displayConfig(WSDLComponent component, UndoManager undoManager) {
    UndoCounter undoCounter = new UndoCounter();
    WSDLModel model = component.getModel();
    
    model.addUndoableEditListener(undoCounter);

    JPanel profConfigPanel = new EndorsingCertificate(component, this);
    DialogDescriptor dlgDesc = new DialogDescriptor(profConfigPanel, getDisplayName());
    Dialog dlg = DialogDisplayer.getDefault().createDialog(dlgDesc);

    dlg.setVisible(true); 
    if (dlgDesc.getValue() == DialogDescriptor.CANCEL_OPTION) {
        for (int i=0; i<undoCounter.getCounter();i++) {
            if (undoManager.canUndo()) {
                undoManager.undo();
            }
        }
    }
    
    model.removeUndoableEditListener(undoCounter);
}
 
Example #12
Source File: PlainDocumentTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testBehaviour() throws Exception {
    Document doc = new PlainDocument();
    doc.insertString(0, "test hello world", null);
    UndoManager undo = new UndoManager();
    doc.addUndoableEditListener(undo);
    Position pos = doc.createPosition(2);
    doc.remove(0, 3);
    assert (pos.getOffset() == 0);
    undo.undo();
    assert (pos.getOffset() == 2);
    
    Position pos2 = doc.createPosition(5);
    doc.remove(4, 2);
    Position pos3 = doc.createPosition(4);
    assertSame(pos2, pos3);
    undo.undo();
    assert (pos3.getOffset() == 5);
}
 
Example #13
Source File: AbstractModelTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testMultipleMutationUndoRedo() throws Exception {
    mModel = Util.loadModel("resources/Empty.xml");
    UndoManager urListener = new UndoManager();
    mModel.addUndoableEditListener(urListener);
		
    //setup
    mModel.startTransaction();
    B b2 = new B(mModel, 2);
    mModel.getRootComponent().addAfter(b2.getName(), b2, TestComponent3._A);
    String v = "testComponentListener.b2";
    b2.setValue(v);
    mModel.endTransaction();
    
    b2 = mModel.getRootComponent().getChild(B.class);
    assertEquals(v, b2.getAttribute(TestAttribute3.VALUE));
    
    urListener.undo();
    b2 = mModel.getRootComponent().getChild(B.class);
    assertNull(b2);

    urListener.redo();
    b2 = mModel.getRootComponent().getChild(B.class);
    assertEquals(v, b2.getAttribute(TestAttribute3.VALUE));
}
 
Example #14
Source File: SyncTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testCreateGlobalElementUndoRedo() throws Exception {
    SchemaModel model = Util.loadSchemaModel("resources/Empty.xsd");
    UndoManager ur = new UndoManager();
    model.addUndoableEditListener(ur);
    SchemaComponentFactory fact = model.getFactory();
    GlobalElement ge = fact.createGlobalElement();
    
    model.startTransaction();
    model.getSchema().addElement(ge);
    ge.setName("Foo"); // edit #1
    LocalComplexType lct = fact.createLocalComplexType();
    Sequence seq = fact.createSequence();
    lct.setDefinition(seq); 
    ge.setInlineType(lct);
    model.endTransaction();
    
    assertEquals(1, model.getSchema().getElements().size());
    ur.undo();
    assertEquals(0, model.getSchema().getElements().size());

    ur.redo();
    ge = model.getSchema().getElements().iterator().next();
    assertEquals("Foo", ge.getName());
    assertNotNull(ge.getInlineType());
    assertNotNull(((LocalComplexType)ge.getInlineType()).getDefinition());
}
 
Example #15
Source File: AbstractModelTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testSyncUndoRedo() throws Exception {
    defaultSetup();
    UndoManager urListener = new UndoManager();
    mModel.addUndoableEditListener(urListener);
    assertEquals("setup: initial", 1, mModel.getRootComponent().getChildren(C.class).size());
    
    Util.setDocumentContentTo(mDoc, "resources/test2.xml");
    mModel.sync();
    assertEquals("setup: sync", 0, mModel.getRootComponent().getChildren(C.class).size());

    urListener.undo();
    assertEquals("undo sync", 1, mModel.getRootComponent().getChildren(C.class).size());

    urListener.redo();
    assertEquals("undo sync", 0, mModel.getRootComponent().getChildren(C.class).size());
}
 
Example #16
Source File: CustomizationWSEditor.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void initializeModels(Node node) throws Exception {
    if (wsdlModels.isEmpty()) {
        undoManager = new UndoManager();
        WSDLModel primaryModel = getPrimaryModel(node);
        populateAllModels(primaryModel);
        Set<WSDLModel> modelSet = wsdlModels.keySet();
        for (WSDLModel wsdlModel : modelSet) {
            wsdlModel.addUndoableEditListener(undoManager);
        }
    }
}
 
Example #17
Source File: SchemaModelResolverTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * A imports B, B imports G. An element in A uses a complex type defined in G.
 * It has to be not accessible.
 */
@Test
public void testResolve6() throws Exception {
    SchemaModel sm = Util.loadSchemaModel2("resources/resolve6.zip", "resolve6/T6A.xsd");
    assert(sm.getState() == State.VALID);
    GlobalElement ge = (GlobalElement)sm.getSchema().getChildren().get(2);
    assertEquals("G1", ge.getName());
    NamedComponentReference ncr = ge.getType();
    String name = ncr.getQName().getNamespaceURI() + ":" + ncr.getQName().getLocalPart();
    assertEquals("http://xml.netbeans.org/schema/G:G1", name);
    //this is when it'll try to resolve
    GlobalComplexType gct = (GlobalComplexType)ncr.get();
    assertNotNull(gct);
    //
    Import gImport = (Import)sm.getSchema().getChildren().get(1);
    assertEquals("T6G.xsd", gImport.getSchemaLocation());
    //
    UndoManager um = new javax.swing.undo.UndoManager();
    AbstractDocumentModel.class.cast(sm).addUndoableEditListener(um);
    //
    sm.startTransaction();
    try {
        sm.getSchema().removeExternalReference(gImport);
    } finally {
        sm.endTransaction();
    }
    //
    // Try resolve G2 type
    // index less by 1 because the import was deleted!
    ge = (GlobalElement)sm.getSchema().getChildren().get(2);
    assertEquals("G2", ge.getName());
    ncr = ge.getType();
    name = ncr.getQName().getNamespaceURI() + ":" + ncr.getQName().getLocalPart();
    assertEquals("http://xml.netbeans.org/schema/G:G2", name);
    //this is when it'll try to resolve
    gct = (GlobalComplexType)ncr.get();
    assertNull(gct);
    //
    um.undo();
}
 
Example #18
Source File: SchemaTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testDeleteRollback() throws Exception {
    UndoManager um = new UndoManager();
    schema.getModel().addUndoableEditListener(um);
    
   GlobalElement stick = schema.getModel().getFactory().createGlobalElement();
   stick.setName("stickAfterRollbackElement");
   model.startTransaction();
   schema.addElement(stick);
   model.endTransaction();
   
   model.startTransaction();
   ArrayList<GlobalComplexType> types = new ArrayList(schema.getComplexTypes());
   ArrayList<GlobalElement> elements = new ArrayList(schema.getElements());
   GlobalElement element = elements.get(0);
   
     if(element.getName().equals("purchaseOrder")) {
        schema.removeElement(element);
                      
        String text = (( AbstractDocumentModel)model).getAccess().getCurrentDocumentText();
        assertTrue(text.indexOf("purchaseOrder")== -1);
        ( (AbstractModel)model).rollbackTransaction();
        text = (( AbstractDocumentModel)model).getAccess().getCurrentDocumentText();
        assertTrue(text.indexOf("purchaseOrder") > 0);
        assertTrue(text.indexOf("stickAfterRollbackElement") > 0);
   
        um.undo();
        text = (( AbstractDocumentModel)model).getAccess().getCurrentDocumentText();
        assertTrue(text.indexOf("stickAfterRollbackElement") == -1);

        um.redo();
        text = (( AbstractDocumentModel)model).getAccess().getCurrentDocumentText();
        assertTrue(text.indexOf("stickAfterRollbackElement") > 0);
       
     }
   
}
 
Example #19
Source File: UndoManagerImpl.java    From ganttproject with GNU General Public License v3.0 5 votes vote down vote up
public UndoManagerImpl(IGanttProject project, ParserFactory parserFactory, DocumentManager documentManager) {
  myProject = project;
  myParserFactory = parserFactory;
  myDocumentManager = documentManager;
  mySwingUndoManager = new UndoManager();
  myUndoEventDispatcher = new UndoableEditSupport();
  GanttLanguage.getInstance().addListener(new GanttLanguage.Listener() {
    public void languageChanged(Event event) {
      UIManager.getDefaults().put("AbstractUndoableEdit.undoText", GanttLanguage.getInstance().getText("undo"));
      UIManager.getDefaults().put("AbstractUndoableEdit.redoText", GanttLanguage.getInstance().getText("redo"));
    }
  });
}
 
Example #20
Source File: ServiceTopComponent.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public ServiceTopComponent(Service service, 
            JaxWsModel jaxWsModel, WSDLModel wsdlModel, Node node, UndoManager undoManager) {
    setLayout(new BorderLayout());
    this.wsdlModel = wsdlModel;
    this.undoManager = undoManager;
    this.node = node;
    this.service = service;
    this.jaxWsModel = jaxWsModel;
}
 
Example #21
Source File: SchemaTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testRollback() throws Exception {
    UndoManager um = new UndoManager();
    schema.getModel().addUndoableEditListener(um);
    
   GlobalElement stick = schema.getModel().getFactory().createGlobalElement();
   stick.setName("stickAfterRollbackElement");
   model.startTransaction();
   schema.addElement(stick);
   model.endTransaction();
   
   GlobalElement ge = schema.getModel().getFactory().createGlobalElement();
   ge.setName("newElement");
   int initialCount = schema.getElements().size();
   model.startTransaction();
   schema.addElement(ge);
   assertEquals(initialCount+1, schema.getElements().size());
   String text = (( AbstractDocumentModel)model).getAccess().getCurrentDocumentText();
   assertTrue(text.indexOf("newElement") > 0);
   ( (AbstractModel)model).rollbackTransaction();
   text = (( AbstractDocumentModel)model).getAccess().getCurrentDocumentText();
   assertTrue(text.indexOf("newElement") == -1);
   assertEquals(initialCount, schema.getElements().size());
   assertTrue(text.indexOf("stickAfterRollbackElement") > 0);
   
   um.undo();
   text = (( AbstractDocumentModel)model).getAccess().getCurrentDocumentText();
   assertTrue(text.indexOf("stickAfterRollbackElement") == -1);

   um.redo();
   text = (( AbstractDocumentModel)model).getAccess().getCurrentDocumentText();
   assertTrue(text.indexOf("stickAfterRollbackElement") > 0);
}
 
Example #22
Source File: JTextComponentMenu.java    From i18n-editor with MIT License 5 votes vote down vote up
public JTextComponentMenu(JTextComponent parent, UndoManager undoManager) {
	super();
	
	this.parent = parent;
	this.undoManager = undoManager;
	int keyMask =Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
	
	undoAction = new UndoAction(undoManager);
	undoAction.putValue(Action.NAME, MessageBundle.get("swing.action.undo"));
	undoAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_Z, keyMask));
	add(undoAction);
	
	addSeparator();
	
	cutAction = new DefaultEditorKit.CutAction();
	cutAction.putValue(Action.NAME, MessageBundle.get("swing.action.cut"));
	cutAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_X, keyMask));
	add(cutAction);
	
	copyAction = new DefaultEditorKit.CopyAction();
	copyAction.putValue(Action.NAME, MessageBundle.get("swing.action.copy"));
	copyAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_C, keyMask));
	add(copyAction);
	
	Action pasteAction = new DefaultEditorKit.PasteAction();
	pasteAction.putValue(Action.NAME, MessageBundle.get("swing.action.paste"));
	pasteAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_V, keyMask));
	add(pasteAction);
	
	deleteAction = new DeleteAction(MessageBundle.get("swing.action.delete"));
	add(deleteAction);
	
	addSeparator();
	
	Action selectAllAction = new SelectAllAction(MessageBundle.get("swing.action.selectall"));
	selectAllAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_A, keyMask));
	add(selectAllAction);
}
 
Example #23
Source File: TextUndoManager.java    From groovy with Apache License 2.0 5 votes vote down vote up
protected void trimEdits(int from, int to) {
    boolean undoable = canUndo();
    boolean redoable = canRedo();

    boolean changed = hasChanged();
    super.trimEdits(from, to);

    firePropertyChangeEvent(UndoManager.UndoName, undoable, canUndo());
    firePropertyChangeEvent(UndoManager.RedoName, redoable, canRedo());
}
 
Example #24
Source File: RedoCommand.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
@Override
public void adjust() {
    Undoable undoable = getTarget(Undoable.class);
    if (undoable != null) {
        UndoManager mgr = undoable.getUndoManager();
        setEnabled(mgr.canRedo());
        setTitle(mgr.getRedoPresentationName());
    } else {
        setEnabled(false);
        setTitle(I18n.Text("Can't Redo"));
    }
}
 
Example #25
Source File: DocumentContentTesting.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static void redo(Context context, final int count) throws Exception {
    final UndoManager undoManager = getValidUndoManager(context);
    logUndoRedoOp(context, "REDO", count);
    int cnt = count;
    while (undoManager.canRedo() && --cnt >= 0) {
        undoManager.redo();
        checkContent(context);
    }
    logPostUndoRedoOp(context, cnt);
}
 
Example #26
Source File: UndoCommand.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
@Override
public void adjust() {
    Undoable undoable = getTarget(Undoable.class);
    if (undoable != null) {
        UndoManager mgr = undoable.getUndoManager();
        setEnabled(mgr.canUndo());
        setTitle(mgr.getUndoPresentationName());
    } else {
        setEnabled(false);
        setTitle(I18n.Text("Can't Undo"));
    }
}
 
Example #27
Source File: AbstractModelTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testUndoWithFaultInEventFiring() throws Exception {
    setupForUndoRedoFault(new FaultInjector() {
        @Override
        public void injectFaultAndCheck(Object actor) throws Exception { 
            mModel.injectFaultInEventFiring();
            ((UndoManager)actor).undo();
        }
    }, false);
}
 
Example #28
Source File: AbstractModelTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testRedoWithFaultInSyncUpdater() throws Exception {
    setupForUndoRedoFault(new FaultInjector() {
        @Override
        public void injectFaultAndCheck(Object actor) throws Exception { 
            ((UndoManager)actor).undo();
            mModel.injectFaultInSyncUpdater();
            ((UndoManager)actor).redo();
        }
    }, true);
}
 
Example #29
Source File: DocumentContentTesting.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static UndoManager getValidUndoManager(PropertyProvider provider) {
    UndoManager undoManager = getUndoManager(provider);
    if (undoManager == null) {
        throw new IllegalStateException("Null UndoManager for property provider " + provider); // NOI18N
    }
    return undoManager;
}
 
Example #30
Source File: AbstractModel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized void addUndoableRefactorListener(UndoableEditListener uel) {
    //
    savedUndoableEditListeners = ues.getUndoableEditListeners();
    if (savedUndoableEditListeners != null) {
        for (UndoableEditListener saved : savedUndoableEditListeners) {
            if (saved instanceof UndoManager) {
                ((UndoManager)saved).discardAllEdits();
            }
        }
    }
    ues = new ModelUndoableEditSupport();
    ues.addUndoableEditListener(uel);
}