当前位置: 首页>>代码示例>>Java>>正文


Java UndoManager.redo方法代码示例

本文整理汇总了Java中javax.swing.undo.UndoManager.redo方法的典型用法代码示例。如果您正苦于以下问题:Java UndoManager.redo方法的具体用法?Java UndoManager.redo怎么用?Java UndoManager.redo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.undo.UndoManager的用法示例。


在下文中一共展示了UndoManager.redo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: run

import javax.swing.undo.UndoManager; //导入方法依赖的package包/类
public void run() {
	Display display = Display.getDefault();
	Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);		
	
	Shell shell = getParentShell();
	shell.setCursor(waitCursor);
       
	try {
   		ProjectExplorerView explorerView = getProjectExplorerView();
   		if (explorerView != null) {
   			UndoManager undoManager = explorerView.getUndoManager();
   			undoManager.redo();
   		}
	}
	catch (Throwable e) {
		ConvertigoPlugin.logException(e, "Unable to redo the last action.");
	}
       finally {
		shell.setCursor(null);
		waitCursor.dispose();
       }
}
 
开发者ID:convertigo,项目名称:convertigo-eclipse,代码行数:23,代码来源:RedoAction.java

示例2: testCreateGlobalElementUndoRedo

import javax.swing.undo.UndoManager; //导入方法依赖的package包/类
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());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:SyncTest.java

示例3: testSetAttributeOnGlobalComplexTypeUndoRedo

import javax.swing.undo.UndoManager; //导入方法依赖的package包/类
public void testSetAttributeOnGlobalComplexTypeUndoRedo() throws Exception {
    SchemaModel model = Util.loadSchemaModel("resources/PurchaseOrder.xsd");
    UndoManager ur = new UndoManager();
    model.addUndoableEditListener(ur);
    GlobalComplexType potype = model.getSchema().getComplexTypes().iterator().next();
    assertEquals("PurchaseOrderType", potype.getName());
    
    model.startTransaction();
    potype.setAbstract(Boolean.TRUE);
    model.endTransaction();
    
    ur.undo();
    assertNull(potype.getAttribute(SchemaAttributes.ABSTRACT));

    ur.redo();
    assertNotNull(potype.getAttribute(SchemaAttributes.ABSTRACT));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:SyncTest.java

示例4: testUndoRedoOnMutationFromEvent

import javax.swing.undo.UndoManager; //导入方法依赖的package包/类
public void testUndoRedoOnMutationFromEvent() throws Exception {
    defaultSetup();
    mModel.addComponentListener(new Handler());
    UndoManager um = new UndoManager();
    mModel.addUndoableEditListener(um);

    mModel.startTransaction();
    mModel.getRootComponent().appendChild("test", new D(mModel, 2));
    mModel.endTransaction();

    um.undo();
    D d = mModel.getRootComponent().getChild(D.class);
    assertNull(d);
    um.redo();
    d = mModel.getRootComponent().getChild(D.class);
    assertNotNull(d.getChild(B.class));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:AbstractModelTest.java

示例5: testUndoRedoWithIdentity

import javax.swing.undo.UndoManager; //导入方法依赖的package包/类
public void testUndoRedoWithIdentity() throws Exception {
    mModel = Util.loadModel("resources/test1_name.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());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:AbstractModelTest.java

示例6: testUndoRedoWithoutIdentity

import javax.swing.undo.UndoManager; //导入方法依赖的package包/类
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());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:AbstractModelTest.java

示例7: onRedo

import javax.swing.undo.UndoManager; //导入方法依赖的package包/类
public void onRedo() {
	if(undoManager.canRedo())
		undoManager.redo();
	else {
		// HACK need to call parent frames undo if we have no changes
		CommonModuleFrame cmf = CommonModuleFrame.getCurrentFrame();
		if(cmf == null) return;

		final UndoManager cmfUndoManager = cmf.getExtension(UndoManager.class);
		if(cmfUndoManager != null && cmfUndoManager.canRedo()) {
			 cmfUndoManager.redo();

			 // reset flag
			 hasChanges = false;
		}
	}
}
 
开发者ID:phon-ca,项目名称:phon,代码行数:18,代码来源:GroupField.java

示例8: actionPerformed

import javax.swing.undo.UndoManager; //导入方法依赖的package包/类
public void actionPerformed(ActionEvent e) 
{
    Document doc = getTextComponent(e).getDocument();
    UndoManager um = getUndoManagerForDocument(doc);
    if(um != null)
    {
        try 
        {               
            um.redo();
        } 
        catch (CannotUndoException ex) 
        {
            System.out.println("Unable to redo: " + ex);
            ex.printStackTrace();
        }
        
        updateUndo(doc);
    }
}
 
开发者ID:OpenIndex,项目名称:OpenIndex-SHEF,代码行数:20,代码来源:CompoundUndoManager.java

示例9: testLongLineUndo

import javax.swing.undo.UndoManager; //导入方法依赖的package包/类
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();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:ViewHierarchyTest.java

示例10: testSetTypes

import javax.swing.undo.UndoManager; //导入方法依赖的package包/类
public void testSetTypes() throws Exception {
    UndoManager um = new UndoManager();
    WSDLModel model = TestCatalogModel.getDefault().getWSDLModel(NamespaceLocation.ECHOCONCAT);
    model.addUndoableEditListener(um);
    TestComponentListener cl = new TestComponentListener();
    PropertyListener pl = new PropertyListener();
    model.addComponentListener(cl);
    model.addPropertyChangeListener(pl);
    
    Definitions d = model.getDefinitions();
    int childCount = d.getChildren().size();
    Types types = d.getTypes();
    assertNotNull(types);
    model.startTransaction();
    d.setTypes(null);
    model.endTransaction();
    
    cl.assertEvent(ComponentEvent.EventType.CHILD_REMOVED, d);
    pl.assertEvent(Definitions.TYPES_PROPERTY, types, null);

    
    um.undo();
    assertEquals(childCount, d.getChildren().size());
    um.redo();
    assertEquals(childCount-1, d.getChildren().size());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:DefinitionsTest.java

示例11: redo

import javax.swing.undo.UndoManager; //导入方法依赖的package包/类
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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:DocumentContentTesting.java

示例12: testRollback

import javax.swing.undo.UndoManager; //导入方法依赖的package包/类
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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:33,代码来源:SchemaTest.java

示例13: testSyncUndoUndo

import javax.swing.undo.UndoManager; //导入方法依赖的package包/类
public void testSyncUndoUndo() throws Exception {
      SchemaModel model = Util.loadSchemaModel("resources/undoredotest.xsd");
      UndoManager um = new UndoManager();
      model.addUndoableEditListener(um);
      
      GlobalComplexType gct = (GlobalComplexType)Util.findComponent(
              model.getSchema(), "/schema/complexType[@name='USAddress']");
      java.util.List<SchemaComponent> seqChildren = gct.getDefinition().getChildren();
      
      assertEquals(3, seqChildren.size());
      
      Util.setDocumentContentTo(model, "resources/undoredotest1.xsd");
      model.sync();
assertEquals(3, seqChildren.size());
      um.undo();
      assertEquals(3, seqChildren.size());
um.redo();
assertEquals(3, seqChildren.size());

Util.setDocumentContentTo(model, "resources/undoredotest2.xsd");
      model.sync();
assertEquals(3, seqChildren.size());
      um.undo();
assertEquals(3, seqChildren.size());
um.undo();
assertEquals(3, seqChildren.size());
  }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:SyncTest.java

示例14: testSyncRemoveAttribute

import javax.swing.undo.UndoManager; //导入方法依赖的package包/类
public void testSyncRemoveAttribute() throws Exception {
    defaultSetup();
    UndoManager um = new UndoManager();
    mModel.addUndoableEditListener(um);
    
    A a1 = mModel.getRootComponent().getChild(TestComponent3.A.class);
    assertNull("setup", a1.getValue());
    
    mModel.startTransaction();
    String testValue = "edit #1: testRemoveAttribute";
    a1.setValue(testValue);
    mModel.endTransaction();
    assertEquals(testValue, a1.getValue());

    um.undo();
    assertNull("after undo expect no attribute 'value'", a1.getValue());
    
    um.redo();
    assertEquals(testValue, a1.getValue());

    Util.setDocumentContentTo(mDoc, "resources/test1.xml");
    mModel.sync();
    assertNull("sync back to original, expect no attribute 'value'", a1.getValue());
    plistener.assertEvent("value", testValue, null);
    listener.assertEvent(ComponentEvent.EventType.VALUE_CHANGED, a1);
    
    um.undo();
    mModel.getAccess().flush(); // after fix for 83963 need flush after undo/redo
    
    assertEquals(testValue, a1.getValue());
    mModel = Util.dumpAndReloadModel(mModel);
    a1 = mModel.getRootComponent().getChild(A.class);
    assertEquals(testValue, a1.getValue());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:35,代码来源:AbstractModelTest.java

示例15: testCopyPasteUndoRedo

import javax.swing.undo.UndoManager; //导入方法依赖的package包/类
public void testCopyPasteUndoRedo() throws Exception {
    defaultSetup();
    UndoManager urListener = new UndoManager();
    mModel.addUndoableEditListener(urListener);
    
    mModel.startTransaction();
    B b2 = new B(mModel, 2);
    mModel.getRootComponent().addAfter(b2.getName(), b2, TestComponent3._A);
    mModel.endTransaction();
    assertEquals("first edit setup", 2, mModel.getRootComponent().getChildren(B.class).size());
    assertEquals("first edit setup", 1, mModel.getRootComponent().getChildren(C.class).size());
		
    B b2Copy = (B) b2.copy(mModel.getRootComponent());

    mModel.startTransaction();
    mModel.getRootComponent().addAfter(b2Copy.getName(), b2Copy, TestComponent3._A);
    mModel.endTransaction();
    
    assertEquals("paste", 3, mModel.getRootComponent().getChildren(B.class).size());
    assertEquals("paste", 1, mModel.getRootComponent().getChildren(C.class).size());
    
    urListener.undo();
    assertEquals("undo paste", 2, mModel.getRootComponent().getChildren(B.class).size());
    assertEquals("undo paste", 1, mModel.getRootComponent().getChildren(C.class).size());
		
    urListener.redo();
    assertEquals("redo paste", 3, mModel.getRootComponent().getChildren(B.class).size());
    assertEquals("redo paste", 1, mModel.getRootComponent().getChildren(C.class).size());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:AbstractModelTest.java


注:本文中的javax.swing.undo.UndoManager.redo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。