I understand this is old, but since I came across it looking for a solution to the same problem, I want to add a note to VonC's answer:
IFileEditorInput
is hidden in the org.eclipse.ui.ide plugin, so for the solution to work, your plugin must specify that as a dependency.
source share