我正在开发一个日食产品。我在插件中添加了一个导航器视图,现在我想通过删除一些默认操作并添加一些自定义操作来自定义其上下文菜单。
如何从菜单中删除操作?我怎样才能添加我的行动?
有没有办法创建上下文菜单?
答案 0 :(得分:2)
最后我以这种方式解决了:
我创建了一个导航器查看器 扩展o.e.ui.navigator.viewer,我 提供一个popupMenu指定 “allowPlatformContributions = false”。 然后我创建了尽可能多的insertionPoint 因为我需要我的上下文菜单。该 我希望eclipse提供的动作 上下文菜单包含在 group.new,group.edit, group.reorganize。生成的xml是:
<extension
point="org.eclipse.ui.navigator.viewer">
.....
<viewer viewerId="...">
<popupMenu
allowsPlatformContributions="false">
<insertionPoint
name="group.xvr.management"
separator="true">
</insertionPoint>
<insertionPoint
name="group.new"
separator="true">
</insertionPoint>
<insertionPoint
name="group.edit"
separator="true">
</insertionPoint>
<insertionPoint
name="group.reorganize">
</insertionPoint>
<insertionPoint
name="group.xvr.launch"
separator="true">
</insertionPoint>
</popupMenu>
</viewer>
...
</extension>
其他两个组名, group.xvr.launch和 group.xvr.management是自定义的 我的行动的占位符。
然后我延长了 o.e.ui.navigator.navigatorContent 创建我的自定义内容我 绑定到查看器。我加入了 导航仪内容尽可能多 我需要的actionProvider。在每一个 他们重写方法 fillContextMenu提供自定义 对上下文菜单的操作。
@Override
public void fillContextMenu(IMenuManager menu) {
menu.appendToGroup("group.xvr.launch", new CommandContributionItem(new CommandContributionItemParameter(...)));
menu.appendToGroup("group.xvr.launch", new CommandContributionItem(new CommandContributionItemParameter(...)));
}
答案 1 :(得分:1)
您需要扩展o.e.ui.navigator.navigatorContent并提供actionProvider。
答案 2 :(得分:0)
您必须扩展导航器视图,并覆盖上下文菜单(应该是createPart控制方法)。现在我无法访问日食源。
希望这会有所帮助。