E4 中的 RCP 工具栏项目顺序更改

RCP Toolbar items order change in e4

我正在尝试将 RCP Eclipse 3 应用程序更新到 Eclipse 4.5 目标平台。根据兼容层的不同,存在一些差异。 一个区别是主菜单中工具栏中项目的顺序。

旧版本:

新版本:

红色标记的图标添加了 ActionBarAdvisor,其他图标添加到 plugin.xml 作为工具栏命令。 为什么顺序会改变?我需要以编程方式添加工具栏项吗?

更新:

如果我使用选项 -clearPersistedState,工具栏的顺序与旧版本中的一样。再次移除标志会创建新版本屏幕截图中显示的工具栏。

我遇到了同样的问题。刚刚创建工作区时,工具栏的顺序正确,下次启动时我添加的 ActionBarAdvisor 按钮在右侧。

你的选择 -clearPersistedState 对我有用。如果有人有信息,我很想知道这个问题的根源

在 Eclipse Bugtracker 中深入研究各种问题后,我找到了解决方案。

在方法 fillCoolBar(ICoolBarManager coolBar) 中,将工具栏项添加到 ToolbarManager 的实例中,然后将其添加为 ID 为 toolbar:org.eclipse.ui.main.toolbar

的 ToolBarContributionItem

到酷栏:

@Override
protected void fillCoolBar(ICoolBarManager coolBar)
{
    IToolBarManager manager = new ToolBarManager(SWT.FLAT);
    manager.add(action1);
    ...

    coolBar.add(new ToolBarContributionItem(manager, "toolbar:org.eclipse.ui.main.toolbar"));
}

在 plugin.xml 中,将工具栏添加到具有相同 ID toolbar:org.eclipse.ui.main.toolbar 的 menuContribution。这会导致在 coolbar 之后添加其他工具栏。