當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。