我正在构建我的自定义编辑器。但是当我右键单击我想要的文件并尝试通过"打开方式"选项使用自定义编辑器打开它时,我的命令处理程序不起作用。为此,我是否必须在插件中使用带有命令 ID 的菜单贡献标签下的 locationURI.xml?如果是,那又如何呢?请查看我当前的插件.xml以便更好地理解。
插件.xml
<extension point="org.eclipse.ui.editors">
<editor
class="launcher.ChartEditor"
default="false"
id="launcher.ChartEditor"
name="ChartEditor">
</editor>
</extension>
<extension
point="org.eclipse.ui.commands">
<command
id="launcher.openChartEditor"
name="OpenChartEditor">
</command>
</extension>
<extension
point="org.eclipse.ui.handlers">
<handler
class="launcher.ChartEditorHandler"
commandId="launcher.openChartEditor">
</handler>
</extension>
"打开方式..."菜单只是直接打开编辑器。它不使用任何命令或处理程序。没有其他方法可以为"打开方式"菜单做出贡献。EditorSelectionDialog
是一样的。
要使用您的命令和处理程序,您确实需要使用menuContributor(或工具栏贡献(,但这必须在Open With以外的其他位置使用。
标准的"打开方式"操作将打开所选编辑器,并向其传递当前所选内容的IEditorInput
。这通常是您可以从中获取文件的IFileEditorInput
。