luft
luft

Reputation: 29

Command Handler not responding for EditorSelectionDialog

i am building my custom Editor. But when i right click on my desired file and try to open it with custom editor via "Open With" option, my command handler does not work. Do i have to use locationURI under menuContribution tag with commandId in plugin.xml for this? If it is then how? Please have a look at my current plugin.xml for better understanding.

Plugin.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>

Upvotes: 1

Views: 60

Answers (1)

greg-449
greg-449

Reputation: 111216

The 'Open With...' menu just opens the editor directly. It does not use any command or handler. There is no other way to contribute to the 'Open With' menu. The EditorSelectionDialog is the same.

To use your command and handler you do need to using a menuContribution (or a tool bar contribution) but this will have to somewhere other than Open With.

The standard 'Open With' action opens the selected editor passing it the IEditorInput for the current selection. This will usually be an IFileEditorInput from which you can get the file.

Upvotes: 0

Related Questions