如何在Eclipse4.xRCP应用程序中以编程方式调用撤销

如何在Eclipse4.xRCP应用程序中以编程方式调用撤销,eclipse,eclipse-rcp,rcp,Eclipse,Eclipse Rcp,Rcp,在EclipseRCP应用程序中,我们编写了一些逻辑,在某些情况下,这些逻辑执行上一个用户操作的撤销。在Eclipse SDK 3.7.2中,以下功能非常有效: IServiceLocator=PlatformUI.getWorkbench(); ICommandService commandService=(ICommandService)serviceLocator.getService(ICommandService.class); Command=commandService.getCo

在EclipseRCP应用程序中,我们编写了一些逻辑,在某些情况下,这些逻辑执行上一个用户操作的撤销。在Eclipse SDK 3.7.2中,以下功能非常有效:

IServiceLocator=PlatformUI.getWorkbench(); ICommandService commandService=(ICommandService)serviceLocator.getService(ICommandService.class); Command=commandService.getCommand(“org.eclipse.ui.edit.undo”)//$非NLS-1$ 试一试{ executeWithChecks(新的ExecutionEvent()); }捕获(NotDefinedException | NotEnabledException | NotHandledException | ExecutionException e){ error(“执行命令org.eclipse.ui.edit.undo时出错”,e); } 将RCP应用程序迁移到Eclipse SDK 4.7.3a(氧气)后,上面的代码在执行语句
命令时引发以下异常。executeWithChecks(new ExecutionEvent())

org.eclipse.core.commands.NotHandledException:命令org.eclipse.ui.edit.undo没有要执行的处理程序
位于org.eclipse.core.commands.Command.executeWithChecks(Command.java:507)
检查command对象确实显示
command.isHandled()
command.getHandler().isHandled()
都返回
false
,但我们不理解为什么:活动编辑器具有焦点,并且在工具栏中启用了撤消按钮(即,可以单击它)

我们尝试了
command.getHandler().execute(newexecutionevent())
,但它什么也没做


有人知道如何使用EclipseSDK4.x从代码中调用撤销吗?我们是否应该使用EclipseAPI的另一部分?

在大多数情况下,4.x中的3.x兼容性API与Eclipse3.x中的相同。这是什么编辑器?编辑器来自:
MapEditorWithPalette
。它继承自
org.eclipse.gef.ui.parts.GraphicalEditorWithFlyOutpalete
,您必须研究该编辑器如何实现撤销。它是否使用编辑器操作贡献者?这是否处理撤消可重定目标操作?