- 根据IEditorInput获取IFile实例
public static IFile getFile(IEditorInput editorInput) {if (editorInput == null) {return null;}Object o = editorInput.getAdapter(IFile.class);if (o instanceof IFile) {return (IFile) o;}return null;}
- 根据IEditorPart获取IFile实例
The code below will demonstrate how to do this.
IFile file = (IFile) editorPart.getEditorInput().getAdapter(IFile.class);
if (file != null) {
// do stuff
}