Iundocontext context= (Iundocontext) Resourcesplugin.getworkspace (). Getadapter (Iundocontext.class); Iworkbenchpartsite workbenchpartsite = Platformui.getworkbench (). Getactiveworkbenchwindow (). GetActivePage ().
Getactiveeditor (). Getsite ();
Ioperationhistory operationhistory = Platformui.getworkbench (). Getoperationsupport (). GetOperationHistory ();
Undoactionhandler undoaction = new Undoactionhandler (workbenchpartsite, context);
Iundoableoperation[] Operations = operationhistory. Getundohistory (Ioperationhistory.global_undo_context);
SYSTEM.OUT.PRINTLN ("Operations ' s length:" +operations.length); for (int i = operations.length-1; I >= 0; i--) {if (Operations[i].canundo ()) {try {System.out.println ("und
O Label: "+ Operations[i].getlabel ());
Operationhistory.undooperation (Operations[i], NULL, undoaction);
} catch (Executionexception e) {//TODO auto-generated catch block E.printstacktrace (); }
}
}
In the case of a refactoring undo, Operations[i].getlabel () outputs a specific refactoring operation name, such as Extract Class or Move method.