如何在rcp应用程序的工具栏中显示撤消和重做动作
我正在使用一个带有工具栏的rcp应用程序来快速访问某些操作,包括撤消和重做.我的问题是,这两个特定操作没有显示在工具栏中.我已将原因定位到应用程序启动时生成的 workbench.xmi
文件.具有属性 key ="persp.hiddenItems"
的标签 persistedState
包含 persp.hideToolbarSC:org.eclipse.ui.edit.undo,persp.hideToolbarSC:org.eclipse.ui.edit.redo
在 value ="..."
属性中.如果我从 workbench.xmi
中删除这些条目,则撤消和重做操作将按原样显示在工具栏中.
I am working on an rcp application with a toolbar for quick access to certain actions, including undo and redo. My problem is that these two specific actions don't show up in the toolbar. I have located the cause to the workbench.xmi
file that is generated when the application launches. A tag persistedState
with an attribute key="persp.hiddenItems"
contains persp.hideToolbarSC:org.eclipse.ui.edit.undo,persp.hideToolbarSC:org.eclipse.ui.edit.redo
in the value="..."
attribute. If I delete these entries from workbench.xmi
, the undo and redo actions show up in the toolbar as they should.
我的问题是:我该怎么做才能使 org.eclipse.ui.edit.undo
和 org.eclipse.ui.edit.redo
不会结束可以从这个属性开始吗?
My question is: What can I do so that org.eclipse.ui.edit.undo
and org.eclipse.ui.edit.redo
don't end up in this attribute to begin with?
我最初使用eclipse neon时没有这个问题,但是当更新到Eclipse 2018-12时,这开始发生.
I originally used eclipse neon without this problem, but when updating to eclipse 2018-12 this started happening.
我最终通过将撤消和重做操作的ID更改为其他内容来使其正常工作.我必须在动作的构造函数中使用 setId(...)
和 setActionDefinedId(...)
设置ID,然后必须在< command id ="..."中< extension point ="org.eclipse.ui.commands">
下的code> plugin.xml 撤消"></command> 标记.
I finally got it to work by changing the IDs of my undo and redo actions to something else. I had to set the ID with setId(...)
and setActionDefinedId(...)
in the actions' constructors, and then the commands had to be defined in plugin.xml
under <extension point="org.eclipse.ui.commands">
in a <command id="..." name="Undo"></command>
tag.
此解决方案比实际解决方案更像是一种解决方法,但对我有用.
This solutions feels more like a workaround than an actual solution, but it works for me.
这是由 org.eclipse.ui.perspectiveExtensions
扩展点的 hiddenToolBarItem
元素设置的.
This is set by the hiddenToolBarItem
element of the org.eclipse.ui.perspectiveExtensions
extension point.
org.eclipse.ui.ide
插件使用它来禁用以下工具栏项:
The org.eclipse.ui.ide
plug-in uses this to disable these tool-bar items:
<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>
除了放弃插件外,我没有其他清除方法.
I don't see a way to clear this other than leaving out the plug-in.