我正在使用一个带有工具栏的rcp应用程序来快速访问某些操作,包括撤消和重做。我的问题是,这两个特定操作没有显示在工具栏中。我已将原因定位到应用程序启动时生成的workbench.xmi
文件。具有属性persistedState
的标签key="persp.hiddenItems"
在persp.hideToolbarSC:org.eclipse.ui.edit.undo,persp.hideToolbarSC:org.eclipse.ui.edit.redo
属性中包含value="..."
。如果我从workbench.xmi
中删除了这些条目,则撤消和重做操作将按原样显示在工具栏中。
我的问题是:我该怎么做才能使org.eclipse.ui.edit.undo
和org.eclipse.ui.edit.redo
不再以该属性开头?
我最初使用eclipse neon时没有这个问题,但是当更新到Eclipse 2018-12时,这开始发生。
编辑:
我最终通过将撤消和重做操作的ID更改为其他内容来使其正常工作。我必须在动作的构造函数中使用setId(...)
和setActionDefinedId(...)
设置ID,然后必须在{{1}中plugin.xml
下<extension point="org.eclipse.ui.commands">
下定义命令。 }标签。
与实际解决方案相比,此解决方案更像是一种解决方法,但对我有用。
答案 0 :(得分:2)
这是由hiddenToolBarItem
扩展点的org.eclipse.ui.perspectiveExtensions
元素设置的。
org.eclipse.ui.ide
插件使用它来禁用以下工具栏项:
<extension
point="org.eclipse.ui.perspectiveExtensions">
<perspectiveExtension targetID="*">
<!--
disable "print" button which is defined by org.eclipse.ui.actions.ActionFactory.PRINT
and contributed by org.eclipse.ui.internal.ide.WorkbenchActionBuilder
-->
<hiddenToolBarItem id="print" />
<!--
disable "undo" button which is defined by org.eclipse.ui.actions.ActionFactory.UNDO
and contributed by org.eclipse.ui.internal.ide.WorkbenchActionBuilder
-->
<hiddenToolBarItem id="org.eclipse.ui.edit.undo" />
<!--
disable "redo" button which is defined by org.eclipse.ui.actions.ActionFactory.REDO
and contributed by org.eclipse.ui.internal.ide.WorkbenchActionBuilder
-->
<hiddenToolBarItem id="org.eclipse.ui.edit.redo" />
</perspectiveExtension>
</extension>
除了放弃插件外,我看不到其他清除方法。
答案 1 :(得分:0)
我遇到了同样的问题。升级到2019年月食后,撤消/重做消失了。
覆盖org.eclipse.ui.ide全局透视图设置中的硬编码的一种方法是直接修改透视图状态。例如。在ApplicationWorkbenchWindowAdvisor.postWindowOpen()
中 WorkbenchPage page = (WorkbenchPage) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
String str = page.getCurrentPerspective().getPersistedState().get(ModeledPageLayout.HIDDEN_ITEMS_KEY);
str=str.replace("persp.hideToolbarSC:org.eclipse.ui.edit.undo,", "");
str=str.replace("persp.hideToolbarSC:org.eclipse.ui.edit.redo,", "");
page.getCurrentPerspective().getPersistedState().put(ModeledPageLayout.HIDDEN_ITEMS_KEY,str);